Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Bachibouzouk committed Sep 12, 2023
1 parent 9bd5b1e commit 219c033
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 22 deletions.
71 changes: 53 additions & 18 deletions src/multi_vector_simulator/C0_data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,29 +727,63 @@ def define_auxiliary_assets_of_energy_providers(dict_values, dso_name):
dict_values, dso_dict, dict_availability_timeseries,
)

define_source(
dict_values=dict_values,
asset_key=dso_name + DSO_CONSUMPTION,
outflow_direction=peak_demand_bus_name(dso_dict[OUTFLOW_DIRECTION]),
price=dso_dict[ENERGY_PRICE],
energy_vector=dso_dict[ENERGY_VECTOR],
emission_factor=dso_dict[EMISSION_FACTOR],
asset_type=dso_dict.get(TYPE_ASSET),
)
grid_availability = False
if grid_availability is False:
define_source(
dict_values=dict_values,
asset_key=dso_name + DSO_CONSUMPTION,
outflow_direction=peak_demand_bus_name(dso_dict[OUTFLOW_DIRECTION]),
price=dso_dict[ENERGY_PRICE],
energy_vector=dso_dict[ENERGY_VECTOR],
emission_factor=dso_dict[EMISSION_FACTOR],
asset_type=dso_dict.get(TYPE_ASSET),
)
else:
pass
# in case of grid availablity the price should be 0 and and extra sink should be added

dict_feedin = change_sign_of_feedin_tariff(dso_dict[FEEDIN_TARIFF], dso_name)

inflow_bus_name = peak_demand_bus_name(dso_dict[INFLOW_DIRECTION], feedin=True)

