Search in sources :

Example 6 with RecordAndContinue

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

the class CloseEventsAbstractTest method testFastSwitching.

/**
 * test the g function switching with a period shorter than the tolerance. We don't
 * need to find any of the events, but we do need to not crash. And we need to
 * preserve the alternating increasing / decreasing sequence.
 */
@Test
public void testFastSwitching() throws OrekitException {
    // setup
    // step size of 10 to land in between two events we would otherwise miss
    Propagator propagator = getPropagator(10);
    RecordAndContinue<EventDetector> handler = new RecordAndContinue<>();
    TimeDetector detector1 = new TimeDetector(9.9, 10.1, 12).withHandler(handler).withMaxCheck(10).withThreshold(0.2);
    propagator.addEventDetector(detector1);
    // action
    propagator.propagate(epoch.shiftedBy(20));
    // verify
    // finds one or three events. Not 2.
    List<Event<EventDetector>> events1 = handler.getEvents();
    Assert.assertEquals(1, events1.size());
    Assert.assertEquals(9.9, events1.get(0).getState().getDate().durationFrom(epoch), 0.1);
    Assert.assertEquals(true, events1.get(0).isIncreasing());
}
Also used : RecordAndContinue(org.orekit.propagation.events.handlers.RecordAndContinue) Propagator(org.orekit.propagation.Propagator) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 Propagator (org.orekit.propagation.Propagator)6 RecordAndContinue (org.orekit.propagation.events.handlers.RecordAndContinue)6 Event (org.orekit.propagation.events.handlers.RecordAndContinue.Event)6 StopOnEvent (org.orekit.propagation.events.handlers.StopOnEvent)6 EventHandler (org.orekit.propagation.events.handlers.EventHandler)1