Oemof
Following sections give detailed instructions on how to create ready-to-use
energy systems using oemof.core.energy_system.EnergySystem objects.
Concept
Oemof aims to be a community driven open science project for enhancing energy system modelling. It consists of several open source repositories to model different aspects of energy supply systems as well as efforts for organising it’s community.
At it’s simulativ core oemof consists of a pyomo interface (the omeof.solph package) for modelling energy supply system components using linear and mixed integer linear problem formulation. By providing a very general approach (oemof.solph.components) as well as customized, specific models (omeof.solph.custom), oemof.solph tries to satisfy the most common use cases.
Apart from it’s optimization core there exist several major helper libraries for providing:
Renewable feed-in data (oemof.feedinlib)
Demand and Output data for themal components (oemof-thermal)
Specific parameters for thermal applications (tespy)
As well as a variety of extensions and small additional packages, all accessible via the main repository
Purpose
Within the context of tessif, oemof solves primarily as another pyomo interface allowing most of tessif's energy system model to be directly transformed without major data loss, In fact tessif’s general approach to energy system simulation was inspired by oemof. While oemof’s human-interface for parameterizing components as well as extracting results tends to be tailored more towards people comfortable with programing, tessif aim’s to provide an interface for engineers.
Examples
Minimum Working Example
Note
The exact same energy system can be accessed using
tessif.examples.data.omf.py_hard.create_mwe().
Import everything necessary:
from oemof import solph import pandas as pd from tessif.frused import namedtuples as nts
Create a simulation time frame of of 2 one hour timesteps as a
pandas.DatetimeIndex:simulation_time = pd.date_range( '7/13/1990', periods=2, freq='H')
Initialize an
EnergySystemobject using the freshly generatedpandas.DatetimeIndex:es = solph.EnergySystem(timeindex=simulation_time)
Create oemof specific
nodesfor a simple energy system consisting of:A Powerline (
Busobject):power_line = solph.Bus( label=nts.Uid( 'Power Line', 53, 10, 'Germany', 'Power', 'Electricity'))
A Demand of 10 energy units (
Sinkobject):demand = solph.Sink( label=nts.Uid( 'Demand', 53, 10, 'Germany', 'Power', 'Electricity'), inputs={power_line: solph.Flow( nominal_value=10, fix=[1,1])})
A Renewable source feeding 8 and 2 energy units (
Sourceobject):renewable = solph.Source( label=nts.Uid( 'Renewable', 53, 10, 'Germany', 'Power', 'Electricity'), outputs={power_line: solph.Flow( nominal_value=10, fix=[0.8, 0.2], variable_costs=9)})
A Distribution Network of Chemically Bound Energy Carriers:
cbet = solph.Bus( label=nts.Uid( 'CBET', 53, 10, 'Germany', 'Power', 'Electricity'))
A Chemically Bound Energy Source (
Busobject):cbe = solph.Source( label=nts.Uid( 'CBE', 53, 10, 'Germany', 'Power', 'Electricity'), outputs={cbet: solph.Flow()})
A Conventional Transformer producting up to 10 energy units costing 10 per unit (
Transformerobject):conventional = solph.Transformer( label=nts.Uid( 'Transformer', 53, 10, 'Germany', 'Power', 'Electricity'), inputs={cbet: solph.Flow()}, outputs={power_line: solph.Flow( nominal_value=10, variable_costs=10)}, converstion_factors={power_line: 0.6})
add()nodes to theEnergySystemobject:es.add(power_line, demand, renewable, cbet, cbe, conventional)
Create an energy system
Modelobject:esm = solph.Model(es)
solve()theModelobject:solver_msg = esm.solve(solver='glpk')
Pump
resultsinto theEnergySystemobject to utilize itsdump()functionality for saving the data:es.results['main'] = solph.processing.results(esm) es.results['meta'] = solph.processing.meta_results(esm)
Get tessifs installation path to dump the results in tessif/tessif/write/omf/dummies
(path getting is quite hacky here. Done in this way to enable doctesting from all kind of crazy locations.)
>>> from tessif.frused.paths import write_dir >>> import os >>> import pathlib >>> dpath = os.path.join(write_dir, 'omf') >>> pathlib.Path(dpath).mkdir(parents=True, exist_ok=True)
Store
resultspumpedEnergySystemobject:dump_msg = es.dump(dpath=dpath, filename='mwe.oemof')
Using this newly generated energy system in a different python context by importing it.
Note
The code of steps 1 to 10 is wrapped in a
create_mwe() function for
convenience meaning it is copy pastable.
Import the wrapper functionality:
>>> from tessif.examples.data.omf.py_hard import create_mwe >>> esys = create_mwe(directory=dpath, filename='mwe.oemof')Confirm the expected output:
>>> for node in esys.nodes: ... print(node.label.name) Power Line Demand Renewable CBET CBE Transformer
For examples on how to extract result information out ouf the optimized energy system using tessif, see
tessif.transform.es2mapping.omf