oemof.solph package¶
Submodules¶
oemof.solph.blocks module¶
Creating sets, variables, constraints and parts of the objective function for the specified groups.
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/blocks.py
SPDXLicenseIdentifier: GPL3.0orlater

class
oemof.solph.blocks.
Bus
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for all balanced buses.
The following constraints are build:
 Bus balance
om.Bus.balance[i, o, t]
 Bus balance

class
oemof.solph.blocks.
Flow
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Flow block with definitions for standard flows.
The following variables are created:
 negative_gradient :
 Difference of a flow in consecutive timesteps if flow is reduced indexed by NEGATIVE_GRADIENT_FLOWS, TIMESTEPS.
 positive_gradient :
 Difference of a flow in consecutive timesteps if flow is increased indexed by NEGATIVE_GRADIENT_FLOWS, TIMESTEPS.
The following sets are created: (> see basic sets at
Model
) SUMMED_MAX_FLOWS
 A set of flows with the attribute
summed_max
being not None.  SUMMED_MIN_FLOWS
 A set of flows with the attribute
summed_min
being not None.  NEGATIVE_GRADIENT_FLOWS
 A set of flows with the attribute
negative_gradient
being not None.  POSITIVE_GRADIENT_FLOWS
 A set of flows with the attribute
positive_gradient
being not None  INTEGER_FLOWS
 A set of flows wher the attribute
integer
is True (forces flow to only take integer values)
The following constraints are build:
 Flow max sum
om.Flow.summed_max[i, o]
 Flow min sum
om.Flow.summed_min[i, o]
 Negative gradient constraint
om.Flow.negative_gradient_constr[i, o]
:  Positive gradient constraint
om.Flow.positive_gradient_constr[i, o]
:
The following parts of the objective function are created:
 If
variable_costs
are set by the user:
The expression can be accessed by
om.Flow.variable_costs
and their value after optimization byom.Flow.variable_costs()
.

class
oemof.solph.blocks.
InvestmentFlow
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for all flows with
investment
being not None.The following sets are created: (> see basic sets at
Model
) FLOWS
 A set of flows with the attribute
invest
of typeoptions.Investment
.  FIXED_FLOWS
 A set of flow with the attribute
fixed
set to True  SUMMED_MAX_FLOWS
 A subset of set FLOWS with flows with the attribute
summed_max
being not None.  SUMMED_MIN_FLOWS
 A subset of set FLOWS with flows with the attribute
summed_min
being not None.  MIN_FLOWS
 A subset of FLOWS with flows having set a value of not None in the first timestep.
The following variables are created:
 invest
om.InvestmentFlow.invest[i, o]
 Value of the investment variable i.e. equivalent to the nominal value of the flows after optimization (indexed by FLOWS)
The following constraints are build:
 Actual value constraint for fixed invest
 flows
om.InvestmentFlow.fixed[i, o, t]
 flows
 Lower bound (min) constraint for invest flows
om.InvestmentFlow.min[i, o, t]
 Upper bound (max) constraint for invest flows
om.InvestmentFlow.max[i, o, t]
 Flow max sum for invest flow
om.InvestmentFlow.summed_max[i, o]
 Flow min sum for invest flow
om.InvestmentFlow.summed_min[i, o]
The following parts of the objective function are created:
 Equivalent periodical costs (epc) expression
om.InvestmentFlow.investment_costs
:
The expression can be accessed by
om.InvestmentFlow.variable_costs
and their value after optimization byom.InvestmentFlow.variable_costs()
. This works similar for investment costs with*.investment_costs
etc.

class
oemof.solph.blocks.
NonConvexFlow
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
 The following sets are created: (> see basic sets at
Model
) A set of flows with the attribute
nonconvex
of type options.NonConvex
. MIN_FLOWS
 A subset of set NONCONVEX_FLOWS with the attribute
min
being not None in the first timestep  STARTUP_FLOWS
 A subset of set NONCONVEX_FLOWS with the attribute
startup_costs
being not None.  SHUTDOWN_FLOWS
 A subset of set NONCONVEX_FLOWS with the attribute
shutdown_costs
being not None.  ACTIVE_FLOWS
 A subset of set NONCONVEX_FLOWS with the attribute
activity_costs
being not None.  MINUPTIMEFLOWS
 A subset of set NONCONVEX_FLOWS with the attribute
minimum_uptime
being not None.  MINDOWNTIMEFLOWS
 A subset of set NONCONVEX_FLOWS with the attribute
minimum_downtime
being not None.
The following variables are created:
 Status variable (binary)
om.NonConvexFlow.status
:  Variable indicating if flow is >= 0 indexed by FLOWS
 Startup variable (binary)
om.NonConvexFlow.startup
:  Variable indicating startup of flow (component) indexed by STARTUP_FLOWS
 Shutdown variable (binary)
om.NonConvexFlow.shutdown
:  Variable indicating shutdown of flow (component) indexed by SHUTDOWN_FLOWS
The following constraints are created:
 Minimum flow constraint
om.NonConvexFlow.min[i,o,t]
 Maximum flow constraint
om.NonConvexFlow.max[i,o,t]
 Startup constraint
om.NonConvexFlow.startup_constr[i,o,t]
 Shutdown constraint
om.NonConvexFlow.shutdown_constr[i,o,t]
 Minimum uptime constraint
om.NonConvexFlow.uptime_constr[i,o,t]
 Minimum downtime constraint
