Search in sources :

Example 46 with Propagator

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

the class KeplerianPropagatorTest method testPropagationDate.

/**
 * Check that the date returned by {@link KeplerianPropagator#propagate(AbsoluteDate)}
 * is the same as the date passed to propagate().
 *
 * @throws OrekitException on error.
 */
@Test
public void testPropagationDate() throws OrekitException {
    // setup
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
    // date s.t. target - date rounds down when represented as a double.
    AbsoluteDate target = initDate.shiftedBy(20.0).shiftedBy(FastMath.ulp(20.0) / 4);
    Orbit ic = new KeplerianOrbit(6378137 + 500e3, 1e-3, 0, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getGCRF(), initDate, mu);
    Propagator propagator = new KeplerianPropagator(ic);
    // action
    SpacecraftState actual = propagator.propagate(target);
    // verify
    Assert.assertEquals(target, actual.getDate());
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 47 with Propagator

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

the class FiniteDifferencePropagatorConverterTest method testGetObjectiveFunctionParametersOnlyScaledOnce.

/**
 * Test case for bug #362. Check that scaling is only applied once.
 *
 * @throws OrekitException on error.
 */
@Test
public void testGetObjectiveFunctionParametersOnlyScaledOnce() throws OrekitException {
    // setup
    // create some arbitrary sample data to run with
    Frame eci = FramesFactory.getGCRF();
    double gm = Constants.EIGEN5C_EARTH_MU;
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Propagator source = new KeplerianPropagator(new KeplerianOrbit(6878137, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, date, gm));
    // Create a mock builder that allows us to check the values passed to it
    PropagatorBuilder builder = Mockito.mock(PropagatorBuilder.class);
    ParameterDriversList list = new ParameterDriversList();
    list.add(new ParameterDriver("p1", 0, 1e-3, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
    Mockito.when(builder.getOrbitalParametersDrivers()).thenReturn(list);
    Mockito.when(builder.getPropagationParametersDrivers()).thenReturn(new ParameterDriversList());
    Mockito.when(builder.getFrame()).thenReturn(eci);
    Mockito.when(builder.getSelectedNormalizedParameters()).thenReturn(new double[1]);
    Mockito.when(builder.buildPropagator(Mockito.any(double[].class))).thenReturn(source);
    // subject under test
    FiniteDifferencePropagatorConverter converter = new FiniteDifferencePropagatorConverter(builder, 1, 100);
    // set some internal variables in FDPC that are not settable using another
    // interface
    converter.convert(source, 1, 2);
    // Forget all the side effect of the call to convert()
    Mockito.clearInvocations(builder);
    // action
    converter.getModel().value(new ArrayRealVector(1));
    // verify
    Mockito.verify(builder).buildPropagator(new double[] { 0 });
    Mockito.verify(builder).buildPropagator(new double[] { 1 });
}
Also used : KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Frame(org.orekit.frames.Frame) ParameterDriversList(org.orekit.utils.ParameterDriversList) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) ArrayRealVector(org.hipparchus.linear.ArrayRealVector) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ParameterDriver(org.orekit.utils.ParameterDriver) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 48 with Propagator

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

the class KeplerianConverterTest method checkFit.

protected void checkFit(final Orbit orbit, final double duration, final double stepSize, final double threshold, final boolean positionOnly, final double expectedRMS, final String... freeParameters) throws OrekitException {
    Propagator p = new KeplerianPropagator(orbit);
    List<SpacecraftState> sample = new ArrayList<SpacecraftState>();
    for (double dt = 0; dt < duration; dt += stepSize) {
        sample.add(p.propagate(orbit.getDate().shiftedBy(dt)));
    }
    PropagatorBuilder builder = new KeplerianPropagatorBuilder(OrbitType.KEPLERIAN.convertType(orbit), PositionAngle.MEAN, 1.0);
    FiniteDifferencePropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, threshold, 1000);
    fitter.convert(sample, positionOnly, freeParameters);
    Assert.assertEquals(expectedRMS, fitter.getRMS(), 0.01 * expectedRMS);
    KeplerianPropagator prop = (KeplerianPropagator) fitter.getAdaptedPropagator();
    Orbit fitted = prop.getInitialState().getOrbit();
    final double eps = 1.0e-12;
    Assert.assertEquals(orbit.getPVCoordinates().getPosition().getX(), fitted.getPVCoordinates().getPosition().getX(), eps * orbit.getPVCoordinates().getPosition().getX());
    Assert.assertEquals(orbit.getPVCoordinates().getPosition().getY(), fitted.getPVCoordinates().getPosition().getY(), eps * orbit.getPVCoordinates().getPosition().getY());
    Assert.assertEquals(orbit.getPVCoordinates().getPosition().getZ(), fitted.getPVCoordinates().getPosition().getZ(), eps * orbit.getPVCoordinates().getPosition().getZ());
    Assert.assertEquals(orbit.getPVCoordinates().getVelocity().getX(), fitted.getPVCoordinates().getVelocity().getX(), -eps * orbit.getPVCoordinates().getVelocity().getX());
    Assert.assertEquals(orbit.getPVCoordinates().getVelocity().getY(), fitted.getPVCoordinates().getVelocity().getY(), eps * orbit.getPVCoordinates().getVelocity().getY());
    Assert.assertEquals(orbit.getPVCoordinates().getVelocity().getZ(), fitted.getPVCoordinates().getVelocity().getZ(), eps * orbit.getPVCoordinates().getVelocity().getZ());
}
Also used : KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) ArrayList(java.util.ArrayList)

