Search in sources :

Example 1 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class ConstantThrustManeuver method getEventsDetectors.

/**
 * {@inheritDoc}
 */
@Override
public Stream<EventDetector> getEventsDetectors() {
    // in forward propagation direction, firing must be enabled
    // at start time and disabled at end time; in backward
    // propagation direction, firing must be enabled
    // at end time and disabled at start time
    final DateDetector startDetector = new DateDetector(startDate).withHandler((SpacecraftState state, DateDetector d, boolean increasing) -> {
        firing = d.isForward();
        return EventHandler.Action.RESET_DERIVATIVES;
    });
    final DateDetector endDetector = new DateDetector(endDate).withHandler((SpacecraftState state, DateDetector d, boolean increasing) -> {
        firing = !d.isForward();
        return EventHandler.Action.RESET_DERIVATIVES;
    });
    return Stream.of(startDetector, endDetector);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) FieldDateDetector(org.orekit.propagation.events.FieldDateDetector) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState)

Example 2 with DateDetector

use of org.orekit.propagation.events.DateDetector 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 3 with DateDetector

use of org.orekit.propagation.events.DateDetector 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 4 with DateDetector

use of org.orekit.propagation.events.DateDetector 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)

Example 5 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class NumericalPropagatorTest method testEventAtBeginningOfEphemeris.

/**
 * test for issue #238
 */
@Test
public void testEventAtBeginningOfEphemeris() 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();
    // events directly on propagation start date are not triggered,
    // so move the event date slightly after
    AbsoluteDate eventDate = initDate.shiftedBy(FastMath.ulp(100.0) / 10.0);
    DateDetector detector = new DateDetector(10, 1e-9, eventDate).withHandler(handler);
    // propagation works fine w/o event detector, but breaks with it
    ephemeris.addEventDetector(detector);
    // action + verify
    // propagate forward
    Assert.assertEquals(ephemeris.propagate(end).getDate().durationFrom(end), 0.0, 0.0);
    // propagate backward
    Assert.assertEquals(ephemeris.propagate(initDate).getDate().durationFrom(initDate), 0.0, 0.0);
    Assert.assertEquals(2, handler.eventCount);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

DateDetector (org.orekit.propagation.events.DateDetector)31 Test (org.junit.Test)27 AbsoluteDate (org.orekit.time.AbsoluteDate)27 SpacecraftState (org.orekit.propagation.SpacecraftState)25 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)15 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)13 Orbit (org.orekit.orbits.Orbit)12 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)9 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)9 LofOffset (org.orekit.attitudes.LofOffset)8 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)7 OrekitException (org.orekit.errors.OrekitException)7 CartesianOrbit (org.orekit.orbits.CartesianOrbit)6 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)6 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)5 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)5 Frame (org.orekit.frames.Frame)5 Arrays (java.util.Arrays)4 List (java.util.List)4 LocalizedCoreFormats (org.hipparchus.exception.LocalizedCoreFormats)4