om.NonConvexFlow.downtime_constr[i,o,t]
The following parts of the objective function are created:
 If
nonconvex.startup_costs
is set by the user:  If
nonconvex.shutdown_costs
is set by the user:  If
nonconvex.activity_costs
is set by the user:

class
oemof.solph.blocks.
Transformer
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for the linear relation of nodes with type
Transformer
The following sets are created: (> see basic sets at
Model
) TRANSFORMERS
 A set with all
Transformer
objects.
The following constraints are created:
 Linear relation
om.Transformer.relation[i,o,t]
oemof.solph.components module¶
This module is designed to hold components with their classes and associated individual constraints (blocks) and groupings. Therefore this module holds the class definition and the block directly located by each other.
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/components.py
SPDXLicenseIdentifier: GPL3.0orlater

class
oemof.solph.components.
ExtractionTurbineCHP
(conversion_factor_full_condensation, *args, **kwargs)[source]¶ Bases:
oemof.solph.network.Transformer
A CHP with an extraction turbine in a linear model. For more options see the
GenericCHP
class.One main output flow has to be defined and is tapped by the remaining flow. The conversion factors have to be defined for the maximum tapped flow ( full CHP mode) and for no tapped flow (full condensing mode). Even though it is possible to limit the variability of the tapped flow, so that the full condensing mode will never be reached.
Parameters:  conversion_factors (dict) – Dictionary containing conversion factors for conversion of inflow to specified outflow. Keys are output bus objects. The dictionary values can either be a scalar or a sequence with length of time horizon for simulation.
 conversion_factor_full_condensation (dict) – The efficiency of the main flow if there is no tapped flow. Only one key is allowed. Use one of the keys of the conversion factors. The key indicates the main flow. The other output flow is the tapped flow.
Note
 The following sets, variables, constraints and objective parts are created
Examples
>>> from oemof import solph >>> bel = solph.Bus(label='electricityBus') >>> bth = solph.Bus(label='heatBus') >>> bgas = solph.Bus(label='commodityBus') >>> et_chp = solph.components.ExtractionTurbineCHP( ... label='variable_chp_gas', ... inputs={bgas: solph.Flow(nominal_value=10e10)}, ... outputs={bel: solph.Flow(), bth: solph.Flow()}, ... conversion_factors={bel: 0.3, bth: 0.5}, ... conversion_factor_full_condensation={bel: 0.5})

class
oemof.solph.components.
ExtractionTurbineCHPBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for the linear relation of nodes with type
ExtractionTurbineCHP
The following sets are created: (> see basic sets at
Model
) VARIABLE_FRACTION_TRANSFORMERS
 A set with all
ExtractionTurbineCHP
objects.
The following two constraints are created:
where is defined as:
where the first equation is the result of the relation between the input flow and the two output flows, the second equation stems from how the two output flows relate to each other, and the symbols used are defined as follows:
symbol explanation attribute fuel input flow flow(inflow, n, t)
is the flow frominflow
node to the node at timestepelectric power flow(n, main_output, t)
is the flow from the node to themain_output
node at timestepthermal output flow(n, tapped_output, t)
is the flow from the node to thetapped_output
node at timesteppower loss index main_flow_loss_index
at node at timestep as defined aboveelectric efficiency without heat extraction conversion_factor_full_condensation
at node at timestepelectric efficiency with max heat extraction conversion_factors
for themain_output
at node at timestepthermal efficiency with maximal heat extraction conversion_factors
for thetapped_output
at node at timestep
CONSTRAINT_GROUP
= True¶

class
oemof.solph.components.
GenericCHP
(*args, **kwargs)[source]¶ Bases:
oemof.network.Transformer
Component GenericCHP to model combined heat and power plants.
Can be used to model (combined cycle) extraction or backpressure turbines and used a mixedinteger linear formulation. Thus, it induces more computational effort than the ExtractionTurbineCHP for the benefit of higher accuracy.
The full set of equations is described in: Mollenhauer, E., Christidis, A. & Tsatsaronis, G. Evaluation of an energy and exergybased generic modeling approach of combined heat and power plants Int J Energy Environ Eng (2016) 7: 167. https://doi.org/10.1007/s4009501602046
For a general understanding of (MI)LP CHP representation, see: Fabricio I. Salgado, P. Short  Term Operation Planning on Cogeneration Systems: A Survey Electric Power Systems Research (2007) Electric Power Systems Research Volume 78, Issue 5, May 2008, Pages 835848 https://doi.org/10.1016/j.epsr.2007.06.001
Note
An adaption for the flow parameter H_L_FG_share_max has been made to set the flue gas losses at maximum heat extraction H_L_FG_max as share of the fuel flow H_F e.g. for combined cycle extraction turbines. The flow parameter H_L_FG_share_min can be used to set the flue gas losses at minimum heat extraction H_L_FG_min as share of the fuel flow H_F e.g. for motoric CHPs. The boolean component parameter back_pressure can be set to model backpressure characteristics.
Also have a look at the examples on how to use it.
Parameters:  fuel_input (dict) – Dictionary with keyvaluepair of oemof.Bus and oemof.Flow object for the fuel input.
 electrical_output (dict) – Dictionary with keyvaluepair of oemof.Bus and oemof.Flow object for the electrical output. Related parameters like P_max_woDH are passed as attributes of the oemof.Flow object.
 heat_output (dict) – Dictionary with keyvaluepair of oemof.Bus and oemof.Flow object for the heat output. Related parameters like Q_CW_min are passed as attributes of the oemof.Flow object.
 Beta (list of numerical values) – Beta values in same dimension as all other parameters (length of optimization period).
 back_pressure (boolean) – Flag to use backpressure characteristics. Set to True and Q_CW_min to zero for backpressure turbines. See paper above for more information.
