From 9fbad207985535fb030cf93adb8008ea29f9250f Mon Sep 17 00:00:00 2001
From: "christoph.von.oy" <christoph.von.oy@rwth-aachen.de>
Date: Wed, 15 Mar 2023 17:49:08 +0100
Subject: [PATCH] Sector stuff

Renamed sector to commdity
In connections.csv replaced sector with output/input index
---
 Model_Library                                 |   2 +-
 README.md                                     |   2 +-
 Tooling                                       |   2 +-
 ...nput_files_released_focused_refactoring.py | 125 ++++++++++++++++++
 .../example_CA/connections.csv                |  14 +-
 .../example_community/connections.csv         |  16 +--
 .../jbr_test_ca/connections.csv               |  16 +--
 .../jbr_test_comm/connections.csv             |  16 +--
 .../prosumer_models/SCN0_CAT1/connections.csv |  16 +--
 .../SCN2_CAT1_PV11/connections.csv            |  22 +--
 .../SCN2_CAT1_PV12_BA/connections.csv         |  34 ++---
 .../SCN2_CAT1_PV13_BA_HP/connections.csv      |  44 +++---
 .../SCN2_CAT1_PV14_HP/connections.csv         |  32 ++---
 .../SCN2_CAT1_PV31/connections.csv            |  22 +--
 .../SCN2_CAT1_PV32_BA/connections.csv         |  32 ++---
 .../SCN2_CAT1_PV33_BA_HP/connections.csv      |  44 +++---
 .../SCN2_CAT1_PV34_HP/connections.csv         |  32 ++---
 .../prosumer_models/SCN3_CAT1/connections.csv |  16 +--
 .../SCN3_CAT1_PV11/connections.csv            |  22 +--
 .../SCN3_CAT1_PV12_BA/connections.csv         |  34 ++---
 .../SCN3_CAT1_PV13_BA_HP/connections.csv      |  46 +++----
 .../SCN3_CAT1_PV14_HP/connections.csv         |  32 ++---
 .../SCN3_CAT1_PV31/connections.csv            |  22 +--
 .../SCN3_CAT1_PV32_BA/connections.csv         |  34 ++---
 .../SCN3_CAT1_PV33_BA_HP/connections.csv      |  46 +++----
 .../SCN3_CAT1_PV34_HP/connections.csv         |  32 ++---
 .../prosumer_models/jbr_test/connections.csv  |  16 +--
 .../mfh_quartal/connections.csv               |  70 +++++-----
 .../office_pv_heatpump/connections.csv        |  30 ++---
 runme.py                                      |  10 +-
 30 files changed, 503 insertions(+), 378 deletions(-)
 create mode 100644 input_files/convert_input_files_released_focused_refactoring.py

diff --git a/Model_Library b/Model_Library
index eedf77f1e6..1d0e19b23f 160000
--- a/Model_Library
+++ b/Model_Library
@@ -1 +1 @@
-Subproject commit eedf77f1e62b29c8ffbf012f6d9b634d155efdaf
+Subproject commit 1d0e19b23f9d69ae0bef98e48522d01cfbf7e797
diff --git a/README.md b/README.md
index a0d07a9dfd..c80186675a 100644
--- a/README.md
+++ b/README.md
@@ -161,7 +161,7 @@ The ineed-dc-framework repository is the framework's main repository. It contain
 The sub-repository Model_Libary contains the mathematical models of component, prosumer, quarter, and city levels. 
 
   - `Components/` : Contains all component models and initialized pre-configured components
-  - `Prosumer/` : Includes BaseProsumer model whhich allows to flexibily model any Prosumer application
+  - `Prosumer/` : Includes Prosumer model whhich allows to flexibily model any Prosumer application
   - `District/` : Will contain district level model (implementation in progress).
   - `City/` : Will contain city level model (implementation in progress).
 
