Search in sources :

Example 1 with RecordAndContinue

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

the class CloseEventsAbstractTest method testCloseEvents.

@Test
public void testCloseEvents() throws OrekitException {
    // setup
    double tolerance = 1;
    Propagator propagator = getPropagator(10);
    RecordAndContinue<EventDetector> handler = new RecordAndContinue<>();
    TimeDetector detector1 = new TimeDetector(5).withHandler(handler).withMaxCheck(10).withThreshold(tolerance);
    propagator.addEventDetector(detector1);
    TimeDetector detector2 = new TimeDetector(5.5).withHandler(handler).withMaxCheck(10).withThreshold(tolerance);
    propagator.addEventDetector(detector2);
    // action
    propagator.propagate(epoch.shiftedBy(20));
    // verify
    List<Event<EventDetector>> events = handler.getEvents();
    Assert.assertEquals(2, events.size());
    Assert.assertEquals(5, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(detector1, events.get(0).getDetector());
    Assert.assertEquals(5.5, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(detector2, events.get(1).getDetector());
}
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)

Example 2 with RecordAndContinue

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

the class CloseEventsAbstractTest method testCloseEventsFirstOneIsResetReverse.

/* The following tests are copies of the above tests, except that they propagate in
     * the reverse direction and all the signs on the time values are negated.
     */
@Test
public void testCloseEventsFirstOneIsResetReverse() throws OrekitException {
    // setup
    // a fairly rare state to reproduce this bug. Two dates, d1 < d2, that
    // are very close. Event triggers on d1 will reset state to break out of
    // event handling loop in AbstractIntegrator.acceptStep(). At this point
    // detector2 has g0Positive == true but the event time is set to just
    // before the event so g(t0) is negative. Now on processing the
    // next step the root solver checks the sign of the start, midpoint,
    // and end of the interval so we need another event less than half a max
    // check interval after d2 so that the g function will be negative at
    // all three times. Then we get a non bracketing exception.
    Propagator propagator = getPropagator(10.0);
    // switched for 9 to 1 to be close to the start of the step
    double t1 = -1;
    Handler<EventDetector> handler1 = new Handler<>(Action.RESET_DERIVATIVES);
    TimeDetector detector1 = new TimeDetector(t1).withHandler(handler1).withMaxCheck(10).withThreshold(1e-9);
    propagator.addEventDetector(detector1);
    RecordAndContinue<EventDetector> handler2 = new RecordAndContinue<>();
    TimeDetector detector2 = new TimeDetector(t1 - 1e-15, t1 - 4.9).withHandler(handler2).withMaxCheck(11).withThreshold(1e-9);
    propagator.addEventDetector(detector2);
    // action
    propagator.propagate(epoch.shiftedBy(-20));
    // verify
    List<Event<EventDetector>> events1 = handler1.getEvents();
    Assert.assertEquals(1, events1.size());
    Assert.assertEquals(t1, events1.get(0).getState().getDate().durationFrom(epoch), 0.0);
    List<Event<EventDetector>> events2 = handler2.getEvents();
    Assert.assertEquals(0, events2.size());
}
Also used : RecordAndContinue(org.orekit.propagation.events.handlers.RecordAndContinue) Propagator(org.orekit.propagation.Propagator) EventHandler(org.orekit.propagation.events.handlers.EventHandler) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) Test(org.junit.Test)

Example 3 with RecordAndContinue

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

the class CloseEventsAbstractTest method testSimultaneousEventsReverse.

@Test
public void testSimultaneousEventsReverse() throws OrekitException {
    // setup
    Propagator propagator = getPropagator(10);
    RecordAndContinue<EventDetector> handler1 = new RecordAndContinue<>();
    TimeDetector detector1 = new TimeDetector(-5).withHandler(handler1).withMaxCheck(10).withThreshold(1);
    propagator.addEventDetector(detector1);
    RecordAndContinue<EventDetector> handler2 = new RecordAndContinue<>();
    TimeDetector detector2 = new TimeDetector(-5).withHandler(handler2).withMaxCheck(10).withThreshold(1);
    propagator.addEventDetector(detector2);
    // action
    propagator.propagate(epoch.shiftedBy(-20));
    // verify
    List<Event<EventDetector>> events1 = handler1.getEvents();
    Assert.assertEquals(1, events1.size());
    Assert.assertEquals(-5, events1.get(0).getState().getDate().durationFrom(epoch), 0.0);
    List<Event<EventDetector>> events2 = handler2.getEvents();
    Assert.assertEquals(1, events2.size());
    Assert.assertEquals(-5, events2.get(0).getState().getDate().durationFrom(epoch), 0.0);
}
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)

Example 4 with RecordAndContinue

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

the class CloseEventsAbstractTest method testCloseEventsReverse.

@Test
public void testCloseEventsReverse() throws OrekitException {
    // setup
    double tolerance = 1;
    Propagator propagator = getPropagator(10);
    RecordAndContinue<EventDetector> handler1 = new RecordAndContinue<>();
    TimeDetector detector1 = new TimeDetector(-5).withHandler(handler1).withMaxCheck(10).withThreshold(tolerance);
    propagator.addEventDetector(detector1);
    RecordAndContinue<EventDetector> handler2 = new RecordAndContinue<>();
    TimeDetector detector2 = new TimeDetector(-5.5).withHandler(handler2).withMaxCheck(10).withThreshold(tolerance);
    propagator.addEventDetector(detector2);
    // action
    propagator.propagate(epoch.shiftedBy(-20));
    // verify
    List<Event<EventDetector>> events1 = handler1.getEvents();
    Assert.assertEquals(1, events1.size());
    Assert.assertEquals(-5, events1.get(0).getState().getDate().durationFrom(epoch), tolerance);
    List<Event<EventDetector>> events2 = handler2.getEvents();
    Assert.assertEquals(1, events2.size());
    Assert.assertEquals(-5.5, events2.get(0).getState().getDate().durationFrom(epoch), tolerance);
}
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)

Example 5 with RecordAndContinue

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

the class CloseEventsAbstractTest method testSimultaneousEvents.

@Test
public void testSimultaneousEvents() throws OrekitException {
    // setup
    Propagator propagator = getPropagator(10);
    RecordAndContinue<EventDetector> handler1 = new RecordAndContinue<>();
    TimeDetector detector1 = new TimeDetector(5).withHandler(handler1).withMaxCheck(10).withThreshold(1);
    propagator.addEventDetector(detector1);
    RecordAndContinue<EventDetector> handler2 = new RecordAndContinue<>();
    TimeDetector detector2 = new TimeDetector(5).withHandler(handler2).withMaxCheck(10).withThreshold(1);
    propagator.addEventDetector(detector2);
    // action
    propagator.propagate(epoch.shiftedBy(20));
    // verify
    List<Event<EventDetector>> events1 = handler1.getEvents();
    Assert.assertEquals(1, events1.size());
    Assert.assertEquals(5, events1.get(0).getState().getDate().durationFrom(epoch), 0.0);
    List<Event<EventDetector>> events2 = handler2.getEvents();
    Assert.assertEquals(1, events2.size());
    Assert.assertEquals(5, events2.get(0).getState().getDate().durationFrom(epoch), 0.0);
}
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