Note
 The following sets, variables, constraints and objective parts are created
Examples
>>> from oemof import solph >>> bel = solph.Bus(label='electricityBus') >>> bth = solph.Bus(label='heatBus') >>> bgas = solph.Bus(label='commodityBus') >>> ccet = solph.components.GenericCHP( ... label='combined_cycle_extraction_turbine', ... fuel_input={bgas: solph.Flow( ... H_L_FG_share_max=[0.183])}, ... electrical_output={bel: solph.Flow( ... P_max_woDH=[155.946], ... P_min_woDH=[68.787], ... Eta_el_max_woDH=[0.525], ... Eta_el_min_woDH=[0.444])}, ... heat_output={bth: solph.Flow( ... Q_CW_min=[10.552])}, ... Beta=[0.122], back_pressure=False) >>> type(ccet) <class 'oemof.solph.components.GenericCHP'>

alphas
¶ Compute or return the _alphas attribute.

class
oemof.solph.components.
GenericCHPBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for the relation of the nodes with type class:.GenericCHP.
TODO: Add test
The following constraints are created:
where depends on the CHP being back pressure or not. If is given, e.g. for a motoric CHP:
The coefficients and can be determined given the efficiencies maximal/minimal load:
math. symbol explanation attribute input of enthalpy through fuel input H_F[n,t]
provided electric power P[n,t]
electric power without district heating P_woDH[n,t]
min. electric power without district heating P_min_woDH[n,t]
max. electric power without district heating P_max_woDH[n,t]
provided heat Q[n,t]
minimal therm. condenser load to cooling water Q_CW_min[n,t]
flue gas enthalpy loss at min heat extraction H_L_FG_min[n,t]
flue gas enthalpy loss at max heat extraction H_L_FG_max[n,t]
share of flue gas loss at min heat extraction H_L_FG_share_min[n,t]
share of flue gas loss at max heat extraction H_L_FG_share_max[n,t]
status variable on/off Y[n,t]
coefficient describing efficiency n.alphas[0][n,t]
coefficient describing efficiency n.alphas[1][n,t]
power loss index Beta[n,t]
el. eff. at min. fuel flow w/o distr. heating Eta_el_min_woDH[n,t]
el. eff. at max. fuel flow w/o distr. heating Eta_el_max_woDH[n,t]

CONSTRAINT_GROUP
= True¶


class
oemof.solph.components.
GenericInvestmentStorageBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Storage with an
Investment
object.The following sets are created: (> see basic sets at
Model
) INVESTSTORAGES
 A set with all storages containing an Investment object.
 INVEST_REL_CAP_IN
 A set with all storages containing an Investment object with coupled investment of input power and storage capacity
 INVEST_REL_CAP_OUT
 A set with all storages containing an Investment object with coupled investment of output power and storage capacity
 INVEST_REL_IN_OUT
 A set with all storages containing an Investment object with coupled investment of input and output power
 INITIAL_CAPACITY
 A subset of the set INVESTSTORAGES where elements of the set have an initial_capacity attribute.
 MIN_INVESTSTORAGES
 A subset of INVESTSTORAGES where elements of the set have an capacity_min attribute greater than zero for at least one time step.
The following variables are created:
 capacity
om.InvestmentStorage.capacity[n, t]
 Level of the storage (indexed by STORAGES and TIMESTEPS)
 invest
om.InvestmentStorage.invest[n, t]
 Nominal capacity of the storage (indexed by STORAGES)
The following constraints are build:
 Storage balance
 Initial capacity of
network.Storage
 Connect the invest variables of the storage and the input flow.
 Connect the invest variables of the storage and the output flow.
 Connect the invest variables of the input and the output flow.
 Maximal capacity
om.InvestmentStorage.max_capacity[n, t]
 Minimal capacity
om.InvestmentStorage.min_capacity[n, t]
The following parts of the objective function are created:
 Equivalent periodical costs (investment costs):
The expression can be accessed by
om.InvestStorages.investment_costs
and their value after optimization byom.InvestStorages.investment_costs()
.
CONSTRAINT_GROUP
= True¶

class
oemof.solph.components.
GenericStorage
(*args, **kwargs)[source]¶ Bases:
oemof.network.Transformer
Component GenericStorage to model with basic characteristics of storages.
Parameters:  nominal_capacity (numeric) – Absolute nominal capacity of the storage
 nominal_output_capacity_ratio (numeric) – DEPRECATED  Define the output capacity as nominal_value in the Flow
class. In case of an investment object in the storage and the flow use
invest_relation_input_capacity
instead. OLD TEXT: Ratio between the nominal outflow of the storage and its capacity. For batteries this is also know as crate. Note: This ratio is used to create the Flow object for the outflow and set its nominal value of the storage in the constructor. If no investment object is defined it is also possible to set the nominal value of the flow directly in its constructor.  nominal_input_capacity_ratio (numeric) – DEPRECATED  Define the input capacity as nominal_value in the Flow
class. In case of an investment object in the storage and the flow use
invest_relation_output_capacity
instead. OLD TEXT: Ratio between the nominal inflow of the storage and its capacity. see: nominal_output_capacity_ratio  invest_relation_input_capacity (numeric or None) –
Ratio between the investment variable of the input Flow and the investment variable of the storage.
 invest_relation_output_capacity (numeric or None) –
