From 842e0110625475aa30e1f5d1e51373ffd28a4935 Mon Sep 17 00:00:00 2001 From: "christoph.von.oy" <christoph.von.oy@rwth-aachen.de> Date: Thu, 2 Feb 2023 09:41:28 +0100 Subject: [PATCH] Moved bi_flow constraints into components --- Model_Library | 2 +- .../convert_input_files_refactoring_part_2.py | 38 +++++++++++++++++++ .../prosumer_models/SCN0_CAT1/connections.csv | 2 + .../SCN2_CAT1_PV11/connections.csv | 2 + .../SCN2_CAT1_PV12_BA/connections.csv | 2 + .../SCN2_CAT1_PV13_BA_HP/connections.csv | 4 ++ .../SCN2_CAT1_PV14_HP/connections.csv | 4 ++ .../SCN2_CAT1_PV31/connections.csv | 2 + .../SCN2_CAT1_PV32_BA/connections.csv | 2 + .../SCN2_CAT1_PV33_BA_HP/connections.csv | 4 ++ .../SCN2_CAT1_PV34_HP/connections.csv | 4 ++ .../prosumer_models/SCN3_CAT1/connections.csv | 2 + .../SCN3_CAT1_PV11/connections.csv | 2 + .../SCN3_CAT1_PV12_BA/connections.csv | 2 + .../SCN3_CAT1_PV13_BA_HP/connections.csv | 4 ++ .../SCN3_CAT1_PV14_HP/connections.csv | 4 ++ .../SCN3_CAT1_PV31/connections.csv | 2 + .../SCN3_CAT1_PV32_BA/connections.csv | 2 + .../SCN3_CAT1_PV33_BA_HP/connections.csv | 4 ++ .../SCN3_CAT1_PV34_HP/connections.csv | 4 ++ .../office_pv_heatpump/connections.csv | 2 + 21 files changed, 93 insertions(+), 1 deletion(-) diff --git a/Model_Library b/Model_Library index 09f026c22c..3b93e0eec3 160000 --- a/Model_Library +++ b/Model_Library @@ -1 +1 @@ -Subproject commit 09f026c22cca6060b606e9cd33483bea01ba59d3 +Subproject commit 3b93e0eec3f1e8451251da02e209a90968ff89c4 diff --git a/input_files/convert_input_files_refactoring_part_2.py b/input_files/convert_input_files_refactoring_part_2.py index 14959bbf79..2948a10f94 100644 --- a/input_files/convert_input_files_refactoring_part_2.py +++ b/input_files/convert_input_files_refactoring_part_2.py @@ -40,6 +40,33 @@ def get_connected_components(matrix, components, comp): def get_connection(matrix, components, comp_from, comp_to): return matrix[components[comp_from]][components[comp_to]] +def get_bypasses(component_name, connections): + inputs = [] + outputs = [] + sector = '' + for i in connections.index: + if connections['to'][i] == component_name and connections['from'][i] not in inputs: + inputs.append(connections['from'][i]) + if sector == '': + sector = connections['sector'][i] + else: + if sector != connections['sector'][i]: + raise KeyError + if connections['from'][i] == component_name and connections['to'][i] not in outputs: + outputs.append(connections['to'][i]) + if sector == '': + sector = connections['sector'][i] + else: + if sector != connections['sector'][i]: + raise KeyError + bypasses = [] + for input in inputs: + for output in outputs: + if input != output: + if not ((connections['sector'] == sector) & (connections['from'] == input) & (connections['to'] == output)).any(): + bypasses.append((sector, input, output)) + return bypasses + def read_config(config_path): config_df = pd.read_csv(config_path) config_dict = config_df.to_dict(orient='list') @@ -59,6 +86,7 @@ renamed_components = {'StandardElectricalConsumption': 'ElectricalConsumption', 'BasicInverter': 'StaticInverter', 'Inverter': 'DynamicInverter'} consumption_components = ['CoolConsumption', 'ChargingInfrastructure', 'ElectricalConsumption', 'HeatConsumption', 'Radiator', 'HotWaterConsumption'] +storage_components = ['LiionBattery', 'HotWaterStorage', 'PressureStorage'] for dirpath, dirnames, filenames in os.walk(".\\input_files"): topology_here = False matrix_files = [] @@ -102,6 +130,16 @@ for dirpath, dirnames, filenames in os.walk(".\\input_files"): raise KeyError for connected_component in get_connected_components(matrix, components, component): all_connections = pd.concat([all_connections, pd.Series({'sector': sector, 'from': component, 'to': connected_component}).to_frame().T], ignore_index = True) + while True: + number_of_connections_before = len(all_connections) + for i in all_components.index: + if all_components['type'][i] in storage_components: + for sector, from_component, to_component in get_bypasses(all_components['name'][i], all_connections): + all_connections = pd.concat([all_connections, pd.Series({'sector': sector, 'from': from_component, 'to': to_component}).to_frame().T], ignore_index = True) + number_of_connections_after = len(all_connections) + if number_of_connections_before == number_of_connections_after: + break + config = read_config(os.path.join(dirpath, "config.csv")) changed_topologies.append(dirpath) new_config = dict() diff --git a/input_files/models/prosumer_models/SCN0_CAT1/connections.csv b/input_files/models/prosumer_models/SCN0_CAT1/connections.csv index 3e485ceed8..f911b10874 100644 --- a/input_files/models/prosumer_models/SCN0_CAT1/connections.csv +++ b/input_files/models/prosumer_models/SCN0_CAT1/connections.csv @@ -4,3 +4,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV11/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV11/connections.csv index 43a54d1318..07be821df1 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV11/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV11/connections.csv @@ -7,3 +7,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV12_BA/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV12_BA/connections.csv index 83a66459d5..907c9e7e18 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV12_BA/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV12_BA/connections.csv @@ -13,3 +13,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV13_BA_HP/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV13_BA_HP/connections.csv index b6e01aecd8..c82fe1d4ec 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV13_BA_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV13_BA_HP/connections.csv @@ -16,3 +16,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/connections.csv index 97283663a5..4048376f0e 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/connections.csv @@ -10,3 +10,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV31/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV31/connections.csv index 43a54d1318..07be821df1 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV31/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV31/connections.csv @@ -7,3 +7,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV32_BA/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV32_BA/connections.csv index fb91ba92c0..aedf9635c2 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV32_BA/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV32_BA/connections.csv @@ -12,3 +12,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV33_BA_HP/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV33_BA_HP/connections.csv index b6e01aecd8..c82fe1d4ec 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV33_BA_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV33_BA_HP/connections.csv @@ -16,3 +16,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN2_CAT1_PV34_HP/connections.csv b/input_files/models/prosumer_models/SCN2_CAT1_PV34_HP/connections.csv index 97283663a5..4048376f0e 100644 --- a/input_files/models/prosumer_models/SCN2_CAT1_PV34_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN2_CAT1_PV34_HP/connections.csv @@ -10,3 +10,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1/connections.csv index 3e485ceed8..f911b10874 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1/connections.csv @@ -4,3 +4,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV11/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV11/connections.csv index 43a54d1318..07be821df1 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV11/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV11/connections.csv @@ -7,3 +7,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV12_BA/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV12_BA/connections.csv index 83a66459d5..907c9e7e18 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV12_BA/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV12_BA/connections.csv @@ -13,3 +13,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV13_BA_HP/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV13_BA_HP/connections.csv index 1ce26af83c..14d304ec74 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV13_BA_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV13_BA_HP/connections.csv @@ -17,3 +17,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV14_HP/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV14_HP/connections.csv index 97283663a5..4048376f0e 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV14_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV14_HP/connections.csv @@ -10,3 +10,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV31/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV31/connections.csv index 43a54d1318..07be821df1 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV31/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV31/connections.csv @@ -7,3 +7,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV32_BA/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV32_BA/connections.csv index 83a66459d5..907c9e7e18 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV32_BA/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV32_BA/connections.csv @@ -13,3 +13,5 @@ gas,gas_grd,gas_boi heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV33_BA_HP/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV33_BA_HP/connections.csv index 1ce26af83c..14d304ec74 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV33_BA_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV33_BA_HP/connections.csv @@ -17,3 +17,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/SCN3_CAT1_PV34_HP/connections.csv b/input_files/models/prosumer_models/SCN3_CAT1_PV34_HP/connections.csv index 97283663a5..4048376f0e 100644 --- a/input_files/models/prosumer_models/SCN3_CAT1_PV34_HP/connections.csv +++ b/input_files/models/prosumer_models/SCN3_CAT1_PV34_HP/connections.csv @@ -10,3 +10,7 @@ heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd heat,gas_boi,water_tes +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd +heat,gas_boi,therm_cns +heat,gas_boi,dhw_dmd diff --git a/input_files/models/prosumer_models/office_pv_heatpump/connections.csv b/input_files/models/prosumer_models/office_pv_heatpump/connections.csv index f05079cf72..2648881f72 100644 --- a/input_files/models/prosumer_models/office_pv_heatpump/connections.csv +++ b/input_files/models/prosumer_models/office_pv_heatpump/connections.csv @@ -11,3 +11,5 @@ electricity,grd,elec_cns heat,heat_pump,water_tes heat,water_tes,therm_cns heat,water_tes,dhw_dmd +heat,heat_pump,therm_cns +heat,heat_pump,dhw_dmd -- GitLab