Search in sources :

Example 1 with RealMatrixPreservingVisitor

use of org.hipparchus.linear.RealMatrixPreservingVisitor in project Orekit by CS-SI.

the class KeplerianOrbitTest method testJacobianFinitedifferencesEllipse.

@Test
public void testJacobianFinitedifferencesEllipse() throws OrekitException {
    AbsoluteDate dateTca = new AbsoluteDate(2000, 04, 01, 0, 0, 0.000, TimeScalesFactory.getUTC());
    double mu = 3.986004415e+14;
    KeplerianOrbit orbKep = new KeplerianOrbit(7000000.0, 0.01, FastMath.toRadians(80.), FastMath.toRadians(80.), FastMath.toRadians(20.), FastMath.toRadians(40.), PositionAngle.MEAN, FramesFactory.getEME2000(), dateTca, mu);
    for (PositionAngle type : PositionAngle.values()) {
        double hP = 2.0;
        double[][] finiteDiffJacobian = finiteDifferencesJacobian(type, orbKep, hP);
        double[][] jacobian = new double[6][6];
        orbKep.getJacobianWrtCartesian(type, jacobian);
        for (int i = 0; i < jacobian.length; i++) {
            double[] row = jacobian[i];
            double[] rowRef = finiteDiffJacobian[i];
            for (int j = 0; j < row.length; j++) {
                Assert.assertEquals(0, (row[j] - rowRef[j]) / rowRef[j], 2.0e-7);
            }
        }
        double[][] invJacobian = new double[6][6];
        orbKep.getJacobianWrtParameters(type, invJacobian);
        MatrixUtils.createRealMatrix(jacobian).multiply(MatrixUtils.createRealMatrix(invJacobian)).walkInRowOrder(new RealMatrixPreservingVisitor() {

            public void start(int rows, int columns, int startRow, int endRow, int startColumn, int endColumn) {
            }

            public void visit(int row, int column, double value) {
                Assert.assertEquals(row == column ? 1.0 : 0.0, value, 5.0e-9);
            }

            public double end() {
                return Double.NaN;
            }
        });
    }
}
Also used : RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 2 with RealMatrixPreservingVisitor

use of org.hipparchus.linear.RealMatrixPreservingVisitor in project Orekit by CS-SI.

the class KeplerianOrbitTest method testJacobianFinitedifferencesHyperbola.

@Test
public void testJacobianFinitedifferencesHyperbola() throws OrekitException {
    AbsoluteDate dateTca = new AbsoluteDate(2000, 04, 01, 0, 0, 0.000, TimeScalesFactory.getUTC());
    double mu = 3.986004415e+14;
    KeplerianOrbit orbKep = new KeplerianOrbit(-7000000.0, 1.2, FastMath.toRadians(80.), FastMath.toRadians(80.), FastMath.toRadians(20.), FastMath.toRadians(40.), PositionAngle.MEAN, FramesFactory.getEME2000(), dateTca, mu);
    for (PositionAngle type : PositionAngle.values()) {
        double hP = 2.0;
        double[][] finiteDiffJacobian = finiteDifferencesJacobian(type, orbKep, hP);
        double[][] jacobian = new double[6][6];
        orbKep.getJacobianWrtCartesian(type, jacobian);
        for (int i = 0; i < jacobian.length; i++) {
            double[] row = jacobian[i];
            double[] rowRef = finiteDiffJacobian[i];
            for (int j = 0; j < row.length; j++) {
                Assert.assertEquals(0, (row[j] - rowRef[j]) / rowRef[j], 3.0e-8);
            }
        }
        double[][] invJacobian = new double[6][6];
        orbKep.getJacobianWrtParameters(type, invJacobian);
        MatrixUtils.createRealMatrix(jacobian).multiply(MatrixUtils.createRealMatrix(invJacobian)).walkInRowOrder(new RealMatrixPreservingVisitor() {

            public void start(int rows, int columns, int startRow, int endRow, int startColumn, int endColumn) {
            }

            public void visit(int row, int column, double value) {
                Assert.assertEquals(row == column ? 1.0 : 0.0, value, 2.0e-8);
            }

            public double end() {
                return Double.NaN;
            }
        });
    }
}
Also used : RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 3 with RealMatrixPreservingVisitor

use of org.hipparchus.linear.RealMatrixPreservingVisitor in project Orekit by CS-SI.

the class CartesianOrbitTest method testJacobianReference.