Ratio between the investment variable of the output Flow and the investment variable of the storage.
 invest_relation_input_output (numeric or None) –
Ratio between the investment variable of the output Flow and the investment variable of the input flow. This ratio used to fix the flow investments to each other. Values < 1 set the input flow lower than the output and > 1 will set the input flow higher than the output flow. If None no relation will be set.
 initial_capacity (numeric) – The capacity of the storage in the first (and last) time step of optimization.
 capacity_loss (numeric (sequence or scalar)) – The relative loss of the storage capacity from between two consecutive timesteps.
 inflow_conversion_factor (numeric (sequence or scalar)) – The relative conversion factor, i.e. efficiency associated with the inflow of the storage.
 outflow_conversion_factor (numeric (sequence or scalar)) – see: inflow_conversion_factor
 capacity_min (numeric (sequence or scalar)) – The nominal minimum capacity of the storage as fraction of the nominal capacity (between 0 and 1, default: 0). To set different values in every time step use a sequence.
 capacity_max (numeric (sequence or scalar)) – see: capacity_min
 investment (
oemof.solph.options.Investment
object) – Object indicating if a nominal_value of the flow is determined by the optimization problem. Note: This will refer all attributes to an investment variable instead of to the nominal_capacity. The nominal_capacity should not be set (or set to None) if an investment object is used.
Note
 The following sets, variables, constraints and objective parts are created
GenericStorageBlock
(if no Investment object present)GenericInvestmentStorageBlock
(if Investment object present)
Examples
Basic usage examples of the GenericStorage with a random selection of attributes. See the Flow class for all Flow attributes.
>>> from oemof import solph
>>> my_bus = solph.Bus('my_bus')
>>> my_storage = solph.components.GenericStorage( ... label='storage', ... nominal_capacity=1000, ... inputs={my_bus: solph.Flow(nominal_value=200, variable_costs=10)}, ... outputs={my_bus: solph.Flow(nominal_value=200)}, ... capacity_loss=0.01, ... initial_capacity=0, ... capacity_max = 0.9, ... inflow_conversion_factor=0.9, ... outflow_conversion_factor=0.93)
>>> my_investment_storage = solph.components.GenericStorage( ... label='storage', ... investment=solph.Investment(ep_costs=50), ... inputs={my_bus: solph.Flow()}, ... outputs={my_bus: solph.Flow()}, ... capacity_loss=0.02, ... initial_capacity=None, ... invest_relation_input_capacity=1/6, ... invest_relation_output_capacity=1/6, ... inflow_conversion_factor=1, ... outflow_conversion_factor=0.8)

class
oemof.solph.components.
GenericStorageBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Storage without an
Investment
object.The following sets are created: (> see basic sets at
Model
) STORAGES
 A set with all
Storage
objects (and no attr:investement of typeInvestment
)  STORAGES_WITH_INVEST_FLOW_REL
 A set with all
Storage
objects with two investment flows coupled with the ‘invest_relation_input_output’ attribute.
The following variables are created:
 capacity
 Capacity (level) for every storage and timestep. The value for the capacity at the beginning is set by the parameter initial_capacity or not set if initial_capacity is None. The variable of storage s and timestep t can be accessed by: om.Storage.capacity[s, t]
The following constraints are created:
 Storage balance
om.Storage.balance[n, t]
 Connect the invest variables of the input and the output flow.
The following parts of the objective function are created:
Nothing added to the objective function.

CONSTRAINT_GROUP
= True¶
oemof.solph.constraints module¶
Additional constraints to be used in an oemof energy model. This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/constraints.py
SPDXLicenseIdentifier: GPL3.0orlater

oemof.solph.constraints.
emission_limit
(om, flows=None, limit=None)[source]¶ Set a global limit for emissions. The emission attribute has to be added to every flow you want to take into account.
Parameters:  om (oemof.solph.Model) – Model to which constraints are added.
 flows (dict) – Dictionary holding the flows that should be considered in constraint. Keys are (source, target) objects of the Flow. If no dictionary is given all flows containing the ‘emission’ attribute will be used.
 limit (numeric) – Absolute emission limit.
Note
Flow objects required an emission attribute!

oemof.solph.constraints.
equate_variables
(model, var1, var2, factor1=1, name=None)[source]¶ Adds a constraint to the given model that set two variables to equal adaptable by a factor.
The following constraints are build:
Parameters:  var1 (pyomo.environ.Var) – First variable, to be set to equal with Var2 and multiplied with factor1.
 var2 (pyomo.environ.Var) – Second variable, to be set equal to (Var1 * factor1).
 factor1 (float) – Factor to define the proportion between the variables.
 name (str) – Optional name for the equation e.g. in the LP file. By default the name is: equate + string representation of var1 and var2.
 model (oemof.solph.Model) – Model to which the constraint is added.
