def d2ASbr_dV2(dSbr_dVa, dSbr_dVm, Sbr, Cbr, Ybr, V, lam):
    """ Computes 2nd derivatives of |complex power flow|**2 w.r.t. V.
    """
    diaglam = spdiag(lam)
    diagSbr_conj = spdiag(conj(Sbr))

    Saa, Sav, Sva, Svv = d2Sbr_dV2(Cbr, Ybr, V, diagSbr_conj * lam)

    Haa = 2 * ( Saa + dSbr_dVa.T * diaglam * conj(dSbr_dVa) ).real()
    Hva = 2 * ( Sva + dSbr_dVm.T * diaglam * conj(dSbr_dVa) ).real()
    Hav = 2 * ( Sav + dSbr_dVa.T * diaglam * conj(dSbr_dVm) ).real()
    Hvv = 2 * ( Svv + dSbr_dVm.T * diaglam * conj(dSbr_dVm) ).real()

    return Haa, Hav, Hva, Hvv
def d2ASbr_dV2 ( dSbr_dVa , dSbr_dVm , Sbr , Cbr , Ybr , V , lam ) : diaglam = spdiag ( lam ) diagSbr_conj = spdiag ( conj ( Sbr ) ) Saa , Sav , Sva , Svv = d2Sbr_dV2 ( Cbr , Ybr , V , diagSbr_conj * lam ) Haa = 2 * ( Saa + dSbr_dVa . T * diaglam * conj ( dSbr_dVa ) ) . real ( ) Hva = 2 * ( Sva + dSbr_dVm . T * diaglam * conj ( dSbr_dVa ) ) . real ( ) Hav = 2 * ( Sav + dSbr_dVa . T * diaglam * conj ( dSbr_dVm ) ) . real ( ) Hvv = 2 * ( Svv + dSbr_dVm . T * diaglam * conj ( dSbr_dVm ) ) . real ( ) return Haa , Hav , Hva , Hvv
Computes 2nd derivatives of |complex power flow|**2 w.r.t. V.