Search in sources :

Example 16 with DSFactory

use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.

the class TimeStampedFieldPVCoordinatesTest method testLinearConstructors.

@Test
public void testLinearConstructors() {
    DSFactory factory = new DSFactory(6, 1);
    TimeStampedFieldPVCoordinates<DerivativeStructure> pv1 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.CCSDS_EPOCH, createVector(1, 0.1, 10, 6), createVector(-1, -0.1, -10, 6), createVector(10, 1.0, 100, 6));
    TimeStampedFieldPVCoordinates<DerivativeStructure> pv2 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.FIFTIES_EPOCH, createVector(2, 0.2, 20, 6), createVector(-2, -0.2, -20, 6), createVector(20, 2.0, 200, 6));
    TimeStampedFieldPVCoordinates<DerivativeStructure> pv3 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, createVector(3, 0.3, 30, 6), createVector(-3, -0.3, -30, 6), createVector(30, 3.0, 300, 6));
    TimeStampedFieldPVCoordinates<DerivativeStructure> pv4 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, createVector(4, 0.4, 40, 6), createVector(-4, -0.4, -40, 6), createVector(40, 4.0, 400, 6));
    checkPV(pv4, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, 4, pv1), 1.0e-15);
    checkPV(pv4, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, factory.constant(4), pv1), 1.0e-15);
    checkPV(pv4, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, factory.constant(4), pv1.toPVCoordinates()), 1.0e-15);
    checkPV(pv2, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.FIFTIES_EPOCH, pv1, pv3), 1.0e-15);
    checkPV(pv3, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, 1, pv1, 1, pv2), 1.0e-15);
    checkPV(pv3, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, factory.constant(1), pv1, factory.constant(1), pv2), 1.0e-15);
    checkPV(pv3, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, factory.constant(1), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates()), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 2, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv1, 1, pv2, 1, pv3), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv3), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv1, 1, pv2, 1, pv4), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv3), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(3), pv1, factory.constant(1), pv2, factory.constant(1), pv4), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv3), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(3), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 5, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 4, pv1, 3, pv2, 2, pv3, 1, pv4), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 5, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(4), pv1, factory.constant(3), pv2, factory.constant(2), pv3, factory.constant(1), pv4), 1.0e-15);
    checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 5, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(4), pv1.toPVCoordinates(), factory.constant(3), pv2.toPVCoordinates(), factory.constant(2), pv3.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) Test(org.junit.Test)

Example 17 with DSFactory

use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testGetMomentum.

