def d2AIbr_dV2(dIbr_dVa, dIbr_dVm, Ibr, Ybr, V, lam):
    """ Computes 2nd derivatives of |complex current|**2 w.r.t. V.
    """
    diaglam = spdiag(lam)
    diagIbr_conj = spdiag(conj(Ibr))

    Iaa, Iav, Iva, Ivv = d2Ibr_dV2(Ybr, V, diagIbr_conj * lam)

    Haa = 2 * ( Iaa + dIbr_dVa.T * diaglam * conj(dIbr_dVa) ).real()
    Hva = 2 * ( Iva + dIbr_dVm.T * diaglam * conj(dIbr_dVa) ).real()
    Hav = 2 * ( Iav + dIbr_dVa.T * diaglam * conj(dIbr_dVm) ).real()
    Hvv = 2 * ( Ivv + dIbr_dVm.T * diaglam * conj(dIbr_dVm) ).real()

    return Haa, Hav, Hva, Hvv
def d2AIbr_dV2 ( dIbr_dVa , dIbr_dVm , Ibr , Ybr , V , lam ) : diaglam = spdiag ( lam ) diagIbr_conj = spdiag ( conj ( Ibr ) ) Iaa , Iav , Iva , Ivv = d2Ibr_dV2 ( Ybr , V , diagIbr_conj * lam ) Haa = 2 * ( Iaa + dIbr_dVa . T * diaglam * conj ( dIbr_dVa ) ) . real ( ) Hva = 2 * ( Iva + dIbr_dVm . T * diaglam * conj ( dIbr_dVa ) ) . real ( ) Hav = 2 * ( Iav + dIbr_dVa . T * diaglam * conj ( dIbr_dVm ) ) . real ( ) Hvv = 2 * ( Ivv + dIbr_dVm . T * diaglam * conj ( dIbr_dVm ) ) . real ( ) return Haa , Hav , Hva , Hvv
Computes 2nd derivatives of |complex current|**2 w.r.t. V.