components

Classes

AbstractEsComponent

Entities only concerned with their unique hashable identifier.

Bus

Entities only concerned with input and output names.

Connector

Entities only concerned with connecting 2 busses.

Source

Entities only concerned with their outputs and related attributes.

Sink

Entities only concerned with their inputs and related attributes.

Transformer

Entities only concerned with mapping their inflows to their outflows.

CHP

Entities that are like Transformers but with additional constraints.

Storage

Entities only concerned with input, output and accumulation.

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.model.

class tessif.model.components.AbstractEsComponent(name, *args, **kwargs)[source]

Bases: object

Entities 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.Uid instance as uid.name

Note

All following arguments are considered optional parameters and are provided using **kwargs.

Parameters:

Warning

The 6 beforneamed arguments together with name form a tessif.frused.namedtuples.Uid object. This Uid object 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 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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)[source]

Create an AbstractEsComponent object from a dictionary of attributes.

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.Bus(name, inputs, outputs, *args, **kwargs)[source]

Bases: AbstractEsComponent

Entities only concerned with input and output names.

Parameters:
  • name (Hashable) – Identifier. Usually a string, aka a name.

  • inputs (Iterable) –

    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.Uid as well as node_uid_style and node_uid_styles for more details on the uid’s string representation. Especially when having issues with non-unique uid solver issues.

  • outputs (Iterable) –

    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.Uid as well as node_uid_style and node_uid_styles for 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:

Warning

The 6 beforneamed arguments together with name form an id as tessif.frused.namedtuples.Uid object. This Uid object 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)

property inputs

Hashable container of str( uid).output/input strings representing the inputs.

property outputs

Hashable container of str( uid).output/input strings representing the outputs.

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.Connector(name, interfaces, *args, **kwargs)[source]

Bases: AbstractEsComponent

Entities 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.Uid as well as node_uid_style and node_uid_styles for 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:

Warning

The 6 beforneamed arguments together with name form an id as tessif.frused.namedtuples.Uid object. This Uid object 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:

conversions (Mapping) –

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 Connector object:

>>> from tessif.model.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

Hashable container of str( uid).output/input strings representing the inputs.

property outputs

Hashable container of str( uid).output/input strings representing the outputs.

property conversions

Mapping of connector relevant (input-name, output-name) tuples to their respective conversion efficiency. With recognized conversion efficiencies between 0 and 1.

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.Source(name, outputs, *args, **kwargs)[source]

Bases: AbstractEsComponent

Entities only concerned with their outputs and related attributes.

Parameters:
  • name (Hashable) – Identifier. Usually a string, aka a name.

  • outputs (Iterable) –

    An iterable of hashable unique identifiers. Usually strings, aka names specifying the source-entity’s outputs. e.g.:

    ('fuel',)
    

Note

All following arguments are considered optional parameters and are provided using **kwargs.

Parameters:

Warning

The 6 beforneamed arguments together with name form an id as tessif.frused.namedtuples.Uid object. This Uid object 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 name to a MinMax NamedTuple describing 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 than accumulated_amounts [output_name].min

    Default:

    {key: MinMax(0, float('+inf')) for key in outputs}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • flow_rates (Mapping) –

    Mapping of each output name to a MinMax tuple 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}
    

  • flow_costs (Mapping) –

    Mapping of each output name to a Number specifying 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}
    

  • flow_emissions (Mapping) –

    Mapping of each output name to a Number specifying 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’.

  • flow_gradients (Mapping) –

    Mapping of each output name to a PositiveNegative tuple 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}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • gradient_costs (Mapping) –

    Mapping of each output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

    Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

    default:

    {k: PositiveNegative(0, 0) for k in outputs}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • timeseries (Mapping, default=None) –

    Mapping an arbitrary number of output names to a MinMax tuple describing the minimum and maximum flow_rates respectively. 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_rate to a certain timeseries:

    import numpy as np
    timeseries = {input_bus': MinMax(
        min=np.array([1, 2]), max=np.array([1, 2]))}
    

  • expandable (Mapping) –

    Mapping of each output name to a boolean variable describing if the mapped Source.flow_rates value can be increased by the solver or not.

    Default:

    {key: False for key in outputs}
    

  • expansion_costs (Mapping) –

    Mapping of each output name to a Number specifying its expansion cost.

    Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

    Default:

    {key: 0 for key in outputs}
    

  • expansion_limits (Mapping) –

    Mapping of each output name to a MinMax tuple describing the minimum and maximum expansion limit.

    Meaning the actual increase of the mapped amount per time will 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:
  • milp (Mapping) –

    Mapping of each output name to a boolean variable describing if the mapped Source.flow_rates parameter can be subject to mixed integer linear constraints.

    Default:

    {key: False, for key in outputs}
    

    Warning

    If milp evaluates to False following 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.

  • status_inertia (OnOff) –

    An OnOff NamedTuple describing 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 OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively

    Default:

    OnOff(0, 0)
    

  • number_of_status_changes (OnOff) –

    NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

    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 Source object:

