Skip to content

Intended behavior of global constraint "define_operational_limit"? #1024

@p-glaum

Description

@p-glaum

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 master branch 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.

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.
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions