Search in sources :

Example 46 with FieldAbsoluteDate

use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.

the class FieldSpacecraftStateTest method doTestShiftVsEcksteinHechlerError.

private <T extends RealFieldElement<T>> void doTestShiftVsEcksteinHechlerError(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T mass = zero.add(2500.);
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    final double ae = 6.378137e6;
    final double c20 = -1.08263e-3;
    final double c30 = 2.54e-6;
    final double c40 = 1.62e-6;
    final double c50 = 2.3e-7;
    final double c60 = -5.5e-7;
    // polynomial models for interpolation error in position, velocity, acceleration and attitude
    // these models grow as follows
    // interpolation time (s)    position error (m)   velocity error (m/s)   acceleration error (m/s²)  attitude error (°)
    // 60                        2                    0.07                  0.002               0.00002
    // 120                       12                    0.3                   0.005               0.00009
    // 300                      170                    1.6                   0.012               0.0009
    // 600                     1200                    5.7                   0.024               0.006
    // 900                     3600                   10.6                   0.034               0.02
    // the expected maximum residuals with respect to these models are about 0.4m, 0.5mm/s, 8μm/s² and 3e-6°
    PolynomialFunction pModel = new PolynomialFunction(new double[] { 1.5664070631933846e-01, 7.5504722733047560e-03, -8.2460562451009510e-05, 6.9546332080305580e-06, -1.7045365367533077e-09, -4.2187860791066264e-13 });
    PolynomialFunction vModel = new PolynomialFunction(new double[] { -3.5472364019908720e-04, 1.6568103861124980e-05, 1.9637913327830596e-05, -3.4248792843039766e-09, -5.6565135131014254e-12, 1.4730170946808630e-15 });
    PolynomialFunction aModel = new PolynomialFunction(new double[] { 3.0731707577766896e-06, 3.9770746399850350e-05, 1.9779039254538660e-09, 8.0263328220724900e-12, -1.5600835252366078e-14, 1.1785257001549687e-18 });
    PolynomialFunction rModel = new PolynomialFunction(new double[] { -2.7689062063188115e-06, 1.7406542538258334e-07, 2.5109795349592287e-09, 2.0399322661074575e-11, 9.9126348912426750e-15, -3.5015638905729510e-18 });
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, attitudeLaw, mass, ae, mu, c20, c30, c40, c50, c60);
    FieldAbsoluteDate<T> centerDate = orbit.getDate().shiftedBy(100.0);
    FieldSpacecraftState<T> centerState = propagator.propagate(centerDate);
    double maxResidualP = 0;
    double maxResidualV = 0;
    double maxResidualA = 0;
    double maxResidualR = 0;
    for (T dt = field.getZero(); dt.getReal() < 900.0; dt = dt.add(5)) {
        FieldSpacecraftState<T> shifted = centerState.shiftedBy(dt);
        FieldSpacecraftState<T> propagated = propagator.propagate(centerDate.shiftedBy(dt));
        FieldPVCoordinates<T> dpv = new FieldPVCoordinates<>(propagated.getPVCoordinates(), shifted.getPVCoordinates());
        double residualP = pModel.value(dt.getReal()) - dpv.getPosition().getNorm().getReal();
        double residualV = vModel.value(dt.getReal()) - dpv.getVelocity().getNorm().getReal();
        double residualA = aModel.value(dt.getReal()) - dpv.getAcceleration().getNorm().getReal();
        double residualR = rModel.value(dt.getReal()) - FastMath.toDegrees(FieldRotation.distance(shifted.getAttitude().getRotation(), propagated.getAttitude().getRotation()).getReal());
        maxResidualP = FastMath.max(maxResidualP, FastMath.abs(residualP));
        maxResidualV = FastMath.max(maxResidualV, FastMath.abs(residualV));
        maxResidualA = FastMath.max(maxResidualA, FastMath.abs(residualA));
        maxResidualR = FastMath.max(maxResidualR, FastMath.abs(residualR));
    }
    Assert.assertEquals(0.40, maxResidualP, 0.01);
    Assert.assertEquals(4.9e-4, maxResidualV, 1.0e-5);
    Assert.assertEquals(2.8e-6, maxResidualR, 1.0e-1);
}
Also used : PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 47 with FieldAbsoluteDate

use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.

the class FieldSpacecraftStateTest method doTestTransform.

private <T extends RealFieldElement<T>> void doTestTransform(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    T mass = zero.add(2500);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
    double maxDP = 0;
    double maxDV = 0;
    double maxDA = 0;
    for (double t = 0; t < orbit.getKeplerianPeriod().getReal(); t += 60) {
        final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(zero.add(t)));
        final Transform transform = state.toSpacecraftState().toTransform().getInverse();
        PVCoordinates pv = transform.transformPVCoordinates(PVCoordinates.ZERO);
        PVCoordinates dPV = new PVCoordinates(pv, state.getPVCoordinates().toPVCoordinates());
        Vector3D mZDirection = transform.transformVector(Vector3D.MINUS_K);
        double alpha = Vector3D.angle(mZDirection, state.getPVCoordinates().toPVCoordinates().getPosition());
        maxDP = FastMath.max(maxDP, dPV.getPosition().getNorm());
        maxDV = FastMath.max(maxDV, dPV.getVelocity().getNorm());
        maxDA = FastMath.max(maxDA, FastMath.toDegrees(alpha));
    }
    Assert.assertEquals(0.0, maxDP, 1.0e-6);
    Assert.assertEquals(0.0, maxDV, 1.0e-9);
    Assert.assertEquals(0.0, maxDA, 1.0e-12);
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 48 with FieldAbsoluteDate

