You only need to use the add_constraints() function if you are using Callback Functions as described in Section 7.2 as opposed to Direct Specification as described in Section 7.1 of the User’s Manual <http://www.pserc.cornell.edu/matpower/docs/MATPOWER-manual-6.0.pdf>.
You convergence failure my just imply that your variable bounds are tight enough that there is no feasible solution. Try relaxing the limits and see if it converges. Vm, Pg and Qg all have limits specified directly in the bus and gen matrices. Vm is bounded by the VMIN and VMAX columns in the bus matrix. Pg and Qg are bounded by the PMIN, PMAX and QMIN, QMAX columns of the gen matrix, respectively. Va is not normally constrained (except at the reference bus), so the bus matrix doesn’t contain bounds for it. In that case, you have to use the standard linear constraints of equation (6.25) to impose bounds. At a lower lever, variable bounds are defined when variables are added via the add_vars() method. The Va, Vm, Pg and Qg variables are added automatically (with their bounds) in opf_setup(), so you can’t really modify them there. But for any variables you add later, you supply the bounds when you call add_vars(). Ray > On Oct 4, 2017, at 3:52 PM, Viswanath Hariharan <[email protected]> wrote: > > So I do not need to use the add_constraints function? Because when I used the > code you mentioned and then runopf(mpc), convergence fails. In general, how > to add box constraints for Va,Vm, Pg and Qg of xr (r = runopf(mpc); r.raw.xr). > If I have to use the add_constraints function, how do I do that? > > Regards > Viswanath Hariharan > > On Wed, Sep 27, 2017 at 1:39 PM, Ray Zimmerman <[email protected] > <mailto:[email protected]>> wrote: > Voltage magnitude constraints are already included. Simply set the VMIN and > VMAX columns in the bus matrix to the desired values. > > For voltage angles, simply define the A, l and u corresponding to equation > (6.25) in the User’s Manual > <http://www.pserc.cornell.edu/matpower/docs/MATPOWER-manual-6.0.pdf>. > Something like the following … > > mpc = loadcase(<your-case-name>); > nb = size(mpc.bus, 1); > ng = size(mpc.gen, 1); > mpc.A = sparse(1:nb, 1:nb, 1, nb > <https://maps.google.com/?q=1:nb,+1,+nb&entry=gmail&source=g>, 2*nb+2*ng); > mpc.u = 0.26 * ones(nb, 1); > mpc.u = -mpc.l; > > — Ray > > > >> On Sep 23, 2017, at 5:25 PM, Viswanath Hariharan <[email protected] >> <mailto:[email protected]>> wrote: >> >> Hello Sir >> >> I want to add voltage magnitude and voltage angle constraints to the >> opf solver but I am not able to figure out how to. >> >> Voltage magnitude constraints ---> 0.9 <= Vm <= 1.1 >> Voltage angle constraints ---> - 0.26 <= Va <= 0.26 (Unrelaxed form) >> >> I read a post where you mentioned to add these constraints to the case >> struct which looked pretty simple in the post but I didn't know how to add >> that to the case struct. >> I was wondering if you can guide me on how to do it. Hoping to hear from >> you soon. >> >> Regards >> Viswanath Hariharan >> Graduate Research Assistant >> Electrical Engineering >> University at Buffalo > >
