/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients polynomial coefficients * @param initial start value * @param maxEval maximum number of evaluations * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.5 */ public Complex[] solveAllComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
public void design() { reset(); double n2 = 2 * nPoles; int pairs = nPoles / 2; for (int i = 0; i < pairs; ++i) { Complex c = ComplexUtils.polar2Complex(1F, Math.PI/2.0 + (2 * i + 1) * Math.PI / n2); addPoleZeroConjugatePairs(c, Complex.INF); } if ((nPoles & 1) == 1) add(new Complex(-1), Complex.INF); } }
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())); }
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())); }
/** * Find a complex root for the polynomial with the given coefficients, * starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients polynomial coefficients * @param initial start value * @param maxEval maximum number of evaluations * @return a complex root of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.1 */ public Complex solveComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solve(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
public Complex response(double normalizedFrequency) { double a0 = getA0(); double a1 = getA1(); double a2 = getA2(); double b0 = getB0(); double b1 = getB1(); double b2 = getB2(); double w = 2 * Math.PI * normalizedFrequency; Complex czn1 = ComplexUtils.polar2Complex(1., -w); Complex czn2 = ComplexUtils.polar2Complex(1., -2 * w); Complex ch = new Complex(1); Complex cbot = new Complex(1); Complex ct = new Complex(b0 / a0); Complex cb = new Complex(1); ct = MathSupplement.addmul(ct, b1 / a0, czn1); ct = MathSupplement.addmul(ct, b2 / a0, czn2); cb = MathSupplement.addmul(cb, a1 / a0, czn1); cb = MathSupplement.addmul(cb, a2 / a0, czn2); ch = ch.multiply(ct); cbot = cbot.multiply(cb); return ch.divide(cbot); }
public double laguerre(double lo, double hi, double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
public StateVariable toSv1(StateVariable sv2) { Complex s2 = new Complex(-sv2.p, -sv2.q); // s2=p2+jq2 Complex u2 = ComplexUtils.polar2Complex(sv2.u, Math.toRadians(sv2.theta)); Complex v2 = u2.divide(SQUARE_3); // v2=u2/sqrt(3) Complex i2 = s2.divide(v2.multiply(3)).conjugate(); // i2=conj(s2/(3*v2)) Complex v1p = v2.add(z.multiply(i2)); // v1'=v2+z*i2 Complex i1p = i2.negate().add(y.multiply(v1p)); // i1'=-i2+v1'*y Complex i1 = i1p.multiply(ratio); // i1=i1p*ration Complex v1 = v1p.divide(ratio); // v1=v1p/ration Complex s1 = v1.multiply(3).multiply(i1.conjugate()); // s1=3*v1*conj(i1) Complex u1 = v1.multiply(SQUARE_3); return new StateVariable(-s1.getReal(), -s1.getImaginary(), u1.abs(), Math.toDegrees(u1.getArgument())); }
/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients polynomial coefficients * @param initial start value * @param maxEval maximum number of evaluations * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.5 */ public Complex[] solveAllComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
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())); }
/** * Find a complex root for the polynomial with the given coefficients, * starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients polynomial coefficients * @param initial start value * @param maxEval maximum number of evaluations * @return a complex root of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.1 */ public Complex solveComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solve(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
public Complex response(double normalizedFrequency) { double w = 2 * Math.PI * normalizedFrequency; Complex czn1 = ComplexUtils.polar2Complex(1., -w); Complex czn2 = ComplexUtils.polar2Complex(1., -2 * w); Complex ch = new Complex(1); Complex cbot = new Complex(1); for (int i = 0; i < m_numBiquads; i++) { Biquad stage = m_biquads[i]; Complex cb = new Complex(1); Complex ct = new Complex(stage.getB0() / stage.getA0()); ct = MathSupplement.addmul(ct, stage.getB1() / stage.getA0(), czn1); ct = MathSupplement.addmul(ct, stage.getB2() / stage.getA0(), czn2); cb = MathSupplement.addmul(cb, stage.getA1() / stage.getA0(), czn1); cb = MathSupplement.addmul(cb, stage.getA2() / stage.getA0(), czn2); ch = ch.multiply(ct); cbot = cbot.multiply(cb); } return ch.divide(cbot); }
/** * Find a complex root for the polynomial with the given coefficients, * starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients polynomial coefficients * @param initial start value * @param maxEval maximum number of evaluations * @return a complex root of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.1 */ public Complex solveComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solve(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
Complex y1 = new Complex(g1, b1); Complex y2 = new Complex(g2, b2); Complex a1 = ComplexUtils.polar2Complex(1 / rho1, -alpha1); Complex a2 = ComplexUtils.polar2Complex(1 / rho2, -alpha2); Complex a1cc = a1.conjugate(); Complex a2cc = a2.conjugate(); computedTheta1 = theta1; } else { Complex v2 = ComplexUtils.polar2Complex(u2, theta2); Complex v1 = v2.multiply(ytr.divide(a1cc.multiply(a2)).multiply(a1cc.multiply(a1).divide(ytr.add(y1)))); computedU1 = v1.abs(); computedTheta2 = theta2; } else { Complex v1 = ComplexUtils.polar2Complex(u1, theta1); Complex v2 = v1.multiply(ytr.divide(a2cc.multiply(a1)).multiply(a2cc.multiply(a2).divide(ytr.add(y2)))); computedU2 = v2.abs(); Complex v1 = ComplexUtils.polar2Complex(computedU1, computedTheta1); Complex v2 = ComplexUtils.polar2Complex(computedU2, computedTheta2);
/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients polynomial coefficients * @param initial start value * @param maxEval maximum number of evaluations * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.5 */ public Complex[] solveAllComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
public static Complex calcStarVoltage(ThreeWindingsTransformer twt, double ratedU0) { Objects.requireNonNull(twt); Complex v1 = ComplexUtils.polar2Complex(getV(twt.getLeg1()), getTheta(twt.getLeg1())); Complex v2 = ComplexUtils.polar2Complex(getV(twt.getLeg2()), getTheta(twt.getLeg2())); Complex v3 = ComplexUtils.polar2Complex(getV(twt.getLeg3()), getTheta(twt.getLeg3())); Complex ytr1 = new Complex(twt.getLeg1().getR(), twt.getLeg1().getX()).reciprocal(); Complex ytr2 = new Complex(adjustedR(twt.getLeg2()), adjustedX(twt.getLeg2())).reciprocal(); Complex ytr3 = new Complex(adjustedR(twt.getLeg3()), adjustedX(twt.getLeg3())).reciprocal(); Complex a01 = new Complex(1, 0); Complex a1 = new Complex(twt.getLeg1().getRatedU() / ratedU0, 0); Complex a02 = new Complex(1, 0); Complex a2 = new Complex(1 / rho(twt.getLeg2(), ratedU0), 0); Complex a03 = new Complex(1, 0); Complex a3 = new Complex(1 / rho(twt.getLeg3(), ratedU0), 0); // IIDM model includes admittance to ground at star bus side in Leg1 Complex ysh01 = new Complex(twt.getLeg1().getG(), twt.getLeg1().getB()); Complex ysh02 = new Complex(0, 0); Complex ysh03 = new Complex(0, 0); Complex y01 = ytr1.negate().divide(a01.conjugate().multiply(a1)); Complex y02 = ytr2.negate().divide(a02.conjugate().multiply(a2)); Complex y03 = ytr3.negate().divide(a03.conjugate().multiply(a3)); Complex y0101 = ytr1.add(ysh01).divide(a01.conjugate().multiply(a01)); Complex y0202 = ytr2.add(ysh02).divide(a02.conjugate().multiply(a02)); Complex y0303 = ytr3.add(ysh03).divide(a03.conjugate().multiply(a03)); return y01.multiply(v1).add(y02.multiply(v2)).add(y03.multiply(v3)).negate() .divide(y0101.add(y0202).add(y0303)); }
public double laguerre(double lo, double hi, double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
Bus calcStarBusV1V2V3Y(BranchTestCase w1, BranchTestCase w2, BranchTestCase w3) { Complex v1 = ComplexUtils.polar2Complex(w1.bus1.u, w1.bus1.theta); Complex v2 = ComplexUtils.polar2Complex(w2.bus1.u, w2.bus1.theta); Complex v3 = ComplexUtils.polar2Complex(w3.bus1.u, w3.bus1.theta); Complex ytr1 = new Complex(w1.branch.end1.r, w1.branch.end1.x).reciprocal(); Complex ytr2 = new Complex(w2.branch.end1.r, w2.branch.end1.x).reciprocal(); Complex ytr3 = new Complex(w3.branch.end1.r, w3.branch.end1.x).reciprocal(); // FIXME consider tap.rho and tap.alpha Complex a01 = new Complex(w1.branch.end2.ratedU / w1.branch.end1.ratedU, 0); Complex a1 = new Complex(1, 0); Complex a02 = new Complex(w2.branch.end2.ratedU / w2.branch.end1.ratedU, 0); Complex a2 = new Complex(1, 0); Complex a03 = new Complex(w3.branch.end2.ratedU / w3.branch.end1.ratedU, 0); Complex a3 = new Complex(1, 0); Complex ysh01 = new Complex(w1.branch.end2.g, w1.branch.end2.b); Complex ysh02 = new Complex(w2.branch.end2.g, w2.branch.end2.b); Complex ysh03 = new Complex(w3.branch.end2.g, w3.branch.end2.b); Complex y01 = ytr1.negate().divide(a01.conjugate().multiply(a1)); Complex y02 = ytr2.negate().divide(a02.conjugate().multiply(a2)); Complex y03 = ytr3.negate().divide(a03.conjugate().multiply(a3)); Complex y0101 = ytr1.add(ysh01).divide(a01.conjugate().multiply(a01)); Complex y0202 = ytr2.add(ysh02).divide(a02.conjugate().multiply(a02)); Complex y0303 = ytr3.add(ysh03).divide(a03.conjugate().multiply(a03)); Complex v0 = y01.multiply(v1).add(y02.multiply(v2)).add(y03.multiply(v3)).negate() .divide(y0101.add(y0202).add(y0303)); Bus starBus = new Bus(); starBus.u = v0.abs(); starBus.theta = v0.getArgument(); return starBus; }
public double laguerre(double lo, double hi, double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
Complex v1 = ComplexUtils.polar2Complex(w.bus1.u, w.bus1.theta); Complex s1 = new Complex(w.expectedFlow1.p, w.expectedFlow1.q); Complex i1 = s1.divide(v1).conjugate();