Workflow for a single node energy system¶
In this application of the ETHOS.FINE framework, a single region energy system is modeled and optimized.
All classes which are available to the user are utilized and examples of the selection of different parameters within these classes are given.
The workflow is structures as follows:
- Required packages are imported and the input data path is set
- An energy system model instance is created
- Commodity sources are added to the energy system model
- Commodity conversion components are added to the energy system model
- Commodity storages are added to the energy system model
- Commodity sinks are added to the energy system model
- The energy system model is optimized
- Selected optimization results are presented
1. Import required packages and set input data path¶
The ETHOS.FINE framework is imported which provides the required classes and functions for modeling the energy system.
import fine as fn
from getData import getData
from pathlib import Path
cwd = Path.cwd()
data = getData()
%matplotlib inline
%load_ext autoreload
%autoreload 2
2. Create an energy system model instance¶
The structure of the energy system model is given by the considered locations, commodities, the number of time steps as well as the hours per time step.
The commodities are specified by a unit (i.e. 'GW_electric', 'GW_H2lowerHeatingValue', 'Mio. t CO2/h') which can be given as an energy or mass unit per hour. Furthermore, the cost unit and length unit are specified.
locations = {"GermanyRegion"}
commodityUnitDict = {"electricity": r"GW$_{el}$", "hydrogen": r"GW$_{H_{2},LHV}$"}
commodities = {"electricity", "hydrogen"}
numberOfTimeSteps = 8760
hoursPerTimeStep = 1
esM = fn.EnergySystemModel(
locations=locations,
commodities=commodities,
numberOfTimeSteps=8760,
commodityUnitsDict=commodityUnitDict,
hoursPerTimeStep=1,
costUnit="1e9 Euro",
lengthUnit="km",
verboseLogLevel=0,
)
3. Add commodity sources to the energy system model¶
3.1. Electricity sources¶
Wind onshore¶
esM.add(
fn.Source(
esM=esM,
name="Wind (onshore)",
commodity="electricity",
hasCapacityVariable=True,
operationRateMax=data["Wind (onshore), operationRateMax"],
capacityMax=data["Wind (onshore), capacityMax"],
investPerCapacity=1.1,
opexPerCapacity=1.1 * 0.02,
interestRate=0.08,
economicLifetime=20,
)
)
Full load hours:
print(data["Wind (onshore), operationRateMax"].sum())
2300.4069071646272
4. Add conversion components to the energy system model¶
New combined cycly gas turbines for hydrogen¶
esM.add(
fn.Conversion(
esM=esM,
name="New CCGT plants (hydrogen)",
physicalUnit=r"GW$_{el}$",
commodityConversionFactors={"electricity": 1, "hydrogen": -1 / 0.6},
hasCapacityVariable=True,
investPerCapacity=0.7,
opexPerCapacity=0.021,
interestRate=0.08,
economicLifetime=33,
)
)
Electrolyzers¶
esM.add(
fn.Conversion(
esM=esM,
name="Electroylzers",
physicalUnit=r"GW$_{el}$",
commodityConversionFactors={"electricity": -1, "hydrogen": 0.7},
hasCapacityVariable=True,
investPerCapacity=0.5,
opexPerCapacity=0.5 * 0.025,
interestRate=0.08,
economicLifetime=10,
)
)
5. Add commodity storages to the energy system model¶
5.1. Electricity storage¶
Lithium ion batteries¶
The self discharge of a lithium ion battery is here described as 3% per month. The self discharge per hours is obtained using the equation (1-$\text{selfDischarge}_\text{hour})^{30*24\text{h}} = 1-\text{selfDischarge}_\text{month}$.
esM.add(
fn.Storage(
esM=esM,
name="Li-ion batteries",
commodity="electricity",
hasCapacityVariable=True,
chargeEfficiency=0.95,
cyclicLifetime=10000,
dischargeEfficiency=0.95,
selfDischarge=1 - (1 - 0.03) ** (1 / (30 * 24)),
chargeRate=1,
dischargeRate=1,
doPreciseTsaModeling=False,
investPerCapacity=0.151,
opexPerCapacity=0.002,
interestRate=0.08,
economicLifetime=22,
)
)
5.2. Hydrogen storage¶
Hydrogen filled salt caverns¶
The maximum capacity is here obtained by: dividing the given capacity (which is given for methane) by the lower heating value of methane and then multiplying it with the lower heating value of hydrogen.
esM.add(
fn.Storage(
esM=esM,
name="Salt caverns (hydrogen)",
commodity="hydrogen",
hasCapacityVariable=True,
capacityVariableDomain="continuous",
capacityPerPlantUnit=133,
chargeRate=1 / 470.37,
dischargeRate=1 / 470.37,
sharedPotentialID="Existing salt caverns",
stateOfChargeMin=0.33,
stateOfChargeMax=1,
capacityMax=data["Salt caverns (hydrogen), capacityMax"],
investPerCapacity=0.00011,
opexPerCapacity=0.00057,
interestRate=0.08,
economicLifetime=30,
)
)
7. Add commodity sinks to the energy system model¶
7.1. Electricity sinks¶
Electricity demand¶
esM.add(
fn.Sink(
esM=esM,
name="Electricity demand",
commodity="electricity",
hasCapacityVariable=False,
operationRateFix=data["Electricity demand, operationRateFix"],
)
)
7.2. Hydrogen sinks¶
Fuel cell electric vehicle (FCEV) demand¶
FCEV_penetration = 0.5
esM.add(
fn.Sink(
esM=esM,
name="Hydrogen demand",
commodity="hydrogen",
hasCapacityVariable=False,
operationRateFix=data["Hydrogen demand, operationRateFix"] * FCEV_penetration,
)
)
8. Optimize energy system model¶
All components are now added to the model and the model can be optimized. If the computational complexity of the optimization should be reduced, the time series data of the specified components can be clustered before the optimization and the parameter timeSeriesAggregation is set to True in the optimize call.
esM.aggregateTemporally(numberOfTypicalPeriods=30)
Clustering time series data with 30 typical periods and 24 time steps per period further clustered to 12 segments per period... (5.4925 sec)
esM.optimize(
timeSeriesAggregation=True, solver=fn.utils.ImplementedSolvers.STANDARD_SOLVER.value
)
Time series aggregation specifications:
Number of typical periods:30, number of time steps per period:24, number of segments per period:12
Declaring sets, variables and constraints for SourceSinkModel
declaring sets...
declaring variables...
declaring constraints...
(0.1647 sec)
Declaring sets, variables and constraints for ConversionModel
declaring sets...
declaring variables...
declaring constraints...
(0.0488 sec)
Declaring sets, variables and constraints for StorageModel
declaring sets...
declaring variables...
declaring constraints...
(0.3974 sec)
Declaring shared potential constraint...
(0.0003 sec)
Declaring linked component quantity constraint...
(0.0000 sec)
Declaring commodity balances...
(0.0161 sec)
(0.0000 sec)
Declaring objective function...
(0.1446 sec)
GLPSOL--GLPK LP/MIP Solver 5.0
Parameter(s) specified in the command line:
--write C:\Users\JA60A~1.BEL\AppData\Local\Temp\tmppz54exqh.glpk.raw --wglp
C:\Users\JA60A~1.BEL\AppData\Local\Temp\tmp5047l8ia.glpk.glp --cpxlp C:\Users\JA60A~1.BEL\AppData\Local\Temp\tmp5rg4_8uf.pyomo.lp
Reading problem data from 'C:\Users\JA60A~1.BEL\AppData\Local\Temp\tmp5rg4_8uf.pyomo.lp'...
8339 rows, 4892 columns, 22821 non-zeros
52744 lines were read
Writing problem data to 'C:\Users\JA60A~1.BEL\AppData\Local\Temp\tmp5047l8ia.glpk.glp'...
43104 lines were written
GLPK Simplex Optimizer 5.0
8339 rows, 4892 columns, 22821 non-zeros
Preprocessing...
8203 rows, 4097 columns, 21770 non-zeros
Scaling...
A: min|aij| = 6.507e-04 max|aij| = 4.545e+02 ratio = 6.986e+05
GM: min|aij| = 2.576e-01 max|aij| = 3.883e+00 ratio = 1.508e+01
EQ: min|aij| = 6.633e-02 max|aij| = 1.000e+00 ratio = 1.508e+01
Constructing initial basis...
Size of triangular part is 7111
0: obj = 0.000000000e+00 inf = 1.583e+03 (745)
1913: obj = 1.175060694e+01 inf = 1.847e-13 (0) 16
* 3297: obj = 7.820770238e+00 inf = 5.285e-13 (0) 13
OPTIMAL LP SOLUTION FOUND
Time used: 0.8 secs
Memory used: 10.0 Mb (10533487 bytes)
Writing basic solution to 'C:\Users\JA60A~1.BEL\AppData\Local\Temp\tmppz54exqh.glpk.raw'...
13240 lines were written
Status: ok
Termination condition: optimal
Statistics:
Branch and bound:
Number of bounded subproblems: 0
Number of created subproblems: 0
Error rc: 0
Time: 0.9601352214813232
Name: unknown
Lower bound: 7.82077023780424
Upper bound: 7.82077023780424
Number of objectives: 1
Number of constraints: 8339
Number of variables: 4892
Number of nonzeros: 22821
Sense: minimize
Solve time: 1.6836094856262207 sec.
Processing optimization output...
for SourceSinkModel ...(0.3352sec)
for ConversionModel ...(0.2209sec)
C:\Programming\FINE\fine\storage.py:2056: UserWarning: Charge and discharge at the same time for component Salt caverns (hydrogen) warnings.warn(
for StorageModel ... (0.7136sec) (1.2779 sec)
9. Selected results output¶
Sources and Sink¶
Show optimization summary
esM.getOptimizationSummary("SourceSinkModel", outputLevel=2)
| GermanyRegion | |||
|---|---|---|---|
| Component | Property | Unit | |
| Electricity demand | operation | [GW$_{el}$*h/a] | 30957.888055 |
| [GW$_{el}$*h] | 30957.888055 | ||
| Hydrogen demand | operation | [GW$_{H_{2},LHV}$*h/a] | 4765.074877 |
| [GW$_{H_{2},LHV}$*h] | 4765.074877 | ||
| Wind (onshore) | NPVcontribution | [1e9 Euro] | 5.545377 |
| TAC | [1e9 Euro/a] | 5.545377 | |
| capacity | [GW$_{el}$] | 41.371855 | |
| capexCap | [1e9 Euro/a] | 4.635196 | |
| commissioning | [GW$_{el}$] | 41.371855 | |
| invest | [1e9 Euro] | 45.50904 | |
| operation | [GW$_{el}$*h/a] | 44223.602817 | |
| [GW$_{el}$*h] | 44223.602817 | ||
| opexCap | [1e9 Euro/a] | 0.910181 |
Plot operation time series (either one or two dimensional)
fig, ax = fn.plotOperation(esM, "Electricity demand", "GermanyRegion")
fig, ax = fn.plotOperationColorMap(esM, "Electricity demand", "GermanyRegion")
Conversion¶
Show optimization summary
esM.getOptimizationSummary("ConversionModel", outputLevel=2)
| GermanyRegion | |||
|---|---|---|---|
| Component | Property | Unit | |
| Electroylzers | NPVcontribution | [1e9 Euro] | 0.424378 |
| TAC | [1e9 Euro/a] | 0.424378 | |
| capacity | [GW$_{el}$] | 4.877081 | |
| capexCap | [1e9 Euro/a] | 0.363414 | |
| commissioning | [GW$_{el}$] | 4.877081 | |
| invest | [1e9 Euro] | 2.438541 | |
| operation | [GW$_{el}$*h/a] | 16851.368489 | |
| [GW$_{el}$*h] | 16851.368489 | ||
| opexCap | [1e9 Euro/a] | 0.060964 | |
| New CCGT plants (hydrogen) | NPVcontribution | [1e9 Euro] | 0.124811 |
| TAC | [1e9 Euro/a] | 0.124811 | |
| capacity | [GW$_{el}$] | 1.525874 | |
| capexCap | [1e9 Euro/a] | 0.092767 | |
| commissioning | [GW$_{el}$] | 1.525874 | |
| invest | [1e9 Euro] | 1.068112 | |
| operation | [GW$_{el}$*h/a] | 4218.529839 | |
| [GW$_{el}$*h] | 4218.529839 | ||
| opexCap | [1e9 Euro/a] | 0.032043 |
fig, ax = fn.plotOperationColorMap(esM, "New CCGT plants (hydrogen)", "GermanyRegion")
Storage¶
Show optimization summary
esM.getOptimizationSummary("StorageModel", outputLevel=2)
| GermanyRegion | |||
|---|---|---|---|
| Component | Property | Unit | |
| Li-ion batteries | NPVcontribution | [1e9 Euro] | 1.010062 |
| TAC | [1e9 Euro/a] | 1.010062 | |
| capacity | [GW$_{el}$*h] | 60.112569 | |
| capexCap | [1e9 Euro/a] | 0.889837 | |
| commissioning | [GW$_{el}$*h] | 60.112569 | |
| invest | [1e9 Euro] | 9.076998 | |
| operationCharge | [GW$_{el}$*h/a] | 6384.378729 | |
| [GW$_{el}$*h] | 6384.378729 | ||
| operationDischarge | [GW$_{el}$*h/a] | 5751.502616 | |
| [GW$_{el}$*h] | 5751.502616 | ||
| opexCap | [1e9 Euro/a] | 0.120225 | |
| Salt caverns (hydrogen) | NPVcontribution | [1e9 Euro] | 0.716143 |
| TAC | [1e9 Euro/a] | 0.716143 | |
| capacity | [GW$_{H_{2},LHV}$*h] | 1235.216115 | |
| capexCap | [1e9 Euro/a] | 0.012069 | |
| commissioning | [GW$_{H_{2},LHV}$*h] | 1235.216115 | |
| invest | [1e9 Euro] | 0.135874 | |
| operationCharge | [GW$_{H_{2},LHV}$*h/a] | 10272.356153 | |
| [GW$_{H_{2},LHV}$*h] | 10272.356153 | ||
| operationDischarge | [GW$_{H_{2},LHV}$*h/a] | 10272.356153 | |
| [GW$_{H_{2},LHV}$*h] | 10272.356153 | ||
| opexCap | [1e9 Euro/a] | 0.704073 |
fig, ax = fn.plotOperationColorMap(
esM,
"Li-ion batteries",
"GermanyRegion",
variableName="stateOfChargeOperationVariablesOptimum",
)
fig, ax = fn.plotOperationColorMap(
esM,
"Salt caverns (hydrogen)",
"GermanyRegion",
variableName="stateOfChargeOperationVariablesOptimum",
)