Non 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_NC.xlsx");
output_plot_isolated = joinpath(@__DIR__, "./results/Img/plot_user_{:s}_NC.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

NC_Model = ModelEC(input_file, EnergyCommunity.GroupNC(), optimizer)
An Energy Community Model
Energy Community problem for a Non-Cooperative Model
User set: ["user1", "user2", "user3"]

Build the mathematical model

build_model!(NC_Model)
An Energy Community Model
Energy Community problem for a Non-Cooperative Model
User set: ["user1", "user2", "user3"]

Optimize the model

optimize!(NC_Model)
An Energy Community Model
Energy Community problem for a Non-Cooperative Model
User set: ["user1", "user2", "user3"]

get objective value

objective_value(NC_Model)
-1.2227418941433681e6

Create plots of the results

plot(NC_Model, output_plot_isolated)

Print summaries of the results

print_summary(NC_Model)

RESULTS - AGGREGATOR
USER              :     user1,     user2,     user3
load              :  0.00e+00,  0.00e+00,  0.00e+00
PV                :  5.00e+01,  2.55e+01,  4.40e+01
generator         :  0.00e+00,  0.00e+00,  0.00e+00
batt              :  0.00e+00,  1.97e+00,  3.72e+00
conv              :  0.00e+00,  1.97e+00,  3.72e+00
wind              :  0.00e+00,  0.00e+00,  3.49e+01
NPV [k€]          : -5.64e+02, -2.23e+02, -4.36e+02
CAPEX [k€]        :  8.50e+01,  3.69e+01,  1.77e+02
OPEX [k€]         :  1.50e+00,  7.78e-01,  2.39e+00
YBill [k€]        : -3.16e+01, -1.22e+01, -1.72e+01
Cthermal [k€]     : -8.57e-17,  0.00e+00,  0.00e+00


Energy flows
USER              :     user1,     user2,     user3
PtotPusP [MWh]    :  1.09e+00,  1.38e+00,  2.26e+00
PtotPusN [MWh]    :  2.12e+01,  8.27e+00,  9.79e+00
PconvP [MWh]      :  0.00e+00,  1.18e-01,  2.81e-01
PconvN [MWh]      :  0.00e+00,  1.28e-01,  3.05e-01
Pren [MWh]        :  1.04e+01,  5.28e+00,  1.70e+01
Pgen [MWh]        : -1.52e-17,  0.00e+00,  0.00e+00
Load [MWh]        :  3.05e+01,  1.22e+01,  2.45e+01

Save summaries

save_summary(NC_Model, output_file_isolated)

Plot the sankey plot of resources

plot_sankey(NC_Model)
Example block output

DataFrame of the business plan

business_plan(NC_Model)
21×11 DataFrame
RowYearCUM_DCFCAPEXOEMFUELEN_SELLEN_CONSPEAKREPREWARDRV
Int64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64
10-299297.0299297.00.00.00.00.00.00.00.00.0
21-3.60845e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
32-4.206e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
43-4.78614e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
54-5.34939e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
65-5.89623e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
76-642715.00.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
87-6.9426e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
98-7.44304e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
109-7.9289e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1110-8.40909e50.04673.14-8.57396e-14607.91656850.62478.271138.92-3.52122e-110.0
1211-8.86706e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1312-9.3117e50.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1413-974338.00.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1514-1.01625e60.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1615-1.0584e60.04673.14-8.57396e-14607.91656850.62478.272277.85-3.52122e-110.0
1716-1.09791e60.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1817-1.13626e60.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
1918-1.1735e60.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
2019-1.20965e60.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-110.0
2120-1.22274e60.04673.14-8.57396e-14607.91656850.62478.270.0-3.52122e-1139750.4

plot business plan

business_plan_plot(NC_Model)
Example block output

This page was generated using Literate.jl.