Search in sources :

Example 91 with AbsoluteDate

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

the class NumericalPropagatorTest method testIssue157.

@Test
public void testIssue157() throws OrekitException {
    try {
        Orbit orbit = new KeplerianOrbit(13378000, 0.05, 0, 0, FastMath.PI, 0, PositionAngle.MEAN, FramesFactory.getTOD(false), new AbsoluteDate(2003, 5, 6, TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
        NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException pe) {
        Assert.assertEquals(OrekitMessages.SINGULAR_JACOBIAN_FOR_ORBIT_TYPE, pe.getSpecifier());
    }
}
Also used : EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 92 with AbsoluteDate

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

the class NumericalPropagatorTest method testEventAtEndOfEphemeris.

/**
 * test for issue #238
 */
@Test
public void testEventAtEndOfEphemeris() throws OrekitException {
    // setup
    // choose duration that will round up when expressed as a double
    AbsoluteDate end = initDate.shiftedBy(100).shiftedBy(3 * FastMath.ulp(100.0) / 4);
    propagator.setEphemerisMode();
    propagator.propagate(end);
    BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    CountingHandler handler = new CountingHandler();
    DateDetector detector = new DateDetector(10, 1e-9, end).withHandler(handler);
    // propagation works fine w/o event detector, but breaks with it
    ephemeris.addEventDetector(detector);
    // action
    // fails when this throws an "out of range date for ephemerides"
    SpacecraftState actual = ephemeris.propagate(end);
    // verify
    Assert.assertEquals(actual.getDate().durationFrom(end), 0.0, 0.0);
    Assert.assertEquals(1, handler.eventCount);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 93 with AbsoluteDate

use of org.orekit.time.AbsoluteDate 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)

Example 94 with AbsoluteDate

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

the class NumericalPropagatorTest method testResetStateEvent.

@Test
public void testResetStateEvent() throws OrekitException {
    final AbsoluteDate resetDate = initDate.shiftedBy(1000);
    CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.RESET_STATE) {

        public SpacecraftState resetState(DateDetector detector, SpacecraftState oldState) {
            return new SpacecraftState(oldState.getOrbit(), oldState.getAttitude(), oldState.getMass() - 200.0);
        }
    };
    propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking));
    checking.assertEvent(false);
    final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200));
    checking.assertEvent(true);
    Assert.assertEquals(initialState.getMass() - 200, finalState.getMass(), 1.0e-10);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 95 with AbsoluteDate

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

the class NumericalPropagatorTest method doTestShift.

private static void doTestShift(final CartesianOrbit orbit, final OrbitType orbitType, final PositionAngle angleType, final boolean withDerivatives, final double error60s, final double error120s, final double error300s, final double error600s, final double error900s) throws OrekitException {
    Utils.setDataRoot("regular-data:atmosphere:potential/grgs-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
    final NumericalPropagator np = createPropagator(new SpacecraftState(orbit), orbitType, angleType);
    // the reference date for shifts is set at 60s, so the propagator can provide derivatives if needed
    // (derivatives are not available in the initial orbit)
    final AbsoluteDate reference = orbit.getDate().shiftedBy(60.0);
    final ShiftChecker checker = new ShiftChecker(withDerivatives, orbitType, angleType, error60s, error120s, error300s, error600s, error900s);
    np.addEventDetector(new DateDetector(30.0, 1.0e-9, reference, reference.shiftedBy(60.0), reference.shiftedBy(120.0), reference.shiftedBy(300.0), reference.shiftedBy(600.0), reference.shiftedBy(900.0)).withHandler(checker));
    np.propagate(reference.shiftedBy(1000.0));
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) AbsoluteDate(org.orekit.time.AbsoluteDate) GRGSFormatReader(org.orekit.forces.gravity.potential.GRGSFormatReader)

Aggregations

AbsoluteDate (org.orekit.time.AbsoluteDate)840 Test (org.junit.Test)632 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)321 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)283 SpacecraftState (org.orekit.propagation.SpacecraftState)279 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)204 PVCoordinates (org.orekit.utils.PVCoordinates)193 Orbit (org.orekit.orbits.Orbit)157 Frame (org.orekit.frames.Frame)152 OrekitException (org.orekit.errors.OrekitException)141 DateComponents (org.orekit.time.DateComponents)134 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)106 CartesianOrbit (org.orekit.orbits.CartesianOrbit)104 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)97 ArrayList (java.util.ArrayList)96 Propagator (org.orekit.propagation.Propagator)90 TimeScale (org.orekit.time.TimeScale)90 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)88 TimeComponents (org.orekit.time.TimeComponents)88 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)87