Search in sources :

Example 56 with Propagator

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

Example 57 with Propagator

use of org.orekit.propagation.Propagator in project Orekit by CS-SI.

the class CloseEventsAbstractTest method testZeroAtBeginningAndEndOfIntervalOppositeSignReverse.

/**
 * check root finding when zero at both ends.
 */
@Test
public void testZeroAtBeginningAndEndOfIntervalOppositeSignReverse() 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(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), 0.0);
    Assert.assertEquals(false, events.get(0).isIncreasing());
    Assert.assertSame(detectorA, events.get(0).getDetector());
    Assert.assertEquals(t2, events.get(1).getState().getDate().durationFrom(epoch), 0.0);
    Assert.assertEquals(true, events.get(1).isIncreasing());
    Assert.assertSame(detectorA, events.get(1).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 58 with Propagator

use of org.orekit.propagation.Propagator in project Orekit by CS-SI.

the class CloseEventsAbstractTest method testTrickyCaseLower.

/**
 * "A Tricky Problem" from bug #239.
 */
@Test
public void testTrickyCaseLower() 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(-10, 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());
}
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 59 with Propagator

use of org.orekit.propagation.Propagator in project Orekit by CS-SI.

the class CloseEventsAbstractTest method testEventChangesGFunctionDefinition.

/**
 * test when one event detector changes the definition of another's g function before
 * the end of the step as a result of a continue action. Not sure if this should be
 * officially supported, but it is used in Orekit's DateDetector, it's useful, and not
 * too hard to implement.
 */
@Test
public void testEventChangesGFunctionDefinition() throws OrekitException {
    // setup
    double maxCheck = 5;
    double tolerance = 1e-6;
    double t1 = 11, t2 = 19;
    // shared event list so we know the order in which they occurred
    List<Event<EventDetector>> events = new ArrayList<>();
    // mutable boolean
    boolean[] swap = new boolean[1];
    final ContinuousDetector detectorA = new ContinuousDetector(t1).withThreshold(maxCheck).withThreshold(tolerance).withHandler(new RecordAndContinue<EventDetector>(events) {

        @Override
        public Action eventOccurred(SpacecraftState s, EventDetector detector, boolean increasing) {
            swap[0] = true;
            return super.eventOccurred(s, detector, increasing);
        }
    });
    ContinuousDetector detectorB = new ContinuousDetector(t2);
    EventDetector detectorC = new AbstractDetector<EventDetector>(maxCheck, tolerance, 100, new RecordAndContinue<>(events)) {

        private static final long serialVersionUID = 1L;

        @Override
        public double g(SpacecraftState s) throws OrekitException {
            if (swap[0]) {
                return detectorB.g(s);
            } else {
                return -1;
            }
        }

        @Override
        protected EventDetector create(double newMaxCheck, double newThreshold, int newMaxIter, EventHandler<? super EventDetector> newHandler) {
            return null;
        }
    };
    Propagator propagator = getPropagator(10);
    propagator.addEventDetector(detectorA);
    propagator.addEventDetector(detectorC);
    // 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(true, 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(detectorC, events.get(1).getDetector());
}
Also used : Action(org.orekit.propagation.events.handlers.EventHandler.Action) ArrayList(java.util.ArrayList) EventHandler(org.orekit.propagation.events.handlers.EventHandler) 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) Test(org.junit.Test)

Example 60 with Propagator

use of org.orekit.propagation.Propagator in project Orekit by CS-SI.

the class CloseEventsAbstractTest method testRootPlusToleranceHasWrongSignAndLessThanTbReverse.

/**
 * check when g(t < root) < 0,  g(root + convergence) < 0.
 */
@Test
public void testRootPlusToleranceHasWrongSignAndLessThanTbReverse() 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.0));
    // verify
    // allowed to report 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)

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