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