-
Notifications
You must be signed in to change notification settings - Fork 624
Description
Version Checks (indicate both or one)
-
I have confirmed this bug exists on the lastest release of PyPSA.
-
I have confirmed this bug exists on the current
masterbranch of PyPSA.
Issue Description
In the global constraint for the operational limit, for stores we do not consider the carrier of the store itself, but the carrier of the bus the store is attached to.
PyPSA/pypsa/optimization/global_constraints.py
Lines 372 to 375 in b1567f7
| bus_carrier = n.stores.bus.map(n.buses.carrier) # noqa: F841 | |
| stores = n.stores.query( | |
| "@bus_carrier == @glc.carrier_attribute and not e_cyclic" | |
| ) |
For generators and storage_units, however, we consider the carrier of the generator/storage_unit and not of the bus it is attached to.
PyPSA/pypsa/optimization/global_constraints.py
Lines 354 to 369 in b1567f7
| gens = n.generators.query("carrier == @glc.carrier_attribute") | |
| if not gens.empty: | |
| p = m["Generator-p"].loc[snapshots, gens.index] | |
| w = DataArray(weightings.generators[snapshots]) | |
| if "dim_0" in w.dims: | |
| w = w.rename({"dim_0": "snapshot"}) | |
| expr = (p * w).sum() | |
| lhs.append(expr) | |
| sus = n.storage_units.query(cond) | |
| if not sus.empty: | |
| sus_i = sus.index | |
| soc = m["StorageUnit-state_of_charge"].loc[snapshots, sus_i] | |
| soc = soc.ffill("snapshot").isel(snapshot=-1) | |
| lhs.append(-1 * soc.sum()) | |
| rhs -= sus.state_of_charge_initial.sum() |
Not sure if this is wanted. In the documentation about Stores, it just says the carrier is the carrier of the store, but it does not say that this has to have the same carrier as the bus carrier.
I think I would change the way, how the global constraint is defined for the stores that, similarly to the generators, we just look at the carrier of the store instead of the bus carrier. On the other hand, I am not sure whether this change would break anything else or might be a breaking change for some people.
Reproducible Example
No response
Expected Behavior
No response
Installed Versions
Details
Replace this line.