EnergySystemModel¶
A description of the EnergySystemModel class is given below. This is the central class of ETHOS.FINE.
It is used to create an energy system model, add components to it, build the optimization problem, solve it
and visualize/export results.
energySystemModel
¶
Classes:
-
EnergySystemModel–EnergySystemModel class.
EnergySystemModel
¶
EnergySystemModel(
locations,
commodities,
commodityUnitsDict,
numberOfTimeSteps=8760,
hoursPerTimeStep=1,
startYear=0,
numberOfInvestmentPeriods=1,
investmentPeriodInterval=1,
stochasticModel=False,
costUnit="1e9 Euro",
lengthUnit="km",
verboseLogLevel=0,
balanceLimit=None,
pathwayBalanceLimit=None,
annuityPerpetuity=False,
)
EnergySystemModel class.
The functionality provided by the EnergySystemModel class is fourfold:
- With it, the basic structure (spatial and temporal resolution, considered commodities) of the investigated energy system is defined.
- It serves as a container for all components investigated in the energy system model. These components, namely sources and sinks, conversion options, storage options, and transmission options (in the core module), can be added to an EnergySystemModel instance.
- It provides the core functionality of modeling and optimizing the energy system based on the specified structure and components on the one hand and of specified simulation parameters on the other hand.
- It stores optimization results which can then be post-processed with other modules.
The parameters which are stored in an instance of the class refer to:
- the modeled spatial representation of the energy system (locations, lengthUnit)
- the modeled temporal representation of the energy system (totalTimeSteps, hoursPerTimeStep, startYear, numberOfInvementPeriods, investmentPeriodInterval, periods, periodsOrder, periodsOccurrences, timeStepsPerPeriod, interPeriodTimeSteps, isTimeSeriesDataClustered, typicalPeriods, tsaInstance, timeUnit)
- the considered commodities in the energy system (commodities, commodityUnitsDict)
- the considered components in the energy system (componentNames, componentModelingDict, costUnit)
- optimization related parameters (pyM, solverSpecs)
The parameters are first set when a class instance is initiated. The parameters which are related to the components (e.g. componentNames) are complemented by adding the components to the class instance.
Instances of this class provide functions for\n * adding components and their respective modeling classes (add) * clustering the time series data of all added components using the time series aggregation package tsam, cf. https://github.com/FZJ-IEK3-VSA/tsam (cluster) * optimizing the specified energy system (optimize), for which a pyomo concrete model instance is built and filled with
(0) basic time sets,
(1) sets, variables and constraints contributed by the component modeling classes,
(2) basic, component overreaching constraints, and
(3) an objective function.
The pyomo instance is then optimized by a specified solver. The optimization results are processed once available. * getting components and their attributes (getComponent, getCompAttr, getOptimizationSummary)
Create an EnergySystemModel class instance.
Required arguments:
:param locations: locations considered in the energy system :type locations: set of strings
:param commodities: commodities considered in the energy system :type commodities: set of strings
:param commodityUnitsDict: dictionary which assigns each commodity a quantitative unit per time (e.g. GW_el, GW_H2, Mio.t_CO2/h). The dictionary is used for results output.
.. note::
Note for advanced users: the scale of these units can influence the numerical stability of the
optimization solver, cf. http://files.gurobi.com/Numerics.pdf where a reasonable range of model
coefficients is suggested.
:type commodityUnitsDict: dictionary of strings
Default arguments:
:param numberOfTimeSteps: number of time steps considered when modeling the energy system (for each time step, or each representative time step, variables and constraints are constituted). Together with the hoursPerTimeStep, the total number of hours considered can be derived. The total number of hours is again used for scaling the arising costs to the arising total annual costs (TAC) which are minimized during optimization. |br| * the default value is 8760. :type totalNumberOfHours: strictly positive integer
:param hoursPerTimeStep: hours per time step |br| * the default value is 1 :type hoursPerTimeStep: strictly positive float
:param numberOfInvestmentPeriods: number of investment periods of transformation path analysis, e.g. for a transformation pathway from 2020 to 2030 with the years 2020, 2025, 2030, the numberOfInvestmentPeriods is 3 |br| * the default value is 1 :type numberOfInvestmentPeriods: strictly positive integer
:param investmentPeriodInterval: interval between the investment of transformation path analysis, e.g. for a transformation pathway from 2020 to 2030 with the years 2020, 2025, 2030, the investmentPeriodInterval is 5 |br| * the default value is 1 :type investmentPeriodInterval: strictly positive integer
:param startYear: year name of first investment period, e.g. for a transformation pathway from 2020 to 2030 with the years 2020, 2025, 2030, the startYear is 2020 |br| * the default value is 0 :type startYear: integer
:param stochasticModel: defines whether to set up a stochastic optimization. The goal of the stochastic optimization is to find a more robust energy system by considering different requirements to find a single energy system design (e.g. various weather years or demand forecasts). These requirements are represented in different investment periods of the model. In contrast to the classical perfect foresight optimization the investment periods do not represent steps of a transformation pathway but possible boundary conditions for the energy system, which need to be considered for the system design and operation |br| * the default value is False :type mode: bool
:param costUnit: cost unit of all cost related values in the energy system. This argument sets the unit of all cost parameters which are given as an input to the EnergySystemModel instance (e.g. for the invest per capacity or the cost per operation).
.. note::
Note for advanced users: the scale of this unit can influence the numerical stability of the
optimization solver, cf. http://files.gurobi.com/Numerics.pdf where a reasonable range of model
coefficients is suggested.
|br| * the default value is '10^9 Euro' (billion euros), which can be a suitable scale for national
energy systems.
:type costUnit: string
:param lengthUnit: length unit for all length-related values in the energy system.
.. note::
Note for advanced users: the scale of this unit can influence the numerical stability of the
optimization solver, cf. http://files.gurobi.com/Numerics.pdf where a reasonable range of model
coefficients is suggested.
|br| * the default value is 'km' (kilometers).
:type lengthUnit: string
:param verboseLogLevel: defines how verbose the console logging is:
- 0: general model logging, warnings and optimization solver logging are displayed.
- 1: warnings are displayed.
- 2: no general model logging or warnings are displayed, the optimization solver logging is set to a
minimum.
.. note::
if required, the optimization solver logging can be separately enabled in the optimizationSpecs
of the optimize function.
|br| * the default value is 0
:type verboseLogLevel: integer (0, 1 or 2)
:param balanceLimit: defines the balanceLimit constraint (various different balanceLimitIDs possible) for specific regions or the whole model and optional also per investment period. The balancelimitID can be assigned to various components of e.g. SourceSinkModel or TransmissionModel to limit the balance of production, consumption and im/export.
Regional dependency:
The balanceLimit is defined as a pd.DataFrame. Each row contains an individual balanceLimitID as
index, the corresponding regional scope as columns and the values as data. The regional scope can be set
for a region with the matching region name as column name or "Total" as column name for setting for the entire system.
If no balanceLimit is to be set for a given location, replace the corresponding entry with 'None' (not 'np.nan').
Temporal dependency:
If the balanceLimit is passed as a dict with the described pd.DataFrames as values it is considered per investment period.
Values are always given in the unit of the esM commodities unit.\n
Optional: A column named 'lowerBound' can be passed to specify if
the limit is an upper or lower bound.
By default an upperBound is considered ('lowerBound'=False).
However, multiple cases can be considered:\n
1) Sources:\n
a) LowerBound=False: UpperBound for commodity from SourceComponent (Define positive value in
balanceLimit). Example: Limit CO2-Emission\n
b) LowerBound=True: LowerBound for commodity from SourceComponent (Define positive value in
balanceLimit). Example: Require minimum production from renewables.\n
2) Sinks:\n
a) LowerBound=False: UpperBound in a mathematical sense for commodity from SinkComponent
(Logically minimum limit for negative values, define negative value in balanceLimit).
Example: Minimum export/consumption of hydrogen.\n
b) LowerBound=True: LowerBound in a mathematical sense for commodity from SourceComponent
(Logically maximum limit for negative values, define negative value in balanceLimit).
Example: Define upper limit for Carbon Capture & Storage.\n
Examples: - balanceLimit for commodity flow into system/ location e.g. due to a source [positive value; lowerBound=False] (e.g. natural gas field): balanceLimit=pd.DataFrame(columns=["Total"], index=["Gas production", "lowerBound"], data=[1000, False] ) - balanceLimit for commodity flow out of system/ location e.g. due to a sink [negative value; lowerBound=True] (e.g. CO2 sink): balanceLimit=pd.DataFrame(columns=["Total"], index=["CO2 Limit", "lowerBound"], data=[-1000, True] ) - balanceLimit per region and per system (flow into system/ location): balanceLimit=pd.DataFrame(columns=["Region1", "Total"], index=["CO2 Limit"], data=[1000, 2000] ) - multiple balanceLimits for different IDs: balanceLimit=pd.DataFrame(columns=["Total", "lowerBound"], index=["CO2 limit", "Gas production"], data=[[400, False], [1000, True]] ) - Different CO2 Limits for each investment period and minimum installed capacity for renewables: balanceLimit = { 2020: pd.DataFrame(index=["CO2 limit", "Renewables"], columns=["Total", "lowerBound"], data=[[-366 * (1 - CO2_reductionTarget * 0.33), True],[430000, True]] ), 2025: pd.DataFrame(index=["CO2 limit", "Renewables"], columns=["Region1", "Total", "lowerBound"], data=[[-366 * (1 - CO2_reductionTarget * 0.67), True],[430000, True]] ), 2030: pd.DataFrame(index=["CO2 limit", "Renewables"], columns=["Region1", "Total", "lowerBound"], data=[[-366 * (1 - CO2_reductionTarget), True],[430000, True]] ) } .. note:: If bounds for sinks shall be specified (e.g. min. export, max. sink volume), values must be defined as negative.
|br| * the default value is None
:type balanceLimit:
* pd.DataFrame
* dictionary with investment periods years as keys, and pd.DataFrame as values
|br| * the default value is None
:type lowerBound: bool
:param pathwayBalanceLimit: the pathway balance limit defines commodity balance (lower or upper bound) for the pathway. The structure is similar to the balanceLimit, however does without the temporal dependency per investment period. Examples: CO2 budget for the entire transformation pathway |br| * the default value is None :type pathwayBalanceLimit: None or pd.DataFrame
:param annuityPerpetuity: if set to True, it is assumed that the design and operation of the last investment period will be maintained forever. Therefore, the cost contribution of each component's last investment period is divided by the component's interest rate to account for perpetuity costs.
To enable annuity perpetuity the interest rate of every component must be greater than 0.
|br| * the default value is False
:type: annuityPerpetuity: bool
Methods:
-
add–Add a component and, if required, its respective modeling class to the EnergySystemModel instance.
-
aggregateSpatially–Spatially clusters the data of all components considered in the Energy System Model (esM) instance
-
aggregateTemporally–Temporally cluster the time series data of all components considered in the EnergySystemModel instance and then
-
createTimeSeriesDataForAggregation–Create and return the time series data, weights, and zero-data columns for aggregation.
-
declareBalanceLimitConstraint–Declare balance limit constraint.
-
declareCommodityBalanceConstraints–Declare commodity balance constraints (one balance constraint for each commodity, location and time step).
-
declareComponentLinkedQuantityConstraints–Declare linked component quantity constraint, e.g. if an engine (E-Motor) is built also a storage (Battery)
-
declareObjective–Declare the objective function by obtaining the contributions to the objective function from all modeling
-
declareOptimizationProblem–Declare the optimization problem belonging to the specified energy system for which a pyomo concrete model
-
declareSharedPotentialConstraints–Declare shared potential constraints, e.g. if a maximum potential of salt caverns has to be shared by
-
declareTimeSets–Set and initialize basic time parameters and sets.
-
getComponent–Return a component of the energy system.
-
getComponentAttribute–Return an attribute of a component considered in the energy system.
-
getOptimizationSummary–Return the optimization summary (design variables, aggregated operation variables, and objective contributions) of a modeling class.
-
optimize–Optimize the specified energy system for which a pyomo ConcreteModel instance is built or called upon.
-
removeComponent–Remove a component from the energy system.
-
updateComponent–Overwrite selected attributes of an existing esM component with new values.
add
¶
Add a component and, if required, its respective modeling class to the EnergySystemModel instance. The added component has to inherit from the FINE class Component.
:param component: the component to be added :type component: An object which inherits from the FINE class Component
aggregateSpatially
¶
aggregateSpatially(
shapefile,
grouping_mode="parameter_based",
n_groups=3,
distance_threshold=None,
aggregatedResultsPath=None,
**kwargs,
)
Spatially clusters the data of all components considered in the Energy System Model (esM) instance and returns a new esM instance with the aggregated data.
:param shapefile: Either the path to the shapefile or the read-in shapefile :type shapefile: string, GeoDataFrame
Default arguments:
:param grouping_mode: Defines how to spatially group the regions. Refer to grouping.py for more information. |br| * the default value is 'parameter_based' :type grouping_mode: string, Options: 'string_based', 'distance_based', 'parameter_based'
:param n_groups: The number of region groups to be formed from the original region set.
This parameter is irrelevant if grouping_mode is 'string_based'.
|br| * the default value is 3
:type n_groups: strictly positive integer, None
:param distance_threshold: The distance threshold at or above which regions will not be aggregated into one. |br| * the default value is None. If not None, n_groups must be None :type distance_threshold: float
:param aggregatedResultsPath: Indicates path to which the aggregated results should be saved. If None, results are not saved. |br| * the default value is None :type aggregatedResultsPath: string, None
Additional keyword arguments that can be passed via kwargs:
:param geom_col_name: The geometry column name in shapefile
|br| * the default value is 'geometry'
:type geom_col_name: string
:param geom_id_col_name: The column in shapefile consisting geom IDs
|br| * the default value is 'index'
:type geom_id_col_name: string
:param separator: Relevant only if grouping_mode is 'string_based'.
The character or string in the region IDs that defines where the ID should be split.
E.g.: region IDs -> ['01_es', '02_es'] and separator='_', then IDs are split at _
and the last part ('es') is taken as the group ID
|br| * the default value is None
:type separator: string
:param position: Relevant only if grouping_mode is 'string_based'.
Used to define the position(s) of the region IDs where the split should happen.
An int i would mean the part from 0 to i is taken as the group ID. A tuple (i,j) would mean
the part i to j is taken at the group ID.
.. note:: either `separator` or `position` must be passed in order to perform string_based_grouping
|br| * the default value is None
:type position: integer/tuple
:param weights: Relevant only if grouping_mode is 'parameter_based'.
Through the weights dictionary, one can assign weights to variable-component pairs. When calculating
distance corresponding to each variable-component pair, these specified weights are
considered, otherwise taken as 1.
It must be in one of the formats:
- If you want to specify weights for particular variables and particular corresponding components:
{ 'components' : Dict[<component_name>, <weight>}], 'variables' : List[<variable_name>] }
- If you want to specify weights for particular variables, but all corresponding components:
{ 'components' : {'all' : <weight>}, 'variables' : List[<variable_name>] }
- If you want to specify weights for all variables, but particular corresponding components:
{ 'components' : Dict[<component_name>, <weight>}], 'variables' : 'all' }
<weight> can be of type integer/float
|br| * the default value is None
:type weights: dictionary
:param aggregation_method: Relevant only if grouping_mode is 'parameter_based'.
The clustering method that should be used to group the regions. Options:
- 'kmedoids_contiguity':
kmedoids clustering with added contiguity constraint.
Refer to TSAM docs for more info: https://github.com/FZJ-IEK3-VSA/tsam/blob/master/tsam/utils/k_medoids_contiguity.py
- 'hierarchical':
sklearn's agglomerative clustering with complete linkage, with a connectivity matrix to ensure contiguity.
Refer to Sklearn docs for more info: https://scikit-learn.org/stable/modules/generated/sklearn.cluster.AgglomerativeClustering.html
|br| * the default value is 'kmedoids_contiguity'
:type aggregation_method: string, Options: 'kmedoids_contiguity', 'hierarchical'
:param solver: Relevant only if grouping_mode is 'parameter_based' and aggregation_method is 'kmedoids_contiguity'
The optimization solver to be chosen.
|br| * the default value is 'gurobi'
:type solver: string, Options: 'gurobi', 'highs', 'glpk'
:param aggregation_function_dict: Contains information regarding the mode of aggregation for each individual variable.
- Possibilities: mean, weighted mean, sum, bool (boolean OR).
- Format of the dictionary
- {<variable_name>: (<mode_of_aggregation>, <weights>),
<variable_name>: (<mode_of_aggregation>, None)}.
<weights> is required only if <mode_of_aggregation> is
'weighted mean'. The name of the variable that should act as weights should be provided. Can be None otherwise.
A default dictionary is considered with the following corresponding modes.
If `aggregation_function_dict` is passed, this default dictionary is updated.
| {"operationRateMax": ("weighted mean", "capacityMax"),
| "operationRateFix": ("sum", None),
| "processedLocationalEligibility": ("bool", None),
| "capacityMax": ("sum", None),
| "investPerCapacity": ("mean", None),
| "investIfBuilt": ("bool", None),
| "opexPerOperation": ("mean", None),
| "opexPerCapacity": ("mean", None),
| "opexIfBuilt": ("bool", None),
| "interestRate": ("mean", None),
| "economicLifetime": ("mean", None),
| "capacityFix": ("sum", None),
| "losses": ("mean", None),
| "distances": ("mean", None),
| "commodityCost": ("mean", None),
| "commodityRevenue": ("mean", None),
| "opexPerChargeOperation": ("mean", None),
| "opexPerDischargeOperation": ("mean", None),
| "QPcostScale": ("sum", None),
| "technicalLifetime": ("mean", None)}
:type aggregation_function_dict: dictionary
:param aggregated_shp_name: Name to be given to the saved shapefiles after aggregation |br| * the default value is 'aggregated_regions' :type aggregated_shp_name: string
:param crs: Coordinate reference system (crs) in which to save the shapefiles |br| * the default value is 3035 :type crs: integer
:param crs: Coordinate reference system (crs) in which to save the shapefiles |br| * the default value is 3035 :type crs: integer
:param aggregated_xr_filename: Name to be given to the saved netCDF file containing aggregated esM data |br| * the default value is 'aggregated_xr_dataset.nc' :type aggregated_xr_filename: string
:returns: Aggregated esM instance
aggregateTemporally
¶
aggregateTemporally(
numberOfTypicalPeriods=40,
numberOfTimeStepsPerPeriod=24,
segmentation=True,
numberOfSegmentsPerPeriod=12,
clusterMethod="hierarchical",
representationMethod="durationRepresentation",
sortValues=False,
storeTSAinstance=False,
rescaleClusterPeriods=False,
**kwargs,
)
Temporally cluster the time series data of all components considered in the EnergySystemModel instance and then stores the clustered data in the respective components. For this, the time series data is broken down into an ordered sequence of periods (e.g. 365 days) and to each period a typical period (e.g. 7 typical days with 24 hours) is assigned. Moreover, the time steps within the periods can further be clustered to bigger time steps with an irregular duration using the segmentation option. For the clustering itself, the tsam package is used (cf. https://github.com/FZJ-IEK3-VSA/tsam). Additional keyword arguments for the TimeSeriesAggregation instance can be added (facilitated by kwargs). As an example: it might be useful to add extreme periods to the clustered typical periods.
.. note:: The segmentation option can be freely combined with all subclasses. However, an irregular time step length is not meaningful for the minimumDownTime and minimumUpTime in the conversionDynamic module, because the time would be different for each segment.
Default arguments:
:param numberOfTypicalPeriods: states the number of typical periods into which the time series data should be clustered. The number of time steps per period must be an integer multiple of the total number of considered time steps in the energy system.
.. note::
Please refer to the tsam package documentation of the parameter noTypicalPeriods for more
information.
|br| * the default value is 7
:type numberOfTypicalPeriods: strictly positive integer
:param numberOfTimeStepsPerPeriod: states the number of time steps per period |br| * the default value is 24 :type numberOfTimeStepsPerPeriod: strictly positive integer
:param segmentation: states whether the typical periods should be further segmented to fewer time steps |br| * the default value is False :type segmentation: boolean
:param numberOfSegmentsPerPeriod: states the number of segments per period |br| * the default value is 24 :type numberOfSegmentsPerPeriod: strictly positive integer
:param clusterMethod: states the method which is used in the tsam package for clustering the time series data. Options are for example 'averaging', 'k_means', 'exact k_medoid' or 'hierarchical'.
.. note::
Please refer to the tsam package documentation of the parameter clusterMethod for more information.
|br| * the default value is 'hierarchical'
:type clusterMethod: string
:param representationMethod: Chosen representation. If specified, the clusters are represented in the chosen way. Otherwise, each clusterMethod has its own commonly used default representation method.
.. note::
Please refer to the tsam package documentation of the parameter representationMethod for more information.
|br| * the default Value is "durationRepresentation"
:type representationMethod: string
:param rescaleClusterPeriods: states if the cluster periods shall get rescaled such that their weighted mean value fits the mean value of the original time series
.. note::
Please refer to the tsam package documentation of the parameter rescaleClusterPeriods for more information.
|br| * the default value is False
:type rescaleClusterPeriods: boolean
:param sortValues: states if the algorithm in the tsam package should use
(a) the sorted duration curves (-> True) or
(b) the original profiles (-> False)
of the time series data within a period for clustering.
.. note::
Please refer to the tsam package documentation of the parameter sortValues for more information.
|br| * the default value is True
:type sortValues: boolean
:param storeTSAinstance: states if the TimeSeriesAggregation instance created during clustering should be stored in the EnergySystemModel instance. |br| * the default value is False :type storeTSAinstance: boolean
createTimeSeriesDataForAggregation
¶
Create and return the time series data, weights, and zero-data columns for aggregation.
Returns: tuple[pd.DataFrame, dict, pd.Index]: Time series data, weight dictionary, and columns containing only zero values.
declareBalanceLimitConstraint
¶
Declare balance limit constraint.
Balance limit constraint can limit the exchange of commodities within the model or over the model region boundaries. See the documentation of the parameters for further explanation. In general the following equation applies:
E_source - E_sink + E_exchange,in - E_exchange,out <= E_lim (LowerBound=False)
E_source - E_sink + E_exchange,in - E_exchange,out >= E_lim (LowerBound=True)
:param pyM: a pyomo ConcreteModel instance which contains parameters, sets, variables, constraints and objective required for the optimization set up and solving. :type pyM: pyomo ConcreteModel
:param timeSeriesAggregation: states if the optimization of the energy system model should be done with
(a) the full time series (False) or
(b) clustered time series data (True).
|br| * the default value is False
:type timeSeriesAggregation: boolean
declareCommodityBalanceConstraints
¶
Declare commodity balance constraints (one balance constraint for each commodity, location and time step).
.. math::
\\underset{\\text{comp} \\in \\mathcal{C}^{comm}_{loc}}{\\sum} \\text{C}^{comp,comm}_{loc,ip,p,t} = 0
:param pyM: a pyomo ConcreteModel instance which contains parameters, sets, variables, constraints and objective required for the optimization set up and solving. :type pyM: pyomo ConcreteModel
declareComponentLinkedQuantityConstraints
¶
Declare linked component quantity constraint, e.g. if an engine (E-Motor) is built also a storage (Battery) and a vehicle body (e.g. BEV Car) needs to be built. Not the capacity of the components, but the number of the components is linked.
:param pyM: a pyomo ConcreteModel instance which contains parameters, sets, variables, constraints and objective required for the optimization set up and solving. :type pyM: pyomo ConcreteModel
declareObjective
¶
Declare the objective function by obtaining the contributions to the objective function from all modeling classes. Currently, the only objective function which can be selected is the sum of the net present value of all components.
.. math:: z^* = \min \underset{comp \in \mathcal{C}}{\sum} \ \underset{loc \in \mathcal{L}^{comp}}{\sum} \left( NPV_{loc}^{comp,cap} + NPV_{loc}^{comp,bin} + NPV_{loc}^{comp,op} \right)
Objective Function detailed:
.. math:: z^* = \min \underset{comp \in \mathcal{C}}{\sum} \ \underset{loc \in \mathcal{L}^{comp}}{\sum} \ \underset{ip \in \mathcal{IP}}{\sum} \text{design}^{comp}{loc,ip} + \text{design}^{comp}} + \text{op}^{comp}_{loc,ip
Contribution of design variable to the objective function
.. math:: design^{comp}{loc,ip} = \sum\limits \text{F}^{comp,bin}}}^{ip{loc,year} \cdot \left( \frac{\text{investPerCap}^{comp}}}{\text{CCF}^{comp{loc,year}} + \text{opexPerCap}^{comp}} \right) \cdot commis^{comp{loc,year} \cdot \text{APVF}^{comp}} \cdot \text{discFactor}^{comp}_{loc,ip
Contribution of binary design variables to the objective function
.. math:: design^{comp}{bin\ loc,ip} = \sum\limits \text{F}^{comp,bin}}}^{ip{loc,year} \cdot \left( \frac{\text{investIfBuilt}^{comp}}} {\text{CCF}^{comp{loc,year}} + \text{opexIfBuilt}^{comp}} \right) \cdot bin^{comp{loc,year} \cdot \text{APVF}^{comp}} \cdot \text{discFactor}^{comp}_{loc,ip
Contribution of operation variables to the objective function
.. math:: op^{comp}{loc,ip} = \underset{(p,t) \in \mathcal{P} \times \mathcal{T}}{\sum} \ \underset{\text{opType} \in \mathcal{O}^{comp}}{\sum} \text{factorPerOp}^{comp,opType}} \cdot op^{comp,opType{loc,ip,p,t} \cdot \frac{\text{freq(p)}}{\tau^{years}} \cdot \text{APVF}^{comp}} \cdot \text{discFactor}^{comp}_{loc,ip
With the annuity present value factor (Rentenbarwertfaktor):
.. math:: APVF^{comp}{loc} = \frac{(1 + \text{interestRate}^{comp}})^{interval} - 1}{\text{interestRate}^{comp{loc} \cdot (1 + \text{interestRate}^{comp} != 0 \ else \ 1})^{interval}} \ if \text{interestRate}^{comp}_{loc
and the discount factor.
.. math:: \text{discFactor}^{comp}{loc,ip} = \frac{1+\text{interestRate}^{comp})^{ip \cdot \text{interval}}}}}{(1+\text{interestRate}^{comp}_{loc
:param pyM: a pyomo ConcreteModel instance which contains parameters, sets, variables, constraints and objective required for the optimization set up and solving. :type pyM: pyomo ConcreteModel
declareOptimizationProblem
¶
declareOptimizationProblem(
timeSeriesAggregation=False,
relaxIsBuiltBinary=False,
relevanceThreshold=None,
)
Declare the optimization problem belonging to the specified energy system for which a pyomo concrete model instance is built and filled with.
- basic time sets,
- sets, variables and constraints contributed by the component modeling classes,
- basic, component overreaching constraints, and
- an objective function.
Default arguments:
:param timeSeriesAggregation: states if the optimization of the energy system model should be done with
(a) the full time series (False) or
(b) clustered time series data (True).
|br| * the default value is False
:type timeSeriesAggregation: boolean
:param relaxIsBuiltBinary: states if the optimization problem should be solved as a relaxed LP to get the lower bound of the problem. |br| * the default value is False :type declaresOptimizationProblem: boolean
:param relevanceThreshold: Force operation parameters to be 0 if values are below the relevance threshold. |br| * the default value is None :type relevanceThreshold: float (>=0) or None
declareSharedPotentialConstraints
¶
Declare shared potential constraints, e.g. if a maximum potential of salt caverns has to be shared by salt cavern storing methane and salt caverns storing hydrogen.
.. math::
\\underset{\\text{comp} \\in \\mathcal{C}^{ID}}{\\sum} \\text{cap}^{comp}_{loc} / \\text{capMax}^{comp}_{loc} \\leq 1
:param pyM: a pyomo ConcreteModel instance which contains parameters, sets, variables, constraints and objective required for the optimization set up and solving. :type pyM: pyomo ConcreteModel
declareTimeSets
¶
Set and initialize basic time parameters and sets.
:param pyM: a pyomo ConcreteModel instance which contains parameters, sets, variables, constraints and objective required for the optimization set up and solving. :type pyM: pyomo ConcreteModel
:param timeSeriesAggregation: states if the optimization of the energy system model should be done with
(a) the full time series (False) or
(b) clustered time series data (True).
|br| * the default value is False
:type timeSeriesAggregation: boolean
:param segmentation: states if the optimization of the energy system model based on clustered time series data should be done with
(a) aggregated typical periods with the original time step length (False) or
(b) aggregated typical periods with further segmented time steps (True).
|br| * the default value is False
:type segmentation: boolean
getComponent
¶
Return a component of the energy system.
:param componentName: name of the component that should be returned :type componentName: string
:returns: the component which has the name componentName :rtype: Component
getComponentAttribute
¶
Return an attribute of a component considered in the energy system.
:param componentName: name of the component from which the attribute should be obtained :type componentName: string
:param attributeName: name of the attribute that should be returned :type attributeName: string
:returns: the attribute specified by the attributeName of the component with the name componentName :rtype: depends on the specified attribute
getOptimizationSummary
¶
Return the optimization summary (design variables, aggregated operation variables, and objective contributions) of a modeling class.
:param modelingClass: name of the modeling class from which the optimization summary should be obtained :type modelingClass: string
:param outputLevel: states the level of detail of the output summary:
- 0: full optimization summary is returned
- 1: full optimization summary is returned but rows in which all values are NaN (not a number) are dropped
- 2: full optimization summary is returned but rows in which all values are NaN or 0 are dropped
|br| * the default value is 0
:type outputLevel: integer (0, 1 or 2)
:returns: the optimization summary of the requested modeling class :rtype: pandas DataFrame
optimize
¶
optimize(
declaresOptimizationProblem=True,
relaxIsBuiltBinary=False,
timeSeriesAggregation=False,
logFileName="",
threads=3,
solver="None",
timeLimit=None,
optimizationSpecs="",
warmstart=False,
relevanceThreshold=None,
includePerformanceSummary=False,
)
Optimize the specified energy system for which a pyomo ConcreteModel instance is built or called upon. A pyomo instance is optimized with the specified inputs, and the optimization results are further processed.
Default arguments:
:param declaresOptimizationProblem: states if the optimization problem should be declared (True) or not (False).
(a) If true, the declareOptimizationProblem function is called and a pyomo ConcreteModel instance is built.
(b) If false a previously declared pyomo ConcreteModel instance is used.
|br| * the default value is True
:type declaresOptimizationProblem: boolean
:param relaxIsBuiltBinary: states if the optimization problem should be solved as a relaxed LP to get the lower bound of the problem. |br| * the default value is False :type declaresOptimizationProblem: boolean
:param timeSeriesAggregation: states if the optimization of the energy system model should be done with
(a) the full time series (False) or
(b) clustered time series data (True).
|br| * the default value is False
:type timeSeriesAggregation: boolean
:param segmentation: states if the optimization of the energy system model based on clustered time series data should be done with
(a) aggregated typical periods with the original time step length (False) or
(b) aggregated typical periods with further segmented time steps (True).
|br| * the default value is False
:type segmentation: boolean
:param logFileName: logFileName is used for naming the log file of the optimization solver output if gurobi is used as the optimization solver. If the logFileName is given as an absolute path (e.g. logFileName = os.path.join(os.getcwd(), 'Results', 'logFileName.txt')) the log file will be stored in the specified directory. Otherwise, it will be stored by default in the directory where the executing python script is called. |br| * the default value is 'job' :type logFileName: string
:param threads: number of computational threads used for solving the optimization (solver dependent input) if gurobi is used as the solver. A value of 0 results in using all available threads. If a value larger than the available number of threads are chosen, the value will reset to the maximum number of threads. |br| * the default value is 3 :type threads: positive integer
:param solver: specifies which solver should solve the optimization problem (which of course has to be installed on the machine on which the model is run). |br| * the default value is 'gurobi' :type solver: string
:param timeLimit: if not specified as None, indicates the maximum solve time of the optimization problem in seconds (solver dependent input). The use of this parameter is suggested when running models in runtime restricted environments (such as clusters with job submission systems). If the runtime limitation is triggered before an optimal solution is available, the best solution obtained up until then (if available) is processed. |br| * the default value is None :type timeLimit: strictly positive integer or None
:param optimizationSpecs: specifies parameters for the optimization solver (see the respective solver documentation for more information). Example: 'LogToConsole=1 OptimalityTol=1e-6' |br| * the default value is an empty string ('') :type optimizationSpecs: string
:param warmstart: specifies if a warm start of the optimization should be considered (not always supported by the solvers). |br| * the default value is False :type warmstart: boolean
:param relevanceThreshold: Force operation parameters to be 0 if values are below the relevance threshold. |br| * the default value is None :type relevanceThreshold: float (>=0) or None
:param includePerformanceSummary: If True this will store a performance summary (in Dataframe format) as attribute ('self.performanceSummary') in the esM instance. The performance summary includes Data about RAM usage (assesed by the psutil package), Gurobi values (extracted from gurobi log with the gurobi-logtools package) and other various paramerts such as model buildtime, runtime and time series aggregation paramerters. |br| * the default value is False :type includePerformanceSummary: boolean
Last edited: November 16, 2023 |br| @author: FINE Developer Team (FZJ IEK-3)
removeComponent
¶
Remove a component from the energy system.
:param componentName: name of the component that should be removed :type componentName: string
:param track: specifies if the removed components should be tracked or not |br| * the default value is False :type track: boolean
:returns: dictionary with the removed componentName and component instance if track is set to True else None. :rtype: dict or None
updateComponent
¶
Overwrite selected attributes of an existing esM component with new values.
.. note:: Be aware of the fact that some attributes are filled automatically while initializing a component. E.g., if you want to change attributes like economic lifetime, there might occur the error that the new value does not match with the technical lifetime of the component. Additionally: You cannot change the name of an existing component by using this function. If you do so, you will not update the component but create a new one with the new name. The old component will still exist.
:param componentName: Name of the component that shall be updated. :type componentName: str
:param updateAttrs: A dict of component attributes as keys and values that shall be set as dict values. :type updateAttrs: dict