use of org.orekit.propagation.events.handlers.RecordAndContinue.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testCloseEventsFirstOneIsReset.
@Test
public void testCloseEventsFirstOneIsReset() 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);
double t1 = 49, t2 = t1 + 1e-15, t3 = t1 + 4.9;
List<Event<EventDetector>> events = new ArrayList<>();
TimeDetector detector1 = new TimeDetector(t1).withHandler(new Handler<>(events, Action.RESET_DERIVATIVES)).withMaxCheck(10).withThreshold(1e-9);
propagator.addEventDetector(detector1);
TimeDetector detector2 = new TimeDetector(t2, t3).withHandler(new RecordAndContinue<>(events)).withMaxCheck(11).withThreshold(1e-9);
propagator.addEventDetector(detector2);
// action
propagator.propagate(epoch.shiftedBy(60));
// verify
Assert.assertEquals(1, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), 0.0);
Assert.assertEquals(detector1, events.get(0).getDetector());
}
use of org.orekit.propagation.events.handlers.RecordAndContinue.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testConvergenceTooTight.
/**
* check when t + tolerance == t.
*/
@Test
public void testConvergenceTooTight() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-18;
double t1 = 15;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
ContinuousDetector detectorA = new ContinuousDetector(t1).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
// action
propagator.propagate(epoch.shiftedBy(30));
// 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());
}
use of org.orekit.propagation.events.handlers.RecordAndContinue.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testToleranceMaxIterationsReverse.
/**
* check when root finding tolerance > event finding tolerance.
*/
@Test
public void testToleranceMaxIterationsReverse() throws OrekitException {
// setup
double maxCheck = 10;
// less than 1 ulp
double tolerance = 1e-18;
AbsoluteDate t1 = epoch.shiftedBy(-15).shiftedBy(FastMath.ulp(-15.0) / 8);
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
FlatDetector detectorA = new FlatDetector(t1).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
// action
propagator.propagate(epoch.shiftedBy(-30));
// verify
Assert.assertEquals(1, events.size());
// use root finder tolerance instead of event finder tolerance.
Assert.assertEquals(t1.durationFrom(epoch), events.get(0).getState().getDate().durationFrom(epoch), FastMath.ulp(-15.0));
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertSame(detectorA, events.get(0).getDetector());
}
use of org.orekit.propagation.events.handlers.RecordAndContinue.Event in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testDoubleRootOppositeSign.
/**
* Check when g(t) has a multiple root. e.g. g(t < root) > 0, g(root) = 0, g(t > root)
* > 0.
*/
@Test
public void testDoubleRootOppositeSign() 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(-20, t1, t1).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(30));
// 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);
}
Aggregations