>>> from tessif.model.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

Hashable container of hashable unique identifiers. Usually a string aka a name representing the outputs.

property accumulated_amounts

Mapping of each output name to a MinMax NamedTuple describing 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 than accumulated_amounts [output_name].min

property flow_rates

Mapping of each output name to a MinMax tuple 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

Mapping of each output name to a Number specifying 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

Mapping of each output name to a Number specifying its emissions

Meaning 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

Mapping of each output name to a PositiveNegative tuple 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

Mapping Mapping of each output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

property timeseries

Mapping of an arbitrary number of output names to a MinMax tuple describing the minimum and maximum flow_rates respectively.

property expandable

Mapping of each output name to a boolean variable describing if the mapped Source.flow_rates value can be increased by the solver or not.

property expansion_costs

Mapping of each output name to a Number specifying its expansion cost.

Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

property expansion_limits

Mapping of each output name to a MinMax tuple describing the minimum and maximum expansion limit.

Meaning the actual increase of the mapped amount per time will be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))

property initial_status

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

OnOff NamedTuple describing 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

OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively.

property number_of_status_changes

An OnOff NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

property costs_for_being_active

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).

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.Sink(name, inputs, *args, **kwargs)[source]

Bases: AbstractEsComponent

Entities only concerned with their inputs and related attributes.

Parameters:
  • name (Hashable) – Identifier. Usually a string, aka a name.

  • inputs (Iterable) –

    An iterable of hashable unique identifiers. Usually strings, aka names specifying the source-entity’s inputs. e.g.:

    ('fuel',)
    

Note

All following arguments are considered optional parameters and are provided using **kwargs.

Parameters:

Warning

The 6 beforneamed arguments together with name form an id as a tessif.frused.namedtuples.Uid object. This Uid object 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 name to a MinMax NamedTuple 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 than accumulated_amounts [input_name].min

    Default:

    {key: MinMax(0, float('+inf')) for key in inputs}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • flow_rates (Mapping) –

    Mapping of each input name to a MinMax tuple 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}
    

  • flow_costs (Mapping) –

    Mapping of each input name to a Number specifying 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}
    

  • flow_emissions (Mapping) –

    Mapping of each input name to a Number specifying 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’.

  • flow_gradients (Mapping) –

    Mapping of each input name to a PositiveNegative tuple 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}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • gradient_costs (Mapping) –

    Mapping of each input name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

    Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

    Default:

    {k: PositiveNegative(0, 0) for k in inputs}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • timeseries (Mapping, default=None) –

    Mapping an arbitrary number of input names to a MinMax tuple describing the minimum and maximum flow_rates respectively. 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_rate to a certain timeseries:

    import numpy as np
    timeseries = {input_bus': MinMax(
        min=np.array([1, 2]), max=np.array([1, 2]))}
    

  • expandable (Mapping) –

    Mapping of each input name to a boolean variable describing if the mapped Sink.flow_rates value can be increased by the solver or not.

    Default:

    {key: False for key in inputs}
    

  • expansion_costs (Mapping) –

    Mapping of each input name to a Number specifying its expansion cost.

    Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

    Default:

    {key: 0 for key in inputs}
    

  • expansion_limits (Mapping) –

    Mapping of each input name to a MinMax tuple describing the minimum and maximum expansion limit.

    Meaning the actual increase of the mapped amount per time will 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:
  • milp (Mapping) –

    Mapping of each output name to a boolean variable describing if the mapped Sink.flow_rates parameter can be subject to mixed integer linear constraints.

    Default:

    {key: False for key in inputs}
    

    Warning

    If milp evaluates to False following 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.

  • status_inertia (OnOff) –

    An OnOff NamedTuple describing 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 OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively.

    Default:

    OnOff(0, 0)
    

  • number_of_status_changes (OnOff) –

    NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

    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 Sink object:

