Unable to add extra constrains
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 ?
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).
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.
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 ?
Please use the mailing-list for support: https://groups.google.com/group/pypsa