Basic example

General description

A basic example to show how to model a simple energy system with oemof.solph.

The following energy system is modeled:

                input/output  bgas     bel
                    |          |        |
                    |          |        |
wind(FixedSource)   |------------------>|
                    |          |        |
pv(FixedSource)     |------------------>|
                    |          |        |
rgas(Commodity)     |--------->|        |
                    |          |        |
demand(Sink)        |<------------------|
                    |          |        |
                    |          |        |
pp_gas(Transformer) |<---------|        |
                    |------------------>|
                    |          |        |
storage(Storage)    |<------------------|
                    |------------------>|

Data

basic_example.csv

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Basic Time Index

General description

A minimal example to show how time steps work.

  • Flows are defined in time intervals, storage content at points in time. Thus, there is one more value for storage contents then for the flow values.
  • Time intervals are named by the time at the beginning of that interval. The quantity changes to the given value at the given point in time.
  • The initial_storage_level of a GenericStorage is given at the first time step. If the storage is balanced, this is the same storage level as in the last time step.
  • The nominal_value in Flows has to be interpreted in means of power: We have nominal_value=0.5, but the maximum change of the storage content of an ideal storage is 0.125.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Activity costs

General description

This example illustrates the effect of activity_costs.

There are the following components:

  • demand_heat: heat demand (constant, for the sake of simplicity)
  • fireplace: wood firing, burns “for free” if somebody is around
  • boiler: gas firing, consumes (paid) gas

Notice that activity_costs is an attribute to NonConvex. This is because it relies on the activity status of a component which is only available for nonconvex flows.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Balanced and unbalanced storage

General description

Example that shows the parameter balanced of GenericStorage.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Electrical

Linear optimal power flow (lopf)

General description

This script shows how to do a linear optimal powerflow (lopf) calculation based on custom oemof components. The example is based on the PyPSA simple lopf example.

Note: As oemof currently does not support models with one timesteps, therefore there are two.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

To draw the graph pygraphviz is required, installed by:

pip install pygraphviz

License

Simon Hilpert - 12.12.2017 - simon.hilpert@uni-flensburg.de

MIT license

Transshipment

General description:

This script shows how use the custom component solph.custom.Link to build a simple transshipment model.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

To draw the graph pygraphviz is required, installed by:

pip install pygraphviz

License

Simon Hilpert - 12.12.2017 - simon.hilpert@uni-flensburg.de

MIT license

Emission constraint

General description

Example that shows how to add an emission constraint in a model.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Flexible modelling

Add constraints

General description

This script shows how to add an individual constraint to the oemof solph OperationalModel. The constraint we add forces a flow to be greater or equal a certain share of all inflows of its target bus. Moreover we will set an emission constraint.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

To draw the graph pygraphviz is required, installed by:

pip install pygraphviz

License

Simon Hilpert - 31.10.2016 - simon.hilpert@uni-flensburg.de

MIT license

Flow count limit

General description

Something…

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Flow gradient

General description

The gradient constraint can restrict a component to change the output within one time step. In this example a storage will buffer this restriction, so the more flexible the power plant can be run the less the storage will be used.

Change the GRADIENT variable in the example to see the effect on the usage of the storage.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Generic Invest limit

Example that shows how to use “Generic Investment Limit”.

There are two supply chains. The energy systems looks like that:

              bus_a_0          bus_a_1
               |                 |
source_a_0 --->|---> trafo_a --->|--->demand_a
                                 |
                   source_a_1--->|
                                 |

              bus_b_0          bus_b_1
               |                 |
source_b_0 --->|---> trafo_b --->|--->demand_b
                                 |
                   source_b_1--->|
                                 |

Everything is identical - the costs for the sources, the demand, the efficiency of the Transformer. And both Transformer have an investment at the output. The source ‘*_1’ is in both cases very expensive, so that a investment is probably done in the transformer. Now, both investments share a third resource, which is called “space” in this example. (This could be anything, and you could use as many additional resources as you want.) And this resource is limited. In this case, every Transformer capacity unit, which might be installed, needs 2 space for ‘trafo a’, and 1 space per installed capacity for ‘trafo b’. And the total space is limited to 24. See what happens, have fun ;)

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

Johannes Röder <johannes.roeder@uni-bremen.de>

MIT license

Investment with minimal invest