use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.

the class FieldSpacecraftStateTest method doTestAdditionalStates.

private <T extends RealFieldElement<T>> void doTestAdditionalStates(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    T mass = zero.add(2500);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
    final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(60));
    T[] add = MathArrays.buildArray(field, 2);
    add[0] = zero.add(1.);
    add[1] = zero.add(2.);
    final FieldSpacecraftState<T> extended = state.addAdditionalState("test-1", add).addAdditionalState("test-2", zero.add(42.0));
    Assert.assertEquals(0, state.getAdditionalStates().size());
    Assert.assertFalse(state.hasAdditionalState("test-1"));
    try {
        state.getAdditionalState("test-1");
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertEquals(oe.getParts()[0], "test-1");
    }
    try {
        state.ensureCompatibleAdditionalStates(extended);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
    }
    try {
        extended.ensureCompatibleAdditionalStates(state);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
    }
    try {
        T[] kk = MathArrays.buildArray(field, 7);
        extended.ensureCompatibleAdditionalStates(extended.addAdditionalState("test-2", kk));
        Assert.fail("an exception should have been thrown");
    } catch (MathIllegalStateException mise) {
        Assert.assertEquals(LocalizedCoreFormats.DIMENSIONS_MISMATCH, mise.getSpecifier());
        Assert.assertEquals(7, ((Integer) mise.getParts()[0]).intValue());
    }
    Assert.assertEquals(2, extended.getAdditionalStates().size());
    Assert.assertTrue(extended.hasAdditionalState("test-1"));
    Assert.assertTrue(extended.hasAdditionalState("test-2"));
    Assert.assertEquals(1.0, extended.getAdditionalState("test-1")[0].getReal(), 1.0e-15);
    Assert.assertEquals(2.0, extended.getAdditionalState("test-1")[1].getReal(), 1.0e-15);
    Assert.assertEquals(42.0, extended.getAdditionalState("test-2")[0].getReal(), 1.0e-15);
    // test various constructors
    T[] dd = MathArrays.buildArray(field, 1);
    dd[0] = zero.add(-6.0);
    Map<String, T[]> map = new HashMap<String, T[]>();
    map.put("test-3", dd);
    FieldSpacecraftState<T> sO = new FieldSpacecraftState<>(state.getOrbit(), map);
    Assert.assertEquals(-6.0, sO.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOA = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), map);
    Assert.assertEquals(-6.0, sOA.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOM = new FieldSpacecraftState<>(state.getOrbit(), state.getMass(), map);
    Assert.assertEquals(-6.0, sOM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOAM = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), state.getMass(), map);
    Assert.assertEquals(-6.0, sOAM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sFromDouble = new FieldSpacecraftState<>(field, sOAM.toSpacecraftState());
    Assert.assertEquals(-6.0, sFromDouble.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
}
Also used : HashMap(java.util.HashMap) DateComponents(org.orekit.time.DateComponents) MathIllegalStateException(org.hipparchus.exception.MathIllegalStateException) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 49 with FieldAbsoluteDate

use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.

the class FieldSpacecraftStateTest method doTestDatesConsistency.

private <T extends RealFieldElement<T>> void doTestDatesConsistency(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    new FieldSpacecraftState<>(orbit, attitudeLaw.getAttitude(orbit.shiftedBy(zero.add(10.0)), orbit.getDate().shiftedBy(10.0), orbit.getFrame()));
}
Also used : BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) DateComponents(org.orekit.time.DateComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit)

Example 50 with FieldAbsoluteDate

use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method wrongAttitude.

@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
    KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 5918362126173997016L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }

        public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }
    };
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, wrongLaw, provider);
    propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) RealFieldElement(org.hipparchus.RealFieldElement) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Aggregations

FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)138 Frame (org.orekit.frames.Frame)57 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)53 AbsoluteDate (org.orekit.time.AbsoluteDate)52 Test (org.junit.Test)51 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)40 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)37 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)37 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)29 OrekitException (org.orekit.errors.OrekitException)28 SpacecraftState (org.orekit.propagation.SpacecraftState)28 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)27 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)25 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)24 PVCoordinates (org.orekit.utils.PVCoordinates)20 Decimal64 (org.hipparchus.util.Decimal64)18 RealFieldElement (org.hipparchus.RealFieldElement)17 OrbitType (org.orekit.orbits.OrbitType)17 DateComponents (org.orekit.time.DateComponents)17 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)14