Search in sources :

Example 16 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestEphemerisDates.

private <T extends RealFieldElement<T>> void doTestEphemerisDates(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-01", tai);
    FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
    FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(startDate, endDate);
    FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
    // test date
    FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
Also used : Frame(org.orekit.frames.Frame) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 17 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestResetDerivativesEvent.

private <T extends RealFieldElement<T>> void doTestResetDerivativesEvent(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    final FieldAbsoluteDate<T> resetDate = initDate.shiftedBy(1000);
    CheckingHandler<FieldDateDetector<T>, T> checking = new CheckingHandler<FieldDateDetector<T>, T>(Action.RESET_DERIVATIVES);
    propagator.addEventDetector(new FieldDateDetector<>(resetDate).withHandler(checking));
    final double dt = 3200;
    checking.assertEvent(false);
    Assert.assertEquals(0.0, propagator.getInitialState().getDate().durationFrom(initDate).getReal(), 1.0e-10);
    propagator.setResetAtEnd(true);
    final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(dt));
    Assert.assertEquals(dt, propagator.getInitialState().getDate().durationFrom(initDate).getReal(), 1.0e-10);
    checking.assertEvent(true);
    final double n = FastMath.sqrt(initialState.getMu() / initialState.getA().getReal()) / initialState.getA().getReal();
    Assert.assertEquals(initialState.getA().getReal(), finalState.getA().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEx().getReal(), finalState.getEquinoctialEx().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEy().getReal(), finalState.getEquinoctialEy().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getHx().getReal(), finalState.getHx().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getHy().getReal(), finalState.getHy().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getLM().getReal() + n * dt, finalState.getLM().getReal(), 6.0e-10);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldDateDetector(org.orekit.propagation.events.FieldDateDetector) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType)

Example 18 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestException.

private <T extends RealFieldElement<T>> void doTestException(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    propagator.setMasterMode(new FieldOrekitStepHandler<T>() {

        private int countDown = 3;

        private FieldAbsoluteDate<T> previousCall = null;

        public void init(FieldSpacecraftState<T> s0, FieldAbsoluteDate<T> t) {
        }

        public void handleStep(FieldOrekitStepInterpolator<T> interpolator, boolean isLast) throws OrekitException {
            if (previousCall != null) {
                System.out.println(interpolator.getCurrentState().getDate().compareTo(previousCall) < 0);
            }
            if (--countDown == 0) {
                throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "dummy error");
            }
        }
    });
    propagator.propagate(initDate.shiftedBy(-3600));
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType) OrekitException(org.orekit.errors.OrekitException)

Example 19 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class NumericalPropagatorTest method testEphemerisDates.

@Test
public void testEphemerisDates() throws OrekitException {
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    AbsoluteDate initialDate = new AbsoluteDate("2015-07-01", tai);
    AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1);
    AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    KeplerianOrbit orbit = new KeplerianOrbit(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit, type);
    NumericalPropagator prop = new NumericalPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(startDate, endDate);
    BoundedPropagator ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0));
    // test date
    AbsoluteDate date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) TimeScale(org.orekit.time.TimeScale) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 20 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class NumericalPropagatorTest method testPropagationTypesElliptical.

@Test
public void testPropagationTypesElliptical() throws OrekitException, ParseException, IOException {
    // setup
    AbsoluteDate initDate = new AbsoluteDate();
    SpacecraftState initialState;
    final Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    final Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
    initDate = AbsoluteDate.J2000_EPOCH;
    final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new SpacecraftState(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit, type);
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(60);
    propagator = new NumericalPropagator(integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    ForceModel gravityField = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getNormalizedProvider(5, 5));
    propagator.addForceModel(gravityField);
    // Propagation of the initial at t + dt
    final PVCoordinates pv = initialState.getPVCoordinates();
    final double dP = 0.001;
    final double dV = initialState.getMu() * dP / (pv.getPosition().getNormSq() * pv.getVelocity().getNorm());
    final PVCoordinates pvcM = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.MEAN);
    final PVCoordinates pviM = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.MEAN);
    final PVCoordinates pveM = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.MEAN);
    final PVCoordinates pvkM = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN);
    final PVCoordinates pvcE = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC);
    final PVCoordinates pviE = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.ECCENTRIC);
    final PVCoordinates pveE = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.ECCENTRIC);
    final PVCoordinates pvkE = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC);
    final PVCoordinates pvcT = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.TRUE);
    final PVCoordinates pviT = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.TRUE);
    final PVCoordinates pveT = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.TRUE);
    final PVCoordinates pvkT = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE);
    Assert.assertEquals(0, pvcM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0);
    Assert.assertEquals(0, pvcM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0);
    Assert.assertEquals(0, pviM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.6);
    Assert.assertEquals(0, pviM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.4);
    Assert.assertEquals(0, pvkM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.5);
    Assert.assertEquals(0, pvkM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.3);
    Assert.assertEquals(0, pveM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.2);
    Assert.assertEquals(0, pveM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2);
    Assert.assertEquals(0, pvcE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0);
    Assert.assertEquals(0, pvcE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0);
    Assert.assertEquals(0, pviE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.03);
    Assert.assertEquals(0, pviE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.04);
    Assert.assertEquals(0, pvkE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.4);
    Assert.assertEquals(0, pvkE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.3);
    Assert.assertEquals(0, pveE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.2);
    Assert.assertEquals(0, pveE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.07);
    Assert.assertEquals(0, pvcT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0);
    Assert.assertEquals(0, pvcT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0);
    Assert.assertEquals(0, pviT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.3);
    Assert.assertEquals(0, pviT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2);
    Assert.assertEquals(0, pvkT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.4);
    Assert.assertEquals(0, pvkT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2);
}
Also used : EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ForceModel(org.orekit.forces.ForceModel) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Aggregations

OrbitType (org.orekit.orbits.OrbitType)69 Test (org.junit.Test)39 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)38 SpacecraftState (org.orekit.propagation.SpacecraftState)35 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)31 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)29 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)28 Orbit (org.orekit.orbits.Orbit)28 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)27 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)25 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)24 Frame (org.orekit.frames.Frame)23 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)23 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)21 AbsoluteDate (org.orekit.time.AbsoluteDate)17 PVCoordinates (org.orekit.utils.PVCoordinates)17 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)16 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)15 CartesianOrbit (org.orekit.orbits.CartesianOrbit)15 PositionAngle (org.orekit.orbits.PositionAngle)15