From 21975be0aa5f754c63e5d9b3cfecdf48f2ae6ac2 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Thu, 5 Dec 2024 09:54:25 +0100 Subject: [PATCH] not all columns did exist in p_max_pu of pypsa network --- .../clearing_algorithms/nodal_pricing.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/assume/markets/clearing_algorithms/nodal_pricing.py b/assume/markets/clearing_algorithms/nodal_pricing.py index 14b9b59b..89c127a1 100644 --- a/assume/markets/clearing_algorithms/nodal_pricing.py +++ b/assume/markets/clearing_algorithms/nodal_pricing.py @@ -147,11 +147,24 @@ def clear( nodal_network = self.network.copy() # Update p_max_pu for generators - nodal_network.generators_t.p_max_pu.update(p_max_pu) - nodal_network.generators_t.p_min_pu.update(p_min_pu) + # Also add new columns which did not yet exist in nodal_network.generators_t + df_p_max_pu = nodal_network.generators_t.p_max_pu + df_p_max_pu.update(p_max_pu) + new_columns = p_max_pu.loc[:,~p_max_pu.columns.isin(df_p_max_pu.columns)] + nodal_network.generators_t.p_max_pu = pd.concat([df_p_max_pu, new_columns], axis=1) + + # Update p_min_pu for generators + df_p_min_pu = nodal_network.generators_t.p_min_pu + df_p_min_pu.update(p_min_pu) + new_columns = p_min_pu.loc[:,~p_min_pu.columns.isin(df_p_min_pu.columns)] + nodal_network.generators_t.p_min_pu = pd.concat([df_p_min_pu, new_columns], axis=1) # Update marginal costs for generators - nodal_network.generators_t.marginal_cost.update(costs) + df_costs = nodal_network.generators_t.marginal_cost + df_costs.update(costs) + new_columns = costs.loc[:,~costs.columns.isin(df_costs.columns)] + nodal_network.generators_t.marginal_cost = pd.concat([df_costs, new_columns], axis=1) + with suppress_output(): status, termination_condition = nodal_network.optimize(