Hi Tobie,
to model if-else relations, you will need the binary status variable of
a committable generator:
https://pypsa.readthedocs.io/en/latest/optimal_power_flow.html#generator-unit-commitment-constraints
You could multiply this status variable with the gap between dispatch
and capacity for each generator.
Beware, this makes your problem nonconvex, and therefore much more
computationally challenging.
You won't be able to retrieve the variable value before the problem is
solved.
Hope this helps,
Fabian
On 15/06/2020 16:02, Tobie Nortje wrote:
> HI,
>
> We have this piece of code that adds a Reserve Margin Constraint to the
> model. in this instance the GeneratorSize minus its current operating
> power should be bigger than 100MW. This works fine and if we add other
> generators we get the exact behaviour we think it should. Basically
> whatever is left from a generation capacity is available to the
> 'reserve' market. (in this toy case)
>
> BUT - and sorry - this is a repeat question:
>
> *We only want a generator (Gen_x) to contribute its excess power to the
> reserve margin IF it was running at this snapshot.*
>
> I have tried to get the value of model.generator_p but it is a
> constraint. I read the docs and found that wrapping it in
> value(model.generator_p['gen1', i]) could work but still an error.
>
> *So in the below example. If only Gen1 was generating power (p>0) and
> Gen2 was not(p=0) then only the Gen1 extra capacity is available to the
> system for 'reserve'*
>
> I am sure it is a simple solution but it has been eluding us for a
> couple of weeks now!
>
> In other words. How to i get access to the value of
> *model.generator_p["Gen1", i**] */so that i can do some if-then-else
> operations with it at every snapshot point. /
>
>
> def extra_functionality(network, snapshots):
> def reserve_market_1(model, i):
> return (network.generators.p_nom['Gen1'] -model.generator_p["Gen1", i]) +\
>
> (network.generators.p_nom['Gen2'] -model.generator_p["Gen2", i]) >= 100
>
> network.model.reserve_market = Constraint(list(snapshots), rule=reserve_market_1)
>
> --
> 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
> <mailto:
pypsa+un...@googlegroups.com>.
> To view this discussion on the web, visit
>
https://groups.google.com/d/msgid/pypsa/30872225-562a-4484-b860-97079aa92c5fo%40googlegroups.com
> <
https://groups.google.com/d/msgid/pypsa/30872225-562a-4484-b860-97079aa92c5fo%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Karlsruhe Institute of Technology (KIT)
Institute for Automation and Applied Informatics (IAI)
Fabian NEUMANN (he/him)
PhD Student in Energy System Modelling
Phone:
+49 721 608 25707 | Mobile:
+49 171 2943831 |
Group:
www.iai.kit.edu/english/esm.php | Personal: www.neumann.fyi |
Github: @fneum | Twitter: @fneum_
Learn about nearly-optimal power system models:
https://arxiv.org/abs/1910.01891
KIT Campus North, Building 445, Office 304
Hermann-von-Helmholtz-Platz 1
76344 Eggenstein-Leopoldshafen
KIT – The Research University in the Helmholtz Association