Cooperative Energy Community
This example is taken from the article Optimal sizing of energy communities with fair revenue sharing and exit clauses: Value, role and business model of aggregators and users by Davide Fioriti et al, url but for a subset of users
The energy community considered in this example consists of 3 users, where:
- all users can install PV system
- only the first user cannot install batteries, whereas the others can
- the third user can install also wind turbines
Import the needed packages
using EnergyCommunity, JuMP
using HiGHS, Plots
Create a base Energy Community example in the data folder; use the default configuration.
folder = joinpath(@__DIR__, "data")
create_example_data(folder, config_name="default")
Input file to load the structure of the energy community based on a yaml file.
input_file = joinpath(@__DIR__, "data/energy_community_model.yml");
Output path of the summary and of the plots
output_file_isolated = joinpath(@__DIR__, "./results/output_file_CO.xlsx");
output_plot_isolated = joinpath(@__DIR__, "./results/Img/plot_user_{:s}_CO.png");
define optimizer and options
optimizer = optimizer_with_attributes(HiGHS.Optimizer, "ipm_optimality_tolerance"=>1e-6)
MathOptInterface.OptimizerWithAttributes(HiGHS.Optimizer, Pair{MathOptInterface.AbstractOptimizerAttribute, Any}[MathOptInterface.RawOptimizerAttribute("ipm_optimality_tolerance") => 1.0e-6])
Define the Non Cooperative model
CO_Model = ModelEC(input_file, EnergyCommunity.GroupCO(), optimizer)
An Energy Community Model
Energy Community problem for a Cooperative Model
User set: ["user1", "user2", "user3"]
Build the mathematical model
build_model!(CO_Model)
An Energy Community Model
Energy Community problem for a Cooperative Model
User set: ["user1", "user2", "user3"]
Optimize the model
optimize!(CO_Model)
An Energy Community Model
Energy Community problem for a Cooperative Model
User set: ["user1", "user2", "user3"]
get objective value
objective_value(CO_Model)
-1.206493189864753e6
Create plots of the results
plot(CO_Model, output_plot_isolated)
Print summaries of the results
print_summary(CO_Model)
[ Info: List of users not specified: all users selected
WARNING: Optimizer of the EnergyCommunity model not specified
RESULTS - AGGREGATOR
NPV Agg [k€] : 0.00e+00
SWtot [k€] : -1.21e+03
SWus [k€] : -1.21e+03
ESha [MWh] : 3.70e+00
RESULTS - USER
USER : user1, user2, user3
PV : 4.08e+01, 4.67e+01, 2.27e+01
batt : 0.00e+00, 3.33e+00, 5.10e+00
conv : 0.00e+00, 3.33e+00, 5.10e+00
wind : 0.00e+00, 0.00e+00, 7.35e+01
NPV [k€] : -5.71e+02, -2.30e+02, -4.51e+02
CAPEX [k€] : 6.94e+01, 6.73e+01, 2.60e+02
OPEX [k€] : 1.22e+00, 1.42e+00, 2.92e+00
YBill [k€] : -3.30e+01, -1.07e+01, -1.26e+01
Cthermal [k€] : 0.00e+00, 0.00e+00, 0.00e+00
Energy flows
USER : user1, user2, user3
PtotPusP [MWh] : 3.31e-01, 5.05e+00, 2.45e+00
PtotPusN [MWh] : 2.24e+01, 7.70e+00, 5.63e+00
PconvP [MWh] : 0.00e+00, 2.76e-01, 3.68e-01
PconvN [MWh] : 0.00e+00, 3.00e-01, 4.00e-01
Pren [MWh] : 8.46e+00, 9.54e+00, 2.13e+01
Pgen [MWh] : 0.00e+00, 0.00e+00, 0.00e+00
Load [MWh] : 3.05e+01, 1.22e+01, 2.45e+01
Save summaries
save_summary(CO_Model, output_file_isolated)
Plot the sankey plot of resources
plot_sankey(CO_Model)
DataFrame of the business plan
business_plan(CO_Model)
Row | Year | CUM_DCF | CAPEX | OEM | FUEL | EN_SELL | EN_CONS | PEAK | REP | REWARD | RV |
---|---|---|---|---|---|---|---|---|---|---|---|
Int64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
1 | 0 | -3.96488e5 | 3.96488e5 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
2 | 1 | -4.50441e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
3 | 2 | -5.02822e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
4 | 3 | -5.53678e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
5 | 4 | -6.03053e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
6 | 5 | -6.50989e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
7 | 6 | -6.9753e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
8 | 7 | -7.42714e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
9 | 8 | -7.86583e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
10 | 9 | -8.29174e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
11 | 10 | -8.7178e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 1686.68 | 3036.93 | 0.0 |
12 | 11 | -9.11926e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
13 | 12 | -9.50903e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
14 | 13 | -9.88744e5 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
15 | 14 | -1.02548e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
16 | 15 | -1.06332e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 3373.36 | 3036.93 | 0.0 |
17 | 16 | -1.09795e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
18 | 17 | -1.13157e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
19 | 18 | -1.16421e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
20 | 19 | -1.1959e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 0.0 |
21 | 20 | -1.20649e6 | 0.0 | 5568.01 | 0.0 | 1666.37 | 52369.5 | 2337.41 | 0.0 | 3036.93 | 36447.2 |
plot business plan
business_plan_plot(CO_Model)
This page was generated using Literate.jl.