Skip to content

Commit

Permalink
First Version of Method for adjusting PtH2-Model with Multiple Links
Browse files Browse the repository at this point in the history
  • Loading branch information
lenzim97 committed Jan 16, 2025
1 parent d79eea9 commit bdc61bc
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions etrago/appl.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,69 @@ def run_etrago(args, json_path):

# import network from database
etrago.build_network_from_db()

def adjust_PtH2_model():

PtH2_links = etrago.network.links[etrago.network.links.carrier == "power_to_H2"].index
PtH2_AC_buses = etrago.network.buses.loc[etrago.network.links.loc[PtH2_links, "bus0"]].index.unique()

from itertools import count

# Zähler für neue Bus- und Store-IDs
next_bus_id = max(etrago.network.buses.index.astype(int)) + 1
next_store_id = max(etrago.network.stores.index.astype(int)) + 1
bus_id_counter = count(start=next_bus_id)
store_id_counter = count(start=next_store_id)

# Iteriere durch alle relevanten Busse
for bus in PtH2_AC_buses:
# Links für den aktuellen Bus
power_to_h2_links = etrago.network.links[
(etrago.network.links.carrier == "power_to_H2") & (etrago.network.links.bus0 == bus)].index
power_to_heat_links = etrago.network.links[
(etrago.network.links.carrier == "power_to_Heat") & (etrago.network.links.bus0 == bus)].index
power_to_o2_links = etrago.network.links[
(etrago.network.links.carrier == "power_to_O2") & (etrago.network.links.bus0 == bus)].index

link_data = []
if len(power_to_heat_links) > 0:
link_data.append({"links": power_to_heat_links, "efficiency": 0.2, "carrier": "waste_heat"})
if len(power_to_o2_links) > 0:
link_data.append({"links": power_to_o2_links, "efficiency": 0.015, "carrier": "O2"})

for idx, data in enumerate(link_data, start=2):
links = data["links"]
efficiency = data["efficiency"]
carrier = data["carrier"]
new_bus_id = next(bus_id_counter)
new_store_id = next(store_id_counter)

# Füge neuen Heat-Bus und Store hinzu
etrago.network.add("Bus", name=new_bus_id, carrier=f"PtH2_extra_bus_{carrier}")
etrago.network.add(
"Store",
name=new_store_id,
bus=new_bus_id,
carrier=f"PtH2_{carrier}",
e_nom_extendable=True,
e_nom=100000,
marginal_cost=0,
capital_cost=0,
e_cyclic=False,
standing_loss=1
)
etrago.network.stores.loc[str(new_store_id), "scn_name"] = args["scn_name"]

# Aktualisiere den Multiple Link mit dem neuen Heat-Bus
etrago.network.links.loc[power_to_h2_links, f"bus{idx}"] = str(new_bus_id)
etrago.network.links.loc[power_to_h2_links, f"efficiency{idx}"] = efficiency

# Erstelle individuelle Links vom neuen Heat-Bus zu den Ziel-Bussen
for link in links:
etrago.network.links.loc[link, "bus0"] = str(new_bus_id)


adjust_PtH2_model()

# adjust network regarding eTraGo setting
etrago.adjust_network()
Expand Down

0 comments on commit bdc61bc

Please sign in to comment.