Search in sources :

Example 51 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class EventDetectorTest method testWrappedException.

@Test
public void testWrappedException() throws OrekitException {
    final Throwable dummyCause = new RuntimeException();
    try {
        // initial conditions
        Frame eme2000 = FramesFactory.getEME2000();
        TimeScale utc = TimeScalesFactory.getUTC();
        final AbsoluteDate initialDate = new AbsoluteDate(2011, 5, 11, utc);
        final AbsoluteDate exceptionDate = initialDate.shiftedBy(3600.0);
        KeplerianPropagator k = new KeplerianPropagator(new EquinoctialOrbit(new PVCoordinates(new Vector3D(4008462.4706055815, -3155502.5373837613, -5044275.9880020910), new Vector3D(-5012.9298276860990, 1920.3567095973078, -5172.7403501801580)), eme2000, initialDate, Constants.WGS84_EARTH_MU));
        k.addEventDetector(new DateDetector(initialDate.shiftedBy(Constants.JULIAN_DAY)) {

            private static final long serialVersionUID = 1L;

            @Override
            public double g(final SpacecraftState s) throws OrekitException {
                final double dt = s.getDate().durationFrom(exceptionDate);
                if (FastMath.abs(dt) < 1.0) {
                    throw new OrekitException(dummyCause, LocalizedCoreFormats.SIMPLE_MESSAGE, "dummy");
                }
                return dt;
            }
        });
        k.propagate(initialDate.shiftedBy(Constants.JULIAN_YEAR));
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertSame(dummyCause, oe.getCause());
    }
}
Also used : Frame(org.orekit.frames.Frame) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 52 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class EventDetectorTest method testIssue108Numerical.

@Test
public void testIssue108Numerical() throws OrekitException {
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
    final double step = 60.0;
    final int n = 100;
    NumericalPropagator propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(step));
    propagator.resetInitialState(new SpacecraftState(orbit));
    GCallsCounter counter = new GCallsCounter(100000.0, 1.0e-6, 20, new StopOnEvent<GCallsCounter>());
    propagator.addEventDetector(counter);
    propagator.propagate(date.shiftedBy(n * step));
    Assert.assertEquals(n + 1, counter.getCount());
}
Also used : Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) PVCoordinates(org.orekit.utils.PVCoordinates) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) Test(org.junit.Test)

Example 53 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class EventDetectorTest method testBasicScheduling.

@Test
public void testBasicScheduling() throws OrekitException {
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
    Propagator propagator = new KeplerianPropagator(orbit);
    double stepSize = 60.0;
    OutOfOrderChecker checker = new OutOfOrderChecker(stepSize);
    propagator.addEventDetector(new DateDetector(date.shiftedBy(5.25 * stepSize)).withHandler(checker));
    propagator.setMasterMode(stepSize, checker);
    propagator.propagate(date.shiftedBy(10 * stepSize));
    Assert.assertTrue(checker.outOfOrderCallDetected());
}
Also used : KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 54 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class FieldEventDetectorTest method doTestIssue108Numerical.

private <T extends RealFieldElement<T>> void doTestIssue108Numerical(Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    final TimeScale utc = TimeScalesFactory.getUTC();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
    final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
    final T step = zero.add(60.0);
    final int n = 100;
    FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, new ClassicalRungeKuttaFieldIntegrator<>(field, step));
    propagator.setOrbitType(OrbitType.EQUINOCTIAL);
    propagator.resetInitialState(new FieldSpacecraftState<>(orbit));
    GCallsCounter<T> counter = new GCallsCounter<>(zero.add(100000.0), zero.add(1.0e-6), 20, new FieldStopOnEvent<GCallsCounter<T>, T>());
    propagator.addEventDetector(counter);
    propagator.propagate(date.shiftedBy(step.multiply(n)));
    Assert.assertEquals(n + 1, counter.getCount());
}
Also used : TimeScale(org.orekit.time.TimeScale) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldCircularOrbit(org.orekit.orbits.FieldCircularOrbit)

Example 55 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class FieldEventDetectorTest method doTestNoisyGFunction.

private <T extends RealFieldElement<T>> void doTestNoisyGFunction(Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    // initial conditions
    Frame eme2000 = FramesFactory.getEME2000();
    TimeScale utc = TimeScalesFactory.getUTC();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2011, 5, 11, utc);
    FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, 2032, 10, 17, utc);
    @SuppressWarnings("unchecked") FieldAbsoluteDate<T>[] interruptDates = (FieldAbsoluteDate<T>[]) Array.newInstance(FieldAbsoluteDate.class, 1);
    interruptDates[0] = new FieldAbsoluteDate<>(field, 2032, 10, 18, utc);
    FieldAbsoluteDate<T> targetDate = new FieldAbsoluteDate<>(field, 2211, 5, 11, utc);
    FieldKeplerianPropagator<T> k1 = new FieldKeplerianPropagator<>(new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(4008462.4706055815), zero.add(-3155502.5373837613), zero.add(-5044275.9880020910)), new FieldVector3D<>(zero.add(-5012.9298276860990), zero.add(1920.3567095973078), zero.add(-5172.7403501801580))), eme2000, initialDate, Constants.WGS84_EARTH_MU));
    FieldKeplerianPropagator<T> k2 = new FieldKeplerianPropagator<>(new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(4008912.4039522274), zero.add(-3155453.3125615157), zero.add(-5044297.6484738905)), new FieldVector3D<>(zero.add(-5012.5883854112530), zero.add(1920.6332221785074), zero.add(-5172.2177085540500))), eme2000, initialDate, Constants.WGS84_EARTH_MU));
    k2.addEventDetector(new FieldCloseApproachDetector<>(zero.add(2015.243454166727), zero.add(0.0001), 100, new FieldContinueOnEvent<FieldCloseApproachDetector<T>, T>(), k1));
    k2.addEventDetector(new FieldDateDetector<>(zero.add(Constants.JULIAN_DAY), zero.add(1.0e-6), interruptDates));
    FieldSpacecraftState<T> s = k2.propagate(startDate, targetDate);
    Assert.assertEquals(0.0, interruptDates[0].durationFrom(s.getDate()).getReal(), 1.1e-6);
}
Also used : Frame(org.orekit.frames.Frame) FieldContinueOnEvent(org.orekit.propagation.events.handlers.FieldContinueOnEvent) TimeScale(org.orekit.time.TimeScale) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

TimeScale (org.orekit.time.TimeScale)116 AbsoluteDate (org.orekit.time.AbsoluteDate)89 Test (org.junit.Test)75 Frame (org.orekit.frames.Frame)44 Orbit (org.orekit.orbits.Orbit)38 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)38 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)35 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)32 SpacecraftState (org.orekit.propagation.SpacecraftState)30 PVCoordinates (org.orekit.utils.PVCoordinates)28 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)25 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)17 OrekitException (org.orekit.errors.OrekitException)17 Propagator (org.orekit.propagation.Propagator)17 EcksteinHechlerPropagator (org.orekit.propagation.analytical.EcksteinHechlerPropagator)15 BodiesElements (org.orekit.data.BodiesElements)14 FundamentalNutationArguments (org.orekit.data.FundamentalNutationArguments)14 CartesianOrbit (org.orekit.orbits.CartesianOrbit)14 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)14 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)13