Example 49 with Propagator

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

the class CloseEventsAbstractTest method testCloseEvents.

@Test
public void testCloseEvents() throws OrekitException {
    // setup
    double tolerance = 1;
    Propagator propagator = getPropagator(10);
    RecordAndContinue<EventDetector> handler = new RecordAndContinue<>();
    TimeDetector detector1 = new TimeDetector(5).withHandler(handler).withMaxCheck(10).withThreshold(tolerance);
    propagator.addEventDetector(detector1);
    TimeDetector detector2 = new TimeDetector(5.5).withHandler(handler).withMaxCheck(10).withThreshold(tolerance);
    propagator.addEventDetector(detector2);
    // action
    propagator.propagate(epoch.shiftedBy(20));
    // verify
    List<Event<EventDetector>> events = handler.getEvents();
    Assert.assertEquals(2, events.size());
    Assert.assertEquals(5, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(detector1, events.get(0).getDetector());
    Assert.assertEquals(5.5, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
    Assert.assertEquals(detector2, events.get(1).getDetector());
}
Also used : RecordAndContinue(org.orekit.propagation.events.handlers.RecordAndContinue) 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 50 with Propagator

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

the class CloseEventsAbstractTest method testToleranceStopReverse.

/**
 * check when root finding tolerance > event finding tolerance.
 */
@Test
public void testToleranceStopReverse() throws OrekitException {
    // setup
    double maxCheck = 10;
    // less than 1 ulp
    double tolerance = 1e-18;
    double t1 = -15.1;
    // 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 Handler<>(events, Action.STOP)).withMaxCheck(maxCheck).withThreshold(tolerance);
    Propagator propagator = getPropagator(10);
    propagator.addEventDetector(detectorA);
    // action
    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(-30.0));
    // verify
    Assert.assertEquals(1, events.size());
    // use root finder tolerance instead of event finder tolerance.
    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(t1, finalState.getDate().durationFrom(epoch), tolerance);
    // try to resume propagation
    finalState = propagator.propagate(epoch.shiftedBy(-30.0));
    // verify it got to the end
    Assert.assertEquals(-30.0, finalState.getDate().durationFrom(epoch), 0.0);
}
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) 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