Search in sources :

Example 66 with Propagator

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);
}
Also used : Propagator(org.orekit.propagation.Propagator) ArrayList(java.util.ArrayList) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) Test(org.junit.Test)

Example 67 with Propagator

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());
}
Also used : ArrayList(java.util.ArrayList) SpacecraftState(org.orekit.propagation.SpacecraftState) Propagator(org.orekit.propagation.Propagator) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Test(org.junit.Test)

Example 68 with Propagator

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());
}
Also used : Propagator(org.orekit.propagation.Propagator) ArrayList(java.util.ArrayList) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 69 with Propagator

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());
}
Also used : Propagator(org.orekit.propagation.Propagator) ArrayList(java.util.ArrayList) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) Test(org.junit.Test)

Example 70 with Propagator

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);
}
Also used : Propagator(org.orekit.propagation.Propagator) ArrayList(java.util.ArrayList) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) Test(org.junit.Test)

Aggregations

Propagator (org.orekit.propagation.Propagator)177 Test (org.junit.Test)141 SpacecraftState (org.orekit.propagation.SpacecraftState)92 AbsoluteDate (org.orekit.time.AbsoluteDate)90 Context (org.orekit.estimation.Context)67 NumericalPropagatorBuilder (org.orekit.propagation.conversion.NumericalPropagatorBuilder)67 ArrayList (java.util.ArrayList)62 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)58 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)51 Orbit (org.orekit.orbits.Orbit)46 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)41 ObservedMeasurement (org.orekit.estimation.measurements.ObservedMeasurement)40 Event (org.orekit.propagation.events.handlers.RecordAndContinue.Event)38 StopOnEvent (org.orekit.propagation.events.handlers.StopOnEvent)38 OrekitException (org.orekit.errors.OrekitException)30 EcksteinHechlerPropagator (org.orekit.propagation.analytical.EcksteinHechlerPropagator)29 GeodeticPoint (org.orekit.bodies.GeodeticPoint)28 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)28 PVCoordinates (org.orekit.utils.PVCoordinates)26 ParameterDriver (org.orekit.utils.ParameterDriver)23