>>> from tessif.model.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

Hashable container of hashable unique identifiers. Usually a string aka a name representing the inputs.

property accumulated_amounts

Mapping of each input name to a MinMax tuple 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 than accumulated_amounts [input_name].min

property flow_rates

Mapping of each input name to a MinMax tuple 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

Mapping of each input name to a Number specifying 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

Mapping of each input name to a Number specifying its emissions

Meaning 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

Mapping of each input name to a PositiveNegative tuple 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

Mapping Mapping of each input name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

property timeseries

Mapping of an arbitrary number of input names to a MinMax tuple describing the minimum and maximum flow_rates respectively.

property expandable

Mapping of each input name to a boolean variable describing if the mapped Sink.flow_rates value can be increased by the solver or not.

property expansion_costs

Mapping of each input name to a Number specifying its expansion cost.

Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

property expansion_limits

Mapping of each input name to a MinMax tuple describing the minimum and maximum expansion limit.

Meaning the actual increase of the mapped amount per time will be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))

property initial_status

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

OnOff NamedTuple describing 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

OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively.

property number_of_status_changes

An OnOff NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

property costs_for_being_active

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).

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.Transformer(name, inputs, outputs, conversions, *args, **kwargs)[source]

Bases: AbstractEsComponent

Entities only concerned with mapping their inflows to their outflows.

Parameters:
  • name (Hashable) – Identifier. Usually a string, aka a name.

  • inputs (Iterable) –

    An iterable of hashable unique identifiers. Usually strings, aka names specifying the transformer-entity’s inputs. e.g.:

    ['fuel_1', 'fuel_2']
    

  • outputs (Iterable) –

    An iterable of hashable unique identifiers. Usually strings, aka names specifying the transformer-entity’s outputs. e.g.:

    ['electricity', 'heat']
    

  • conversions (Mapping) –

    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:

Warning

The 6 beforneamed arguments together with name form an id as a tessif.frused.namedtuples.Uid object. This Uid object 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:
  • flow_rates (Mapping) –

    Mapping of each input/output name to a MinMax tuple 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]}
    

  • flow_costs (Mapping) –

    Mapping of each input/output name to a Number specifying 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]}
    

  • flow_emissions (Mapping) –

    Mapping of each input/output name to a Number specifying 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’.

  • flow_gradients (Mapping) –

    Mapping of each input/output name to a PositiveNegative tuple 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]}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • gradient_costs (Mapping) –

    Mapping of each input/output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

    Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

    Default:

    {k: PositiveNegative(0, 0) for k in [*inputs, *outputs]}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • timeseries (Mapping, default=None) –

    Mapping an arbitrary number of output names to a MinMax tuple describing the minimum and maximum flow_rates respectively. 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_rate to a certain timeseries:

    import numpy as np
    timeseries = {input_bus': MinMax(
        min=np.array([1, 2]), max=np.array([1, 2]))}
    

  • expandable (Mapping) –

    Mapping of each input name to a boolean variable describing if the mapped Transformer.flow_rates value can be increased by the solver or not.

    Default:

    {key: False for key in [*inputs, *outputs]}
    

  • expansion_costs (Mapping) –

    Mapping of each input/output name to a Number specifying its expansion cost.

    Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

    Default:

    {key: 0 for key in [*inputs, *outputs]}
    

  • expansion_limits (Mapping) –

    Mapping of each input/output name to a MinMax tuple describing the minimum and maximum expansion limit.

    Meaning the actual increase of the mapped amount per time will 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 name to a boolean variable describing if the mapped Transformer.flow_rates parameter 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 milp evaluates to False following 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.

  • status_inertia (OnOff) –

    An OnOff NamedTuple describing 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 OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively

    Default:

    OnOff(0, 0)
    

  • number_of_status_changes (OnOff) –

    NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

    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 Transformer object:

