Java Code Examples for org.apache.commons.math3.complex.Complex#subtract()

The following examples show how to use org.apache.commons.math3.complex.Complex#subtract() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinkData.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
static BranchAdmittanceMatrix kronChain(Complex yFirstConnected11, Complex yFirstConnected12,
    Complex yFirstConnected21, Complex yFirstConnected22, Complex ySecondConnected11,
    Complex ySecondConnected12, Complex ySecondConnected21, Complex ySecondConnected22) {
    BranchAdmittanceMatrix admittance = new BranchAdmittanceMatrix();

    admittance.y11 = yFirstConnected11.subtract(yFirstConnected21.multiply(yFirstConnected12)
        .divide(yFirstConnected22.add(ySecondConnected22)));
    admittance.y12 = ySecondConnected21.multiply(yFirstConnected12)
        .divide(yFirstConnected22.add(ySecondConnected22)).negate();
    admittance.y21 = yFirstConnected21.multiply(ySecondConnected12)
        .divide(yFirstConnected22.add(ySecondConnected22)).negate();
    admittance.y22 = ySecondConnected11.subtract(
        ySecondConnected21.multiply(ySecondConnected12).divide(yFirstConnected22.add(ySecondConnected22)));

    return admittance;
}
 
Example 2
Source File: SV.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
public SV otherSide(double r, double x, double g, double b, double ratio) {
    Complex z = new Complex(r, x); // z=r+jx
    Complex y = new Complex(g, b); // y=g+jb
    Complex s1 = new Complex(p, q); // s1=p1+jq1
    Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a));
    Complex v1 = u1.divide(Math.sqrt(3f)); // v1=u1/sqrt(3)

    Complex v1p = v1.multiply(ratio); // v1p=v1*rho
    Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1))
    Complex i1p = i1.divide(ratio); // i1p=i1/rho
    Complex i2 = i1p.subtract(y.multiply(v1p)); // i2=i1p-y*v1p
    Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2
    Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2)

    Complex u2 = v2.multiply(Math.sqrt(3f));
    return new SV(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument()));
}
 
Example 3
Source File: SV.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
public SV otherSide(double r, double x, double g1, double b1, double g2, double b2, double ratio) {
    Complex z = new Complex(r, x); // z=r+jx
    Complex y1 = new Complex(g1, b1); // y1=g1+jb1
    Complex y2 = new Complex(g2, b2); // y2=g2+jb2
    Complex s1 = new Complex(p, q); // s1=p1+jq1
    Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a));
    Complex v1 = u1.divide(Math.sqrt(3f)); // v1=u1/sqrt(3)

    Complex v1p = v1.multiply(ratio); // v1p=v1*rho
    Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1))
    Complex i1p = i1.divide(ratio); // i1p=i1/rho
    Complex i2p = i1p.subtract(y1.multiply(v1p)); // i2p=i1p-y1*v1p
    Complex v2 = v1p.subtract(z.multiply(i2p)); // v2p=v1p-z*i2
    Complex i2 = i2p.subtract(y2.multiply(v2)); // i2=i2p-y2*v2
    Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2)

    Complex u2 = v2.multiply(Math.sqrt(3f));
    return new SV(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument()));
}
 
Example 4
Source File: LinkData.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
static Complex kronAntenna(Complex y11, Complex y12, Complex y21, Complex y22, boolean isOpenFrom) {
    Complex ysh = Complex.ZERO;

    if (isOpenFrom) {
        if (!y11.equals(Complex.ZERO)) {
            ysh = y22.subtract(y21.multiply(y12).divide(y11));
        }
    } else {
        if (!y22.equals(Complex.ZERO)) {
            ysh = y11.subtract(y12.multiply(y21).divide(y22));
        }
    }
    return ysh;
}
 
Example 5
Source File: TransformerModel.java    From ipst with Mozilla Public License 2.0 5 votes vote down vote up
public StateVariable toSv2(StateVariable sv1) {
    Complex s1 = new Complex(-sv1.p, -sv1.q); // s1=p1+jq1
    Complex u1 = ComplexUtils.polar2Complex(sv1.u, Math.toRadians(sv1.theta));
    Complex v1 = u1.divide(SQUARE_3); // v1=u1/sqrt(3)
    Complex v1p = v1.multiply(ratio); // v1p=v1*rho
    Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1))
    Complex i1p = i1.divide(ratio); // i1p=i1/rho
    Complex i2 = i1p.subtract(y.multiply(v1p)).negate(); // i2=-(i1p-y*v1p)
    Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2
    Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2)
    Complex u2 = v2.multiply(SQUARE_3);
    return new StateVariable(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument()));
}