Description
Currently, distributed slack is supported for the non-linear power flow (n.pf()) via the distribute_slack and slack_weights parameters. However, these parameters are nonexistent for linear power flow (n.lpf()).
If a network has an active power mismatch prior to running n.lpf(), the entire imbalance is absorbed by the single slack bus. This can produce unrealistic power flows radiating from a single node. While the original feature request for distributed slack (Issue #10) mentioned both lpf and pf, PR 107 only implemented it for the non-linear module. Currently, the only workaround for linear power flow is to manually calculate the system mismatch and adjust the generator p_set values before calling n.lpf(), a feature which can be added directly to the lpf() function through adding a distribute_slack and slack_weights parameters to the linear power flow functions, mimicking similar behavior found in pf().
Proposed Solution
Bring feature parity to n.lpf() by adding the distribute_slack (boolean) and slack_weights parameters to the linear power flow API, mimicking the behavior already present in n.pf().
- Update the function signatures for n.lpf(), pypsa.pf.network_lpf(), and pypsa.pf.sub_network_lpf() to accept distribute_slack=False and slack_weights=None as default keyword arguments.
- If distribute_slack=True, compute and allocate the total active power mismatch to the active power injections of generators based on the provided slack_weights (defaulting to proportional to p_set or p_nom, matching the n.pf() logic).
- Proceed with the standard DC power flow calculation
All of this can be done manually outside of PyPSA, but adding it as a feature would streamline my workflow. Curious if others would find this feature valuable. I am happy to open a PR to implement the feature if so.
Thanks!
Description
Currently, distributed slack is supported for the non-linear power flow (
n.pf()) via thedistribute_slackandslack_weightsparameters. However, these parameters are nonexistent for linear power flow (n.lpf()).If a network has an active power mismatch prior to running
n.lpf(), the entire imbalance is absorbed by the single slack bus. This can produce unrealistic power flows radiating from a single node. While the original feature request for distributed slack (Issue #10) mentioned bothlpfandpf, PR 107 only implemented it for the non-linear module. Currently, the only workaround for linear power flow is to manually calculate the system mismatch and adjust the generator p_set values before calling n.lpf(), a feature which can be added directly to thelpf()function through adding adistribute_slackandslack_weightsparameters to the linear power flow functions, mimicking similar behavior found inpf().Proposed Solution
Bring feature parity to n.lpf() by adding the distribute_slack (boolean) and slack_weights parameters to the linear power flow API, mimicking the behavior already present in n.pf().
All of this can be done manually outside of PyPSA, but adding it as a feature would streamline my workflow. Curious if others would find this feature valuable. I am happy to open a PR to implement the feature if so.
Thanks!