use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testDoubleRoot.
/**
* Check when g(t) has a multiple root. e.g. g(t < root) < 0, g(root) = 0, g(t > root)
* < 0.
*/
@Test
public void testDoubleRoot() 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);
TimeDetector detectorB = new TimeDetector(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.assertTrue(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.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testEventCausedByStateResetReverse.
/**
* Test a reset event triggering another event at the same time.
*/
@Test
public void testEventCausedByStateResetReverse() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
double t1 = -15.0;
SpacecraftState newState = new SpacecraftState(new KeplerianOrbit(6378137 + 500e3, 0, FastMath.PI / 2, 0, 0, FastMath.PI / 2, PositionAngle.TRUE, eci, epoch.shiftedBy(t1), mu));
// 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 Handler<EventDetector>(events, Action.RESET_STATE) {
@Override
public SpacecraftState resetState(EventDetector detector, SpacecraftState oldState) {
return newState;
}
}).withMaxCheck(maxCheck).withThreshold(tolerance);
LatitudeCrossingDetector detectorB = new LatitudeCrossingDetector(earth, FastMath.toRadians(80)).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(-40.0));
// verify
// really we only care that the Rules of Event Handling are not violated,
Assert.assertEquals(2, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertEquals(detectorA, events.get(0).getDetector());
Assert.assertEquals(t1, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(false, events.get(1).isIncreasing());
Assert.assertEquals(detectorB, events.get(1).getDetector());
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testToleranceMaxIterations.
/**
* check when root finding tolerance > event finding tolerance.
*/
@Test
public void testToleranceMaxIterations() 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), tolerance);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertSame(detectorA, events.get(0).getDetector());
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testRootPlusToleranceHasWrongSignAndLessThanTb.
/**
* check when g(t < root) < 0, g(root + convergence) < 0.
*/
@Test
public void testRootPlusToleranceHasWrongSignAndLessThanTb() throws OrekitException {
// setup
// test is fragile w.r.t. implementation and these parameters
double maxCheck = 10;
double tolerance = 0.5;
double t1 = 11, t2 = 11.4, t3 = 12.0;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
FlatDetector detectorB = new FlatDetector(t1, t2, t3).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(30));
// verify
// allowed to find t1 or t3.
Assert.assertEquals(1, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertSame(detectorB, events.get(0).getDetector());
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testRootPlusToleranceHasWrongSignReverse.
/**
* check when g(t < root) < 0, g(root + convergence) < 0.
*/
@Test
public void testRootPlusToleranceHasWrongSignReverse() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
final double toleranceB = 0.3;
double t1 = -11, t2 = -11.1, t3 = -11.2;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
TimeDetector detectorA = new TimeDetector(t2).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
TimeDetector detectorB = new TimeDetector(-50, t1, t3).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(toleranceB);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(-30.0));
// verify
// we only care that the rules are satisfied. There are multiple solutions.
Assert.assertEquals(3, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), toleranceB);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertSame(detectorB, events.get(0).getDetector());
Assert.assertEquals(t3, events.get(1).getState().getDate().durationFrom(epoch), toleranceB);
Assert.assertEquals(false, events.get(1).isIncreasing());
Assert.assertSame(detectorB, events.get(1).getDetector());
Assert.assertEquals(t2, events.get(2).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(2).isIncreasing());
Assert.assertSame(detectorA, events.get(2).getDetector());
// ascending order
Assert.assertTrue(events.get(0).getState().getDate().compareTo(events.get(1).getState().getDate()) >= 0);
Assert.assertTrue(events.get(1).getState().getDate().compareTo(events.get(2).getState().getDate()) >= 0);
}
Aggregations