From 9e61e30ff45a13da92dbce2f0c7f69721d480e99 Mon Sep 17 00:00:00 2001 From: Max Parzen Date: Fri, 16 Dec 2022 11:00:39 +0000 Subject: [PATCH] Fix EQ constraint in case no hydro exist --- scripts/solve_network.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/solve_network.py b/scripts/solve_network.py index d1331b0d..575cd078 100755 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -216,18 +216,21 @@ def add_EQ_constraints(n, o, scaling=1e-1): .T.groupby(ggrouper, axis=1) .apply(join_exprs) ) - lhs_spill = ( - linexpr( - ( - -n.snapshot_weightings.stores * scaling, - get_var(n, "StorageUnit", "spill").T, + if not n.storage_units_t.inflow.empty: + lhs_spill = ( + linexpr( + ( + -n.snapshot_weightings.stores * scaling, + get_var(n, "StorageUnit", "spill").T, + ) ) + .T.groupby(sgrouper, axis=1) + .apply(join_exprs) ) - .T.groupby(sgrouper, axis=1) - .apply(join_exprs) - ) - lhs_spill = lhs_spill.reindex(lhs_gen.index).fillna("") - lhs = lhs_gen + lhs_spill + lhs_spill = lhs_spill.reindex(lhs_gen.index).fillna("") + lhs = lhs_gen + lhs_spill + else: + lhs = lhs_gen define_constraints(n, lhs, ">=", rhs, "equity", "min")