>>> import pprint
>>> from tessif.model.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

Hashable container of hashable unique identifiers. Usually a string aka a name representing the inputs.

property outputs

Hashable container of hashable unique identifiers. Usually a string aka a name representing the outputs.

property conversions

Mapping of 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

Mapping of each input/output name to a MinMax tuple 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

Mapping of each input/output name to a Number specifying 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

Mapping of each input/output name to a Number specifying its emissions

Meaning 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

Mapping of each input/output name to a PositiveNegative tuple 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

Mapping Mapping of each input/output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

property timeseries

Mapping of an arbitrary number of input/output names to a MinMax tuple describing the minimum and maximum flow_rates respectively.

property expandable

Mapping of each input/output name to a boolean variable describing if the mapped Transformer.flow_rates value can be increased by the solver or not.

property expansion_costs

Mapping of each input/output name to a Number specifying its expansion cost.

Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

property expansion_limits

Mapping of each input/output name to a MinMax tuple describing the minimum and maximum expansion limit.

Meaning the actual increase of the mapped amount per time will be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))

property initial_status

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

OnOff NamedTuple describing 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

OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively.

property number_of_status_changes

An OnOff NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

property costs_for_being_active

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).

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.CHP(name, inputs, outputs, *args, **kwargs)[source]

Bases: Transformer

Entities that are like Transformers but with additional constraints.

Parameters:
  • name (Hashable) – Identifier. Usually a string, aka a name.

  • inputs (Iterable) –

    An iterable of hashable unique identifiers. Usually strings, aka names specifying the chp-entity’s inputs. e.g.:

    ['fuel_1', 'fuel_2']
    

  • outputs (Iterable) –

    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:

Warning

The 6 beforenamed arguments together with name form an id as a tessif.frused.namedtuples.Uid object. This Uid object 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) – Mapping where 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 MinMax where 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.

  • enthalpy_loss (MinMax) –

    Share of flue gas enthalpy loss at min/max heat extraction.

    Expects a MinMax where 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 MinMax where 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.

  • power_loss_index (list) –

    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.

  • min_condenser_load (list) –

    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.

  • conversions (Mapping) –

    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.

  • flow_rates (Mapping) –

    Mapping of each input/output name to a MinMax tuple 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]}
    

  • flow_costs (Mapping) –

    Mapping of each input/output name to a Number specifying 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]}
    

  • flow_emissions (Mapping) –

    Mapping of each input/output name to a Number specifying 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’.

  • flow_gradients (Mapping) –

    Mapping of each input/output name to a PositiveNegative tuple 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]}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • gradient_costs (Mapping) –

    Mapping of each input/output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

    Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

    Default:

    {k: PositiveNegative(0, 0) for k in [*inputs, *outputs]}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • timeseries (Mapping, default=None) –

    Mapping an arbitrary number of output names to a MinMax tuple describing the minimum and maximum flow_rates respectively. 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_rate to a certain timeseries:

    import numpy as np
    timeseries = {input_bus': MinMax(
        min=np.array([1, 2]), max=np.array([1, 2]))}
    

  • expandable (Mapping) –

    Mapping of each input name to a boolean variable describing if the mapped CHP.flow_rates value can be increased by the solver or not.

    Default:

    {key: False for key in [*inputs, *outputs]}
    

  • expansion_costs (Mapping) –

    Mapping of each input/output name to a Number specifying its expansion cost.

    Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

    Default:

    {key: 0 for key in [*inputs, *outputs]}
    

  • expansion_limits (Mapping) –

    Mapping of each input/output name to a MinMax tuple describing the minimum and maximum expansion limit.

    Meaning the actual increase of the mapped amount per time will 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 name to a boolean variable describing if the mapped CHP.flow_rates parameter 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 milp evaluates to False following 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.

  • status_inertia (OnOff) –

    An OnOff NamedTuple describing 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 OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively

    Default:

    OnOff(0, 0)
    

  • number_of_status_changes (OnOff) –

    NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

    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 CHP object:

