cllp

Api

transform

Transform a tessif energy system into an calliope energy system.

Internal Functionalities

parse_flow_parameters

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

parse_cost_parameters

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

generate_calliope_bus_like_loc

Generates calliope locations, transmissions and links out of tessif busses.

generate_calliope_supply

Create calliope supply out of tessif sources.

generate_calliope_demand

Create calliope demand out of tessif sinks.

generate_calliope_conversion

Create calliope conversion out of tessif transformers.

generate_calliope_conversion_plus

Create calliope conversion_plus specific data out of tessif transformers with multiple in or outputs.

generate_calliope_storage

Create calliope storages out of tessif storages.

generate_calliope_connector

Create calliope location out of tessif connectors.

tessif.transform.es2es.cllp is a tessif module aggregating all the functionality for automatically transforming a tessif energy system into an calliope energy system.

Also the model data will be saved in .yaml and .csv files in calliope style. This way these files can be used to be extended with calliope specific parameters which might not be supported by tessif. If this is done, native calliope post processing functions need to be used for analysing the model restults.

class tessif.transform.es2es.cllp.MyDumper(stream: StreamType, default_style: Any = None, default_flow_style: bool | None = None, canonical: int | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, line_break: Any = None, encoding: Any = None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: Any = None, tags: Any = None, block_seq_indent: Any = None, top_level_colon_align: Any = None, prefix_colon: Any = None)[source]

Bases: RoundTripDumper

Dumper class to raise human readability of the written yaml files by creating Blank lines between the different technologies. Adapted class MyDumper from –> https://github.com/yaml/pyyaml/issues/127

tessif.transform.es2es.cllp.parse_flow_parameters(component, target, timesteps)[source]

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

Parameters:
  • component – Tessif component of which it’s flow related parameters are parsed into calliope recognizable parameters

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

  • timesteps (int) – Integer representing number of timesteps.

Returns:

flow_params – Dictionary representing the parsed flow parameters ready to be used as key word arguments for creating calliope components. In special cases the dict will be adjusted in another function.

Return type:

dict

Warning

Component has different negative and positive flow gradient. Calliope sets gradient as a single value for both directions. Falling back on negative gradient for calliope.

Calliope does not have installed capacities. The calliope min expansion is used to portray the installed capacity, this results in the tessif min expansion to not be able to be covered by calliope.

Calliope storages only use one efficiency value for both directions. Falling back to outflow efficiency for both directions in case inflow and outflow are not the same.

Calliope considers storage initial soc and storage loss as fraction of its capacity, so the initial soc and storage loss is set to Zero if the capacity is zero or infinity. Furthermore the initial soc will be set to Zero if it is set variable in tessif, due to Calliope not being able to handle a variable initial soc.

If capacity is zero the the flow rates minimum is ignored cause calliope uses relative values. If capacity is infinity the flow rates will be min 0 and max 1 as relative values.

Calliope does not have installed capacities. The calliope min expansion is used to portray the installed capacity, this results in the tessif min expansion to not be able to be covered by calliope.

Maximum expansion limit is below current installed capacity. Falling back on current installed capacity as expansion maximum.

Calliope doesnt support tessif’s milp parameters. Thus they will be ignored.

tessif.transform.es2es.cllp.parse_cost_parameters(component, flow)[source]

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

Parameters:
  • component – Tessif component of which it’s cost/emission related parameters are parsed into calliope recognizable parameters

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

Returns:

costs – Dictionary representing the costs ready to be used as key word arguments for creating calliope components. Calliope considers emissions as another cost parameter. The objective minimises only the monetary costs by default and not emission costs. In special cases the dict will be adjusted in another function.

Return type:

dict

Warning

Calliope doesn’t support gradient costs and they will be ignored.

Storage expansion costs will only be defined by capacity expansion costs

Calliope only considers fixed ratios of energy flow to storage capacity.

tessif.transform.es2es.cllp.generate_calliope_bus_like_loc(busses)[source]

Generates calliope locations, transmissions and links out of tessif busses.

