Transform

Tessif system model to pypsa system model transformation.

tessif_pypsa_0_19_3.transform is a tessif_pypsa_0_19_3 module aggregating all the functionality for automatically transforming a tessif system model into a pypsa energy system.

tessif_pypsa_0_19_3.transform.infer_pypsa_transformer_types(tessif_transformers, forced_links=None)[source]

Utility to infer how tessif transformers should be transformed into pypsa components.

Tessif transformers can have singular or multiple outputs and therefor be both:

For a tessif transformer being transformed into a pypsa link, one of the following has to be true:

  • Transformer.node_type is found inside tessif.frused.spellings.combined_heat_power

  • number of Transformer.outputs > 1

On the other hand, for a tessif transformer beeing transformed into a pypsa generator, one of the following has to be true:

  • Transformer.node_type is found inside tessif.frused.spellings.power_plant or inside tessif.frused.spellings.heat_plant.

  • number of Transformer.outputs equals number of Transformer.inputs equals 1.

Parameters
  • tessif_transformers (Iterable) – Iterable of tessif transformers of which the appropriate transformation type is to be inferred.

  • forced_links (Container, None, default=None) –

    Container of uid representations of tessif transformers to be transfrormed into pypsa links.

Returns

inferred_transformers – Mapping of Tessif transformer uids keyed either by links or by generators

Return type

dict

tessif_pypsa_0_19_3.transform.compute_unneeded_supply_chains(tessif_es, pypsa_generator_uids)[source]

Utility to compute unneeded tessif components uids.

Due to transforming certain tessif transformers into pypsa generators corresponding supply chains (usually a tessif bus and a tessif source) are not needed and hence need to be removed, to allow succesfull optimization.

Parameters
  • tessif_es (tessif.model.energy_system.AbstractEnergySystem) – The tessif energy system of which the generator supply chains are to be removed.

  • pypsa_generator_uids (Iterable) – Iterable of tessif transformers of which the corresponding supply chains need to be removed. Returned by infer_pypsa_transformer_types() [‘generators’] by design.

Returns

components_to_remove – Dictionairy of componend uid lists keyed by pypsa component type of components which are to be removed.

Return type

dict

tessif_pypsa_0_19_3.transform.parse_flow_parameters(component, interface)[source]

Utility to parse flow related parameters from Tessif components to Pypsa components

Parameters
  • component (tessif.model.components.AbstractEsComponent) – Tessif component of which it’s flow related parameters are parsed into pypsa recognizable parameters

  • interface (str) – String representing the flow related interface from the components point of view. One of the components interfaces.

Returns

parsed_flow_parameters – Dictionairy representing the parsed flow parameters ready to be used as key word arguments for creating pypsa components.

Return type

dict

Raises

ValueError: – A value error is raised in case a nominal_value (max flow_rate value) is requested to be infinit AND in addition to milp parameters. This is due to the fact that an infinit nominal value is parsed into an expansion problem because pypsa can not deal with infinity values. Which in turn causes conflicts in dealing with milp parameters.

tessif_pypsa_0_19_3.transform.create_pypsa_busses(busses)[source]

Creates pypsa buses out of tessif busses.

Parameters

busses (Sequence) – Sequence of tessif.model.components.Bus objects that are to be transformed into bus objects.

Returns

Sequence of pypsa dictionairies representing the bus components.

Return type

Sequence

tessif_pypsa_0_19_3.transform.create_pypsa_generators_from_sources(sources, tessif_busses)[source]

Create pypsa generators out of tessif sources.

Parameters
  • sources (Sequence) – Sequence of tessif.model.components.Source objects that are to be transformed into generator objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as sources.

Returns

Sequence of pypsa dictionairies representing the generator components representing tessif sources.

Return type

class:~collections.abc.Sequence

Note

Tessif sources can have multiple outputs, pypsa generators not. So in case a tessif source requests to have multiple outputs, a singular pypsa generator is created for each output.

tessif_pypsa_0_19_3.transform.create_pypsa_sinks(sinks, tessif_busses, timeseries='max')[source]

Create pypsa generators out of tessif sinks.

Parameters
  • sinks (Sequence) – Sequence of tessif.model.components.Sink objects that are to be transformed into load objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as sources.

  • timeseries (str, ['max', 'min', 'avg']) –

    String specifying how to handle timeseries values. Since pypsa loads can only handle fixed timeseries values (in contrast to time varying range of lower and upper load limits), a flag has to be stated how timeseries values are to be handled.

    Must be one of:

    • max (default):

      flow_rate.max is used, for setting the timeseries values.

    • min (default):

      flow_rate.min is used, for setting the timeseries values.

    • avg:

      The average of each time step between flow_rate.min and flow_rate.max is used.

Returns

Sequence of pypsa dictionairies representing the load components representing tessif sinks.

Return type