@Test
public void testGetMomentum() {
    // setup
    DSFactory factory = new DSFactory(1, 1);
    DerivativeStructure oneDS = factory.getDerivativeField().getOne();
    DerivativeStructure zeroDS = factory.getDerivativeField().getZero();
    FieldVector3D<DerivativeStructure> zero = new FieldVector3D<>(zeroDS, zeroDS, zeroDS);
    FieldVector3D<DerivativeStructure> i = new FieldVector3D<>(oneDS, zeroDS, zeroDS);
    FieldVector3D<DerivativeStructure> j = new FieldVector3D<>(zeroDS, oneDS, zeroDS);
    FieldVector3D<DerivativeStructure> k = new FieldVector3D<>(zeroDS, zeroDS, oneDS);
    FieldVector3D<DerivativeStructure> p = new FieldVector3D<>(oneDS, factory.constant(-2), factory.constant(3));
    FieldVector3D<DerivativeStructure> v = new FieldVector3D<>(factory.constant(-9), factory.constant(8), factory.constant(-7));
    // action + verify
    Assert.assertEquals(new FieldPVCoordinates<>(p, v).getMomentum(), p.crossProduct(v));
    // check simple cases
    Assert.assertEquals(new FieldPVCoordinates<>(i, i.scalarMultiply(-1)).getMomentum(), zero);
    Assert.assertEquals(new FieldPVCoordinates<>(i, j).getMomentum(), k);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 18 with DSFactory

use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testLinearConstructors.

@Test
public void testLinearConstructors() {
    DSFactory factory = new DSFactory(6, 1);
    FieldPVCoordinates<DerivativeStructure> pv1 = new FieldPVCoordinates<>(createVector(1, 0.1, 10, 6), createVector(-1, -0.1, -10, 6));
    FieldPVCoordinates<DerivativeStructure> pv2 = new FieldPVCoordinates<>(createVector(2, 0.2, 20, 6), createVector(-2, -0.2, -20, 6));
    FieldPVCoordinates<DerivativeStructure> pv3 = new FieldPVCoordinates<>(createVector(3, 0.3, 30, 6), createVector(-3, -0.3, -30, 6));
    FieldPVCoordinates<DerivativeStructure> pv4 = new FieldPVCoordinates<>(createVector(4, 0.4, 40, 6), createVector(-4, -0.4, -40, 6));
    checkPV(pv4, new FieldPVCoordinates<>(4, pv1), 1.0e-15);
    checkPV(pv4, new FieldPVCoordinates<>(factory.constant(4), pv1), 1.0e-15);
    checkPV(pv4, new FieldPVCoordinates<>(factory.constant(4), pv1.toPVCoordinates()), 1.0e-15);
    checkPV(pv2, new FieldPVCoordinates<>(pv1, pv3), 1.0e-15);
    checkPV(pv3, new FieldPVCoordinates<>(1, pv1, 1, pv2), 1.0e-15);
    checkPV(pv3, new FieldPVCoordinates<>(factory.constant(1), pv1, factory.constant(1), pv2), 1.0e-15);
    checkPV(pv3, new FieldPVCoordinates<>(factory.constant(1), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates()), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(2, pv4), new FieldPVCoordinates<>(3, pv1, 1, pv2, 1, pv3), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(3, pv3), new FieldPVCoordinates<>(3, pv1, 1, pv2, 1, pv4), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(3, pv3), new FieldPVCoordinates<>(factory.constant(3), pv1, factory.constant(1), pv2, factory.constant(1), pv4), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(3, pv3), new FieldPVCoordinates<>(factory.constant(3), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(5, pv4), new FieldPVCoordinates<>(4, pv1, 3, pv2, 2, pv3, 1, pv4), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(5, pv4), new FieldPVCoordinates<>(factory.constant(4), pv1, factory.constant(3), pv2, factory.constant(2), pv3, factory.constant(1), pv4), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(5, pv4), new FieldPVCoordinates<>(factory.constant(4), pv1.toPVCoordinates(), factory.constant(3), pv2.toPVCoordinates(), factory.constant(2), pv3.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) Test(org.junit.Test)

Example 19 with DSFactory

use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testGetAngularVelocity.

@Test
public void testGetAngularVelocity() {
    // setup
    DSFactory factory = new DSFactory(1, 1);
    DerivativeStructure oneDS = factory.getDerivativeField().getOne();
    DerivativeStructure zeroDS = factory.getDerivativeField().getZero();
    FieldVector3D<DerivativeStructure> zero = new FieldVector3D<>(zeroDS, zeroDS, zeroDS);
    FieldVector3D<DerivativeStructure> i = new FieldVector3D<>(oneDS, zeroDS, zeroDS);
    FieldVector3D<DerivativeStructure> j = new FieldVector3D<>(zeroDS, oneDS, zeroDS);
    FieldVector3D<DerivativeStructure> k = new FieldVector3D<>(zeroDS, zeroDS, oneDS);
    FieldVector3D<DerivativeStructure> p = new FieldVector3D<>(oneDS, factory.constant(-2), factory.constant(3));
    FieldVector3D<DerivativeStructure> v = new FieldVector3D<>(factory.constant(-9), factory.constant(8), factory.constant(-7));
    // action + verify
    Assert.assertEquals(new FieldPVCoordinates<>(p, v).getAngularVelocity(), p.crossProduct(v).scalarMultiply(p.getNormSq().reciprocal()));
    // check extra simple cases
    Assert.assertEquals(new FieldPVCoordinates<>(i, i.scalarMultiply(-1)).getAngularVelocity(), zero);
    Assert.assertEquals(new FieldPVCoordinates<>(i.scalarMultiply(2), j).getAngularVelocity(), k.scalarMultiply(0.5));
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 20 with DSFactory

use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.

the class IERSConventionsTest method checkGMSTRate.

private void checkGMSTRate(final TimeScalarFunction gmst, final TimeScalarFunction gmstRate, final AbsoluteDate date, final double span, final double sampleStep, final double h, final double tolerance) throws OrekitException {
    UnivariateDifferentiableFunction differentiated = new FiniteDifferencesDifferentiator(4, h).differentiate(new UnivariateFunction() {

        @Override
        public double value(final double dt) {
            return gmst.value(date.shiftedBy(dt));
        }
    });
    DSFactory factory = new DSFactory(1, 1);
    double maxRateError = 0;
    for (double dt = 0; dt < span; dt += sampleStep) {
        double rateRef = differentiated.value(factory.variable(0, dt)).getPartialDerivative(1);
        double rate = gmstRate.value(date.shiftedBy(dt));
        maxRateError = FastMath.max(maxRateError, FastMath.abs(rateRef - rate));
    }
    Assert.assertEquals(0, maxRateError, tolerance);
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)

Aggregations

DSFactory (org.hipparchus.analysis.differentiation.DSFactory)76 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)64 Test (org.junit.Test)41 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)36 FiniteDifferencesDifferentiator (org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)25 SpacecraftState (org.orekit.propagation.SpacecraftState)24 Frame (org.orekit.frames.Frame)23 AbsoluteDate (org.orekit.time.AbsoluteDate)20 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)18 UnivariateDifferentiableFunction (org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction)17 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)17 PVCoordinates (org.orekit.utils.PVCoordinates)17 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)16 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)15 OrbitType (org.orekit.orbits.OrbitType)15 RandomGenerator (org.hipparchus.random.RandomGenerator)14 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)14 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)14 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)14 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)14