For tessif post processing it is needed to read the results from the busses. To connect components over these busses different locations for each component as well as for busses are being used. Bus locations don’t contain any component, but transmissions to connect to components. Besides the location itself the transmission (no losses) and the links (information which locations to connect with the give transmission) are defined as well.

Parameters:

busses (Iterable) – Iterable of tessif.model.components.Bus objects that are to be transformed into calliope locations, links and transmissions.

Returns:

  • loc dict – Dictionary object yielding the bus location.

  • links dict – Dictionary object yielding the bus connected location. Links contain information about what regions are connected with which kind of transmission.

  • transmission dict – Dictionary object yielding the loss free transmissions between bus and component.

Warning

Dots are no valid symbols in component names, cause they are used to separate component from carrier in bus input/output data.

tessif.transform.es2es.cllp.generate_calliope_supply(sources, timeframe, es_name)[source]

Create calliope supply out of tessif sources.

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

  • timeframe – The timeframe to be analysed with the model.

  • es_name – Model name which is used to save the timeseries CSV files in correct folder.

Returns:

  • supply dict – Dictionary yielding the components data.

  • loc dict – Dictionary object yielding the components location.

Warning

Calliope can only handle sources of one output.

Calliope handles timeseries relative to flow rates max. If flow rate max is zero or infinity, the timeseries max is used as maximum.

tessif.transform.es2es.cllp.generate_calliope_demand(sinks, timeframe, es_name)[source]

Create calliope demand out of tessif sinks.

Parameters:
  • sinks (Sequence) – Sequence of tessif.model.components.Sinks objects that are to be transformed into calliope demand.

  • timeframe – The timeframe to be analysed with the model.

  • es_name – Model name which is used to save the timeseries CSV files in correct folder.

Returns:

  • demand dict – Dictionary yielding the components data.

  • loc dict – Dictionary object yielding the components location.

Warning

Calliope can only handle sinks of single inputs.

Calliope can only consider one given timeseries for demands. If different max and min timeseries are given, the minimum timeseries will be used.

tessif.transform.es2es.cllp.generate_calliope_conversion(transformers, timeframe, es_name)[source]

Create calliope conversion out of tessif transformers.

Parameters:
  • transformers (Sequence) – Sequence of tessif.model.components.Transformers objects that are to be transformed into calliope conversion.

  • timeframe – The timeframe to be analysed with the model.

  • es_name – Model name which is used to save the timeseries CSV files in correct folder.

Returns:

  • conversion dict – Dictionary yielding the components data.

  • loc dict – Dictionary object yielding the components location.

Warning

Calliope does only support timeseries for sinks and sources. Others will be ignored.

tessif.transform.es2es.cllp.generate_calliope_conversion_plus(transformer, timesteps)[source]

Create calliope conversion_plus specific data out of tessif transformers with multiple in or outputs. Calliope can consider any number of in and outputs, but only 3 that are forced to act at same time. In tessif definition e.g. CHP’s are always forced to produce heat as well when electricity is produced.

Parameters:
  • transformer – A single tranformer of tessif.model.components.Transformers objects that are to be transformed into calliope conversion_plus, due to having multi inputs or multi outputs, which cant be handled by the conversion technology.

  • timesteps – The number of timesteps to be analysed with the model.

Returns:

Dictionary returning the conversion_plus specific data ready to be used in generate_calliope_conversion.

Return type:

conv_plus dict

Raises:

NotImplementedError – Raised if more than 1 input or more than 3 outputs is used, because calliope can’t handle these cases in combination with tessif parameter definitions.

Warning

Calliope does not have installed capacities. The calliope min expansion is used to portray the installed capacity, this results in the tessif min expansion to not be able to be covered by calliope.

Calliope only considers one representative capacity value on multiple output transformers. The capacity of the other outputs are set relative to the primary carrier and so are their expansion limits.

Calliope doesnt support tessif’s milp parameters. Thus they will be ignored.

tessif.transform.es2es.cllp.generate_calliope_storage(storages, timeframe)[source]

Create calliope storages out of tessif storages.

