Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pypower/opf_costfcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def opf_costfcn(x, om, return_hessian=False):

## polynomial cost of P and Q
df_dPgQg = zeros(2 * ng) ## w.r.t p.u. Pg and Qg
df_dPgQg[ipol] = baseMVA * polycost(gencost[ipol, :], xx[ipol], 1)
if len(ipol):
df_dPgQg[ipol] = baseMVA * polycost(gencost[ipol, :], xx[ipol], 1)
df = zeros(nxyz)
df[iPg] = df_dPgQg[:ng]
df[iQg] = df_dPgQg[ng:ng + ng]
Expand Down
5 changes: 3 additions & 2 deletions pypower/opf_hessfcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ def opf_hessfcn(x, lmbda, om, Ybus, Yf, Yt, ppopt, il=None, cost_mult=1.0):
d2f_dPg2 = zeros(ng)#sparse((ng, 1)) ## w.r.t. p.u. Pg
d2f_dQg2 = zeros(ng)#sparse((ng, 1)) ## w.r.t. p.u. Qg
ipolp = find(pcost[:, MODEL] == POLYNOMIAL)
d2f_dPg2[ipolp] = \
if len(ipol):
d2f_dPg2[ipolp] = \
baseMVA**2 * polycost(pcost[ipolp, :], Pg[ipolp] * baseMVA, 2)
if any(qcost): ## Qg is not free
if qcost.any(): ## Qg is not free
ipolq = find(qcost[:, MODEL] == POLYNOMIAL)
d2f_dQg2[ipolq] = \
baseMVA**2 * polycost(qcost[ipolq, :], Qg[ipolq] * baseMVA, 2)
Expand Down