Fix EQ constraint in case no hydro exist

This commit is contained in:
Max Parzen 2022-12-16 11:00:39 +00:00 committed by GitHub
parent bc8ac24c33
commit 9e61e30ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,18 +216,21 @@ def add_EQ_constraints(n, o, scaling=1e-1):
.T.groupby(ggrouper, axis=1) .T.groupby(ggrouper, axis=1)
.apply(join_exprs) .apply(join_exprs)
) )
lhs_spill = ( if not n.storage_units_t.inflow.empty:
linexpr( lhs_spill = (
( linexpr(
-n.snapshot_weightings.stores * scaling, (
get_var(n, "StorageUnit", "spill").T, -n.snapshot_weightings.stores * scaling,
get_var(n, "StorageUnit", "spill").T,
)
) )
.T.groupby(sgrouper, axis=1)
.apply(join_exprs)
) )
.T.groupby(sgrouper, axis=1) lhs_spill = lhs_spill.reindex(lhs_gen.index).fillna("")
.apply(join_exprs) lhs = lhs_gen + lhs_spill
) else:
lhs_spill = lhs_spill.reindex(lhs_gen.index).fillna("") lhs = lhs_gen
lhs = lhs_gen + lhs_spill
define_constraints(n, lhs, ">=", rhs, "equity", "min") define_constraints(n, lhs, ">=", rhs, "equity", "min")