Skip to content

Commit

Permalink
Add activity bounds to MIMO facade
Browse files Browse the repository at this point in the history
  • Loading branch information
henhuy committed Apr 22, 2024
1 parent 3dd0ef7 commit d634ea6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
type;name;region;year;carrier;tech;expandable;primary;capacity_cost;capacity_potential;from_bus_0;from_bus_1;to_bus_0;to_bus_1;to_bus_2;groups;conversion_factor_gas;conversion_factor_hydro;conversion_factor_heat;emission_factor_gas_co2;emission_factor_hydro_co2;flow_share_fix_gas
mimo;mimo;DE;2021;elec;mimo;true;electricity;1.2;20;gas;hydro;electricity;heat;co2;{"in": ["gas", "hydro"], "out": ["electricity", "heat"]};1.2;1.3;1.2;0.5;0.3;profile_DE
type;name;region;year;carrier;tech;expandable;primary;capacity_cost;capacity_potential;from_bus_0;from_bus_1;to_bus_0;to_bus_1;to_bus_2;groups;conversion_factor_gas;conversion_factor_hydro;conversion_factor_heat;activity_bound_max;emission_factor_gas_co2;emission_factor_hydro_co2;flow_share_fix_gas
mimo;mimo;DE;2021;elec;mimo;true;electricity;1.2;20;gas;hydro;electricity;heat;co2;{"in": ["gas", "hydro"], "out": ["electricity", "heat"]};1.2;1.3;1.2;18;0.5;0.3;profile_DE
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@
"type": "number",
"format": "default"
},
{
"name": "activity_bound_max",
"type": "number",
"format": "default"
},
{
"name": "emission_factor_gas_co2",
"type": "number",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_datapackage_results_for_investment_var_outputs():
check_results_for_investment_var_output(results)

# Check emissions:
gas_input = 20 * 1.2 * 0.8
hydro_input = 20 * 1.3 * 0.2
gas_input = 18 * 1.2 * 0.8
hydro_input = 18 * 1.3 * 0.2
assert results[("mimo", "co2")]["sequences"]["flow"].values[0] == pytest.approx(
gas_input * 0.5 + hydro_input * 0.3
)
5 changes: 1 addition & 4 deletions tests/test_mimo_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
from oemof.solph.components import Source
from oemof.solph.flows import Flow

from oemof_industry.mimo_converter import (
MultiInputMultiOutputConverter,
MultiInputMultiOutputConverterBlock,
)
from oemof_industry.mimo_converter import MultiInputMultiOutputConverter


def test_invalid_flow_shares():
Expand Down
20 changes: 11 additions & 9 deletions tests/test_mimo_investment.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_investment_fix_outputs():
},
conversion_factors={b_gas: 1.2, b_hydro: 1.3, b_heat: 1.2},
flow_shares={"fix": {b_gas: [0.8, 0.3], b_heat: 0.8}},
activity_bounds={"max": 18}
)
)

Expand All @@ -87,11 +88,11 @@ def test_investment_fix_outputs():
# create result object
results = processing.convert_keys_to_strings(processing.results(om))

assert results[("mimo", "electricity")]["scalars"]["invest"] == 20
assert results[("mimo", "electricity")]["scalars"]["invest"] == 18

assert results[("mimo", "heat")]["sequences"]["flow"].values[0] == 20 * 0.8 * 1.2
assert results[("heat_import", "heat")]["sequences"]["flow"].values[0] == 100 - 20 * 0.8 * 1.2
assert results[("mimo", "electricity")]["sequences"]["flow"].values[0] == 20
assert results[("mimo", "heat")]["sequences"]["flow"].values[0] == 18 * 0.8 * 1.2
assert results[("heat_import", "heat")]["sequences"]["flow"].values[0] == 100 - 18 * 0.8 * 1.2
assert results[("mimo", "electricity")]["sequences"]["flow"].values[0] == 18


def test_investment_var_outputs():
Expand Down Expand Up @@ -134,6 +135,7 @@ def test_investment_var_outputs():
},
conversion_factors={b_gas: 1.2, b_hydro: 1.3, b_heat: 1.2},
flow_shares={"fix": {b_gas: [0.8, 0.3, 0.3]}},
activity_bounds={"max": 18}
)
)

Expand All @@ -150,10 +152,10 @@ def test_investment_var_outputs():


def check_results_for_investment_var_output(results):
assert results[("mimo", "electricity")]["scalars"]["invest"] == 20
assert results[("mimo", "heat")]["sequences"]["flow"].values[0] == 20 * 1.2
assert results[("heat_import", "heat")]["sequences"]["flow"].values[0] == 100 - 20 * 1.2
assert results[("mimo", "electricity")]["scalars"]["invest"] == 18
assert results[("mimo", "heat")]["sequences"]["flow"].values[0] == pytest.approx(18 * 1.2)
assert results[("heat_import", "heat")]["sequences"]["flow"].values[0] == pytest.approx(100 - 18 * 1.2)
assert results[("mimo", "electricity")]["sequences"]["flow"].values[0] == 0

assert results[("gas", "mimo")]["sequences"]["flow"].values[0] == pytest.approx(20 * 1.2 * 0.8)
assert results[("hydro", "mimo")]["sequences"]["flow"].values[0] == pytest.approx(20 * 1.3 * 0.2)
assert results[("gas", "mimo")]["sequences"]["flow"].values[0] == pytest.approx(18 * 1.2 * 0.8)
assert results[("hydro", "mimo")]["sequences"]["flow"].values[0] == pytest.approx(18 * 1.3 * 0.2)

0 comments on commit d634ea6

Please sign in to comment.