Examples
The following example shows how to define a transmission line in the investment mode by connecting both investment variables. Note that the equivalent periodical costs (epc) of the line are 40. You could also add them to one line and set them to 0 for the other line.
>>> import pandas as pd >>> from oemof import solph >>> date_time_index = pd.date_range('1/1/2012', periods=5, freq='H') >>> energysystem = solph.EnergySystem(timeindex=date_time_index) >>> bel1 = solph.Bus(label='electricity1') >>> bel2 = solph.Bus(label='electricity2') >>> energysystem.add(bel1, bel2) >>> energysystem.add(solph.Transformer( ... label='powerline_1_2', ... inputs={bel1: solph.Flow()}, ... outputs={bel2: solph.Flow( ... investment=solph.Investment(ep_costs=20))})) >>> energysystem.add(solph.Transformer( ... label='powerline_2_1', ... inputs={bel2: solph.Flow()}, ... outputs={bel1: solph.Flow( ... investment=solph.Investment(ep_costs=20))})) >>> om = solph.Model(energysystem) >>> line12 = energysystem.groups['powerline_1_2'] >>> line21 = energysystem.groups['powerline_2_1'] >>> solph.constraints.equate_variables( ... om, ... om.InvestmentFlow.invest[line12, bel2], ... om.InvestmentFlow.invest[line21, bel1])

oemof.solph.constraints.
investment_limit
(model, limit=None)[source]¶ Set an absolute limit for the total investment costs of an investment optimization problem:
Parameters:  model (oemof.solph.Model) – Model to which the constraint is added
 limit (float) – Absolute limit of the investment (i.e. RHS of constraint)
oemof.solph.custom module¶
This module is designed to hold custom components with their classes and associated individual constraints (blocks) and groupings. Therefore this module holds the class definition and the block directly located by each other.
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/custom.py
SPDXLicenseIdentifier: GPL3.0orlater

class
oemof.solph.custom.
ElectricalBus
(*args, **kwargs)[source]¶ Bases:
oemof.solph.network.Bus
A electrical bus object. Every node has to be connected to Bus. This Bus is used in combination with ElectricalLine objects for linear optimal power flow (lopf) simulations.
Notes
 The following sets, variables, constraints and objective parts are created
 The objects are also used inside:

class
oemof.solph.custom.
ElectricalLine
(*args, **kwargs)[source]¶ Bases:
oemof.solph.network.Transformer
An ElectricalLine to be used in linear optimal power flow calculations. based on angle formulation. Check out the Notes below before using this component!
Parameters: reactance (float or array of floats) – Reactance of the line to be modelled Notes
 To use this object the connected buses need to be of the type
ElectricalBus
.  It does not work together with flows that have set the attr.`nonconvex`, i.e. unit commitment constraints are not possible
 Input and output of this component are set equal, therefore just use either only the input or the output to parameterize.
 Default attribute min of in/outflows is overwritten by 1 if not set differently by the user
 The following sets, variables, constraints and objective parts are created
 To use this object the connected buses need to be of the type

class
oemof.solph.custom.
ElectricalLineBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for the linear relation of nodes with type class:.ElectricalLine
The following constraints are created:
 Linear relation
om.ElectricalLine.electrical_flow[n,t]
TODO: Add equate constraint of flows
The following variable are created:
TODO: Add voltage angle variable
TODO: Add fix slack bus voltage angle to zero constraint / bound
TODO: Add tests

CONSTRAINT_GROUP
= True¶
 Linear relation

class
oemof.solph.custom.
GenericCAES
(*args, **kwargs)[source]¶ Bases:
oemof.solph.network.Transformer
Component GenericCAES to model arbitrary compressed air energy storages.
The full set of equations is described in: Kaldemeyer, C.; Boysen, C.; Tuschy, I. A Generic Formulation of Compressed Air Energy Storage as Mixed Integer Linear Program – Unit Commitment of Specific Technical Concepts in Arbitrary Market Environments Materials Today: Proceedings 00 (2018) 0000–0000 [currently in review]
Parameters:  electrical_input (dict) – Dictionary with keyvaluepair of oemof.Bus and oemof.Flow object for the electrical input.
 fuel_input (dict) – Dictionary with keyvaluepair of oemof.Bus and oemof.Flow object for the fuel input.
 electrical_output (dict) – Dictionary with keyvaluepair of oemof.Bus and oemof.Flow object for the electrical output.
Notes
 The following sets, variables, constraints and objective parts are created
GenericCAES
TODO: Add description for constraints. See referenced paper until then!
Examples
>>> from oemof import solph >>> bel = solph.Bus(label='bel') >>> bth = solph.Bus(label='bth') >>> bgas = solph.Bus(label='bgas') >>> # dictionary with parameters for a specific CAES plant >>> concept = { ... 'cav_e_in_b': 0, ... 'cav_e_in_m': 0.6457267578, ... 'cav_e_out_b': 0, ... 'cav_e_out_m': 0.3739636077, ... 'cav_eta_temp': 1.0, ... 'cav_level_max': 211.11, ... 'cmp_p_max_b': 86.0918959849, ... 'cmp_p_max_m': 0.0679999932, ... 'cmp_p_min': 1, ... 'cmp_q_out_b': 19.3996965679, ... 'cmp_q_out_m': 1.1066036114, ... 'cmp_q_tes_share': 0, ... 'exp_p_max_b': 46.1294016678, ... 'exp_p_max_m': 0.2528340303, ... 'exp_p_min': 1, ... 'exp_q_in_b': 2.2073411014, ... 'exp_q_in_m': 1.129249765, ... 'exp_q_tes_share': 0, ... 'tes_eta_temp': 1.0, ... 'tes_level_max': 0.0} >>> # generic compressed air energy storage (caes) plant >>> caes = solph.custom.GenericCAES( ... label='caes', ... electrical_input={bel: solph.Flow()}, ... fuel_input={bgas: solph.Flow()}, ... electrical_output={bel: solph.Flow()}, ... params=concept, fixed_costs=0) >>> type(caes) <class 'oemof.solph.custom.GenericCAES'>