# define feed-in sink of the DSO
define_sink(
dict_values=dict_values,
asset_key=dso_name + DSO_FEEDIN,
price=dict_feedin,
inflow_direction=inflow_bus_name,
specific_costs={VALUE: 0, UNIT: CURR + "/" + UNIT},
energy_vector=dso_dict[ENERGY_VECTOR],
asset_type=dso_dict.get(TYPE_ASSET),
)
if grid_availability is False:
define_sink(
dict_values=dict_values,
asset_key=dso_name + DSO_FEEDIN,
price=dict_feedin,
inflow_direction=inflow_bus_name,
specific_costs={VALUE: 0, UNIT: CURR + "/" + UNIT},
energy_vector=dso_dict[ENERGY_VECTOR],
asset_type=dso_dict.get(TYPE_ASSET),
)
else:
# def maingrid_feedin(micro_grid_system, experiment):
# logging.debug("Added to oemof model: maingrid feedin")
# bus_electricity_ng_feedin = solph.Bus(label=BUS_ELECTRICITY_NG_FEEDIN)
# micro_grid_system.add(bus_electricity_ng_feedin)
#
# # create and add demand sink to micro_grid_system - fixed
# sink_maingrid_feedin = solph.components.Sink(
# label=SINK_MAINGRID_FEEDIN,
# inputs={
# bus_electricity_ng_feedin: solph.Flow(
# fix=experiment[GRID_AVAILABILITY],
# investment=solph.Investment(ep_costs=0),
# )
# },
# )
# micro_grid_system.add(sink_maingrid_feedin)
#
# # to fill in for not really provided feed in
# source_maingrid_feedin_symbolic = solph.components.Source(
# label=SINK_MAINGRID_FEEDIN_SYMBOLIC,
# outputs={bus_electricity_ng_feedin: solph.Flow()},
# )
# micro_grid_system.add(source_maingrid_feedin_symbolic)
# return bus_electricity_ng_feedin
# the price should be 0 and an extra source should be added here
pass
dso_dict.update(
{
CONNECTED_CONSUMPTION_SOURCE: dso_name + DSO_CONSUMPTION,
Expand Down Expand Up @@ -1062,6 +1096,7 @@ def define_transformer_for_peak_demand_pricing(
VALUE: 0,
UNIT: CURR + "/" + dict_dso[UNIT] + "/" + UNIT_YEAR,
},
# add price here instead of in sinks
DISPATCH_PRICE: {VALUE: 0, UNIT: CURR + "/" + dict_dso[UNIT] + "/" + UNIT_HOUR},
OEMOF_ASSET_TYPE: OEMOF_TRANSFORMER,
ENERGY_VECTOR: dict_dso[ENERGY_VECTOR],
Expand Down
7 changes: 6 additions & 1 deletion src/multi_vector_simulator/D0_modelling_and_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ def run_oemof(dict_values, save_energy_system_graph=False, return_les=False):
model_building.plot_networkx_graph(
dict_values, model, save_energy_system_graph=save_energy_system_graph
)

# import logging
# logging.getLogger().setLevel(logging.INFO)
logging.debug("Creating oemof model based on created components and busses...")
local_energy_system = solph.Model(model)
logging.debug("Created oemof model based on created components and busses.")

local_energy_system = D2.add_constraints(
local_energy_system, dict_values, dict_model
)
import ipdb

ipdb.set_trace()

model_building.store_lp_file(dict_values, local_energy_system)

model, results_main, results_meta = model_building.simulating(
Expand Down
23 changes: 21 additions & 2 deletions src/multi_vector_simulator/D1_model_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
EMISSION_FACTOR,
BETA,
INVESTMENT_BUS,
GRID_AVAILABILITY,
)
from multi_vector_simulator.utils.helpers import get_item_if_list, get_length_if_list
from multi_vector_simulator.utils.exceptions import (
Expand Down Expand Up @@ -324,7 +325,10 @@ def sink(model, dict_asset, **kwargs):
- test_sink_dispatchable_multiple_input_busses()
"""
if TIMESERIES in dict_asset:
if GRID_AVAILABILITY in dict_asset:
pass
# add the sink and symbolic source directly here for simplicity
elif TIMESERIES in dict_asset:
sink_non_dispatchable(model, dict_asset, **kwargs)

else:
Expand Down Expand Up @@ -380,7 +384,11 @@ def source(model, dict_asset, **kwargs):
- test_source_dispatchable_fix_normalized_timeseries()
- test_source_dispatchable_fix_timeseries_not_normalized_timeseries()
"""
if DISPATCHABILITY in dict_asset and dict_asset[DISPATCHABILITY] is True:
if GRID_AVAILABILITY in dict_asset:
pass
# add the source and symbolic sink directly here for simplicity

elif DISPATCHABILITY in dict_asset and dict_asset[DISPATCHABILITY] is True:
check_optimize_cap(
model,
dict_asset,
Expand Down Expand Up @@ -1258,6 +1266,17 @@ def sink_non_dispatchable(model, dict_asset, **kwargs):
Indirectly updated `model` and dict of asset in `kwargs` with the sink object.
"""

# sink_maingrid_feedin = solph.components.Sink(
# label=SINK_MAINGRID_FEEDIN,
# inputs={
# bus_electricity_ng_feedin: solph.Flow(
# fix=experiment[GRID_AVAILABILITY],
# investment=solph.Investment(ep_costs=0),
# )
# },
# )

# check if the sink has multiple input busses
if isinstance(dict_asset[INFLOW_DIRECTION], list):
inputs = {}
Expand Down
4 changes: 4 additions & 0 deletions src/multi_vector_simulator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ def main(**kwargs):
dict_values, save_energy_system_graph=save_energy_system_graph,
)

import ipdb

ipdb.set_trace()

print("")
logging.debug("Accessing script: E0_evaluation")
E0.evaluate_dict(dict_values, results_main, results_meta)
Expand Down
2 changes: 1 addition & 1 deletion src/multi_vector_simulator/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import tempfile

from oemof.tools import logger
import oemof.solph as solph
from oemof import solph

# Loading all child functions
import multi_vector_simulator.B0_data_input_json as B0
Expand Down
1 change: 1 addition & 0 deletions src/multi_vector_simulator/utils/constants_json_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
FEEDIN_TARIFF = "feedin_tariff"
PEAK_DEMAND_PRICING = "peak_demand_pricing"
PEAK_DEMAND_PRICING_PERIOD = "peak_demand_pricing_period"
GRID_AVAILABILITY = "grid_availability"

# Asset definitions: Transformer
INVESTMENT_BUS = "investment_bus"
Expand Down

0 comments on commit 219c033

Please sign in to comment.