simulate

omf

Optimize an energy system using the oemof library as well data stored somewhere.

omf_from_es

Optimize an energy system using the oemof library.

ppsa_from_es

Optimize an energy system using Pypsa .

tsf

Optimize an energy system using the Tessif library.

fine_from_es

Optimize an energy system using fine .

cllp_from_es

Optimize an energy system using Calliope .

simulate is a tessif module to wrap energy system simulation calls into a convenient and ready to use interface. energy systems using oemof.

Create powerfull, indepth, hassle-low wrappers that allow simulating the most common use cases needing only an input location and some remarks on wich parser and transformers to use.

tessif.simulate.omf(path, parser, solver='cbc', is_tessif=False, **kwargs)[source]

Optimize an energy system using the oemof library as well data stored somewhere.

Parameters:
  • path (str) – String representing of the energy system data path. Passed to parser.

  • parser (Callable) –

    Functional used to read in and parse the energy system data. Usually one found in tessif.parse

    Use functools.partial() for supplying parameters. See also the Examples section.

  • solver (str, default='cbc') –

    String specifying the solver to be used. For FOSS application, this is usually either cbc or glpk.

    But since pyomo is used for interfacing the solver. Any of it’s supported solvers can be used.

    Note

    In case the link above is servered, use the pyomo command:

    pyomo help --solvers
    

  • is_tessif (bool, default=False,) –

    Boolean indicating if the read in data source is to be interpreted as a tessif energy system.

    If True the energy system data is interpreted as tessif energy system and automatically transformed into an oemof energy system.

    If False the energy system data is interpreted as oemof energy system

  • kwargs

    Keywords parameterizing the solver used as well as the energy system transformation process.

    Use one of solve's parameters for tweaking the solver. All others will be passed to tessif.transform.mapping2es.omf.transform() (Effectively passing it to oemof.core.energy_system.EnergySystem.add())

Returns:

optimized_es – Energy system carrying the optimization results.

Return type:

EnergySystem

Examples

Monkey patch logging level to silence warnings:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Read in the oemof standard enregy system and simulate it:

>>> from tessif.simulate import omf
>>> from tessif.parse import xl_like
>>> from tessif.frused.paths import example_dir
>>> import os
>>> es = omf(
...     path=os.path.join(example_dir, 'data', 'omf',
...         'xlsx', 'energy_system.xlsx'),
...     parser=xl_like)
>>> print(type(es.results))
<class 'pyomo.opt.results.results_.SolverResults'>
>>> print(len(es.nodes) is len(es.results['main']))
True

Use functools.partial to tweak the parser and use glpk solver:

>>> import os
>>> import functools
>>> from tessif.frused.paths import example_dir
>>> import tessif.parse as parse
>>> import tessif.simulate as simulate
>>> es = simulate.omf(
...     path=os.path.join(example_dir, 'data', 'omf',
...         'xlsx', 'energy_system.ods'),
...     parser=functools.partial(
...     parse.xl_like, sheet_name=None, engine='odf'),
...     solver='glpk')
>>> print(type(es.results))
<class 'pyomo.opt.results.results_.SolverResults'>
>>> print(len(es.nodes) is len(es.results['main']))
True

Use tessif’s energy system data interface:

>>> import os
>>> from tessif.frused.paths import example_dir
>>> import tessif.parse as parse
>>> import tessif.simulate as simulate
>>> es = simulate.omf(
...     path=os.path.join(example_dir, 'data', 'tsf',
...                       'cfg', 'flat', 'basic'),
...     parser=parse.flat_config_folder,
...     solver='cbc',
...     is_tessif=True)

Show some results:

>>> import tessif.transform.es2mapping.omf as oemof_results
>>> resultier = oemof_results.LoadResultier(es)
>>> print(resultier.node_load['Power Line'])
Power Line           Battery  Generator  Solar Panel  Battery  Demand
2015-01-01 00:00:00     -0.0       -0.0        -12.0      1.0    11.0
2015-01-01 01:00:00     -8.0       -0.0         -3.0      0.0    11.0
2015-01-01 02:00:00     -0.9       -3.1         -7.0      0.0    11.0
>>> stoRes = oemof_results.StorageResultier(es)
>>> print(stoRes.node_soc['Battery'])
2015-01-01 00:00:00    10.0
2015-01-01 01:00:00     1.0
2015-01-01 02:00:00     0.0
Freq: H, Name: Battery, dtype: float64
tessif.simulate.omf_from_es(energy_system, solver='cbc', **kwargs)[source]

Optimize an energy system using the oemof library.

Parameters:
  • energy_system (EnergySystem) – Oemof energy system to be simulated.

  • solver (str, default='cbc') –

    String specifying the solver to be used. For FOSS application, this is usually either cbc or glpk.

    But since pyomo is used for interfacing the solver. Any of it’s supported solvers can be used.

    Note

    In case the link above is servered, use the pyomo cli command:

    pyomo help --solvers
    

  • kwargs

    Keywords parameterizing the solver used as well as the energy system transformation process.

    Use one of solve's parameters for tweaking the solver.

