Investment module for ExtractionTurbineCHP

First of all thank you to all oemof developers for this powerful, yet intuitive Framework.

Now to the issue, I am trying to make a combined investment and dispatch model. One of the elements of the energy system is a CHP with the investment module. I tried this variant, basically splitting the emissions, costs and investment on both outputs (it doesn’t make sense but it’s the best I can come up with):

BHKW = solph.ExtractionTurbineCHP(label='bhkw',
                                  inputs={Gas: solph.Flow()},
                                  outputs={Electricity: solph.Flow(emission_factor=1,
                                                                 variable_costs=1,
                                                                 investment=solph.Investment(ep_costs=1, maximum = 100000)),
                                           Heat: solph.Flow(emission_factor=1,
                                                                  variable_costs=1,
                                                                  investment=solph.Investment(ep_costs=1, maximum = 100000))},
                                  conversion_factors={Electricity: 0.4, Heat: 0.4},
                                  conversion_factor_full_condensation={Electricity: 0.5})

And also another variant where I put the emission factor, variable costs and investment inside the Input bracket instead of splitting them on the outputs. Even when drastically reducing the variable costs and emission factors to make it a more viable option, both variants result in an investment of 0 with the code not showing any errors.

My question is therefore: what is the right way to incorporate the investment module in this component?

Hi, @walid.maatoug, welcome to the oemof community.

The component itself is tested, so the error might be somewhere else. Therefore it is helpful to provide a minimal example.

For me it is strange that you have an BHKW modeled as an extraction turbine, because the electricity-heat-ratio of a BHKW is normally fixed. I just want to mention this, but you may have a special BHKW.

I wrote a minimal example to show how the component work and for me everything works fine:

import pandas as pd

from oemof import solph

solver = "cbc"  # 'glpk', 'gurobi',....
number_of_time_steps = 24 * 7 * 8

date_time_index = pd.date_range("1/1/2012", periods=number_of_time_steps,
                                freq="H")

# add es
energysystem = solph.EnergySystem(timeindex=date_time_index)

# add buses
bgas = solph.Bus(label="natural_gas")
bel = solph.Bus(label="electricity")
bheat = solph.Bus(label="heat")
energysystem.add(bgas, bel, bheat)

# add gas
energysystem.add(
    solph.Source(
        label="rgas",
        outputs={bgas: solph.Flow()},
    )
)

# add heat demand
hd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] * 14 * 8
energysystem.add(
    solph.Sink(
        label="demand_heat",
        inputs={bheat: solph.Flow(fix=hd, nominal_value=1)},
    )
)

# create simple sink object representing the electrical demand
energysystem.add(
    solph.Sink(
        label="demand_elec",
        inputs={bel: solph.Flow()},
    )
)

# add bhkw
bhkw = solph.ExtractionTurbineCHP(
    label="bhkw",
    inputs={
        bgas: solph.Flow(
            emission_factor=1,
            variable_costs=1,
            investment=solph.Investment(ep_costs=1),
        )
    },
    outputs={
        bel: solph.Flow(),
        bheat: solph.Flow(),
    },
    conversion_factors={bel: 0.4, bheat: 0.4},
    conversion_factor_full_condensation={bel: 0.5},
)

energysystem.add(bhkw)

model = solph.Model(energysystem)
model.solve(solver=solver, solve_kwargs={"tee": False})


results = solph.processing.results(model)

print(results[(bgas, bhkw)]["scalars"])

The result of this example:

invest    30.0

Hi @uwe.krien, thank you for your quick answer.
It turned out that there wasn’t an error and the model worked fine. I included a relatively high emission factor in the gas source and didn’t consider that it will also be taken into account.