Skip to content

Commit

Permalink
not all columns did exist in p_max_pu of pypsa network
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Dec 6, 2024
1 parent 255a288 commit b20e36d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions assume/markets/clearing_algorithms/nodal_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,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(
Expand Down

0 comments on commit b20e36d

Please sign in to comment.