Constraint preventing simultaneous dispatch

66 views
Skip to first unread message

Matthew Smith

unread,
Mar 1, 2025, 6:35:02 AM3/1/25
to pypsa

Dear PyPSA community,

I have a network which has a PPA load and a generator simulating flexible demand (i.e. a market to sell excess power). I need to make a constraint that restricts the sale of power to flexible demand while the PPA load is not fulfilled. I’ve sketched out the network in the attached picture.

 Does anyone know how I can formulate this constraint? I can’t think of a mathematical way of constraining generation only when another generator is generating.

 Thanks for the help.

 Regards,

Matt

PyPSA constraint challenge.png

Priftis Konstantinos

unread,
Mar 2, 2025, 3:01:41 AM3/2/25
to Matthew Smith, pypsa

Hi Matt,

A constraint would be feasible but I don't think you really need one here. You would typically treat both the PPA and flexible demand as two demands with different fulfillment priority where the PPA is cheaper to fulfill. Examples to achieve this are either the generation costs of the flexible demand being higher or a tweak of the wheeling charges of the links.

-K


--
You received this message because you are subscribed to the Google Groups "pypsa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pypsa+un...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/pypsa/80a45c80-1447-4853-990b-5f032fc2c4b7n%40googlegroups.com.

Matthew Smith

unread,
Mar 2, 2025, 4:24:42 AM3/2/25
to Priftis Konstantinos, pypsa

Hi K,

Thanks for the response.

In some cases, this doesn't work. The PPA might have a lower price than the market sale, but have specific terms forbidding sale to the market during periods when the PPA is not fulfilled. There would be scenarios where the optimal decision would be to charge the ESS and discharge it to the market at a time when both the PPA load is being fully met and the market price is high.

Best regards,
Matt

Priftis Konstantinos

unread,
Mar 2, 2025, 8:06:43 AM3/2/25
to Matthew Smith, pypsa

Hi Matt,

Mathematically, you can do 100*Gflex_on <= X, where:

X is either the flow of the line to the PPA or the amount of demand the PPA consumes. I am not a PyPSA user but I assume you have access to those variables. You also need to run an integer optimisation since G_on needs to be a binary variable that turns the flex generator on or off (PyPsa should somehow give you access to that too).

Despite that, I would still not recommend this approach since it adds complexity to the model and I think you can achieve it via not using the real PPA price or meddling with the line usage costs.

Best Regards,
K

Matthew Smith

unread,
Mar 4, 2025, 4:15:18 PM3/4/25
to pypsa
Hi K,

Thank you for the solution. The drawback is that to get the Gflex_on (Generator-status) variable I need to solve the model with unit commitment; this increases the calculation time by 30x, and I need to use a rolling horizon optimisation. But still, better than no solution! Strangely the constraint fails when X is exactly 50, but I'm working through that.

I'm still trying to think of mathematical solutions which don't require unit commitment, i.e. just using the MW power flow variables Gflex_p and X.  These are much faster to solve. Are you aware of any resources or examples of mathematically novel ways of building constraints in Linopy? The education would help.

Ideally would like to solve it by meddling with line usage costs. But this PPA condition is quite binary. If any units are sold to the market while the PPA is not fulfilled, then the plant is charged a penalty. However, there is no penalty for underserving the PPA if no units are sold to the market. 

Best regards,
Matt

Reply all
Reply to author
Forward
0 new messages