Based on dAbr_dV.m from MATPOWER by Ray Zimmerman, developed at
        PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
        information.

        @rtype: tuple
        @return: The partial derivatives of the squared flow magnitudes w.r.t
                 voltage magnitude and voltage angle given the flows and flow
                 sensitivities. Flows could be complex current or complex or
                 real power.

def dAbr_dV(self, dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St):
        """ Based on dAbr_dV.m from MATPOWER by Ray Zimmerman, developed at
        PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
        information.

        @rtype: tuple
        @return: The partial derivatives of the squared flow magnitudes w.r.t
                 voltage magnitude and voltage angle given the flows and flow
                 sensitivities. Flows could be complex current or complex or
                 real power.
        """
        il = range(len(Sf))

        dAf_dPf = csr_matrix((2 * Sf.real, (il, il)))
        dAf_dQf = csr_matrix((2 * Sf.imag, (il, il)))
        dAt_dPt = csr_matrix((2 * St.real, (il, il)))
        dAt_dQt = csr_matrix((2 * St.imag, (il, il)))

        # Partial derivative of apparent power magnitude w.r.t voltage
        # phase angle.
        dAf_dVa = dAf_dPf * dSf_dVa.real + dAf_dQf * dSf_dVa.imag
        dAt_dVa = dAt_dPt * dSt_dVa.real + dAt_dQt * dSt_dVa.imag
        # Partial derivative of apparent power magnitude w.r.t. voltage
        # amplitude.
        dAf_dVm = dAf_dPf * dSf_dVm.real + dAf_dQf * dSf_dVm.imag
        dAt_dVm = dAt_dPt * dSt_dVm.real + dAt_dQt * dSt_dVm.imag

        return dAf_dVa, dAf_dVm, dAt_dVa, dAt_dVm