class
oemof.solph.custom.
GenericCAESBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for nodes of class:.GenericCAES.

CONSTRAINT_GROUP
= True¶


class
oemof.solph.custom.
Link
(*args, **kwargs)[source]¶ Bases:
oemof.solph.network.Transformer
A Link object with 1…2 inputs and 1…2 outputs.
Parameters: conversion_factors (dict) – Dictionary containing conversion factors for conversion of each flow. Keys are the connected tuples (input, output) bus objects. The dictionary values can either be a scalar or a sequence with length of time horizon for simulation. Notes
 The sets, variables, constraints and objective parts are created
Examples
>>> from oemof import solph >>> bel0 = solph.Bus(label="el0") >>> bel1 = solph.Bus(label="el1")
>>> link = solph.custom.Link( ... label="transshipment_link", ... inputs={bel0: solph.Flow(), bel1: solph.Flow()}, ... outputs={bel0: solph.Flow(), bel1: solph.Flow()}, ... conversion_factors={(bel0, bel1): 0.92, (bel1, bel0): 0.99}) >>> print(sorted([x[1][5] for x in link.conversion_factors.items()])) [0.92, 0.99]
>>> type(link) <class 'oemof.solph.custom.Link'>
>>> sorted([str(i) for i in link.inputs]) ['el0', 'el1']
>>> link.conversion_factors[(bel0, bel1)][3] 0.92

class
oemof.solph.custom.
LinkBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for the relation of nodes with type
Link
The following constraints are created:
TODO: Add description for constraints TODO: Add tests

CONSTRAINT_GROUP
= True¶


class
oemof.solph.custom.
OffsetTransformer
(*args, **kwargs)[source]¶ Bases:
oemof.solph.network.Transformer
An object with one input and one output.
Parameters: coefficients (dict) – Dictionary containing the first two polynomial coefficients i.e. the yintersect and slope of a linear equation. Keys are the connected tuples (input, output) bus objects. The dictionary values can either be a scalar or a sequence with length of time horizon for simulation. Notes
 The sets, variables, constraints and objective parts are created
Examples
>>> from oemof import solph
>>> bel = solph.Bus(label='bel') >>> bth = solph.Bus(label='bth')
>>> ostf = solph.custom.OffsetTransformer( ... label='ostf', ... inputs={bel: solph.Flow( ... nominal_value=60, min=0.5, max=1.0, ... nonconvex=solph.NonConvex())}, ... outputs={bth: solph.Flow()}, ... coefficients={(bel, bth): [20, 0.5]})
>>> type(ostf) <class 'oemof.solph.custom.OffsetTransformer'>

class
oemof.solph.custom.
OffsetTransformerBlock
(*args, **kwargs)[source]¶ Bases:
pyomo.core.base.block.SimpleBlock
Block for the relation of nodes with type
OffsetTransformer
The following constraints are created:
TODO: Add description for constraints
TODO: Add test

CONSTRAINT_GROUP
= True¶

oemof.solph.groupings module¶
list: Groupings needed on an energy system for it to work with solph.
If you want to use solph on an energy system, you need to create it with these groupings specified like this:
from oemof.network import EnergySystem import solph
energy_system = EnergySystem(groupings=solph.GROUPINGS)
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/groupings.py
SPDXLicenseIdentifier: GPL3.0orlater