Parameters:
Returns:

  • storage dict – Dictionary yielding the components data.

  • loc dict – Dictionary object yielding the components location.

  • cyclic_store bool – Boolean object yielding if the storage is cyclic or not.

Warning

Calliope does only support timeseries for sinks and sources. Others will be ignored.

Final_soc can only be taken into account if it equals initial_soc and both are not None. Else it will be a result of the optimization.

tessif.transform.es2es.cllp.generate_calliope_connector(connectors, busses)[source]

Create calliope location out of tessif connectors. A connector component does not exist in calliope. The tessif connector is to be transformed into a transmission-only-location linked to the bus locations connected to the connector with transmission with losses. The connector efficiency is splitted on both transmission lines going from bus1 over connector location to bus2. Also the transmission are forced to be one way only, so the transmission bus2 over connector location to bus1 can have a different efficiency So overall 4 transmission lines and one location are used to represent the tessif connector in calliope.

Parameters:
Returns:

  • loc dict – Dictionary object yielding the components location.

  • links dict – Dictionary object yielding the components links. Links contain information about what regions are connected with which kind of transmission.

  • transmission dict – Dictionary object yielding the components transmissions with connector losses.

tessif.transform.es2es.cllp.transform(tessif_es, warnings=False, aggregate=None)[source]

Transform a tessif energy system into an calliope energy system. In difference to the transform function the transform_and_save_yaml function does save the model in calliope style. Meaning the model is saved in separate yaml files as well as timeseries in csv files. These files are then read to build the calliope.core.model.Model.

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

  • warnings – Boolean to determine whether calliope specific warnings shall be shown in output or errors only.

  • aggregate (int, default=None) –

    Integer defining the time series aggregation. E.g. “6” means that 6 of the hourly timesteps are going to be aggregated to one 6 hour timestep.

    Note

    The length of the optimized timeframe should be divisible by this value.

Returns:

calliope_es – The calliope energy system model that was transformed out of the tessif energy system model.

Return type:

calliope.core.model.Model

Warning

The calliope transformation doesn’t support Tessif CHP Component. Using a Transformer with 2 outputs is recommended.

Calliope either has all or none storages cyclic. If the es2es transformation wants some to be cyclic and others not to be, none will be cyclic.

Calliope only considers global emission constraints.

Raises:
  • ValueError – Calliope needs timeframes of at least 2 periods.

  • NotImplementedError – Raised if more than 1 input or more than 3 outputs is used, because calliope can’t handle these cases in combination with tessif parameter definitions.

  • TypeError – For timeseries aggregation the parameter ‘aggregate’ needs to be of type integer.

Examples

Use the example hub’s create_mwe() utility for showcasing basic usage:

  1. Create the mwe:

    >>> from tessif.examples.data.tsf.py_hard import create_mwe
    >>> tsf_es = create_mwe()
    
  2. Transform the tessif energy system:

    >>> from tessif.transform.es2es import cllp
    >>> cllp_es = cllp.transform(tsf_es)
    
  1. Simulate the calliope energy system model:

    >>> import tessif.simulate as simulate
    >>> optimized_calliope_es = simulate.cllp_from_es(cllp_es)
    
  2. Extract some results:

    >>> import tessif.transform.es2mapping.cllp as transform_calliope_results
    >>> node_results = transform_calliope_results.CalliopeResultier(
    ...     optimized_calliope_es)
    >>> for node in node_results.nodes:
    ...     print(node)
    Battery
    Demand
    Gas Station
    Generator
    Pipeline
    Powerline
    
    >>> load_results = transform_calliope_results.LoadResultier(
    ...     optimized_calliope_es)
    >>> print(load_results.node_load['Powerline'])
    Powerline            Battery  Generator  Battery  Demand
    1990-07-13 00:00:00    -10.0       -0.0      0.0    10.0
    1990-07-13 01:00:00     -0.0      -10.0      0.0    10.0
    1990-07-13 02:00:00     -0.0      -10.0      0.0    10.0
    1990-07-13 03:00:00     -0.0      -10.0      0.0    10.0