@Test
public void testJacobianReference() throws OrekitException {
    Vector3D position = new Vector3D(-29536113.0, 30329259.0, -100125.0);
    Vector3D velocity = new Vector3D(-2194.0, -2141.0, -8.0);
    PVCoordinates pvCoordinates = new PVCoordinates(position, velocity);
    CartesianOrbit orbit = new CartesianOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
    double[][] jacobian = new double[6][6];
    orbit.getJacobianWrtCartesian(PositionAngle.MEAN, jacobian);
    for (int i = 0; i < jacobian.length; i++) {
        double[] row = jacobian[i];
        for (int j = 0; j < row.length; j++) {
            Assert.assertEquals((i == j) ? 1 : 0, row[j], 1.0e-15);
        }
    }
    double[][] invJacobian = new double[6][6];
    orbit.getJacobianWrtParameters(PositionAngle.MEAN, invJacobian);
    MatrixUtils.createRealMatrix(jacobian).multiply(MatrixUtils.createRealMatrix(invJacobian)).walkInRowOrder(new RealMatrixPreservingVisitor() {

        public void start(int rows, int columns, int startRow, int endRow, int startColumn, int endColumn) {
        }

        public void visit(int row, int column, double value) {
            Assert.assertEquals(row == column ? 1.0 : 0.0, value, 1.0e-15);
        }

        public double end() {
            return Double.NaN;
        }
    });
}
Also used : RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Test(org.junit.Test)

Example 4 with RealMatrixPreservingVisitor

use of org.hipparchus.linear.RealMatrixPreservingVisitor in project Orekit by CS-SI.

the class EquinoctialOrbitTest method testJacobianFinitedifferences.

@Test
public void testJacobianFinitedifferences() throws OrekitException {
    AbsoluteDate dateTca = new AbsoluteDate(2000, 04, 01, 0, 0, 0.000, TimeScalesFactory.getUTC());
    double mu = 3.986004415e+14;
    EquinoctialOrbit orbEqu = new EquinoctialOrbit(7000000.0, 0.01, -0.02, 1.2, 2.1, FastMath.toRadians(40.), PositionAngle.MEAN, FramesFactory.getEME2000(), dateTca, mu);
    for (PositionAngle type : PositionAngle.values()) {
        double hP = 2.0;
        double[][] finiteDiffJacobian = finiteDifferencesJacobian(type, orbEqu, hP);
        double[][] jacobian = new double[6][6];
        orbEqu.getJacobianWrtCartesian(type, jacobian);
        for (int i = 0; i < jacobian.length; i++) {
            double[] row = jacobian[i];
            double[] rowRef = finiteDiffJacobian[i];
            for (int j = 0; j < row.length; j++) {
                Assert.assertEquals(0, (row[j] - rowRef[j]) / rowRef[j], 4.0e-9);
            }
        }
        double[][] invJacobian = new double[6][6];
        orbEqu.getJacobianWrtParameters(type, invJacobian);
        MatrixUtils.createRealMatrix(jacobian).multiply(MatrixUtils.createRealMatrix(invJacobian)).walkInRowOrder(new RealMatrixPreservingVisitor() {

            public void start(int rows, int columns, int startRow, int endRow, int startColumn, int endColumn) {
            }

            public void visit(int row, int column, double value) {
                Assert.assertEquals(row == column ? 1.0 : 0.0, value, 7.0e-9);
            }

            public double end() {
                return Double.NaN;
            }
        });
    }
}
Also used : RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 5 with RealMatrixPreservingVisitor

use of org.hipparchus.linear.RealMatrixPreservingVisitor in project Orekit by CS-SI.

the class CircularOrbitTest method testJacobianFinitedifferences.

@Test
public void testJacobianFinitedifferences() throws OrekitException {
    AbsoluteDate dateTca = new AbsoluteDate(2000, 04, 01, 0, 0, 0.000, TimeScalesFactory.getUTC());
    double mu = 3.986004415e+14;
    CircularOrbit orbCir = new CircularOrbit(7000000.0, 0.01, -0.02, 1.2, 2.1, 0.7, PositionAngle.MEAN, FramesFactory.getEME2000(), dateTca, mu);
    for (PositionAngle type : PositionAngle.values()) {
        double hP = 2.0;
        double[][] finiteDiffJacobian = finiteDifferencesJacobian(type, orbCir, hP);
        double[][] jacobian = new double[6][6];
        orbCir.getJacobianWrtCartesian(type, jacobian);
        for (int i = 0; i < jacobian.length; i++) {
            double[] row = jacobian[i];
            double[] rowRef = finiteDiffJacobian[i];
            for (int j = 0; j < row.length; j++) {
                Assert.assertEquals(0, (row[j] - rowRef[j]) / rowRef[j], 8.0e-9);
            }
        }
        double[][] invJacobian = new double[6][6];
        orbCir.getJacobianWrtParameters(type, invJacobian);
        MatrixUtils.createRealMatrix(jacobian).multiply(MatrixUtils.createRealMatrix(invJacobian)).walkInRowOrder(new RealMatrixPreservingVisitor() {

            public void start(int rows, int columns, int startRow, int endRow, int startColumn, int endColumn) {
            }

            public void visit(int row, int column, double value) {
                Assert.assertEquals(row == column ? 1.0 : 0.0, value, 4.0e-9);
            }

            public double end() {
                return Double.NaN;
            }
        });
    }
}
Also used : RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

RealMatrixPreservingVisitor (org.hipparchus.linear.RealMatrixPreservingVisitor)5 Test (org.junit.Test)5 AbsoluteDate (org.orekit.time.AbsoluteDate)4 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)1 PVCoordinates (org.orekit.utils.PVCoordinates)1 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)1