|
| 1 | +# Example |
| 2 | + |
| 3 | +[TulipaProfileFitting.jl](https://github.com/TulipaEnergy/TulipaProfileFitting.jl) is primarily used to fit power production curves of renewable sources such as wind and solar. In this example, we have generated a time series for a wind power plant's power production using a method developed in [1]. The file [wind\_power\_profile.csv](./files/wind_power_profile.csv) contains all the details of the profile. |
| 4 | + |
| 5 | +So, Let's start loading the values from the file! |
| 6 | + |
| 7 | +[1] Staffell, I., & Pfenninger, S. (2016). Using bias-corrected reanalysis to simulate current and future wind power output. Energy, 114, 1224-1239. <https://doi.org/10.1016/j.energy.2016.08.068> |
| 8 | + |
| 9 | +```julia |
| 10 | +using TulipaProfileFitting |
| 11 | +using CSV |
| 12 | +using Plots |
| 13 | + |
| 14 | +file_url = "https://github.com/TulipaEnergy/TulipaProfileFitting.jl/tree/main/docs/src/files/wind_power_profile.csv" |
| 15 | + |
| 16 | +df = DataFrame(CSV.File(file_url, header=4)) |
| 17 | +``` |
| 18 | + |
| 19 | +From the dataframe we can get the profile values as follows: |
| 20 | + |
| 21 | +```julia |
| 22 | +profile_values = df.electricity |
| 23 | +``` |
| 24 | + |
| 25 | +The current capacity factor (e.g., mean value) can be determined using the following command: |
| 26 | + |
| 27 | +```julia |
| 28 | +current_cp = round(sum(profile_values)/8760;digits=2) |
| 29 | +``` |
| 30 | + |
| 31 | +Let's define a new capacity factor as 0.6 |
| 32 | + |
| 33 | +```julia |
| 34 | +target_cp = 0.6 |
| 35 | +``` |
| 36 | + |
| 37 | +We can use the function ``fit\_profile`` in this package to obtain the coefficient that fit the values to the target. |
| 38 | + |
| 39 | +```julia |
| 40 | +coefficient = fit_profile(profile_values, target_cp) |
| 41 | +``` |
| 42 | + |
| 43 | +The coefficient is the output of an optimization problem. To learn more, please refer to the mathematical formulation section. |
| 44 | + |
| 45 | +Using the coefficient, we can determine the new profile and plot the power production curves. |
| 46 | + |
| 47 | +```julia |
| 48 | +fitted_profile = profile_values.^coefficient |
| 49 | +``` |
| 50 | + |
| 51 | +We can plot the results using: |
| 52 | + |
| 53 | +```julia |
| 54 | +plot(profile_values, label="profile") |
| 55 | +plot!(fitted_profile, label="fitted") |
| 56 | +plot!(title="Profiles values - not sorted") |
| 57 | +``` |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +```julia |
| 62 | +plot(sort(profile_values,rev=true), label="profile") |
| 63 | +plot!(sort(fitted_profile,rev=true), label="fitted") |
| 64 | +plot!(title="Profiles values - sorted") |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +It can be observed that the fitted curve primarily affects the intermediate value within the entire range. The values closer to one or zero remain relatively unchanged. This outcome is expected since the primary objective of the package is to adjust the intermediate value, thereby increasing or decreasing the capacity factor. |
0 commit comments