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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations