Fixed relation between transformer inputs

Dear community,

it might be a simple question, but challenges me today: How do I set a fixed relation (through every timestep, or variable) between multiple inputs in one Transformer?
Examples of such cases would be a biodigester, in which electricity and heat is required to process a certain amount of biomass, or any other transformer using input flows of different units.
Thank you in advance!

You can use the conversion_factor parameter of the Transformer class.

You can set a conversion factor for each input and each output flow.

Let’s assume that the efficiency of the process is 0.6. So you have to put 1.67 energy units into the process to get one energy unit of biogas. The input units are divided into 0.167 (10%) units electricity, 0.33 (20%) units heat and 1.17 (70%) units biomass. The model is using power and energy units only so you have to be sure that everything fits e.g. the temperature level and the energy content of the biomass.

from oemof.solph import (
    Transformer,
    Bus,
    Flow,
    EnergySystem,
    Model,
    Sink,
    Source,
    processing,
)
import pandas as pd

bel = Bus("bus electricity")
bbgas = Bus("bus biogas")
bbmas = Bus("bus biomass")
bheat = Bus("bus heat")

date_time_index = pd.date_range("1/1/2012", periods=3, freq="H")
es = EnergySystem(timeindex=date_time_index)
es.add(bel, bbgas, bbmas, bheat)

es.add(
    Transformer(
        label="biogas converter",
        inputs={bel: Flow(), bbmas: Flow(), bheat: Flow()},
        outputs={bbgas: Flow(variable_cost=5, nominal_value=34)},
        conversion_factors={bheat: 0.2, bel: 0.1, bbmas: 0.7, bbgas: 0.6},
    )
)
es.add(
    Sink(
        label="demand biogas",
        inputs={bbgas: Flow(nominal_value=15, fix=[0.9, 0.3, 0.7])},
    )
)
es.add(Source(label="electricity source", outputs={bel: Flow()}))
es.add(Source(label="biomass source", outputs={bbmas: Flow()}))
es.add(Source(label="heat source", outputs={bheat: Flow()}))
model = Model(es)
model.solve()
result = processing.results(model)
flows = pd.DataFrame(
    {
        "{0} to {1}".format(k[0].label, k[1].label): result[k]["sequences"][
            "flow"
        ]
        for k in result.keys()
        if not isinstance(k[0], Source) and not isinstance(k[1], Sink)
    }
)
print(flows.sum())

You get three i/o equations for your Transformer:

biogas/0.6 = heat/0.2
biogas/0.6 = electricity/0.1
biogas/0.6 = biomass/0.7

The biogas demand in the first time step is 15*0.9 = 13.5

heat = 13.5/0.6*0.2 = 4.5
electricity = 13.5/0.6*0.1 = 2.25
biomass = 13.5/0.6*0.7 = 15.75

Total input = 22.5

Check: 22.5*0.6 = 13.5

Thank you Uwe, so it actually requires some thinking on your own…:wink:
Thank you for your detailed answer and example, that of course solves the question!
Regards!