Example that shows how to use “Offset-Invest”.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

Minimal and maximal runtime

General description

Example that illustrates how to model min and max runtimes.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Simple heat and power dispatch

General description

This example shows how to create an energysystem with oemof objects and solve it with the solph module. Results are plotted with solph.

Dispatch modelling is a typical thing to do with solph. However cost does not have to be monetary but can be emissions etc. In this example a least cost dispatch of different generators that meet an inelastic demand is undertaken. Some of the generators are renewable energies with marginal costs of zero. Additionally, it shows how combined heat and power units may be easily modelled as well.

Data

input_data.csv

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Spreadsheet (Excel) Reader

General description

As the csv-reader was removed with version 0.2 this example shows how to create an excel-reader. The example is equivalent to the old csv-reader example. Following the example one can customise the excel reader to ones own needs.

The pandas package supports the ‘.xls’ and the ‘.xlsx’ format but one can create read and adept the files with open source software such as libreoffice, openoffice, gnumeric,…

Data

scenario.xlsx

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

pip3 install openpyxl

If you want to plot the energy system’s graph, you have to install pygraphviz using:

pip3 install pygraphviz

For pygraphviz under Windows, some hints are available in the oemof Wiki: https://github.com/oemof/oemof/wiki/Windows—general

Start and shutdown costs

General description

Example that illustrates how to model startup and shutdown costs attributed to a binary flow.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Storage investment

Optimize all technologies

General description

This example shows how to perform a capacity optimization for an energy system with storage. The following energy system is modeled:

               input/output  bgas     bel
                    |          |        |
                    |          |        |
wind(FixedSource)   |------------------>|
                    |          |        |
pv(FixedSource)     |------------------>|
                    |          |        |
gas_resource        |--------->|        |
(Commodity)         |          |        |
                    |          |        |
demand(Sink)        |<------------------|
                    |          |        |
                    |          |        |
pp_gas(Transformer) |<---------|        |
                    |------------------>|
                    |          |        |
storage(Storage)    |<------------------|
                    |------------------>|

The example exists in four variations. The following parameters describe the main setting for the optimization variation 1:

  • optimize wind, pv, gas_resource and storage
  • set investment cost for wind, pv and storage
  • set gas price for kWh

Results show an installation of wind and the use of the gas resource. A renewable energy share of 51% is achieved.

Have a look at different parameter settings. There are four variations of this example in the same folder.

Data

storage_investment.csv

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Optimize only gas and storage

General description

This example shows how to perform a capacity optimization for an energy system with storage. The following energy system is modeled:

               input/output  bgas     bel
                    |          |        |
                    |          |        |
wind(FixedSource)   |------------------>|
                    |          |        |
pv(FixedSource)     |------------------>|
                    |          |        |
gas_resource        |--------->|        |
(Commodity)         |          |        |
                    |          |        |
demand(Sink)        |<------------------|
                    |          |        |
                    |          |        |
pp_gas(Transformer) |<---------|        |
                    |------------------>|
                    |          |        |
storage(Storage)    |<------------------|
                    |------------------>|

The example exists in four variations. The following parameters describe the main setting for the optimization variation 2:

  • optimize gas_resource and storage
  • set installed capacities for wind and pv
  • set investment cost for storage
  • set gas price for kWh

Results show a higher renewable energy share than in variation 1 (78% compared to 51%) due to preinstalled renewable capacities. Storage is not installed as the gas resource is cheaper.

Have a look at different parameter settings. There are four variations of this example in the same folder.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Optimize only storage with fossil share

General description

This example shows how to perform a capacity optimization for an energy system with storage. The following energy system is modeled:

               input/output  bgas     bel
                    |          |        |
                    |          |        |
wind(FixedSource)   |------------------>|
                    |          |        |
pv(FixedSource)     |------------------>|
                    |          |        |
gas_resource        |--------->|        |
(Commodity)         |          |        |
                    |          |        |
demand(Sink)        |<------------------|
                    |          |        |
                    |          |        |
pp_gas(Transformer) |<---------|        |
                    |------------------>|
                    |          |        |
storage(Storage)    |<------------------|
                    |------------------>|

The example exists in four variations. The following parameters describe the main setting for the optimization variation 3:

  • calculate storage
  • set installed capacities for wind and pv
  • set investment cost for storage
  • remove the gas price and set a fossil share
  • now it becomes a calculation of storage capacity (no cost optimization)

