PyPSA icon indicating copy to clipboard operation
PyPSA copied to clipboard

Unable to add extra constrains

Open martynvandijke opened this issue 9 years ago • 4 comments

Hi,

I want to add more constrains to the linear optimal Power Flow network.lopf(snapshots=network.snapshots,extra_functionality=constrains,keep_files=True) My constraints function looks like

def constrains():
         network = Constraint( (network.generators.p_min_pu * network.generators.p_nom ) <= network.generators.p_nom )

The constrained is not reflected in the optimisation process does anyone know what i am doing wrong ?

martynvandijke avatar Mar 07 '17 13:03 martynvandijke

For (volunteer-run) support, please use the mailing list. See https://pypsa.org/doc/optimal_power_flow.html#custom-constraints-and-other-functionality for a brief description of the custom constraints functionality, look at the examples linked there and look in the code in pypsa/opf.py for the variable names. For example, it should be e.g. network.model = Constraint(network.generators.loc[gen_name,"p_min_pu"]*network.model.generator_p_nom[gen_name] <= some_constant).

nworbmot avatar Mar 07 '17 15:03 nworbmot

def constraint(network, snapshots): network.model.constraint_name = Constraint(network.generators.loc[gen_name,"p_min_pu"]*network.model.generator_p_nom[gen_name] <= some_constant)

to be precise.

coroa avatar Mar 07 '17 17:03 coroa

Thank you for your answers, this indeed works. I am still struggling to limit the to be calculated optimised power to a number

network.model.constraint_name = Constraint( network.generators.loc[gen_name, "p_nom_opt"] > constant )

Any ideas how to accomplish this ?

martynvandijke avatar Mar 08 '17 09:03 martynvandijke

Please use the mailing-list for support: https://groups.google.com/group/pypsa

coroa avatar Mar 08 '17 09:03 coroa