diff --git a/Tooling b/Tooling
index 0c0e53de7c..70c50a8cd1 160000
--- a/Tooling
+++ b/Tooling
@@ -1 +1 @@
-Subproject commit 0c0e53de7c208ec319d660072c45e3e206f801b5
+Subproject commit 70c50a8cd16381928ed5e162b03f214750889a13
diff --git a/input_files/convert_input_files_released_focused_refactoring.py b/input_files/convert_input_files_released_focused_refactoring.py
new file mode 100644
index 0000000000..6664da3b65
--- /dev/null
+++ b/input_files/convert_input_files_released_focused_refactoring.py
@@ -0,0 +1,125 @@
+"""
+This script inspects the input files and modifies them such that they adhere to the new input file specification used by the framework after merge of merge request !13 Release focused refactoring.
+"""
+
+import os.path
+import pandas as pd
+
+def component_to_commodities(type):
+    if type == "AbsorptionChiller":
+        return "heat", "cold", None
+    if type == "CompressorChiller":
+        return "electricity", "cold", None
+    if type == "CoolConsumption":
+        return "cold", None, None
+    if type == "CoolGrid":
+        return "cold", "cold", None
+    if type == "ChargingInfrastructure":
+        return "electricity", None, None
+    if type == "ElectricalBusBar":
+        return "electricity", "electricity", None
+    if type == "ElectricalConsumption":
+        return "electricity", None, None
+    if type == "ElectricalGrid":
+        return "electricity", "electricity", None
+    if type == "PVGenerator":
+        return None, "electricity", None
+    if type == "DynamicInverter":
+        return "electricity", "electricity", None
+    if type == "StaticInverter":
+        return "electricity", "electricity", None
+    if type == "LiionBattery":
+        return "electricity", "electricity", None
+    if type == "BHKW":
+        return "gas", "heat", "electricity"
+    if type == "CHP":
+        return "gas", "heat", "electricity"
+    if type == "GasGrid":
+        return "gas", "gas", None
+    if type == "ElectricBoiler":
+        return "electricity", "heat", None
+    if type == "GasBoiler":
+        return "gas", "heat", None
+    if type == "HeatGrid":
+        return "heat", "heat", None
+    if type == "ElectricRadiator":
+        return "electricity", "heat", None
+    if type == "HeatConsumption":
+        return "heat", None, None
+    if type == "Radiator":
+        return "heat", None, None
+    if type == "UnderfloorHeat":
+        return "heat", "heat", None
+    if type == "HeatExchanger":
+        return "heat", "heat", None
+    if type == "GasHeatPump":
+        return "gas", "heat", None
+    if type == "HeatPump":
+        return "electricity", "heat", None
+    if type == "HotWaterConsumption":
+        return "heat", None, None
+    if type == "SolarThermalCollector":
+        return None, "heat", None
+    if type == "HotWaterStorage":
+        return "heat", "heat", None
+    if type == "PEMElectrolyzer":
+        return "electricity", "hydrogen", None
+    if type == "PEMFuelCell":
+        return "hydrogen", "electricity", "heat"
+    if type == "PEMElectrolyzer":
+        return "electricity", "hydrogen", None
+    if type == "PressureStorage":
+        return "hydrogen", "hydrogen", None
+    raise KeyError
+
+changed_topologies = []
+invalid_topologies = []
+for dirpath, dirnames, filenames in os.walk(".\\input_files"):
+    components_here = False
+    connections_here = False
+    for filename in filenames:
+        if filename == "components.csv":
+            components_file = filename
+            components_here = True
+        elif filename == "connections.csv":
+            connections_file = filename
+            connections_here = True
+    
+    if components_here and connections_here:
+        try:
+            print(f"Inspecting topology {dirpath}")
+            components_df = pd.read_csv(os.path.join(dirpath, components_file))
+            components = {}
+            for i in components_df.index:
+                components[components_df["name"][i]] = components_df.loc[i]
+            connections = pd.read_csv(os.path.join(dirpath, connections_file))
+            connections['output'] = pd.Series("", index = connections.index)
+            connections['input'] = pd.Series("", index = connections.index)
+            for i in connections.index:
+                commodity = connections['sector'][i]
+                connection_from = connections['from'][i]
+                connection_to = connections['to'][i]
+                from_type = components[connection_from]['type']
+                input_commodity, output_commodity_1, output_commodity_2 = component_to_commodities(from_type)
+                if commodity == output_commodity_1:
+                    connections['output'][i] = "1"
+                elif commodity == output_commodity_2:
+                    connections['output'][i] = "2"
+                else:
+                    raise KeyError
+                to_type = components[connection_to]['type']
+                input_commodity, output_commodity_1, output_commodity_2 = component_to_commodities(to_type)
+                if commodity == input_commodity:
+                    connections['input'][i] = ""
+                else:
+                    raise KeyError
+            connections.drop("sector", axis = 1)
+            connections = connections[["from", "output", "to", "input"]]
+            changed_topologies.append(dirpath)
+            connections.to_csv(os.path.join(dirpath, "connections.csv"), index = False)
+        except:
+            invalid_topologies.append(dirpath)
+for directory in changed_topologies:
+    print(f"Modified topology {directory}!")
+for file in invalid_topologies:
+    print(f"Topology {file} breaks some part of the input file specification!")
diff --git a/input_files/models/district_models/example_CA/connections.csv b/input_files/models/district_models/example_CA/connections.csv
index 792c8b1f4f..2221e07d38 100644
--- a/input_files/models/district_models/example_CA/connections.csv
+++ b/input_files/models/district_models/example_CA/connections.csv
@@ -1,7 +1,7 @@
-sector,from,to
-electricity,inv_pv_bat,battery
-electricity,inv_pv_bat,grd
-electricity,inv_pv_bat,elec_cns
-electricity,battery,inv_pv_bat
-electricity,grd,inv_pv_bat
-electricity,grd,elec_cns
+from,output,to,input
+inv_pv_bat,1,battery,
+inv_pv_bat,1,grd,
+inv_pv_bat,1,elec_cns,
+battery,1,inv_pv_bat,
+grd,1,inv_pv_bat,
+grd,1,elec_cns,
diff --git a/input_files/models/district_models/example_community/connections.csv b/input_files/models/district_models/example_community/connections.csv
index d63037e151..92ceec7f32 100644
--- a/input_files/models/district_models/example_community/connections.csv
+++ b/input_files/models/district_models/example_community/connections.csv
@@ -1,8 +1,8 @@
-sector,from,to
-electricity,pv_roof,inv_pv_bat
-electricity,inv_pv_bat,battery
-electricity,inv_pv_bat,grd
-electricity,inv_pv_bat,elec_cns
-electricity,battery,inv_pv_bat
-electricity,grd,inv_pv_bat
-electricity,grd,elec_cns
+from,output,to,input
+pv_roof,1,inv_pv_bat,
+inv_pv_bat,1,battery,
+inv_pv_bat,1,grd,
+inv_pv_bat,1,elec_cns,
+battery,1,inv_pv_bat,
+grd,1,inv_pv_bat,
+grd,1,elec_cns,
diff --git a/input_files/models/district_models/jbr_test_ca/connections.csv b/input_files/models/district_models/jbr_test_ca/connections.csv
index d63037e151..92ceec7f32 100644
--- a/input_files/models/district_models/jbr_test_ca/connections.csv
+++ b/input_files/models/district_models/jbr_test_ca/connections.csv
@@ -1,8 +1,8 @@
-sector,from,to
-electricity,pv_roof,inv_pv_bat
-electricity,inv_pv_bat,battery
-electricity,inv_pv_bat,grd
-electricity,inv_pv_bat,elec_cns
-electricity,battery,inv_pv_bat
-electricity,grd,inv_pv_bat
-electricity,grd,elec_cns
+from,output,to,input
+pv_roof,1,inv_pv_bat,
+inv_pv_bat,1,battery,
+inv_pv_bat,1,grd,
+inv_pv_bat,1,elec_cns,
+battery,1,inv_pv_bat,
+grd,1,inv_pv_bat,
+grd,1,elec_cns,
diff --git a/input_files/models/district_models/jbr_test_comm/connections.csv b/input_files/models/district_models/jbr_test_comm/connections.csv
index d63037e151..92ceec7f32 100644
--- a/input_files/models/district_models/jbr_test_comm/connections.csv
+++ b/input_files/models/district_models/jbr_test_comm/connections.csv
@@ -1,8 +1,8 @@
-sector,from,to
-electricity,pv_roof,inv_pv_bat
-electricity,inv_pv_bat,battery
-electricity,inv_pv_bat,grd
-electricity,inv_pv_bat,elec_cns
-electricity,battery,inv_pv_bat
-electricity,grd,inv_pv_bat
-electricity,grd,elec_cns
+from,output,to,input
+pv_roof,1,inv_pv_bat,
+inv_pv_bat,1,battery,
+inv_pv_bat,1,grd,
+inv_pv_bat,1,elec_cns,
+battery,1,inv_pv_bat,
+grd,1,inv_pv_bat,
+grd,1,elec_cns,
diff --git a/input_files/models/prosumer_models/SCN0_CAT1/connections.csv b/input_files/models/prosumer_models/SCN0_CAT1/connections.csv
index f911b10874..793bf1329f 100644
--- a/input_files/models/prosumer_models/SCN0_CAT1/connections.csv
+++ b/input_files/models/prosumer_models/SCN0_CAT1/connections.csv
@@ -1,8 +1,8 @@
-sector,from,to
-electricity,grd,elec_cns
-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
+from,output,to,input
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 07be821df1..29bf9c9ef8 100644
--- a/input_files/models/prosumer_models/SCN2_CAT1_PV11/connections.csv
+++ b/input_files/models/prosumer_models/SCN2_CAT1_PV11/connections.csv
@@ -1,11 +1,11 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 907c9e7e18..80ceeebd58 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
@@ -1,17 +1,17 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,elec_cns
-electricity,grd,inv_bat
-electricity,inv_bat,battery
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,elec_cns,
+grd,1,inv_bat,
+inv_bat,1,battery,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 c82fe1d4ec..41209ff3aa 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
@@ -1,22 +1,22 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-electricity,inv_bat,battery
-electricity,inv_bat,heat_pump
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,heat_pump,
+grd,1,elec_cns,
+inv_bat,1,battery,
+inv_bat,1,heat_pump,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 4048376f0e..b419198fc1 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
@@ -1,16 +1,16 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,heat_pump,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 07be821df1..29bf9c9ef8 100644
--- a/input_files/models/prosumer_models/SCN2_CAT1_PV31/connections.csv
+++ b/input_files/models/prosumer_models/SCN2_CAT1_PV31/connections.csv
@@ -1,11 +1,11 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 aedf9635c2..f28a5c3435 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
@@ -1,16 +1,16 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,elec_cns
-electricity,inv_bat,battery
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,elec_cns,
+inv_bat,1,battery,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 c82fe1d4ec..41209ff3aa 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
@@ -1,22 +1,22 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-electricity,inv_bat,battery
-electricity,inv_bat,heat_pump
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,heat_pump,
+grd,1,elec_cns,
+inv_bat,1,battery,
+inv_bat,1,heat_pump,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 4048376f0e..b419198fc1 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
@@ -1,16 +1,16 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,heat_pump,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 f911b10874..793bf1329f 100644
--- a/input_files/models/prosumer_models/SCN3_CAT1/connections.csv
+++ b/input_files/models/prosumer_models/SCN3_CAT1/connections.csv
@@ -1,8 +1,8 @@
-sector,from,to
-electricity,grd,elec_cns
-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
+from,output,to,input
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 07be821df1..29bf9c9ef8 100644
--- a/input_files/models/prosumer_models/SCN3_CAT1_PV11/connections.csv
+++ b/input_files/models/prosumer_models/SCN3_CAT1_PV11/connections.csv
@@ -1,11 +1,11 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 907c9e7e18..80ceeebd58 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
@@ -1,17 +1,17 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,elec_cns
-electricity,grd,inv_bat
-electricity,inv_bat,battery
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,elec_cns,
+grd,1,inv_bat,
+inv_bat,1,battery,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 14d304ec74..c3805591c3 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
@@ -1,23 +1,23 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-electricity,grd,inv_bat
-electricity,inv_bat,battery
-electricity,inv_bat,heat_pump
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,heat_pump,
+grd,1,elec_cns,
+grd,1,inv_bat,
+inv_bat,1,battery,
+inv_bat,1,heat_pump,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 4048376f0e..b419198fc1 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
@@ -1,16 +1,16 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,heat_pump,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 07be821df1..29bf9c9ef8 100644
--- a/input_files/models/prosumer_models/SCN3_CAT1_PV31/connections.csv
+++ b/input_files/models/prosumer_models/SCN3_CAT1_PV31/connections.csv
@@ -1,11 +1,11 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 907c9e7e18..80ceeebd58 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
@@ -1,17 +1,17 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,elec_cns
-electricity,grd,inv_bat
-electricity,inv_bat,battery
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,elec_cns,
+grd,1,inv_bat,
+inv_bat,1,battery,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+gas_boi,1,therm_cns,
+gas_boi,1,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 14d304ec74..c3805591c3 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
@@ -1,23 +1,23 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,inv_pv,inv_bat
-electricity,battery,inv_bat
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-electricity,grd,inv_bat
-electricity,inv_bat,battery
-electricity,inv_bat,heat_pump
-electricity,inv_bat,grd
-electricity,inv_bat,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+inv_pv,1,inv_bat,
+battery,1,inv_bat,
+grd,1,heat_pump,
+grd,1,elec_cns,
+grd,1,inv_bat,
+inv_bat,1,battery,
+inv_bat,1,heat_pump,
+inv_bat,1,grd,
+inv_bat,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,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 4048376f0e..b419198fc1 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
@@ -1,16 +1,16 @@
-sector,from,to
-electricity,pv_roof,inv_pv
-electricity,inv_pv,heat_pump
-electricity,inv_pv,grd
-electricity,inv_pv,elec_cns
-electricity,grd,heat_pump
-electricity,grd,elec_cns
-gas,gas_grd,gas_boi
-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
+from,output,to,input
+pv_roof,1,inv_pv,
+inv_pv,1,heat_pump,
+inv_pv,1,grd,
+inv_pv,1,elec_cns,
+grd,1,heat_pump,
+grd,1,elec_cns,
+gas_grd,1,gas_boi,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+gas_boi,1,water_tes,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
+gas_boi,1,therm_cns,
+gas_boi,1,dhw_dmd,
diff --git a/input_files/models/prosumer_models/jbr_test/connections.csv b/input_files/models/prosumer_models/jbr_test/connections.csv
index d63037e151..92ceec7f32 100644
--- a/input_files/models/prosumer_models/jbr_test/connections.csv
+++ b/input_files/models/prosumer_models/jbr_test/connections.csv
@@ -1,8 +1,8 @@
-sector,from,to
-electricity,pv_roof,inv_pv_bat
-electricity,inv_pv_bat,battery
-electricity,inv_pv_bat,grd
-electricity,inv_pv_bat,elec_cns
-electricity,battery,inv_pv_bat
-electricity,grd,inv_pv_bat
-electricity,grd,elec_cns
+from,output,to,input
+pv_roof,1,inv_pv_bat,
+inv_pv_bat,1,battery,
+inv_pv_bat,1,grd,
+inv_pv_bat,1,elec_cns,
+battery,1,inv_pv_bat,
+grd,1,inv_pv_bat,
+grd,1,elec_cns,
diff --git a/input_files/models/prosumer_models/mfh_quartal/connections.csv b/input_files/models/prosumer_models/mfh_quartal/connections.csv
index 24fbbcbe2b..6bbcae8221 100644
--- a/input_files/models/prosumer_models/mfh_quartal/connections.csv
+++ b/input_files/models/prosumer_models/mfh_quartal/connections.csv
@@ -1,35 +1,35 @@
-sector,from,to
-electricity,grd,ecns1
-electricity,grd,ecns2
-electricity,grd,ecns3
-electricity,grd,ecns4
-electricity,grd,ecns5
-electricity,grd,ecns6
-electricity,pv,grd
-electricity,pv,bat
-electricity,pv,ecns1
-electricity,pv,ecns2
-electricity,pv,ecns3
-electricity,pv,ecns4
-electricity,pv,ecns5
-electricity,pv,ecns6
-electricity,bat,ecns1
-electricity,bat,ecns2
-electricity,bat,ecns3
-electricity,bat,ecns4
-electricity,bat,ecns5
-electricity,bat,ecns6
-electricity,chp,grd
-electricity,chp,ecns1
-electricity,chp,ecns2
-electricity,chp,ecns3
-electricity,chp,ecns4
-electricity,chp,ecns5
-electricity,chp,ecns6
-gas,gas_grd,chp
-heat,chp,tcns1
-heat,chp,tcns2
-heat,chp,tcns3
-heat,chp,tcns4
-heat,chp,tcns5
-heat,chp,tcns6
+from,output,to,input
+grd,1,ecns1,
+grd,1,ecns2,
+grd,1,ecns3,
+grd,1,ecns4,
+grd,1,ecns5,
+grd,1,ecns6,
+pv,1,grd,
+pv,1,bat,
+pv,1,ecns1,
+pv,1,ecns2,
+pv,1,ecns3,
+pv,1,ecns4,
+pv,1,ecns5,
+pv,1,ecns6,
+bat,1,ecns1,
+bat,1,ecns2,
+bat,1,ecns3,
+bat,1,ecns4,
+bat,1,ecns5,
+bat,1,ecns6,
+chp,2,grd,
+chp,2,ecns1,
+chp,2,ecns2,
+chp,2,ecns3,
+chp,2,ecns4,
+chp,2,ecns5,
+chp,2,ecns6,
+gas_grd,1,chp,
+chp,1,tcns1,
+chp,1,tcns2,
+chp,1,tcns3,
+chp,1,tcns4,
+chp,1,tcns5,
+chp,1,tcns6,
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 2648881f72..1e8111f230 100644
--- a/input_files/models/prosumer_models/office_pv_heatpump/connections.csv
+++ b/input_files/models/prosumer_models/office_pv_heatpump/connections.csv
@@ -1,15 +1,15 @@
-sector,from,to
-electricity,pv_roof,inv_pv_bat
-electricity,inv_pv_bat,battery
-electricity,inv_pv_bat,heat_pump
-electricity,inv_pv_bat,grd
-electricity,inv_pv_bat,elec_cns
-electricity,battery,inv_pv_bat
-electricity,grd,inv_pv_bat
-electricity,grd,heat_pump
-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
+from,output,to,input
+pv_roof,1,inv_pv_bat,
+inv_pv_bat,1,battery,
+inv_pv_bat,1,heat_pump,
+inv_pv_bat,1,grd,
+inv_pv_bat,1,elec_cns,
+battery,1,inv_pv_bat,
+grd,1,inv_pv_bat,
+grd,1,heat_pump,
+grd,1,elec_cns,
+heat_pump,1,water_tes,
+water_tes,1,therm_cns,
+water_tes,1,dhw_dmd,
+heat_pump,1,therm_cns,
+heat_pump,1,dhw_dmd,
diff --git a/runme.py b/runme.py
index 29ac2e8040..7f76e0a2ed 100644
--- a/runme.py
+++ b/runme.py
@@ -1,7 +1,7 @@
 import pandas as pd
 import Tooling.input_profile_processor.input_profile_processor
