Search in sources :

Example 16 with RealFieldElement

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

the class FieldKeplerianPropagatorTest method doTestWrongAttitude.

private <T extends RealFieldElement<T>> void doTestWrongAttitude(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(1.0e10), zero.add(1.0e-4), zero.add(1.0e-2), zero, zero, zero, PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

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

        @Override
        public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }
    };
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, wrongLaw);
    propagator.propagate(new FieldAbsoluteDate<>(field).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) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Example 17 with RealFieldElement

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

the class FramesFactoryTest method testUnwrapShiftingTransformProvider.

@Test
public void testUnwrapShiftingTransformProvider() throws OrekitException {
    TransformProvider raw = new TransformProvider() {

        private static final long serialVersionUID = 1L;

        public Transform getTransform(final AbsoluteDate date) {
            double dt = date.durationFrom(AbsoluteDate.J2000_EPOCH);
            double sin = FastMath.sin(dt * MathUtils.TWO_PI / Constants.JULIAN_DAY);
            return new Transform(date, new PVCoordinates(new Vector3D(sin, Vector3D.PLUS_I), Vector3D.ZERO));
        }

        public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
            throw new UnsupportedOperationException("never called in this test");
        }
    };
    Frame parent = FramesFactory.getGCRF();
    Frame frame = new Frame(parent, new ShiftingTransformProvider(raw, CartesianDerivativesFilter.USE_P, AngularDerivativesFilter.USE_R, 4, Constants.JULIAN_DAY, 10, Constants.JULIAN_YEAR, 2 * Constants.JULIAN_DAY), "sine");
    double maxErrorNonShifting = 0;
    double maxErrorShifting = 0;
    for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 60.0) {
        AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
        Transform reference = raw.getTransform(date);
        Transform nonShifting = FramesFactory.getNonInterpolatingTransform(parent, frame, date);
        Transform shifting = parent.getTransformTo(frame, date);
        double errorNonShifting = Vector3D.distance(reference.getTranslation(), nonShifting.getTranslation());
        maxErrorNonShifting = FastMath.max(maxErrorNonShifting, errorNonShifting);
        double errorShifting = Vector3D.distance(reference.getTranslation(), shifting.getTranslation());
        maxErrorShifting = FastMath.max(maxErrorShifting, errorShifting);
    }
    Assert.assertEquals(0.0, maxErrorNonShifting, 1.0e-15);
    Assert.assertEquals(1.0, maxErrorShifting, 1.0e-15);
}
Also used : RealFieldElement(org.hipparchus.RealFieldElement) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 18 with RealFieldElement

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

the class FieldCartesianOrbitTest method doTestNonKeplerianDerivatives.

private <T extends RealFieldElement<T>> void doTestNonKeplerianDerivatives(Field<T> field) throws OrekitException {
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, "2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
    final FieldVector3D<T> position = new FieldVector3D<>(field.getZero().add(6896874.444705), field.getZero().add(1956581.072644), field.getZero().add(-147476.245054));
    final FieldVector3D<T> velocity = new FieldVector3D<>(field.getZero().add(166.816407662), field.getZero().add(-1106.783301861), field.getZero().add(-7372.745712770));
    final FieldVector3D<T> acceleration = new FieldVector3D<>(field.getZero().add(-7.466182457944), field.getZero().add(-2.118153357345), field.getZero().add(0.160004048437));
    final TimeStampedFieldPVCoordinates<T> pv = new TimeStampedFieldPVCoordinates<>(date, position, velocity, acceleration);
    final Frame frame = FramesFactory.getEME2000();
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final FieldCartesianOrbit<T> orbit = new FieldCartesianOrbit<>(pv, frame, mu);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot().getReal(), 4.3e-8);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot().getReal(), 2.1e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot().getReal(), 5.3e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot().getReal(), 4.4e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot().getReal(), 8.0e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot().getReal(), 1.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot().getReal(), 7.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot().getReal(), 8.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot().getReal(), 7.0e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot().getReal(), 5.7e-16);
}
Also used : Frame(org.orekit.frames.Frame) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) Function(java.util.function.Function) FieldMatrixPreservingVisitor(org.hipparchus.linear.FieldMatrixPreservingVisitor) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) ArrayList(java.util.ArrayList) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) MathArrays(org.hipparchus.util.MathArrays) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FastMath(org.hipparchus.util.FastMath) Method(java.lang.reflect.Method) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) OrekitMatchers.relativelyCloseTo(org.orekit.OrekitMatchers.relativelyCloseTo) FramesFactory(org.orekit.frames.FramesFactory) Test(org.junit.Test) InvocationTargetException(java.lang.reflect.InvocationTargetException) Field(org.hipparchus.Field) MathUtils(org.hipparchus.util.MathUtils) List(java.util.List) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) OrekitException(org.orekit.errors.OrekitException) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) RealFieldElement(org.hipparchus.RealFieldElement) TimeScalesFactory(org.orekit.time.TimeScalesFactory) MatrixUtils(org.hipparchus.linear.MatrixUtils) Decimal64Field(org.hipparchus.util.Decimal64Field) Transform(org.orekit.frames.Transform) Assert(org.junit.Assert) Frame(org.orekit.frames.Frame) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates)

Aggregations

RealFieldElement (org.hipparchus.RealFieldElement)18 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)16 Test (org.junit.Test)12 Frame (org.orekit.frames.Frame)11 AbsoluteDate (org.orekit.time.AbsoluteDate)11 OrekitException (org.orekit.errors.OrekitException)10 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)7 Transform (org.orekit.frames.Transform)7 Field (org.hipparchus.Field)6 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)6 FastMath (org.hipparchus.util.FastMath)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Function (java.util.function.Function)5 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)5 FiniteDifferencesDifferentiator (org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)5 UnivariateDifferentiableFunction (org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction)5 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)5 FieldMatrixPreservingVisitor (org.hipparchus.linear.FieldMatrixPreservingVisitor)5 MatrixUtils (org.hipparchus.linear.MatrixUtils)5