Search in sources :

Example 61 with Propagator

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

the class CloseEventsAbstractTest method testFastSwitchingReverse.

/**
 * test the g function switching with a period shorter than the tolerance. We don't
 * need to find any of the events, but we do need to not crash. And we need to
 * preserve the alternating increasing / decreasing sequence.
 */
@Test
public void testFastSwitchingReverse() throws OrekitException {
    // setup
    // step size of 10 to land in between two events we would otherwise miss
    Propagator propagator = getPropagator(10);
    List<Event<EventDetector>> events = new ArrayList<>();
    TimeDetector detector1 = new TimeDetector(-9.9, -10.1, -12).withHandler(new RecordAndContinue<>(events)).withMaxCheck(10).withThreshold(0.2);
    propagator.addEventDetector(detector1);
    // action
    propagator.propagate(epoch.shiftedBy(-20));
    // verify
    // finds one or three events. Not 2.
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(-9.9, events.get(0).getState().getDate().durationFrom(epoch), 0.2);
    Assert.assertEquals(true, events.get(0).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 62 with Propagator

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

the class CloseEventsAbstractTest method testConvergenceTooTightReverse.

/**
 * check when t + tolerance == t.
 */
@Test
public void testConvergenceTooTightReverse() 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.0));
    // 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());
}
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 63 with Propagator

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

the class CloseEventsAbstractTest method testRootFindingTolerance.

/**
 * 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 testRootFindingTolerance() 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));
    // 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 64 with Propagator

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

the class CloseEventsAbstractTest method testMultipleBackupsReverse.

/**
 * Test where an event detector has to back up multiple times.
 */
@Test
public void testMultipleBackupsReverse() 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);
    ContinuousDetector detectorB = new ContinuousDetector(-50, t1, t3, t4, t7).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
    ContinuousDetector detectorC = new ContinuousDetector(-50, 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.0));
    // verify
    // really we only care that the Rules of Event Handling are not violated,
    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 65 with Propagator

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

the class CloseEventsAbstractTest method testZeroAtBeginningAndEndOfInterval.

/**
 * check root finding when zero at both ends.
 */
@Test
public void testZeroAtBeginningAndEndOfInterval() 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), 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(false, 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)

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