Components
Tessif component library.
components is a tessif module
transforming the abstract data representation of an energy system stored as
mapping into a
‘class-instance’ like structure.
Mapping like representations are usually returned by utilities part of the
parse module.
Note
Tessif’s energy system model components are deliberately (somewhat) redundant
from a computer science point of view. They are designed to be intuitively used
by engineers. Hence parameters, attributes and namespaces are aggregated in a
way an engineer would classify such components. For more on that see
tessif.system_model.
Classes
Entities only concerned with their unique hashable identifier. |
|
Entities only concerned with input and output names. |
|
Entities only concerned with connecting 2 busses. |
|
Entities only concerned with their outputs and related attributes. |
|
Entities only concerned with their inputs and related attributes. |
|
Entities only concerned with mapping their inflows to their outflows. |
|
Entities that are like Transformers but with additional constraints. |
|
Entities only concerned with input, output and accumulation. |
- class tessif.components.AbstractEsComponent(name, *args, **kwargs)[source]
Bases:
objectEntities only concerned with their unique hashable identifier.
If it quacks like an AbstractEsComponent, if it walks like an AbstractEsComponent it is an AbstractEsComponent.
- Parameters
name¶ (Hashable) – Identifier. Parsed into a
namedtuples.Uidinstance asuid.name
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform atessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- duplicate(prefix='', separator='_', suffix='copy')[source]
Duplicate this component.
Duplicate the energy system component and return it. Potentially modifying it’s
name.- Parameters
prefix¶ (str, default='') – String added to the beginning of the component’s
name, separated byseparator.separator¶ (str, default='_') – String used for adding the
prefixand thesuffixto the component’sname.suffix¶ (str, default='') – String added to the beginning of the component’s
name, separated byseparator.
- classmethod from_attributes(attributes)[source]
Create component from attribute dictionary.
Create an
AbstractEsComponentobject from a dictionary ofattributes.
- property attributes
Dictionairy of component attributes.
Mappingof entity’s energy system component attribute names to its respective attribute values.
- property parameters
Dictionairy of component parameters (attributes).
Mappingof the entity’s parameter names to its respective values.Note
Redundant to
attributes. Interface designed for engineers since they would call these valuesparameters, whereas in pythonattributeswould be the more accurate terminology.
- property uid
Component identifier as Uid namedtuples.
namedtuples.Uidinstance as a hashable unique identifier.
- class tessif.components.Bus(name, inputs, outputs, *args, **kwargs)[source]
Bases:
tessif.components.AbstractEsComponentEntities only concerned with input and output names.
- Parameters
name¶ (Hashable) – Identifier. Usually a string, aka a name.
An iterable of str(
AbstractEsComponent.uid).output/ input strings specifying the bus-entity’s inputs. e.g.:['node1.electricity', 'node2.electricity',]
Note
Take a look at
tessif.frused.namedtuples.Uidas well asnode_uid_styleandnode_uid_stylesfor more details on the uid’s string representation. Especially when having issues with non-unique uid solver issues.An iterable of str(
AbstractEsComponent.uid).output/ input strings specifying the bus-entity’s inputs. e.g.:['node1.electricity', 'node2.electricity',]
Note
Take a look at
tessif.frused.namedtuples.Uidas well asnode_uid_styleandnode_uid_stylesfor more details on the uid’s string representation. Especially when having issues with non-unique uid solver issues.
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform an id astessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)
- class tessif.components.Connector(name, interfaces, *args, **kwargs)[source]
Bases:
tessif.components.AbstractEsComponentEntities only concerned with connecting 2 busses.
- Parameters
name¶ (Hashable) – Identifier. Usually a string, aka a name.
interfaces¶ (Collection) –
Collection of length 2 specifying the bus entity’s interfaces to connect to. Takes the form of (str(
Bus.uid), str(Bus.uid)) e.g.:('my_bus_001', 'my_bus_002') ['my_bus_001', 'my_bus_002']
Note
Take a look at
tessif.frused.namedtuples.Uidas well asnode_uid_styleandnode_uid_stylesfor more details on the uid’s string representation. Especially when having issues with non-unique uid
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform an id astessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- Parameters
Mapping of connector relevant (str(input.uid), str(output.uid)) tuples to their respective conversion efficiency. With recognized conversion efficiencies between 0 and 1 (\(\left[0, 1\right]\)) e.g.:
{('bus1', 'bus2'): 0.4, ('bus2', 'bus1'): 1,}
Is interpreted in a way that for 1 quantity flowing from ‘bus1’ to ‘bus2’, 2.5 (1/0.4) quantities are needed. For 1 quantity flowing from ‘bus2’ to ‘bus1’ on the other hand only 1 quantity is nedded.
Example
Default parameterized
Connectorobject:>>> from tessif.components import Connector >>> connector = Connector(name='my_connector', ... interfaces=('bus_01', 'bus_02')) >>> print(connector.uid) my_connector
>>> for k, v in connector.attributes.items(): ... print('{} = {}'.format( ... k, sorted(v) if isinstance(v, frozenset) else v)) ... # Frozensets are transformed to sorted lists for doctesting consistency conversions = {('bus_01', 'bus_02'): 1.0, ('bus_02', 'bus_01'): 1.0} inputs = ['bus_01', 'bus_02'] interfaces = ['bus_01', 'bus_02'] outputs = ['bus_01', 'bus_02'] timeseries = None uid = my_connector
- property inputs
Frozenset of input uids.
Hashablecontainer of str(uid).output/input strings representing the inputs.
- class tessif.components.Source(name, outputs, *args, **kwargs)[source]
Bases:
tessif.components.AbstractEsComponentEntities only concerned with their outputs and related attributes.
- Parameters
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform an id astessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- Parameters
accumulated_amounts¶ (Mapping) –
Mapping of each
output nameto aMinMaxNamedTupledescribing the minimum/maximum quantity the entity’s outflow has available (in total).Meaning the total sum of a particular outflow happening during the simulated time period is less equal than
accumulated_amounts[output_name].max and greater equal thanaccumulated_amounts[output_name].minDefault:
{key: MinMax(0, float('+inf')) for key in outputs}
Mapping of each
output nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
Default:
{key: MinMax(0, float('+inf')) for key in outputs}
Mapping of each
output nameto aNumberspecifying its cost.Meaning for each amount per time that is going out this amount of cost-unit is taken into account (by the solver).
Default:
{key: 0 for key in outputs}
Mapping of each
output nameto aNumberspecifying its emission.Meaning for each amount per time that is going out this amount of emission-unit is taken into account (by the solver).
Default:
{key: 0 for key in outputs}
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
Mapping of each
output nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
Default:
{k: PositiveNegative(float('+inf'),float('+inf')) for k in outputs}
Mapping of each
output nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).default:
{k: PositiveNegative(0, 0) for k in outputs}
timeseries¶ (Mapping, default=None) –
Mapping an arbitrary number of
output namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively. For ExampleSetting the maximum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=0, max=np.array([10, 42]))}
Setting the minimum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=np.array([1, 2]), max=float('+inf'))}
Fixing the
flow_rateto a certain timeseries:import numpy as np timeseries = {input_bus': MinMax( min=np.array([1, 2]), max=np.array([1, 2]))}
Mapping of each
output nameto a boolean variable describing if the mappedSource.flow_ratesvalue can be increased by the solver or not.Default:
{key: False for key in outputs}
Mapping of each
output nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).Default:
{key: 0 for key in outputs}
Mapping of each
output nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somwhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))Default:
{key: MinMax(0, float('+inf')) for key in outputs}
Note
Providing non default parameters for the following set of arguments will cause the optimization problem to most likely turn into a Mixed Integer Linear Problem
- Parameters
Mapping of each
output nameto a boolean variable describing if the mappedSource.flow_ratesparameter can be subject to mixed integer linear constraints.Default:
{key: False, for key in outputs}
Warning
If
milpevaluates toFalsefollowing set of parameters is most likely ignored during optimization.initial_status¶ (bool, default=True) – Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do, in the beginning of the evaluated timeframe.
An
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing stil respectively.Default:
OnOff(0, 0)
status_changing_costs¶ (OnOff) –
An
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectivelyDefault:
OnOff(0, 0)
number_of_status_changes¶ (OnOff) –
NamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.Default:
OnOff(float('+inf'), float('+inf'))
costs_for_being_active¶ (
Number, default = 0) –Costs for not being inactive.
Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
Example
Default parameterized
Sourceobject:>>> from tessif.components import Source >>> source = Source(name='my_source', outputs=('fuel',)) >>> print(source.uid) my_source
>>> print(source.outputs) frozenset({'fuel'})
>>> for k, v in source.attributes.items(): ... print('{} = {}'.format( ... k, sorted(v) if isinstance(v, frozenset) else v)) ... # Frozensets are transformed to sorted lists for doctesting consistency accumulated_amounts = {'fuel': MinMax(min=0.0, max=inf)} costs_for_being_active = 0.0 expandable = {'fuel': False} expansion_costs = {'fuel': 0.0} expansion_limits = {'fuel': MinMax(min=0.0, max=inf)} flow_costs = {'fuel': 0.0} flow_emissions = {'fuel': 0.0} flow_gradients = {'fuel': PositiveNegative(positive=inf, negative=inf)} flow_rates = {'fuel': MinMax(min=0.0, max=inf)} gradient_costs = {'fuel': PositiveNegative(positive=0.0, negative=0.0)} initial_status = 1 interfaces = ['fuel'] milp = {'fuel': False} number_of_status_changes = OnOff(on=inf, off=inf) outputs = ['fuel'] status_changing_costs = OnOff(on=0.0, off=0.0) status_inertia = OnOff(on=0, off=0) timeseries = None uid = my_source
- property outputs
Frozenset of output uids.
Hashablecontainer of hashable unique identifiers. Usually a string aka a name representing the outputs.
- property accumulated_amounts
Dictionairy of accumulated amount constraints.
Mappingof eachoutput nameto aMinMaxNamedTupledescribing the minimum/maximum quantity the entity’s outflow has available (in total).Meaning the total sum of a particular outflow happening during the simulated time period is less equal than
accumulated_amounts[output_name].max and greater equal thanaccumulated_amounts[output_name].min
- property flow_rates
Dictionairy of flow rate constraints.
Mappingof eachoutput nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
- property flow_costs
Dictionairy of flow cost constraints.
Mappingof eachoutput nameto aNumberspecifying its cost.Meaning for each amount per time that is going out this amount of cost-unit is taken into account (by the solver).
- property flow_emissions
Dictionairy of flow emission constraints.
Mappingof eachoutput nameto aNumberspecifying its emissionsMeaning for each amount per time that is going out this amount of emission-unit is taken into account (by the solver).
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
- property flow_gradients
Dictionairy of flow gradient constraints.
Mappingof eachoutput nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
- property gradient_costs
Dictionairy of flow gradient costs.
MappingMapping of eachoutput nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).
- property timeseries
Tuple of flow_rates constraining timeserieses.
Mappingof an arbitrary number ofoutput namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively.
- property expandable
True, if maximum flow_rate is subject to solver changes.
Mappingof eachoutput nameto a boolean variable describing if the mappedSource.flow_ratesvalue can be increased by the solver or not.
- property expansion_costs
Dictionairy of maximum flow rate expansion costs.
Mappingof eachoutput nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).
- property expansion_limits
Dictionairy of maximum flow rate expansion limits.
Mappingof eachoutput nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))
- property initial_status
True, if component is milp constrained and active at first time step.
Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do in the beginning of the evaluated timeframe.
- property status_inertia
Tuple of status-inertia (milp) constraints.
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing still respectively.
- property status_changing_costs
Tuple of status-changing (milp) constraints.
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectively.
- property number_of_status_changes
Tuple of allowed milp status changing constraints.
An
OnOffNamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.
- property costs_for_being_active
Milp constained activity costs.
A
Number, default = 0 Describing the costs for not being inactive.Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
- class tessif.components.Sink(name, inputs, *args, **kwargs)[source]
Bases:
tessif.components.AbstractEsComponentEntities only concerned with their inputs and related attributes.
- Parameters
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform an id as atessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- Parameters
accumulated_amounts¶ (Mapping) –
Mapping of each
input nameto aMinMaxNamedTupledescribing the minimum/maximum quantity the entity’s inflow has available (in total).Meaning the total sum of a particular inflow happening during the simulated time period is less equal than
accumulated_amounts[input_name].max and greater equal thanaccumulated_amounts[input_name].minDefault:
{key: MinMax(0, float('+inf')) for key in inputs}
Mapping of each
input nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going in during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
Default:
{key: MinMax(0, float('+inf')) for key in inputs}
Mapping of each
input nameto aNumberspecifying its cost.Meaning for each amount per time that is going in this amount of cost-unit is taken into account (by the solver).
Default:
{key: 0 for key in inputs}
Mapping of each
input nameto aNumberspecifying its emission.Meaning for each amount per time that is going in this amount of emission-unit is taken into account (by the solver).
Default:
{key: 0 for key in inputs}
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
Mapping of each
input nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
Default:
k: PositiveNegative(float('+inf'),float('+inf')) for k in inputs}
Mapping of each
input nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).Default:
{k: PositiveNegative(0, 0) for k in inputs}
timeseries¶ (Mapping, default=None) –
Mapping an arbitrary number of
input namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively. For ExampleSetting the maximum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=0, max=np.array([10, 42]))}
Setting the minimum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=np.array([1, 2]), max=float('+inf'))}
Fixing the
flow_rateto a certain timeseries:import numpy as np timeseries = {input_bus': MinMax( min=np.array([1, 2]), max=np.array([1, 2]))}
Mapping of each
input nameto a boolean variable describing if the mappedSink.flow_ratesvalue can be increased by the solver or not.Default:
{key: False for key in inputs}
Mapping of each
input nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).Default:
{key: 0 for key in inputs}
Mapping of each
input nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somwhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))Default:
{key: MinMax(0, float('+inf')) for key in inputs}
Note
Providing non default parameters for the following set of arguments will cause the optimization problem to most likely turn into a Mixed Integer Linear Problem
- Parameters
Mapping of each
output nameto a boolean variable describing if the mappedSink.flow_ratesparameter can be subject to mixed integer linear constraints.Default:
{key: False for key in inputs}
Warning
If
milpevaluates toFalsefollowing set of parameters is most likely ignored during optimization.initial_status¶ (bool, default=True) – Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do, in the beginning of the evaluated timeframe.
An
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing stil respectively.Default:
OnOff(0, 0)
status_changing_costs¶ (OnOff) –
An
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectively.Default:
OnOff(0, 0)
number_of_status_changes¶ (OnOff) –
NamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.Default:
OnOff(float('+inf'), float('+inf'))
costs_for_being_active¶ (
Number, default = 0) –Costs for not being inactive.
Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
Example
Default parameterized
Sinkobject:>>> from tessif.components import Sink >>> sink = Sink(name='my_sink', inputs=('electricity',)) >>> print(sink.uid) my_sink
>>> print(sink.inputs) frozenset({'electricity'})
Accessing all its
attributes:>>> for k, v in sink.attributes.items(): ... print('{} = {}'.format( ... k, sorted(v) if isinstance(v, frozenset) else v)) ... # frozensets are transformed to sorted lists for doctesting consistency accumulated_amounts = {'electricity': MinMax(min=0.0, max=inf)} costs_for_being_active = 0.0 expandable = {'electricity': False} expansion_costs = {'electricity': 0.0} expansion_limits = {'electricity': MinMax(min=0.0, max=inf)} flow_costs = {'electricity': 0.0} flow_emissions = {'electricity': 0.0} flow_gradients = {'electricity': PositiveNegative(positive=inf, negative=inf)} flow_rates = {'electricity': MinMax(min=0.0, max=inf)} gradient_costs = {'electricity': PositiveNegative(positive=0.0, negative=0.0)} initial_status = 1 inputs = ['electricity'] interfaces = ['electricity'] milp = {'electricity': False} number_of_status_changes = OnOff(on=inf, off=inf) status_changing_costs = OnOff(on=0.0, off=0.0) status_inertia = OnOff(on=0, off=0) timeseries = None uid = my_sink
- property inputs
Frozenset of input uids.
Hashablecontainer of hashable unique identifiers. Usually a string aka a name representing the inputs.
- property accumulated_amounts
Dictionairy of accumulated amount constraints.
Mappingof eachinput nameto aMinMaxtuple describing the minimum/maximum quantity the entity’s inflow has available (in total).Meaning the total sum of a particular inflow happening during the simulated time period is less equal than
accumulated_amounts[input_name].max and greater equal thanaccumulated_amounts[input_name].min
- property flow_rates
Dictionairy of flow rate constraints.
Mappingof eachinput nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going in during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
- property flow_costs
Dictionairy of flow cost constraints.
Mappingof eachinput nameto aNumberspecifying its cost.Meaning for each amount per time that is going in this amount of cost-unit is taken into account (by the solver).
- property flow_emissions
Dictionairy of flow emission constraints.
Mappingof eachinput nameto aNumberspecifying its emissionsMeaning for each amount per time that is going in this amount of emission-unit is taken into account (by the solver).
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
- property flow_gradients
Dictionairy of flow gradient constraints.
Mappingof eachinput nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
- property gradient_costs
Dictionairy of flow gradient costs.
MappingMapping of eachinput nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).
- property timeseries
Tuple of flow_rates constraining timeserieses.
Mappingof an arbitrary number ofinput namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively.
- property expandable
True, if maximum flow_rate is subject to solver changes.
Mappingof eachinput nameto a boolean variable describing if the mappedSink.flow_ratesvalue can be increased by the solver or not.
- property expansion_costs
Dictionairy of maximum flow rate expansion costs.
Mappingof eachinput nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).
- property expansion_limits
Dictionairy of maximum flow rate expansion limits.
Mappingof eachinput nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))
- property initial_status
True, if component is milp constrained and active at first time step.
Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do in the beginning of the evaluated timeframe.
- property status_inertia
Tuple of status-inertia (milp) constraints.
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing still respectively.
- property status_changing_costs
Tuple of status-changing (milp) constraints.
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectively.
- property number_of_status_changes
Tuple of allowed milp status changing constraints.
An
OnOffNamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.
- property costs_for_being_active
Milp constained activity costs.
A
Number, default = 0 Describing the costs for not being inactive.Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
- class tessif.components.Transformer(name, inputs, outputs, conversions, *args, **kwargs)[source]
Bases:
tessif.components.AbstractEsComponentEntities only concerned with mapping their inflows to their outflows.
- Parameters
name¶ (Hashable) – Identifier. Usually a string, aka a name.
An iterable of hashable unique identifiers. Usually strings, aka names specifying the transformer-entity’s inputs. e.g.:
['fuel_1', 'fuel_2']
An iterable of hashable unique identifiers. Usually strings, aka names specifying the transformer-entity’s outputs. e.g.:
['electricity', 'heat']
Mapping of transformer relevant (input-name, output-name) tuples to their respective conversion efficiency. With recognized conversion efficiencies between 0 and 1 (\(\left[0, 1\right]\)) e.g.:
{('fuel_1', 'electricity'): 0.4, ('fuel_2', 'electricity'): 0.8,}
Is interpreted in a way that for transforming 1 quantity of ‘electricity’ 2.5 quantities (1/0.4) of ‘fuel_1’ and 1.25 quantities (1/0.8) of ‘fuel_2’ are needed.
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform an id as atessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- Parameters
Mapping of each
input/output nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going in/out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
Default:
{key: MinMax(0, float('+inf')) for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aNumberspecifying its cost.Meaning for each amount per time that is going in/out this amount of cost-unit is taken into account (by the solver).
Default:
{key: 0 for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aNumberspecifying its emission.Meaning for each amount per time that is going in/out this amount of emission-unit is taken into account (by the solver).
Default:
{key: 0 for key in [*inputs, *outputs]}
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
Mapping of each
input/output nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
Default:
{k: PositiveNegative(float('+inf'),float('+inf')) for k in [*inputs, *outputs]}
Mapping of each
input/output nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).Default:
{k: PositiveNegative(0, 0) for k in [*inputs, *outputs]}
timeseries¶ (Mapping, default=None) –
Mapping an arbitrary number of
output namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively. For ExampleSetting the maximum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=0, max=np.array([10, 42]))}
Setting the minimum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=np.array([1, 2]), max=float('+inf'))}
Fixing the
flow_rateto a certain timeseries:import numpy as np timeseries = {input_bus': MinMax( min=np.array([1, 2]), max=np.array([1, 2]))}
Mapping of each
input nameto a boolean variable describing if the mappedTransformer.flow_ratesvalue can be increased by the solver or not.Default:
{key: False for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).Default:
{key: 0 for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somwhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))Default:
{k: MinMax(0, float('+inf')) for k in [*inputs, *outputs]}
Note
Providing non default parameters for the following set of arguments will cause the optimization problem to most likely turn into a Mixed Integer Linear Problem
- Parameters
milp¶ (bool, default=False,) –
Mapping of each
input/output nameto a boolean variable describing if the mappedTransformer.flow_ratesparameter can be subject to mixed integer linear constraints.Default:
{key: False for key in [*inputs, *outputs]}
milp¶ –
Boolean variable indicating if the component’s parameters are to be parsed as mixed integer-linear optimization problem or not.
Warning
If
milpevaluates toFalsefollowing set of parameters is most likely ignored during optimization.initial_status¶ (bool, default=True) – Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do, in the beginning of the evaluated timeframe.
An
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing stil respectively.Default:
OnOff(0, 0)
status_changing_costs¶ (OnOff) –
An
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectivelyDefault:
OnOff(0, 0)
number_of_status_changes¶ (OnOff) –
NamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.Default:
OnOff(float('+inf'), float('+inf'))
costs_for_being_active¶ (
Number, default = 0) –Costs for not being inactive.
Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
Example
Default parameterized
Transformerobject:>>> import pprint >>> from tessif.components import Transformer >>> transformer = Transformer( ... name='my_transformer', inputs=('fuel',), outputs=('electricity',), ... conversions={('fuel', 'electricity'): 0.42}) >>> print(transformer.uid) my_transformer
>>> print(transformer.inputs) frozenset({'fuel'})
>>> print(transformer.outputs) frozenset({'electricity'})
>>> print(sorted(transformer.interfaces)) ['electricity', 'fuel']
Accessing all its
attributes:>>> for k, v in transformer.attributes.items(): ... print('{} = {}'.format( ... k, sorted(v) if isinstance(v, frozenset) else v)) ... # frozensets are sorted for consistent doctesting conversions = {('fuel', 'electricity'): 0.42} costs_for_being_active = 0.0 expandable = {'electricity': False, 'fuel': False} expansion_costs = {'electricity': 0.0, 'fuel': 0.0} expansion_limits = {'electricity': MinMax(min=0.0, max=inf), 'fuel': MinMax(min=0.0, max=inf)} flow_costs = {'electricity': 0.0, 'fuel': 0.0} flow_emissions = {'electricity': 0.0, 'fuel': 0.0} flow_gradients = {'electricity': PositiveNegative(positive=inf, negative=inf), 'fuel': PositiveNegative(positive=inf, negative=inf)} flow_rates = {'electricity': MinMax(min=0.0, max=inf), 'fuel': MinMax(min=0.0, max=inf)} gradient_costs = {'electricity': PositiveNegative(positive=0.0, negative=0.0), 'fuel': PositiveNegative(positive=0.0, negative=0.0)} initial_status = 1 inputs = ['fuel'] interfaces = ['electricity', 'fuel'] milp = {'electricity': False, 'fuel': False} number_of_status_changes = OnOff(on=inf, off=inf) outputs = ['electricity'] status_changing_costs = OnOff(on=0.0, off=0.0) status_inertia = OnOff(on=0, off=0) timeseries = None uid = my_transformer
- property inputs
Frozenset of input uids.
Hashablecontainer of hashable unique identifiers. Usually a string aka a name representing the inputs.
- property outputs
Frozenset of ouptu uids.
Hashablecontainer of hashable unique identifiers. Usually a string aka a name representing the outputs.
- property conversions
Dictionairy of conversion constraints.
Mappingof transformer relevant (inflow-name, outflow-name) tuples to their respective conversion efficiency. With recognized conversion efficiencies between 0 and 1 (\(\left[0, 1\right]\))
- property flow_rates
Dictionairy of flow rate constraints.
Mappingof eachinput/output nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
- property flow_costs
Dictionairy of flow cost constraints.
Mappingof eachinput/output nameto aNumberspecifying its cost.Meaning for each amount per time that is going out this amount of cost-unit is taken into account (by the solver).
- property flow_emissions
Dictionairy of flow emission constraints.
Mappingof eachinput/output nameto aNumberspecifying its emissionsMeaning for each amount per time that is going out this amount of emission-unit is taken into account (by the solver).
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
- property flow_gradients
Dictionairy of flow gradient constraints.
Mappingof eachinput/output nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
- property gradient_costs
Dictionairy of flow gradient costs.
MappingMapping of eachinput/output nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).
- property timeseries
Tuple of flow_rates constraining timeserieses.
Mappingof an arbitrary number ofinput/output namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively.
- property expandable
True, if maximum flow_rate is subject to solver changes.
Mappingof eachinput/output nameto a boolean variable describing if the mappedTransformer.flow_ratesvalue can be increased by the solver or not.
- property expansion_costs
Dictionairy of maximum flow rate expansion costs.
Mappingof eachinput/output nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).
- property expansion_limits
Dictionairy of maximum flow rate expansion limits.
Mappingof eachinput/output nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))
- property initial_status
True, if component is milp constrained and active at first time step.
Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do in the beginning of the evaluated timeframe.
- property status_inertia
Tuple of status-inertia (milp) constraints.
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing still respectively.
- property status_changing_costs
Tuple of status-changing (milp) constraints.
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectively.
- property number_of_status_changes
Tuple of allowed milp status changing constraints.
An
OnOffNamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.
- property costs_for_being_active
Milp constained activity costs.
A
Number, default = 0 Describing the costs for not being inactive.Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
- class tessif.components.CHP(name, inputs, outputs, *args, **kwargs)[source]
Bases:
tessif.components.TransformerEntities that are like Transformers but with additional constraints.
- Parameters
name¶ (Hashable) – Identifier. Usually a string, aka a name.
An iterable of hashable unique identifiers. Usually strings, aka names specifying the chp-entity’s inputs. e.g.:
['fuel_1', 'fuel_2']
An iterable of hashable unique identifiers. Usually strings, aka names specifying the chp-entity’s outputs. e.g.:
['electricity', 'heat']
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforenamed arguments together with
nameform an id as atessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- Parameters
back_pressure¶ (bool,) – Boolean to specify if back-pressure characteristics shall be used. Set to True and Q_CW_min to zero for back-pressure turbines.
conversion_factor_full_condensation¶ (Mapping) –
Mappingwhere the (inflow-name, outflow-name) tuple of the main flow is the only key and it’s conversion efficiency when there is no tapped flow is it’s value. Conversion efficiencies are expected to be between 0 and 1 (\(\left[0, 1\right]\)).el_efficiency_wo_dist_heat¶ (MinMax) –
Electric efficiency at min/max fuel flow without district heating.
Expects a
MinMaxwhere both the min and the max value are a list where the length is the same as the number of timesteps and each entry is a float value between 0 and 1 giving the efficiency at that timestep.Share of flue gas enthalpy loss at min/max heat extraction.
Expects a
MinMaxwhere both the min and the max value are a list where the length is the same as the number of timesteps and each entry is a float value between 0 and 1 giving the share of flue gas enthalpy loss for that timestep.power_wo_dist_heat¶ (MinMax) –
Min/max electric power without district heating.
Expects a
MinMaxwhere both the min and the max value are a list where the length is the same as the number of timesteps and each entry is the power at that timestep.Marginal loss of electric power for each additional unit of heat.
Expects a list where the length is the same as the number of timesteps and each entry is a float value between 0 and 1 giving the marginal loss of power at that timestep.
Minimal thermal condenser load to cooling water.
Expects a list where the length is the same as the number of timesteps and each entry is the minimal condenser load at that timestep.
Mapping of chp relevant (input-name, output-name) tuples to their respective conversion efficiency. With recognized conversion efficiencies between 0 and 1 (\(\left[0, 1\right]\)) e.g.:
{('fuel_1', 'electricity'): 0.4, ('fuel_2', 'electricity'): 0.8,}
Is interpreted in a way that for transforming 1 quantity of ‘electricity’ 2.5 quantities (1/0.4) of ‘fuel_1’ and 1.25 quantities (1/0.8) of ‘fuel_2’ are needed.
In the CHP class ‘conversions’ is optional because the efficiencies can also be specified with ‘el_efficiency_wo_dist_heat’ and ‘power_loss_index’. Using both ways to specify the efficiencies at the same time might lead to unexpected results.
Mapping of each
input/output nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going in/out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
In the CHP Class it is also possible to constrain the flow rates with a combination of ‘power_wo_dist_heat’, ‘enthalpy_loss’, ‘min_condenser_load’ and ‘power_loss_index’. It should be possible to combine those attributes with ‘flow_rates’ but if problems appear, try to leave ‘flow_rates’ away and change the other attributes in such a way that you have the same behvior.
Default:
{key: MinMax(0, float('+inf')) for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aNumberspecifying its cost.Meaning for each amount per time that is going in/out this amount of cost-unit is taken into account (by the solver).
Default:
{key: 0 for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aNumberspecifying its emission.Meaning for each amount per time that is going in/out this amount of emission-unit is taken into account (by the solver).
Default:
{key: 0 for key in [*inputs, *outputs]}
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
Mapping of each
input/output nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
Default:
{k: PositiveNegative(float('+inf'),float('+inf')) for k in [*inputs, *outputs]}
Mapping of each
input/output nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).Default:
{k: PositiveNegative(0, 0) for k in [*inputs, *outputs]}
timeseries¶ (Mapping, default=None) –
Mapping an arbitrary number of
output namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively. For ExampleSetting the maximum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=0, max=np.array([10, 42]))}
Setting the minimum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=np.array([1, 2]), max=float('+inf'))}
Fixing the
flow_rateto a certain timeseries:import numpy as np timeseries = {input_bus': MinMax( min=np.array([1, 2]), max=np.array([1, 2]))}
Mapping of each
input nameto a boolean variable describing if the mappedCHP.flow_ratesvalue can be increased by the solver or not.Default:
{key: False for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).Default:
{key: 0 for key in [*inputs, *outputs]}
Mapping of each
input/output nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))Default:
{k: MinMax(0, float('+inf')) for k in [*inputs, *outputs]}
Note
Providing non default parameters for the following set of arguments will cause the optimization problem to most likely turn into a Mixed Integer Linear Problem
- Parameters
milp¶ (bool, default=False,) –
Mapping of each
input/output nameto a boolean variable describing if the mappedCHP.flow_ratesparameter can be subject to mixed integer linear constraints.Default:
{key: False for key in [*inputs, *outputs]}
milp¶ –
Boolean variable indicating if the component’s parameters are to be parsed as mixed integer-linear optimization problem or not.
Warning
If
milpevaluates toFalsefollowing set of parameters is most likely ignored during optimization.initial_status¶ (bool, default=True) – Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do, in the beginning of the evaluated timeframe.
An
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing stil respectively.Default:
OnOff(0, 0)
status_changing_costs¶ (OnOff) –
An
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectivelyDefault:
OnOff(0, 0)
number_of_status_changes¶ (OnOff) –
NamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.Default:
OnOff(float('+inf'), float('+inf'))
costs_for_being_active¶ (
Number, default = 0) –Costs for not being inactive.
Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
Example
Variable efficiency
CHPobject:>>> import pprint >>> from tessif.components import CHP >>> chp = CHP( ... name='my_chp', inputs=('fuel',), outputs=('electricity','heat',), ... conversions={('fuel', 'electricity'): 0.3, ('fuel', 'heat'): 0.5}, ... conversion_factor_full_condensation={('fuel', 'electricity'): 0.5}) >>> print(chp.uid) my_chp
>>> print(chp.inputs) frozenset({'fuel'})
>>> print(sorted(chp.outputs)) ['electricity', 'heat']
>>> print(sorted(chp.interfaces)) ['electricity', 'fuel', 'heat']
Accessing all its
attributes:>>> for k, v in chp.attributes.items(): ... print('{} = {}'.format( ... k, sorted(v) if isinstance(v, frozenset) else v)) ... # frozensets are sorted for consistent doctesting back_pressure = None conversion_factor_full_condensation = {('fuel', 'electricity'): 0.5} conversions = {('fuel', 'electricity'): 0.3, ('fuel', 'heat'): 0.5} costs_for_being_active = 0.0 el_efficiency_wo_dist_heat = MinMax(min=None, max=None) enthalpy_loss = MinMax(min=None, max=None) expandable = {'electricity': False, 'fuel': False, 'heat': False} expansion_costs = {'electricity': 0.0, 'fuel': 0.0, 'heat': 0.0} expansion_limits = {'electricity': MinMax(min=0.0, max=inf), 'fuel': MinMax(min=0.0, max=inf), 'heat': MinMax(min=0.0, max=inf)} flow_costs = {'electricity': 0.0, 'fuel': 0.0, 'heat': 0.0} flow_emissions = {'electricity': 0.0, 'fuel': 0.0, 'heat': 0.0} flow_gradients = {'electricity': PositiveNegative(positive=inf, negative=inf), 'fuel': PositiveNegative(positive=inf, negative=inf), 'heat': PositiveNegative(positive=inf, negative=inf)} flow_rates = {'electricity': MinMax(min=0.0, max=inf), 'fuel': MinMax(min=0.0, max=inf), 'heat': MinMax(min=0.0, max=inf)} gradient_costs = {'electricity': PositiveNegative(positive=0.0, negative=0.0), 'fuel': PositiveNegative(positive=0.0, negative=0.0), 'heat': PositiveNegative(positive=0.0, negative=0.0)} initial_status = 1 inputs = ['fuel'] interfaces = ['electricity', 'fuel', 'heat'] milp = {'electricity': False, 'fuel': False, 'heat': False} min_condenser_load = None number_of_status_changes = OnOff(on=inf, off=inf) outputs = ['electricity', 'heat'] power_loss_index = None power_wo_dist_heat = MinMax(min=None, max=None) status_changing_costs = OnOff(on=0.0, off=0.0) status_inertia = OnOff(on=0, off=0) timeseries = None uid = my_chp
- property back_pressure
True if characterized as back-pressure.
Boolean to specify if back-pressure characteristics shall be used. Set to True and Q_CW_min to zero for back-pressure turbines.
- property conversion_factor_full_condensation
Dictionairy of efficiencies when fully condensating.
Mappingwhere the (inflow-name, outflow-name) tuple of the main flow is the only key and it’s conversion efficiency when there is no tapped flow is it’s value. Conversion efficiencies are expected to be between 0 and 1 (\(\left[0, 1\right]\)).
- property el_efficiency_wo_dist_heat
Electric efficiency at min/max fuel flow without district heating.
Expects a
MinMaxwhere both the min and the max value are a list where the length is the same as the number of timesteps and each entry is a float value between 0 and 1 giving the efficiency at that timestep.
- property enthalpy_loss
Share of flue gas loss at min/max heat extraction.
Expects a
MinMaxwhere both the min and the max value are a list where the length is the same as the number of timesteps and each entry is a float value between 0 and 1 giving the share of flue gas enthalpy loss for that timestep.
- property min_condenser_load
Minimal thermal condenser load to cooling water.
Expects a list where the length is the same as the number of timesteps and each entry is the minimal condenser load at that timestep.
- property power_loss_index
Marginal loss of electric power for each additional unit of heat.
Expects a list where the length is the same as the number of timesteps and each entry is a float value between 0 and 1 giving the marginal loss of power at that timestep.
- class tessif.components.Storage(name, input, output, capacity, *args, **kwargs)[source]
Bases:
tessif.components.AbstractEsComponentEntities only concerned with input, output and accumulation.
- Parameters
name¶ (Hashable) – Identifier. Usually a string, aka a name.
Hashable unique identifier. Usually a string specifying the storage-entity’s input e.g:
'electricity'Hashable unique identifier. Usually a string specifying the storage-entity’s output e.g:
'electricity'capacity¶ (Number) – Maximum number of units the entity is able to accumulate.
Note
All following arguments are considered optional parameters and are provided using **kwargs.
- Parameters
latitude¶ (Number) – Geospatial latitude in degree. Parsed into a
namedtuples.Uidinstance asuid.latitudelongitude¶ (Number) – Geospatial longitude in degree. Parsed into a
namedtuples.Uidinstance asuid.longituderegion¶ (str) – Arbitrary regional categorization string. Parsed into a
namedtuples.Uidinstance asuid.regionsector¶ (str) – Arbitrary sector categorization string.Parsed into a
namedtuples.Uidinstance asuid.sectorcarrier¶ (str) – Arbitrary energy carrier categorization string.Parsed into a
namedtuples.Uidinstance asuid.carriercomponent¶ (str) – String specifying the components type. Used for post-processing.
node_type¶ (str) – Arbitrary node type categorization string. Parsed into a
namedtuples.Uidinstance asuid.node_type
Warning
The 6 beforneamed arguments together with
nameform an id as atessif.frused.namedtuples.Uidobject. ThisUidobject as well as its string representation (str(Uid)) must be unique.The string representation can be tweaked using
node_uid_style. But in total the overall combination of these parameters must be unique and will form the components hashable uid (unique identifier)- Parameters
initial_soc¶ (Number, default = 0) –
Amount of stored units at the beginning of the evaluated timeframe.
Usually something between 0 and
capacity(\(\left[0, \text{capacity}\right]\)).final_soc¶ (Number,None, default = None) –
Amount of stored units at the end of the evaluated timeframe.
Usually something between 0 and
capacity(\(\left[0, \text{capacity}\right]\)).If
None, the solver does not constrain the final soc. However since currently no plugin supports constraining the final soc, this value is primarily used to force a state of charge equilibrium at the beginning and the end of the simulated timeframe. Meaningfinal_soc == initial_socso the total energy balance of the simulated systems stays 0.Use
Noneto ensure, different socs at first and last timestep are valid.idle_changes¶ (
PositiveNegative) – APositiveNegativeNamedTupledescribing state of charge changes of two following discrete timesteps.Mapping of each
input/output nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going in/out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
Default:
{key: MinMax(0, float('+inf')) for key in [*input, *output]}
flow_efficiencies¶ (Mapping) –
Mapping of each
input/output nameto aNumberspecifying its efficiency.Meaning for each amount per time that is going in/out the amount times its respective efficiency is available for storing.
Default:
{k: InOut(1, 1) for k in [*input, *output]}
Mapping of each
input/output nameto aNumberspecifying its cost.Meaning for each amount per time that is going in/out this amount of cost-unit is taken into account (by the solver).
Default:
{key: 0 for key in [*input, *output]}
Mapping of each
input/output nameto aNumberspecifying its emission.Meaning for each amount per time that is going in/out this amount of emission-unit is taken into account (by the solver).
Default:
{key: 0 for key in [*input, *output]}
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
Mapping of each
input/output nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
Default:
{k: PositiveNegative(float('+inf'),float('+inf')) for k in [*input, *output]}
Mapping of each
input/output nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).Default:
{k: PositiveNegative(0, 0) for k in [*input, *output]}
timeseries¶ (Mapping, default=None) –
Mapping an arbitrary number of
input/output namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively.For Example
Setting the maximum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=0, max=np.array([10, 42]))}
Setting the minimum
flow_rate:import numpy as np timeseries = {'input_bus': MinMax( min=np.array([1, 2]), max=float('+inf'))}
Fixing the
flow_rateto a certain timeseries:import numpy as np timeseries = {input_bus': MinMax( min=np.array([1, 2]), max=np.array([1, 2]))}
Mapping of each
inputandoutputname orcapacityto a boolean variable describing if the mappedStorage.flow_rates/ the capacity value can be increased by the solver or not.Default:
{key: False for key in [*input, *output, 'capacity']}
For example:
expandable: {'capacity': True, f'{Storage.output}': True}
fixed_expansion_ratios¶ (Mapping) –
Mapping of each
inputandoutputname to a boolean variable describing if the mappedflow rateexpansion is fixed in relation to the installedcapacity.Default:
{key: True for key in [*input, *output]}
For example:
{f'{Storage.input}': True, f'{Storage.output}': True}
Mapping of each
input/output nameor the keywordcapacityto aNumberspecifying its expansion cost.Meaning for each unit the
capacityor the maximum of the mappedamount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).Default:
{key: 0 for key in [*input, *output, 'capacity']}
Mapping of each
input/output nameor the keyword capacity to aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the
capacityor the mappedamount per timewill be somwhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))Default:
{k: MinMax(0, float('+inf')) for k in [*input, *output, 'capacity']}
Note
Providing non default parameters for the following set of arguments will cause the optimization problem to most likely turn into a Mixed Integer Linear Problem
- Parameters
Mapping of each
input/output nameto a boolean variable describing if the mappedStorage.flow_ratesparameter can be subject to mixed integer linear constraints.Default:
{key: False for key in [*inputs, *outputs]}
Warning
If
milpevaluates toFalsefollowing set of parameters is most likely ignored during optimization.initial_status¶ (bool, default=True) – Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do, in the beginning of the evaluated timeframe.
An
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing stil respectively.Default:
OnOff(0, 0)
status_changing_costs¶ (OnOff) –
An
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectivelyDefault:
OnOff(0, 0)
number_of_status_changes¶ (OnOff) –
NamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.Default:
OnOff(float('+inf'), float('+inf'))
costs_for_being_active¶ (
Number, default = 0) –Costs for not being inactive.
Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).
Example
Default parameterized
Storageobject with no need to seperate in and outflow:>>> import pprint >>> from tessif.components import Storage >>> storage = Storage( ... name='my_storage', input='electricity', output='electricity', ... capacity=100) >>> print(storage.uid) my_storage
>>> print(storage.input) electricity
>>> print(storage.output) electricity
>>> print(sorted(storage.interfaces)) ['electricity']
Following example transforms the frozensets into sorted lists, to enable doctesting
Accessing all its
attributes:>>> for k, v in storage.attributes.items(): ... print('{} = {}'.format( ... k, sorted(v) if isinstance(v, frozenset) else v)) ... # frozensets are transformed to sorted list for doctesting consistency capacity = 100 costs_for_being_active = 0.0 expandable = {'capacity': False, 'electricity': False} expansion_costs = {'capacity': 0.0, 'electricity': 0.0} expansion_limits = {'capacity': MinMax(min=0.0, max=inf), 'electricity': MinMax(min=0.0, max=inf)} final_soc = None fixed_expansion_ratios = {'electricity': True} flow_costs = {'electricity': 0.0} flow_efficiencies = {'electricity': InOut(inflow=1.0, outflow=1.0)} flow_emissions = {'electricity': 0.0} flow_gradients = {'electricity': PositiveNegative(positive=inf, negative=inf)} flow_rates = {'electricity': MinMax(min=0.0, max=inf)} gradient_costs = {'electricity': PositiveNegative(positive=0.0, negative=0.0)} idle_changes = PositiveNegative(positive=0.0, negative=0.0) initial_soc = 0.0 initial_status = 1 input = electricity interfaces = ['electricity'] milp = {'electricity': False} number_of_status_changes = OnOff(on=inf, off=inf) output = electricity status_changing_costs = OnOff(on=0.0, off=0.0) status_inertia = OnOff(on=0, off=0) timeseries = None uid = my_storage
- property input
Input uid.
Hashableunique identifier. Usually a string aka name representing the storage-entity’s input.
- property output
Output uid.
Hashableunique identifier. Usually a string aka name representing the storage-entity’s output.
- property capacity
Maximum installed capacity.
Maximum
Numberof units the entity is able to accumulate.
- property initial_soc
Initial SOC constraint.
The
Numberof units the entity has accumulated at the beginning of the evaluated timeframe. Usually something between 0 andcapacity(\(\left[0, \text{capacity}\right]\)).
- property final_soc
Final SOC constriant.
The
Numberof units the entity has accumulated at the end of the evaluated timeframe. Usually something between 0 andcapacity(\(\left[0, \text{capacity}\right]\)).Can also be
Noneto not constrain the final soc.
- property idle_changes
Namedtuple of idle change constraints.
A
PositiveNegativeNamedTupledescribing state of charge changes of two following discrete timesteps.
- property flow_rates
Dictionairy of flow rate constraints.
Mappingof eachinput/output nameto aMinMaxtuple describing the minimum and maximum amount per time.Meaning each flow going out during one discrete timestep is greater equal than the minimum amount per time and less equal than the maximum amount per time mapped to its name.
- property flow_efficiencies
Dictionairy of flow efficiency constraints.
Mappingof eachinput/output nameto aNumberspecifying its efficiency.Meaning for each amount per time that is going in/out the amount times its respective efficiency is available for storing.
- property flow_costs
Dictionairy of flow cost constraints.
Mappingof eachinput/output nameto aNumberspecifying its cost.Meaning for each amount per time that is going out this amount of cost-unit is taken into account (by the solver).
- property flow_emissions
Dictionairy of flow emission constraints.
Mappingof eachinput/output nameto aNumberspecifying its emissionsMeaning for each amount per time that is going out this amount of emission-unit is taken into account (by the solver).
Note
This unit primarily serves as system wide constrain parameter as in ‘All emissions must remain below 100 units’.
- property flow_gradients
Dictionairy of flow gradient constraints.
Mappingof eachinput/output nameto aPositiveNegativetuple describing the maximum positive or negative change between two following timesteps.Meaning each flow amount increase/decrease between two following discrete timesteps is less equal than the maximum change mapped to its name.
- property gradient_costs
Dictionairy of flow gradient costs.
MappingMapping of eachinput/output nameto aPositiveNegativetuple describing the costs for the respectiveflow_gradients.Meaning for each unit of change of its mapped
flow_ratesthis amount of cost-unit is taken into account (by the solver).
- property timeseries
Tuple of flow_rates constraining timeserieses.
Mappingof an arbitrary number ofinput/output namesto aMinMaxtuple describing the minimum and maximumflow_ratesrespectively.
- property expandable
True, if maximum flow_rate is subject to solver changes.
Mappingof eachinput/output nameto a boolean variable describing if the mappedStorage.flow_ratesvalue can be increased by the solver or not.
- property fixed_expansion_ratios
Dictionairy of coupled capacity and flow rate expansion constraints.
Mappingof eachinputandoutputname to a boolean variable describing if the mappedflow rateexpansion is fixed in relation to the installedcapacity.
- property expansion_costs
Dictionairy of maximum flow rate expansion costs.
Mappingof eachinput/output nameto aNumberspecifying its expansion cost.Meaning for each unit the maximum of the mapped
amount per timeis increased (by the solver) this amount of cost-unit is taken into account (by the solver).
- property expansion_limits
Dictionairy of maximum flow rate expansion limits.
Mappingof eachinput/output nameto aMinMaxtuple describing the minimum and maximum expansion limit.Meaning the actual increase of the mapped
amount per timewill be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))
- property initial_status
True, if component is milp constrained and active at first time step.
Status variable, indicating if the entity is running, operating, working, doing the things its supposed to do in the beginning of the evaluated timeframe.
- property status_inertia
Tuple of status-inertia (milp) constraints.
OnOffNamedTupledescribing the minimum uptime and downtime. With up and downtime describing the minimum amount of following discrete timesteps the entity as to be operating or standing still respectively.
- property status_changing_costs
Tuple of status-changing (milp) constraints.
OnOffNamedTupledescribing the cost for changing status fromontooffand fromofftoonrespectively.
- property number_of_status_changes
Tuple of allowed milp status changing constraints.
An
OnOffNamedTupledescribing the number of times the entity can change its status fromontooffand fromofftoonrespectively.
- property costs_for_being_active
Milp constained activity costs.
A
Number, default = 0 Describing the costs for not being inactive.Meaning for each discrete time step the entity’s boolean status variable is
True, this amount of cost units is taken in to account (by the solver).