Returns:

optimized_es – Energy system carrying the optimization results.

Return type:

EnergySystem

Examples

Use the oemof example hub to generate an energy system that can be optimized:

Setting spellings.get_from’s logging level to debug for decluttering doctest output:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Import and parse the data:

>>> import os
>>> from tessif.frused.paths import example_dir
>>> from tessif.parse import xl_like
>>> p = os.path.join(example_dir,
...     'data', 'omf', 'xlsx', 'energy_system.xls')
>>> energy_system_mapping = xl_like(p, engine='xlrd')

Transform the parsed data into an energy system:

>>> from tessif.transform.mapping2es.omf import transform
>>> energy_system = transform(energy_system_mapping)

Simulate the energy system:

>>> optimized_es = omf_from_es(energy_system)

Roughly verify that everything went as expected:

>>> print(type(optimized_es.results))
<class 'pyomo.opt.results.results_.SolverResults'>
>>> print(len(optimized_es.nodes) is len(optimized_es.results['main']))
True
tessif.simulate.tsf(path, parser, **kwargs)[source]

Optimize an energy system using the Tessif library.

Warning

Not yet implemented!

tessif.simulate.ppsa_from_es(energy_system, solver='cbc', **kwargs)[source]

Optimize an energy system using Pypsa .

Parameters:
  • energy_system (pypsa.Network) – Pypsa energy system to be simulated

  • solver (str, default='cbc') –

    String specifying the solver to be used. For FOSS application, this is usually either cbc or glpk.

    But since pyomo is used for interfacing the solver. Any of it’s supported solvers can be used.

    Pypsa also allows using its own solver. Archieved by passing pypsa.

    Note

    In case the link above is servered, use the pyomo command:

    pyomo help --solvers
    

  • kwargs

    Keywords parameterizing the solver used as well as the energy system transformation process.

    Use one of lopf's parameters for tweaking the solver.

Returns:

optimized_es – Energy system carrying the optimization results.

Return type:

EnergySystem

Examples

Setting spellings.get_from’s logging level to debug for decluttering doctest output:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Use the pypsa example hub to create an energy system that can be optimized:

>>> import tessif.examples.data.pypsa.py_hard as pypsa_hardcoded_examples
>>> pypsa_energy_system = pypsa_hardcoded_examples.create_mwe()

Simulate the energy system:

>>> optimized_pypsa_es = ppsa_from_es(pypsa_energy_system)

Roughly verify that everything went as expected:

>>> print(optimized_pypsa_es.objective)
190.0
tessif.simulate.fine_from_es(energy_system, solver='cbc', tsa=False, **kwargs)[source]

Optimize an energy system using fine .

Parameters:
  • energy_system (fine energy system model) – fine energy system to be simulated

  • solver (str, default='cbc') –

    String specifying the solver to be used. For FOSS application, this is usually either cbc or glpk.

    But since pyomo is used for interfacing the solver. Any of it’s supported solvers can be used.

    Note

    In case the link above is servered, use the pyomo command:

    pyomo help --solvers
    

  • kwargs – Keywords parameterizing the solver used as well as the energy system transformation process.

Returns:

optimized_es – Energy system carrying the optimization results.

Return type:

energy system model

Examples

Setting spellings.get_from’s logging level to debug for decluttering doctest output:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Use the fine example hub to create an energy system that can be optimized:

>>> import tessif.examples.data.fine.py_hard as fine_hardcoded_examples
>>> fine_energy_system = fine_hardcoded_examples.create_mwe()

Simulate the energy system:

>>> optimized_fine_es = fine_from_es(fine_energy_system)

Roughly verify that everything went as expected:

>>> print(round(optimized_fine_es.objectiveValue * optimized_fine_es.numberOfYears,0))
78.0
tessif.simulate.cllp_from_es(energy_system, solver='cbc', save=False, **kwargs)[source]

Optimize an energy system using Calliope .

Parameters:
  • energy_system (calliope.core.model.Model) – Calliope energy system to be simulated

  • solver (str, default='cbc') –

    String specifying the solver to be used. For FOSS application, this is usually either cbc or glpk.

    But since pyomo is used for interfacing the solver. Any of it’s supported solvers can be used.

    Note

    In case the link above is servered, use the pyomo command:

    pyomo help --solvers
    

  • save (boolean, default=False) –

    Boolean deciding whether the optimized energy system (energy system data as well as results) is gonna be saved in csv-files or not.

    Note

    Earlier saves do not get overwritten.

  • kwargs – Keywords parameterizing the solver used as well as the energy system transformation process.

Returns:

optimized_es – Energy system carrying the optimization results.

Return type:

Model

Examples

Setting spellings.get_from’s logging level to debug for decluttering doctest output:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Use the calliope example hub to create an energy system that can be optimized:

>>> from tessif.frused.paths import example_dir
>>> import calliope
>>> calliope_es = calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml')

Simulate the energy system:

>>> optimized_es = cllp_from_es(calliope_es)

Roughly verify that everything went as expected:

>>> print(round(optimized_es.results.objective_function_value), 0)
105 0