Sequence

tessif_pypsa_0_19_3.transform.create_pypsa_excess_sinks(sinks, tessif_busses)[source]

Create pypsa generators out of tessif sinks.

Parameters
  • sinks (Sequence) – Sequence of tessif.model.components.Sink objects that are to be transformed into storage units objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as sources.

Returns

Sequence of pypsa dictionairies representing the storage unit components representing tessif excess sinks.

Return type

Sequence

tessif_pypsa_0_19_3.transform.create_pypsa_generators_from_transformers(transformers, tessif_busses)[source]

Create pypsa generators out of tessif transformers.

Parameters
  • transformers (Sequence) –

    Sequence of tessif.model.components.Transformer objects that are to be transformed into generator objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as transformers.

Returns

Sequence of pypsa dictionairies representing the generator components representing tessif transformers.

Return type

class:~collections.abc.Sequence

Note

Tessif transformers can have multiple outputs, pypsa generators not. So in case a tessif transformer requests to have multiple outputs, a singular pypsa generator is created for each output.

Create pypsa links out of tessif transformers.

Parameters
  • transformers (Sequence) – Sequence of tessif.model.components.Transformer objects that are to be transformed into link objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as transformers.

Returns

Sequence of pypsa dictionairies representing the link components representing tessif transformers.

Return type

class:~collections.abc.Sequence

Warning

In case of chp transformation pypsa uses the highest installed capacity as reference capacity to calculate outgoing flows using the respective conversion factors.

Make sure the conversion factors reflect the expected installed capacities. If target capacaties are 100 and 50, make sure conversion factors are of ration 2/1 (i.e 0.6 and 0.3).

Raises

NotImplementedError – Raised if more than 1 input is used, because tessif can’t handle this case yet.

tessif_pypsa_0_19_3.transform.create_pypsa_connectors(connectors, tessif_busses)[source]

Create pypsa links out of tessif connectors.

Parameters
  • connectors (Sequence) –

    Sequence of tessif.model.components.Connector objects that are to be transformed into link objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as connectors.

Returns

Sequence of pypsa dictionairies representing the link components representing tessif connectors.

Return type

class:~collections.abc.Sequence

Note

Transforming tessif connectors to pypsa links following compatibility issues are faced:

  • Pypsa links are one-directional according to their efficiency calculations. For bidirectional tessif links to make sense, bidirectional pypsa links are set to an efficiency of 1.0.

  • Tessif connectors are not designed to constrain their flows, where as pypsa links are. Therefor pypsa links created from tessif connectors are parameterized as follows:

    1. nominal capacity is extendable having no extension costs

    2. specific min/max power flow is set to -1.0/1.0 respectively

    3. flow specific costs are set to 0.0

tessif_pypsa_0_19_3.transform.create_pypsa_storages(storages, tessif_busses)[source]

Create pypsa generators out of tessif storages.

Parameters
  • storages (Sequence) –

    Sequence of tessif.model.components.Storage objects that are to be transformed into generator objects.

  • tessif_busses (Sequence) – Sequence of tessif.model.components.Bus objects present in the same energy system as storages.

Returns

Sequence of pypsa dictionairies representing the storage components representing tessif storages.

Return type

Sequence

Note

Pypsa forces the ratio of capacity and output flow to be constant, even during expansion. Doing that it restricts possible capacty expansion in relation to out_flow expansion. Meaning, outflow expansion is subject to parameterization while capacity expansion is just a subsequent byproduct.

Since this seems quite unintuitive, tessif parameterizes it the other way round, meaning the values for capacity expansion are enforced on the flow rate expansion repsecting the stated ration of capacity to flow rate.

tessif_pypsa_0_19_3.transform.transform(tessif_es, transformer_style='infer', forced_links=None, excess_sinks=None, **kwargs)[source]

Transform a tessif energy system into a pypsa energy system.

Parameters
  • tessif_es (tessif.model.energy_system.AbstractEnergySystem) – The tessif energy system that is to be transformed into a pypsa energy system.

  • transformer_style (str) –

    String specifying how tessif transformer should be transformed into pypsa components:

    • infer (default):

      Transformers are treated according to infer_pypsa_transformer_types() with the exception of forced_links, which are treated as Pypsa links

    • links:

      All transformers are treated as links, giving up pypsa commitment simulations and plant related CO2 emissions, but preserving tessif energy system representation. (Meaning all nodes present inside the tessif energy system will be present inside the pypsa energy system.)

  • forced_links (Container, None, default=None) –

    Container of uid representations of tessif transformers to be transfrormed into pypsa links.

  • excess_sinks (Container, None, default=None) – Container of uid representations of tessif sinks to be transfrormed into pypsa store units.

Returns

pypsa_es – The pypsa energy system that was transformed out of the tessif energy system.

Return type

pypsa.Network