-import Model_Library.Prosumer.main as main
-import Model_Library.District.main_district as main_district
+import Model_Library.Prosumer.main as main_prosumer
+import Model_Library.District.main as main_district
 from enum import Enum
 
 class SimulationScope(Enum):
@@ -46,7 +46,7 @@ prosumer_dict = {'SCN2_CAT1_PV11_3000_6000':{'config_path': 'input_files/models/
                                                       'therm_cns': 'demand_heat_2',
                                                       'dhw_dmd': 'demand_hot_water_2'}}}
 
-prosumer_main = main.Main(prosumer_dict, input_profiles, t_horizon, t_step)
+prosumer_main = main_prosumer.ProsumerMain(prosumer_dict, input_profiles, t_horizon, t_step)
 
 prosumer_sizing_strategy = 'annuity'
 prosumer_main.optimize_sizing(prosumer_sizing_strategy)
@@ -62,12 +62,12 @@ community_assets_dict = {'ca_bat': {'config_path': 'input_files/models/district_
                                     'topology_path': 'input_files/models/district_models/example_CA',
                                     'profiles': {'elec_cns': 'demand_electric_3'}}}
 
-community_assets = main.Main_CA(community_assets_dict, input_profiles, t_horizon, t_step).community_assets
+community_assets = main_prosumer.CommunityAssetMain(community_assets_dict, input_profiles, t_horizon, t_step).community_assets
 
 community_dict = {'community': {'config_path': 'input_files/models/district_models/example_community/config.csv',
                                 'profiles': {'elec_price': 'elec_price_1'}}}
 
-community_main = main_district.MainDistrict(community_dict, prosumers, community_assets, input_profiles, t_horizon, t_step)
+community_main = main_district.CommunityMain(community_dict, prosumers, community_assets, input_profiles, t_horizon, t_step)
 
 community_sizing_strategy = 'max_operational_profit'
 community_main.optimize_sizing(community_sizing_strategy)
-- 
GitLab