Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenericCHP component example is broken #1050

Open
fwitte opened this issue Feb 8, 2024 · 2 comments
Open

GenericCHP component example is broken #1050

fwitte opened this issue Feb 8, 2024 · 2 comments

Comments

@fwitte
Copy link
Member

fwitte commented Feb 8, 2024

Describe the bug
The example

To Reproduce

  • Install current version oemof.solph
  • Create a minimal example (see below)
from oemof import solph


date_time_index = solph.create_time_index(2012, number=3)
energysystem = solph.EnergySystem(
    timeindex=date_time_index, infer_last_interval=False
)

gas_bus = solph.Bus(label="gas")
heat_demand_bus = solph.Bus(label="heat demand")
electricity_bus = solph.Bus(label="electricity")

gas_source = solph.components.Source(
    label="gas source", outputs={gas_bus: solph.Flow(variable_costs=75)}
)
heat_sink = solph.components.Sink(
    label="heat sink",
    inputs={heat_demand_bus: solph.Flow(fix=[10, 11, 12], nominal_value=1)}
)
electricity_sink = solph.components.Sink(
    label="electricity sink", inputs={electricity_bus: solph.Flow(variable_costs=-100)}
)

ccet = solph.components.GenericCHP(
    label='combined_cycle_extraction_turbine',
    fuel_input={gas_bus: solph.flows.Flow(
        custom_attributes={"H_L_FG_share_max": [0.183]})},
    electrical_output={electricity_bus: solph.flows.Flow(
        custom_attributes={
            "P_max_woDH": [15.5946],
            "P_min_woDH": [6.8787],
            "Eta_el_max_woDH": [0.525],
            "Eta_el_min_woDH": [0.444],
        })},
    heat_output={heat_demand_bus: solph.flows.Flow(
        custom_attributes={"Q_CW_min": [1.0552]})},
    beta=[0.122], back_pressure=False
)

energysystem.add(
    gas_bus, gas_source, heat_demand_bus, heat_sink,
    ccet,
    electricity_bus, electricity_sink#, electricity_source
)

om = solph.Model(energysystem)

om.solve(solver="cbc", solve_kwargs={"tee": False})

Expected behavior
Model solves

Screenshots

ERROR:pyomo.core:Rule failed when generating expression for Constraint GenericCHPBlock.H_F_1 with index ("<oemof.solph.components._generic_chp.GenericCHP: 'combined_cycle_extraction_turbine'>", 1):
IndexError: list index out of range
ERROR:pyomo.core:Constructing component 'GenericCHPBlock.H_F_1' from data=None failed:
IndexError: list index out of range

Desktop (please complete the following information):

  • OS: Windows10
  • Python version: 3.11
@p-snft
Copy link
Member

p-snft commented Feb 21, 2024

Interesting. Your code has the issue that you give lists that are too short ([15.5946]). However, changing that (to 3*[15.5946]) does not solve the issue.

At the same time, there is a test, test_gen_chp, that runs without issues. Probably, the parameters lead to an infeasible problem.

@fwitte
Copy link
Member Author

fwitte commented Feb 21, 2024

The snippet is actually based on the the API docs example here https://oemof-solph.readthedocs.io/en/stable/reference/oemof.solph.components.html#module-oemof.solph.components._generic_chp. Interestingly, in that docstring example only the creation of the component is tested, not adding it to a energysystem and solving that.

Agree on the solving issue, I should have added a slack heat generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants