Skip to content

Commit

Permalink
refactor: calculate marginal cost via linearized quadratic (Breakthro…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen authored and FabianHofmann committed Mar 22, 2022
1 parent 91dc12b commit 98f3736
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion powersimdata/input/export_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"rename": {
"startup": "startup_cost",
"shutdown": "shutdown_cost",
"c1": "marginal_cost",
}
},
"branch": {
Expand Down Expand Up @@ -397,6 +396,12 @@ def export_to_pypsa(

gencost = grid.gencost["before"]
gencost = gencost.rename(columns=pypsa_const["cost"]["rename"])
# Linearize quadratic curves as applicable
fixed = grid.plant["Pmin"] == grid.plant["Pmax"]
linearized = gencost.loc[~fixed, "c1"] + gencost.loc[~fixed, "c2"] * (
grid.plant.loc[~fixed, "Pmax"] + grid.plant.loc[~fixed, "Pmin"]
)
gencost["marginal_cost"] = linearized.combine_first(gencost["c1"])
gencost = gencost[pypsa_const["cost"]["rename"].values()]

carriers = pd.DataFrame(index=generators.carrier.unique(), dtype=object)
Expand Down

0 comments on commit 98f3736

Please sign in to comment.