oemof.solph.groupings.
constraint_grouping
(node, fallback=<function <lambda>>)[source]¶ Grouping function for constraints.
This function can be passed in a list to
groupings
ofoemof.solph.network.EnergySystem
.Parameters:  node (
Node <oemof.network.Node
) – The node for which the figure out a constraint group.  fallback (callable, optional) – A function of one argument. If node doesn’t have a constraint_group attribute, this is used to group the node instead. Defaults to not group the node at all.
 node (
oemof.solph.models module¶
Solph Optimization Models
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/models.py
SPDXLicenseIdentifier: GPL3.0orlater

class
oemof.solph.models.
BaseModel
(energysystem, **kwargs)[source]¶ Bases:
pyomo.core.base.PyomoModel.ConcreteModel
The BaseModel for other solphmodels (Model, MultiPeriodModel, etc.)
Parameters:  energysystem (EnergySystem object) – Object that holds the nodes of an oemof energy system graph
 constraint_groups (list (optional)) – Solph looks for these groups in the given energy system and uses them
to create the constraints of the optimization problem.
Defaults to
Model.CONSTRAINTS
 objective_weighting (array like (optional)) – Weights used for temporal objective function expressions. If nothing is passed timeincrement will be used which is calculated from the freq length of the energy system timeindex .
 auto_construct (boolean) – If this value is true, the set, variables, constraints, etc. are added, automatically when instantiating the model. For sequential model building process set this value to False and use methods _add_parent_block_sets, _add_parent_block_variables, _add_blocks, _add_objective

CONSTRAINT_GROUPS
= []¶

receive_duals
()[source]¶ Method sets solver suffix to extract information about dual variables from solver. Shadow prices (duals) and reduced costs (rc) are set as attributes of the model.

solve
(solver='cbc', solver_io='lp', **kwargs)[source]¶ Takes care of communication with solver to solve the model.
Parameters:  solver (string) – solver to be used e.g. “glpk”,”gurobi”,”cplex”
 solver_io (string) – pyomo solver interface file format: “lp”,”python”,”nl”, etc.
 **kwargs (keyword arguments) – Possible keys can be set see below:
Other Parameters:  solve_kwargs (dict) – Other arguments for the pyomo.opt.SolverFactory.solve() method Example : {“tee”:True}
 cmdline_options (dict) – Dictionary with command line options for solver e.g. {“mipgap”:”0.01”} results in “–mipgap 0.01” {“interior”:” “} results in “–interior” Gurobi solver takes numeric parameter values such as {“method”: 2}

class
oemof.solph.models.
Model
(energysystem, **kwargs)[source]¶ Bases:
oemof.solph.models.BaseModel
An energy system model for operational and investment optimization.
Parameters:  energysystem (EnergySystem object) – Object that holds the nodes of an oemof energy system graph
 constraint_groups (list) – Solph looks for these groups in the given energy system and uses them
to create the constraints of the optimization problem.
Defaults to
Model.CONSTRAINTS
 following basic sets are created** (**The) –
 NODES – A set with all nodes of the given energy system.
 TIMESTEPS – A set with all timesteps of the given time horizon.
 FLOWS – A 2 dimensional set with all flows. Index: (source, target)
 following basic variables are created** (**The) –
 flow – Flow from source to target indexed by FLOWS, TIMESTEPS. Note: Bounds of this variable are set depending on attributes of the corresponding flow object.

CONSTRAINT_GROUPS
= [<class 'oemof.solph.blocks.Bus'>, <class 'oemof.solph.blocks.Transformer'>, <class 'oemof.solph.blocks.InvestmentFlow'>, <class 'oemof.solph.blocks.Flow'>, <class 'oemof.solph.blocks.NonConvexFlow'>]¶
oemof.solph.network module¶
Classes used to model energy supply systems within solph.
Classes are derived from oemof core network classes and adapted for specific optimization tasks. An energy system is modelled as a graph/network of nodes with very specific constraints on which types of nodes are allowed to be connected.
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/network.py
SPDXLicenseIdentifier: GPL3.0orlater

class
oemof.solph.network.
Bus
(*args, **kwargs)[source]¶ Bases:
oemof.network.Bus
A balance object. Every node has to be connected to Bus.
Notes
 The following sets, variables, constraints and objective parts are created

class
oemof.solph.network.
EnergySystem
(**kwargs)[source]¶ Bases:
oemof.energy_system.EnergySystem
A variant of
EnergySystem
specially tailored to solph.In order to work in tandem with solph, instances of this class always use
solph.GROUPINGS
. If custom groupings are supplied via the groupings keyword argument,solph.GROUPINGS
is prepended to those.If you know what you are doing and want to use solph without
solph.GROUPINGS
, you can just usecore's EnergySystem
directly.

class
oemof.solph.network.
Flow
(**kwargs)[source]¶ Bases:
oemof.network.Edge
Defines a flow between two nodes.
Keyword arguments are used to set the attributes of this flow. Parameters which are handled specially are noted below. For the case where a parameter can be either a scalar or a sequence, a scalar value will be converted to a sequence containing the scalar value at every index. This sequence is then stored under the paramter’s key.
Parameters:  nominal_value (numeric) – The nominal value of the flow. If this value is set the corresponding optimization variable of the flow object will be bounded by this value multiplied with min(lower bound)/max(upper bound).
 max (numeric (sequence or scalar)) – Normed maximum value of the flow. The flow absolute maximum will be
calculated by multiplying
nominal_value
withmax
 min (numeric (sequence or scalar)) – Nominal minimum value of the flow (see
max
).  actual_value (numeric (sequence or scalar)) – Specific value for the flow variable. Will be multiplied with the
nominal_value
to get the absolute value. Iffixed
is set toTrue
the flow variable will be fixed toactual_value * nominal_value
, i.e. this value is set exogenous.  positive_gradient (
dict
, default:{‘ub’: None, ‘costs’: 0}
) –A dictionary containing the following two keys:
’ub’
: numeric (sequence, scalar or None), the normed upper bound on the positive difference (flow[t1] < flow[t]
) of two consecutive flow values.’costs`
: numeric (scalar or None), the gradient cost per unit.
 negative_gradient (
dict
, default:{‘ub’: None, ‘costs’: 0}
) –A dictionary containing the following two keys:
’ub’
: numeric (sequence, scalar or None), the normed upper bound on the negative difference (flow[t1] > flow[t]
) of two consecutive flow values.’costs`
: numeric (scalar or None), the gradient cost per unit.
 summed_max (numeric) – Specific maximum value summed over all timesteps. Will be multiplied with the nominal_value to get the absolute limit.
 summed_min (numeric) – see above
 variable_costs (numeric (sequence or scalar)) – The costs associated with one unit of the flow. If this is set the costs will be added to the objective expression of the optimization problem.
 fixed (boolean) – Boolean value indicating if a flow is fixed during the optimization
problem to its exante set value. Used in combination with the
actual_value
.  investment (
Investment
) – Object indicating if a nominal_value of the flow is determined by the optimization problem. Note: This will refer all attributes to an investment variable instead of to the nominal_value. The nominal_value should not be set (or set to None) if an investment object is used.  nonconvex (
NonConvex
) – If a nonconvex flow object is added here, the flow constraints will be altered significantly as the mathematical model for the flow will be different, i.e. constraint etc. fromNonConvexFlow
will be used instead ofFlow
. Note: at the moment this does not work if the investment attribute is set .
Notes
 The following sets, variables, constraints and objective parts are created
Flow
InvestmentFlow
(additionally if Investment object is present)NonConvexFlow
(If nonconvex object is present, CAUTION: replaces
Flow
class and a MILP will be build)
Examples
Creating a fixed flow object:
>>> f = Flow(actual_value=[10, 4, 4], fixed=True, variable_costs=5) >>> f.variable_costs[2] 5 >>> f.actual_value[2] 4
Creating a flow object with timedepended lower and upper bounds:
>>> f1 = Flow(min=[0.2, 0.3], max=0.99, nominal_value=100) >>> f1.max[1] 0.99

class
oemof.solph.network.
Sink
(*args, **kwargs)[source]¶ Bases:
oemof.network.Sink
An object with one input flow.

class
oemof.solph.network.
Source
(*args, **kwargs)[source]¶ Bases:
oemof.network.Source
An object with one output flow.

class
oemof.solph.network.
Transformer
(*args, **kwargs)[source]¶ Bases:
oemof.network.Transformer
A linear Transformer object with n inputs and n outputs.
Parameters: conversion_factors (dict) – Dictionary containing conversion factors for conversion of each flow. Keys are the connected bus objects. The dictionary values can either be a scalar or a sequence with length of time horizon for simulation. Examples
Defining an linear transformer:
>>> from oemof import solph >>> bgas = solph.Bus(label='natural_gas') >>> bcoal = solph.Bus(label='hard_coal') >>> bel = solph.Bus(label='electricity') >>> bheat = solph.Bus(label='heat')
>>> trsf = solph.Transformer( ... label='pp_gas_1', ... inputs={bgas: solph.Flow(), bcoal: solph.Flow()}, ... outputs={bel: solph.Flow(), bheat: solph.Flow()}, ... conversion_factors={bel: 0.3, bheat: 0.5, ... bgas: 0.8, bcoal: 0.2}) >>> print(sorted([x[1][5] for x in trsf.conversion_factors.items()])) [0.2, 0.3, 0.5, 0.8]
>>> type(trsf) <class 'oemof.solph.network.Transformer'>
>>> sorted([str(i) for i in trsf.inputs]) ['hard_coal', 'natural_gas']
>>> trsf_new = solph.Transformer( ... label='pp_gas_2', ... inputs={bgas: solph.Flow()}, ... outputs={bel: solph.Flow(), bheat: solph.Flow()}, ... conversion_factors={bel: 0.3, bheat: 0.5}) >>> trsf_new.conversion_factors[bgas][3] 1
Notes
 The following sets, variables, constraints and objective parts are created
oemof.solph.options module¶
Optional classes to be added to a network class. This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/options.py
SPDXLicenseIdentifier: GPL3.0orlater

class
oemof.solph.options.
Investment
(maximum=inf, minimum=0, ep_costs=0, existing=0)[source]¶ Bases:
object
Parameters:  maximum (float) – Maximum of the additional invested capacity
 minimum (float) – Minimum of the additional invested capacity
 ep_costs (float) – Equivalent periodical costs for the investment, if period is one year these costs are equal to the equivalent annual costs.
 existing (float) – Existing / installed capacity. The invested capacity is added on top of this value.

class
oemof.solph.options.
NonConvex
(**kwargs)[source]¶ Bases:
object
Parameters:  startup_costs (numeric) – Costs associated with a start of the flow (representing a unit).
 shutdown_costs (numeric) – Costs associated with the shutdown of the flow (representing a unit).
 activity_costs (numeric) – Costs associated with the active operation of the flow, independently from the actual output.
 minimum_uptime (numeric (1 or positive integer)) – Minimum time that a flow must be greater then its minimum flow after startup. Be aware that minimum up and downtimes can contradict each other and may lead to infeasible problems.
 minimum_downtime (numeric (1 or positive integer)) – Minimum time a flow is forced to zero after shutting down. Be aware that minimum up and downtimes can contradict each other and may to infeasible problems.
 initial_status (numeric (0 or 1)) – Integer value indicating the status of the flow in the first time step (0 = off, 1 = on). For minimum up and downtimes, the initial status is set for the respective values in the edge regions e.g. if a minimum uptime of four timesteps is defined, the initial status is fixed for the four first and last timesteps of the optimization period. If both, up and downtimes are defined, the initial status is set for the maximum of both e.g. for six timesteps if a minimum downtime of six timesteps is defined in addition to a four timestep minimum uptime.

max_up_down
¶ Compute or return the _max_up_down attribute.
oemof.solph.plumbing module¶
Plumbing stuff.
This file is part of project oemof (github.com/oemof/oemof). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location oemof/oemof/solph/plumbing.py
SPDXLicenseIdentifier: GPL3.0orlater

oemof.solph.plumbing.
sequence
(sequence_or_scalar)[source]¶ Tests if an object is sequence (except string) or scalar and returns a the original sequence if object is a sequence and a ‘emulated’ sequence object of class _Sequence if object is a scalar or string.
Parameters: sequence_or_scalar (arraylike, None, int, float) – Examples
>>> sequence([1,2]) [1, 2]
>>> x = sequence(10) >>> x[0] 10
>>> x[10] 10 >>> print(x) [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]