Results show now the installation of storage because a higher renewable share than achieved in variation 2 is now required (80% compared to 78%).

Have a look at different parameter settings. There are four variations of this example in the same folder.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Optimize all technologies with fossil share

General description

This example shows how to perform a capacity optimization for an energy system with storage. The following energy system is modeled:

               input/output  bgas     bel
                    |          |        |
                    |          |        |
wind(FixedSource)   |------------------>|
                    |          |        |
pv(FixedSource)     |------------------>|
                    |          |        |
gas_resource        |--------->|        |
(Commodity)         |          |        |
                    |          |        |
demand(Sink)        |<------------------|
                    |          |        |
                    |          |        |
pp_gas(Transformer) |<---------|        |
                    |------------------>|
                    |          |        |
storage(Storage)    |<------------------|
                    |------------------>|

The example exists in four variations. The following parameters describe the main setting for the optimization variation 4:

  • optimize wind, pv, and storage
  • set investment cost for wind, pv and storage
  • set a fossil share

Results show now the achievement of 80% renewable energy share by solely installing a little more wind and pv (compared to variation 2). Storage is not installed.

Have a look at different parameter settings. There are four variations of this example in the same folder.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Tuple as label

General description

You should have grasped the basic_example to understand this one.

This is an example to show how the label attribute can be used with tuples to manage the results of large energy system. Even though, the feature is introduced in a small example it is made for large system.

In small energy system you normally address the node, you want your results from, directly. In large systems you may want to group your results and collect all power plants of a specific region or pv feed-in of all regions.

Therefore you can use named tuples as label. In a named tuple you need to specify the fields:

>>> label = namedtuple('solph_label', ['region', 'tag1', 'tag2'])
>>> pv_label = label('region_1', 'renewable_source', 'pv')
>>> pp_gas_label = label('region_2', 'power_plant', 'natural_gas')
>>> demand_label = label('region_3', 'electricity', 'demand')

You always have to address all fields but you can use empty strings or None as place holders.

>>> elec_bus = label('region_4', 'electricity', '')
>>> print(elec_bus)
solph_label(region='region_4', tag1='electricity', tag2='')
>>> elec_bus = label('region_4', 'electricity', None)
>>> print(elec_bus)
solph_label(region='region_4', tag1='electricity', tag2=None)

Now you can filter the results using the label or the instance:

>>> for key, value in results.items():  # Loop results (keys are tuples!)
...     if isinstance(key[0], comp.Sink) & (key[0].label.tag2 == 'demand'):
...         print("elec demand {0}: {1}".format(key[0].label.region,
...                                             value['sequences'].sum()))

elec demand region_1: 3456 elec demand region_2: 2467 …

In the example below a subclass is created to define ones own string output. By default the output of a namedtuple is field1=value1, field2=value2,…:

>>> print(str(pv_label))
solph_label(region='region_1', tag1='renewable_source', tag2='pv')

With the subclass we created below the output is different, because we defined our own string representation:

>>> new_pv_label = Label('region_1', 'renewable_source', 'pv')
>>> print(str(new_pv_label))
region_1_renewable_source_pv

You still will be able to get the original string using repr:

>>> print(repr(new_pv_label))
Label(tag1='region_1', tag2='renewable_source', tag3='pv')

This a helpful adaption for automatic plots etc..

Afterwards you can use format to define your own custom string.: >>> print(‘{0}+{1}-{2}’.format(pv_label.region, pv_label.tag2, pv_label.tag1)) region_1+pv-renewable_source

Data

basic_example.csv

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

License

MIT license

Variable CHP

General description

This example is not a real use case of an energy system but an example to show how a combined heat and power plant (chp) with an extraction turbine works in contrast to a chp (eg. block device) with a fixed heat fraction. Both chp plants distribute power and heat to a separate heat and power Bus with a heat and power demand. The i/o balance plot shows that the fixed chp plant produces heat and power excess and therefore needs more natural gas. The bar plot just shows the difference in the usage of natural gas.

Installation requirements

This example requires oemof.solph (v0.5.x), install by:

pip install oemof.solph[examples]

Optional to see the i/o balance plot:

pip install git+https://github.com/oemof/oemof_visio.git

License

MIT license