Search in sources :

Example 51 with Propagator

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

the class CloseEventsAbstractTest method testRootFindingToleranceReverse.

/**
 * Test case for two event detectors. DetectorA has event at t2, DetectorB at t3, but
 * due to the root finding tolerance DetectorB's event occurs at t1. With t1 < t2 <
 * t3.
 */
@Test
public void testRootFindingToleranceReverse() throws OrekitException {
    // setup
    double maxCheck = 10;
    double t2 = -11, t3 = t2 - 1e-5;
    List<Event<EventDetector>> events = new ArrayList<>();
    TimeDetector detectorA = new TimeDetector(t2).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(1e-6);
    FlatDetector detectorB = new FlatDetector(t3).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(0.5);
    Propagator propagator = getPropagator(10);
    propagator.addEventDetector(detectorA);
    propagator.addEventDetector(detectorB);
    // action
    propagator.propagate(epoch.shiftedBy(-30.0));
    // verify
    // if these fail the event finding did its job,
    // but this test isn't testing what it is supposed to be
    Assert.assertSame(detectorB, events.get(0).getDetector());
    Assert.assertSame(detectorA, events.get(1).getDetector());
    Assert.assertTrue(events.get(0).getState().getDate().compareTo(events.get(1).getState().getDate()) > 0);
    // check event detection worked
    Assert.assertEquals(2, events.size());
    Assert.assertEquals(t3, events.get(0).getState().getDate().durationFrom(epoch), 0.5);
    Assert.assertEquals(true, events.get(0).isIncreasing());
    Assert.assertEquals(t2, events.get(1).getState().getDate().durationFrom(epoch), 1e-6);
    Assert.assertEquals(true, events.get(1).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 52 with Propagator

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

the class CloseEventsAbstractTest method testRootPlusToleranceHasWrongSign.

/**
 * check when g(t < root) < 0,  g(root + convergence) < 0.
 */
@Test
public void testRootPlusToleranceHasWrongSign() 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(1e-6);
    TimeDetector detectorB = new TimeDetector(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));
    // verify
    // we only care that the rules are satisfied, there are other 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());
    // chronological
    for (int i = 1; i < events.size(); i++) {
        Assert.assertTrue(events.get(i).getState().getDate().compareTo(events.get(i - 1).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)

Example 53 with Propagator

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

the class CloseEventsAbstractTest method testMultipleBackups.

/**
 * Test where an event detector has to back up multiple times.
 */
@Test
public void testMultipleBackups() throws OrekitException {
    // setup
    double maxCheck = 10;
    double tolerance = 1e-6;
    double t1 = 1.0, t2 = 2, t3 = 3, t4 = 4, t5 = 5, t6 = 6.5, t7 = 7;
    // shared event list so we know the order in which they occurred
    List<Event<EventDetector>> events = new ArrayList<>();
    ContinuousDetector detectorA = new ContinuousDetector(t6).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
    FlatDetector detectorB = new FlatDetector(t1, t3, t4, t7).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
    ContinuousDetector detectorC = new ContinuousDetector(t2, t5).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
    Propagator propagator = getPropagator(10);
    propagator.addEventDetector(detectorA);
    propagator.addEventDetector(detectorB);
    propagator.addEventDetector(detectorC);
    // action
    propagator.propagate(epoch.shiftedBy(30));
    // verify
    // need at least 5 events to check that multiple backups occurred
    Assert.assertEquals(5, events.size());
    Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(true, events.get(0).isIncreasing());
    Assert.assertEquals(detectorB, events.get(0).getDetector());
    Assert.assertEquals(t2, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(true, events.get(1).isIncreasing());
    Assert.assertEquals(detectorC, events.get(1).getDetector());
    // reporting t3 and t4 is optional, seeing them is not.
    // we know a root was found at t3 because events are reported at t2 and t5.
    /*
        Assert.assertEquals(t3, events.get(2).getT(), tolerance);
        Assert.assertEquals(false, events.get(2).isIncreasing());
        Assert.assertEquals(detectorB, events.get(2).getHandler());
        Assert.assertEquals(t4, events.get(3).getT(), tolerance);
        Assert.assertEquals(true, events.get(3).isIncreasing());
        Assert.assertEquals(detectorB, events.get(3).getHandler());
        */
    Assert.assertEquals(t5, events.get(2).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(false, events.get(2).isIncreasing());
    Assert.assertEquals(detectorC, events.get(2).getDetector());
    Assert.assertEquals(t6, events.get(3).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(true, events.get(3).isIncreasing());
    Assert.assertEquals(detectorA, events.get(3).getDetector());
    Assert.assertEquals(t7, events.get(4).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(false, events.get(4).isIncreasing());
    Assert.assertEquals(detectorB, events.get(4).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 54 with Propagator

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

the class CloseEventsAbstractTest method testEventCausedByStateReset.

/**
 * Test a reset event triggering another event at the same time.
 */
@Test
public void testEventCausedByStateReset() 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(true, 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 55 with Propagator

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

the class CloseEventsAbstractTest method testShortBracketingIntervalReverse.

/**
 * The root finder requires the start point to be in the interval (a, b) which is hard
 * when there aren't many numbers between a and b. This test uses a second event
 * detector to force a very small window for the first event detector.
 */
@Test
public void testShortBracketingIntervalReverse() throws OrekitException {
    // setup
    double maxCheck = 10;
    double tolerance = 1e-6;
    final double t1 = FastMath.nextDown(-10.0), t2 = -10.5;
    // shared event list so we know the order in which they occurred
    List<Event<EventDetector>> events = new ArrayList<>();
    // never zero so there is no easy way out
    EventDetector detectorA = new AbstractDetector<EventDetector>(maxCheck, tolerance, 100, new RecordAndContinue<>(events)) {

        private static final long serialVersionUID = 1L;

        @Override
        public double g(SpacecraftState state) {
            final AbsoluteDate t = state.getDate();
            if (t.compareTo(epoch.shiftedBy(t1)) > 0) {
                return -1;
            } else if (t.compareTo(epoch.shiftedBy(t2)) > 0) {
                return 1;
            } else {
                return -1;
            }
        }

        @Override
        protected EventDetector create(double newMaxCheck, double newThreshold, int newMaxIter, EventHandler<? super EventDetector> newHandler) {
            return null;
        }
    };
    TimeDetector detectorB = new TimeDetector(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.0));
    // verify
    Assert.assertEquals(3, 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(t1, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(true, 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());
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) Propagator(org.orekit.propagation.Propagator) ArrayList(java.util.ArrayList) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) EventHandler(org.orekit.propagation.events.handlers.EventHandler) AbsoluteDate(org.orekit.time.AbsoluteDate) 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