You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am trying to use the eTraGo data (from the openenergy db) directly in PyPSA. However, the linear powerflow analysis always yields me a bunch of heavily overloaded lines (every 100th-200th line, many over 200%). This happens regardless of the scenario; the consistency check gives no further information.
These are exemplary plots for 24h:
I have no idea where I went wrong, do you have any idea how to figure out this issue? I would very much appreciate any help!
This is my code:
# pylint: disable=no-memberimportpypsaimportfilter_egoasfeimportpandasaspdimportnumpyasnpfromwarningsimportsimplefiltersimplefilter(action="ignore", category=pd.errors.PerformanceWarning)
# set reference coordinate systemnetwork=pypsa.Network(crs=4326)
df_line=fe.df_line.reset_index(drop=True)
df_bus=fe.df_bus.reset_index(drop=True)
df_gen=fe.df_gen.reset_index(drop=True)
df_gen_pq=fe.df_gen_pq.reset_index(drop=True)
df_load=fe.df_load.reset_index(drop=True)
df_load_pq=fe.df_load_pq.reset_index(drop=True)
df_trans=fe.df_trans.reset_index(drop=True)
df_store=fe.df_store.reset_index(drop=True)
# Create the date rangedefget_date_range(x):
ifx==None:
returnpd.date_range('2023-01-01', periods=1, freq="YE")
ifisinstance(x, np.float64):
returnpd.date_range('2023-01-01', periods=1, freq="YE")
assertlen(x) in [8760, 17520, 26280], len(x)
freq= (365*24*60) /len(x)
returnpd.date_range('2023-01-01', periods=len(x), freq="{}min".format(freq))
# Set time points for solution# CAUTION! Input is ignored if not relevant for snapshotssnapshots=pd.date_range('2023-01-01', periods=365*24, freq='h')
network.set_snapshots(snapshots)
fori, rowindf_bus.iterrows():
network.add(
"Bus",
"My bus {}".format(i),
v_nom=row["v_nom"],
carrier=row["current_type"],
v_mag_pu_min=row["v_mag_pu_min"],
v_mag_pu_max=row["v_mag_pu_max"],
x=row["geom"].x,
y=row["geom"].y
)
fori, rowindf_line.iterrows():
network.add(
"Line",
"My line {}".format(i),
bus0="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus0"]].index[0]),
bus1="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus1"]].index[0]),
x=row["x"],
r=row["r"],
g=row["g"],
b=row["b"],
s_nom=row["s_nom"],
s_nom_extendable=row["s_nom_extendable"],
s_nom_min=row["s_nom_min"],
s_nom_max=row["s_nom_max"],
length=row["length"],
terrain_factor=row["terrain_factor"],
)
network.lines.loc[
network.lines.r==0, "r"
] =0.0001print("Set gens:")
fori, rowindf_gen.iterrows():
x_p=df_gen_pq[df_gen_pq["generator_id"] ==row["generator_id"]]["p_set"].iloc[0]
x_q=df_gen_pq[df_gen_pq["generator_id"] ==row["generator_id"]]["q_set"].iloc[0]
network.add(
"Generator",
"My gen {}".format(i),
bus="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus"]].index[0]),
p_set=pd.Series(x_p, index=get_date_range(x_p)),
q_set=pd.Series(x_q, index=get_date_range(x_q)),
control=row["control"],
p_nom=row["p_nom"],
p_nom_extendable=row["p_nom_extendable"],
p_nom_min=row["p_nom_min"],
p_nom_max=row["p_nom_max"],
p_min_pu=row["p_min_pu_fixed"],
p_max_pu=row["p_max_pu_fixed"],
sign=row["sign"],
)
print("Set loads:")
fori, rowindf_load.iterrows():
x_p=df_load_pq[df_load_pq["load_id"] ==row["load_id"]]["p_set"].iloc[0]
x_q=df_load_pq[df_load_pq["load_id"] ==row["load_id"]]["q_set"].iloc[0]
network.add(
"Load",
"My load {}".format(i),
bus="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus"]].index[0]),
p_set=pd.Series(x_p, index=get_date_range(x_p)),
q_set=pd.Series(x_q, index=get_date_range(x_q)),
sign=row["sign"]
)
fori, rowindf_trans.iterrows():
network.add(
"Transformer",
"My transformer {}".format(i),
bus0="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus0"]].index[0]),
bus1="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus1"]].index[0]),
x=row["x"],
r=row["r"],
g=row["g"],
b=row["b"],
s_nom=row["s_nom"],
s_nom_extendable=row["s_nom_extendable"],
s_nom_min=row["s_nom_min"],
s_nom_max=row["s_nom_max"],
tap_ratio=row["tap_ratio"],
phase_shift=row["phase_shift"]
)
# Set resistance of transformersnetwork.transformers.loc[
network.transformers.r==0, "r"
] =0.0001# Set vnom of transformersnetwork.transformers["v_nom"] =network.buses.loc[
network.transformers.bus0.values, "v_nom"
].valuesfori, rowindf_store.iterrows():
network.add(
"StorageUnit",
"My storage {}".format(i),
bus="My bus {}".format(df_bus[df_bus["bus_id"] ==row["bus"]].index[0]),
# former_dispatch=row["dispatch"], # I think this means yes or no time-seriescontrol=row["control"],
sign=row["sign"],
p_nom=row["p_nom"],
p_nom_extendable=row["p_nom_extendable"],
p_nom_min=row["p_nom_min"],
p_nom_max=row["p_nom_max"],
p_min_pu=row["p_min_pu_fixed"],
p_max_pu=row["p_max_pu_fixed"],
state_of_charge_initial=row["soc_initial"],
max_hours=row["max_hours"],
standing_loss=row["standing_loss"],
efficiency_store=row["efficiency_store"],
efficiency_dispatch=row["efficiency_dispatch"],
cyclic_state_of_charge=row["soc_cyclic"]
)
The text was updated successfully, but these errors were encountered:
Hi, I am trying to use the eTraGo data (from the openenergy db) directly in PyPSA. However, the linear powerflow analysis always yields me a bunch of heavily overloaded lines (every 100th-200th line, many over 200%). This happens regardless of the scenario; the consistency check gives no further information.
These are exemplary plots for 24h:
I have no idea where I went wrong, do you have any idea how to figure out this issue? I would very much appreciate any help!
This is my code:
The text was updated successfully, but these errors were encountered: