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 5, 2024
1 parent 76b0db8 commit 21975be
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 @@ -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)

Check warning on line 154 in assume/markets/clearing_algorithms/nodal_pricing.py

View check run for this annotation

Codecov / codecov/patch

assume/markets/clearing_algorithms/nodal_pricing.py#L151-L154

Added lines #L151 - L154 were not covered by tests

# 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)

Check warning on line 160 in assume/markets/clearing_algorithms/nodal_pricing.py

View check run for this annotation

Codecov / codecov/patch

assume/markets/clearing_algorithms/nodal_pricing.py#L159-L160

Added lines #L159 - L160 were not covered by tests

# 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)

Check warning on line 167 in assume/markets/clearing_algorithms/nodal_pricing.py

View check run for this annotation

Codecov / codecov/patch

assume/markets/clearing_algorithms/nodal_pricing.py#L167

Added line #L167 was not covered by tests

with suppress_output():
status, termination_condition = nodal_network.optimize(
Expand Down

0 comments on commit 21975be

Please sign in to comment.