>>> import pprint
>>> from tessif.model.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

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

Mapping where 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 MinMax where 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 MinMax where 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.

property power_wo_dist_heat

Min/max electric power without district heating.

Expects a MinMax where 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.

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

property conversions

Mapping of 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 costs_for_being_active

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).

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

property expandable

Mapping of each input/output name to a boolean variable describing if the mapped Transformer.flow_rates value can be increased by the solver or not.

property expansion_costs

Mapping of each input/output name to a Number specifying its expansion cost.

Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

property expansion_limits

Mapping of each input/output name to a MinMax tuple describing the minimum and maximum expansion limit.

Meaning the actual increase of the mapped amount per time will be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))

property flow_costs

Mapping of each input/output name to a Number specifying 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

Mapping of each input/output name to a Number specifying its emissions

Meaning 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

Mapping of each input/output name to a PositiveNegative tuple 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 flow_rates

Mapping of each input/output name to a MinMax tuple 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.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property gradient_costs

Mapping Mapping of each input/output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

property initial_status

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 inputs

Hashable container of hashable unique identifiers. Usually a string aka a name representing the inputs.

property interfaces

frozenset holding the component’s in- and outputs.

property number_of_status_changes

An OnOff NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

property outputs

Hashable container of hashable unique identifiers. Usually a string aka a name representing the outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property status_changing_costs

OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively.

property status_inertia

OnOff NamedTuple describing 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 timeseries

Mapping of an arbitrary number of input/output names to a MinMax tuple describing the minimum and maximum flow_rates respectively.

property uid

namedtuples.Uid instance as a hashable unique identifier.

class tessif.model.components.Storage(name, input, output, capacity, *args, **kwargs)[source]

Bases: AbstractEsComponent

Entities only concerned with input, output and accumulation.

Parameters:
  • name (Hashable) – Identifier. Usually a string, aka a name.

  • input (Hashable) –

    Hashable unique identifier. Usually a string specifying the storage-entity’s input e.g:

    'electricity'
    

  • output (Hashable) –

    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:

Warning

The 6 beforneamed arguments together with name form an id as a tessif.frused.namedtuples.Uid object. This Uid object 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 most models do not support 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. Meaning final_soc == initial_soc so the total energy balance of the simulated systems stays 0.

    Use None to ensure, different socs at first and last timestep are valid.

  • idle_changes (PositiveNegative) – A PositiveNegative NamedTuple describing state of charge changes of two following discrete timesteps.

  • flow_rates (Mapping) –

    Mapping of each input/output name to a MinMax tuple 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 name to a Number specifying 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]}
    

  • flow_costs (Mapping) –

    Mapping of each input/output name to a Number specifying 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]}
    

  • flow_emissions (Mapping) –

    Mapping of each input/output name to a Number specifying 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’.

  • flow_gradients (Mapping) –

    Mapping of each input/output name to a PositiveNegative tuple 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]}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • gradient_costs (Mapping) –

    Mapping of each input/output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

    Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

    Default:

    {k: PositiveNegative(0, 0) for k in [*input, *output]}
    

    Warning

    Parameter not well established and tested. Recommended only for experienced users, since most likely some debugging is required.

  • timeseries (Mapping, default=None) –

    Mapping an arbitrary number of input/output names to a MinMax tuple describing the minimum and maximum flow_rates respectively.

    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_rate to a certain timeseries:

    import numpy as np
    timeseries = {input_bus': MinMax(
        min=np.array([1, 2]), max=np.array([1, 2]))}
    

  • expandable (Mapping) –

    Mapping of each input and output name or capacity to a boolean variable describing if the mapped Storage.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 input and output name to a boolean variable describing if the mapped flow rate expansion is fixed in relation to the installed capacity.

    Default:

    {key: True for key in [*input, *output]}
    

    For example:

    {f'{Storage.input}': True, f'{Storage.output}': True}
    

  • expansion_costs (Mapping) –

    Mapping of each input/output name or the keyword capacity to a Number specifying its expansion cost.

    Meaning for each unit the capacity or the maximum of the mapped amount per time is 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']}
    

  • expansion_limits (Mapping) –

    Mapping of each input/output name or the keyword capacity to a MinMax tuple describing the minimum and maximum expansion limit.

    Meaning the actual increase of the capacity or the mapped amount per time will 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:
  • milp (Mapping) –

    Mapping of each input/output name to a boolean variable describing if the mapped Storage.flow_rates parameter can be subject to mixed integer linear constraints.

    Default:

    {key: False for key in [*inputs, *outputs]}
    

    Warning

    If milp evaluates to False following 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.

  • status_inertia (OnOff) –

    An OnOff NamedTuple describing 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 OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively

    Default:

    OnOff(0, 0)
    

  • number_of_status_changes (OnOff) –

    NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

    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 Storage object with no need to seperate in and outflow:

