Skip to content

Commit 0f9662a

Browse files
committed
Add possibility for user to choose which bus has the investment
For transformers only
1 parent 2c75302 commit 0f9662a

File tree

2 files changed

+49
-36
lines changed

2 files changed

+49
-36
lines changed

src/multi_vector_simulator/D1_model_components.py

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
OEMOF_ExtractionTurbineCHP,
5656
EMISSION_FACTOR,
5757
BETA,
58+
INVESTMENT_BUS,
5859
)
5960
from multi_vector_simulator.utils.helpers import get_item_if_list, get_length_if_list
6061
from multi_vector_simulator.utils.exceptions import (
@@ -659,6 +660,13 @@ def transformer_constant_efficiency_optimize(model, dict_asset, **kwargs):
659660
"""
660661
missing_dispatch_prices_or_efficiencies = None
661662

663+
investment_bus = dict_asset.get(INVESTMENT_BUS)
664+
investment = solph.Investment(
665+
ep_costs=dict_asset[SIMULATION_ANNUITY][VALUE],
666+
maximum=dict_asset[MAXIMUM_ADD_CAP][VALUE],
667+
existing=dict_asset[INSTALLED_CAP][VALUE],
668+
)
669+
662670
# check if the transformer has multiple input or multiple output busses
663671
# the investment object is always in the output bus
664672
if isinstance(dict_asset[INFLOW_DIRECTION], list) or isinstance(
@@ -682,25 +690,22 @@ def transformer_constant_efficiency_optimize(model, dict_asset, **kwargs):
682690
logging.error(missing_dispatch_prices_or_efficiencies)
683691
raise ValueError(missing_dispatch_prices_or_efficiencies)
684692

693+
if investment_bus is None:
694+
investment_bus = dict_asset[OUTFLOW_DIRECTION]
695+
685696
inputs = {}
686697
for i, bus in enumerate(dict_asset[INFLOW_DIRECTION]):
687-
if i==0 :
688-
opts=dict(investment=solph.Investment(
689-
ep_costs=dict_asset[SIMULATION_ANNUITY][VALUE],
690-
maximum=dict_asset[MAXIMUM_ADD_CAP][VALUE],
691-
existing=dict_asset[INSTALLED_CAP][VALUE],
692-
))
693-
else:
694-
opts = {}
695698
inputs[kwargs[OEMOF_BUSSES][bus]] = solph.Flow(
696699
variable_costs=get_item_if_list(
697700
dict_asset[DISPATCH_PRICE][VALUE], i
698701
),
699-
**opts
702+
investment=investment if bus == investment_bus else None,
700703
)
701704

705+
bus = dict_asset[OUTFLOW_DIRECTION]
702706
outputs = {
703-
kwargs[OEMOF_BUSSES][dict_asset[OUTFLOW_DIRECTION]]: solph.Flow(
707+
kwargs[OEMOF_BUSSES][bus]: solph.Flow(
708+
investment=investment if bus == investment_bus else None
704709
)
705710
}
706711

@@ -728,24 +733,24 @@ def transformer_constant_efficiency_optimize(model, dict_asset, **kwargs):
728733
logging.error(missing_dispatch_prices_or_efficiencies)
729734
raise ValueError(missing_dispatch_prices_or_efficiencies)
730735

731-
inputs = {kwargs[OEMOF_BUSSES][dict_asset[INFLOW_DIRECTION]]: solph.Flow()}
736+
if investment_bus is None:
737+
investment_bus = dict_asset[INFLOW_DIRECTION]
738+
bus = dict_asset[INFLOW_DIRECTION]
739+
inputs = {
740+
kwargs[OEMOF_BUSSES][bus]: solph.Flow(
741+
investment=investment if bus == investment_bus else None
742+
)
743+
}
732744
outputs = {}
733745
efficiencies = {}
734746

735747
for i, (bus, efficiency) in enumerate(
736748
zip(dict_asset[OUTFLOW_DIRECTION], dict_asset[EFFICIENCY][VALUE])
737749
):
738-
if i == 0:
739-
investment_params = dict(
740-
investment=solph.Investment(
741-
ep_costs=dict_asset[SIMULATION_ANNUITY][VALUE],
742-
maximum=dict_asset[MAXIMUM_ADD_CAP][VALUE],
743-
existing=dict_asset[INSTALLED_CAP][VALUE],
744-
)
745-
)
746-
else:
747-
investment_params = {}
748-
outputs[kwargs[OEMOF_BUSSES][bus]] = solph.Flow(**investment_params)
750+
751+
outputs[kwargs[OEMOF_BUSSES][bus]] = solph.Flow(
752+
investment=investment if bus == investment_bus else None
753+
)
749754
efficiencies[kwargs[OEMOF_BUSSES][bus]] = efficiency
750755
else:
751756
# multiple inputs and multiple outputs
@@ -760,31 +765,36 @@ def transformer_constant_efficiency_optimize(model, dict_asset, **kwargs):
760765
logging.error(missing_dispatch_prices_or_efficiencies)
761766
raise ValueError(missing_dispatch_prices_or_efficiencies)
762767
else:
763-
check_list_parameters_transformers_single_input_single_output(dict_asset, model.timeindex.size)
768+
check_list_parameters_transformers_single_input_single_output(
769+
dict_asset, model.timeindex.size
770+
)
764771

765772
# single input and single output
766-
inputs = {kwargs[OEMOF_BUSSES][dict_asset[INFLOW_DIRECTION]]: solph.Flow()}
773+
774+
if investment_bus is None:
775+
investment_bus = dict_asset[OUTFLOW_DIRECTION]
776+
777+
bus = dict_asset[INFLOW_DIRECTION]
778+
inputs = {
779+
kwargs[OEMOF_BUSSES][dict_asset[INFLOW_DIRECTION]]: solph.Flow(
780+
investment=investment if bus == investment_bus else None
781+
)
782+
}
783+
784+
bus = dict_asset[OUTFLOW_DIRECTION]
767785
if AVAILABILITY_DISPATCH in dict_asset.keys():
768786
# This key is only present in DSO peak demand pricing transformers.
769787
outputs = {
770-
kwargs[OEMOF_BUSSES][dict_asset[OUTFLOW_DIRECTION]]: solph.Flow(
771-
investment=solph.Investment(
772-
ep_costs=dict_asset[SIMULATION_ANNUITY][VALUE],
773-
maximum=dict_asset[MAXIMUM_ADD_CAP][VALUE],
774-
existing=dict_asset[INSTALLED_CAP][VALUE],
775-
),
788+
kwargs[OEMOF_BUSSES][bus]: solph.Flow(
789+
investment=investment if bus == investment_bus else None,
776790
variable_costs=dict_asset[DISPATCH_PRICE][VALUE],
777791
max=dict_asset[AVAILABILITY_DISPATCH].values,
778792
)
779793
}
780794
else:
781795
outputs = {
782-
kwargs[OEMOF_BUSSES][dict_asset[OUTFLOW_DIRECTION]]: solph.Flow(
783-
investment=solph.Investment(
784-
ep_costs=dict_asset[SIMULATION_ANNUITY][VALUE],
785-
maximum=dict_asset[MAXIMUM_ADD_CAP][VALUE],
786-
existing=dict_asset[INSTALLED_CAP][VALUE],
787-
),
796+
kwargs[OEMOF_BUSSES][bus]: solph.Flow(
797+
investment=investment if bus == investment_bus else None,
788798
variable_costs=dict_asset[DISPATCH_PRICE][VALUE],
789799
)
790800
}

src/multi_vector_simulator/utils/constants_json_strings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
PEAK_DEMAND_PRICING = "peak_demand_pricing"
105105
PEAK_DEMAND_PRICING_PERIOD = "peak_demand_pricing_period"
106106

107+
# Asset definitions: Transformer
108+
INVESTMENT_BUS = "investment_bus"
109+
107110
# Asset definitions: Storage
108111
C_RATE = "c_rate"
109112
INPUT_POWER = "input power"

0 commit comments

Comments
 (0)