use of org.orekit.propagation.events.handlers.RecordAndContinue.Event 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.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testDoubleRootOppositeSignReverse.
/**
* Check when g(t) has a multiple root. e.g. g(t < root) > 0, g(root) = 0, g(t > root)
* > 0.
*/
@Test
public void testDoubleRootOppositeSignReverse() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
double t1 = -11;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
TimeDetector detectorA = new TimeDetector(t1).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
ContinuousDetector detectorB = new ContinuousDetector(-50, t1, t1).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
detectorB.g(state(t1));
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(-30.0));
// verify
Assert.assertEquals(1, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), 0.0);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertSame(detectorA, events.get(0).getDetector());
// detector worked correctly
Assert.assertEquals(0.0, detectorB.g(state(t1)), 0.0);
Assert.assertTrue(detectorB.g(state(t1 + 1e-6)) > 0);
Assert.assertTrue(detectorB.g(state(t1 - 1e-6)) > 0);
}
use of org.orekit.propagation.events.handlers.RecordAndContinue.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testTrickyCaseLowerReverse.
/**
* "A Tricky Problem" from bug #239.
*/
@Test
public void testTrickyCaseLowerReverse() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
double t1 = -1.0, t2 = -15, t3 = -16, t4 = -17, t5 = -18;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
TimeDetector detectorA = new TimeDetector(t3).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
TimeDetector detectorB = new TimeDetector(-50, t1, t2, t5).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
TimeDetector detectorC = new TimeDetector(t4).withHandler(new Handler<>(events, Action.RESET_DERIVATIVES)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
propagator.addEventDetector(detectorC);
// action
propagator.propagate(epoch.shiftedBy(-30));
// verify
// really we only care that the Rules of Event Handling are not violated,
// but I only know one way to do that in this case.
Assert.assertEquals(5, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(false, events.get(0).isIncreasing());
Assert.assertEquals(t2, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(1).isIncreasing());
Assert.assertEquals(t3, events.get(2).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(2).isIncreasing());
Assert.assertEquals(t4, events.get(3).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(3).isIncreasing());
Assert.assertEquals(t5, events.get(4).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(false, events.get(4).isIncreasing());
}
use of org.orekit.propagation.events.handlers.RecordAndContinue.Event 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.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testZeroAtBeginningAndEndOfIntervalOppositeSign.
/**
* check root finding when zero at both ends.
*/
@Test
public void testZeroAtBeginningAndEndOfIntervalOppositeSign() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
double t1 = 10, t2 = 20;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
ContinuousDetector detectorA = new ContinuousDetector(-10, t1, t2).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
// action
propagator.propagate(epoch.shiftedBy(30));
// verify
Assert.assertEquals(2, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(false, events.get(0).isIncreasing());
Assert.assertSame(detectorA, events.get(0).getDetector());
Assert.assertEquals(t2, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(1).isIncreasing());
Assert.assertSame(detectorA, events.get(1).getDetector());
}
Aggregations