>>> import pprint
>>> from tessif.model.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

Hashable unique identifier. Usually a string aka name representing the storage-entity’s input.

property output

Hashable unique identifier. Usually a string aka name representing the storage-entity’s output.

property capacity

Maximum Number of units the entity is able to accumulate.

property initial_soc

The Number of units the entity has accumulated at the beginning of the evaluated timeframe. Usually something between 0 and capacity (\(\left[0, \text{capacity}\right]\)).

property final_soc

The Number of units the entity has accumulated at the end of the evaluated timeframe. Usually something between 0 and capacity (\(\left[0, \text{capacity}\right]\)).

Can also be None to not constrain the final soc.

property idle_changes

A PositiveNegative NamedTuple describing state of charge changes of two following discrete timesteps.

property flow_rates

Mapping of each input/output name to a MinMax tuple 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

Mapping of each input/output name to a Number specifying 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

Mapping of each input/output name to a Number specifying 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

Mapping of each input/output name to a Number specifying its emissions

Meaning 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

Mapping of each input/output name to a PositiveNegative tuple 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

Mapping Mapping of each input/output name to a PositiveNegative tuple describing the costs for the respective flow_gradients.

Meaning for each unit of change of its mapped flow_rates this amount of cost-unit is taken into account (by the solver).

property timeseries

Mapping of an arbitrary number of input/output names to a MinMax tuple describing the minimum and maximum flow_rates respectively.

property expandable

Mapping of each input/output name to a boolean variable describing if the mapped Storage.flow_rates value can be increased by the solver or not.

property fixed_expansion_ratios

Mapping of each input and output name to a boolean variable describing if the mapped flow rate expansion is fixed in relation to the installed capacity.

property expansion_costs

Mapping of each input/output name to a Number specifying its expansion cost.

Meaning for each unit the maximum of the mapped amount per time is increased (by the solver) this amount of cost-unit is taken into account (by the solver).

property expansion_limits

Mapping of each input/output name to a MinMax tuple describing the minimum and maximum expansion limit.

Meaning the actual increase of the mapped amount per time will be somewhere between the given minimum and maximum. (\(\left[\text{min}, \text{max}\right]\))

property initial_status

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

OnOff NamedTuple describing 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

OnOff NamedTuple describing the cost for changing status from on to off and from off to on respectively.

property number_of_status_changes

An OnOff NamedTuple describing the number of times the entity can change its status from on to off and from off to on respectively.

property attributes

Mapping of entity’s energy system component attribute names to its respective attribute values.

property costs_for_being_active

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).

duplicate(prefix='', separator='_', suffix='copy')

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 by separator.

  • separator (str, default='_') – String used for adding the prefix and the suffix to the component’s name.

  • suffix (str, default='') – String added to the beginning of the component’s name, separated by separator.

classmethod from_attributes(attributes)

Create an AbstractEsComponent object from a dictionary of attributes.

property interfaces

frozenset holding the component’s in- and outputs.

property parameters

Mapping of the entity’s parameter names to its respective values.

Note

Redundant to attributes. Interface designed for engineers since they would call these values parameters, whereas in python attributes would be the more accurate terminology.

property uid

namedtuples.Uid instance as a hashable unique identifier.