Search in sources :

Example 11 with TimeScale

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

the class FieldNumericalPropagatorTest method doTestEphemerisDatesBackward.

private <T extends RealFieldElement<T>> void doTestEphemerisDatesBackward(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-05", tai);
    FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
    FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(endDate, startDate);
    FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
    // test date
    FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
Also used : Frame(org.orekit.frames.Frame) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 12 with TimeScale

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

the class FieldNumericalPropagatorTest method doTestEphemerisDates.

private <T extends RealFieldElement<T>> void doTestEphemerisDates(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-01", tai);
    FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
    FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(startDate, endDate);
    FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
    // test date
    FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
Also used : Frame(org.orekit.frames.Frame) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 13 with TimeScale

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

the class NumericalPropagatorTest method testEphemerisDates.

@Test
public void testEphemerisDates() throws OrekitException {
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    AbsoluteDate initialDate = new AbsoluteDate("2015-07-01", tai);
    AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1);
    AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    KeplerianOrbit orbit = new KeplerianOrbit(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit, type);
    NumericalPropagator prop = new NumericalPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(startDate, endDate);
    BoundedPropagator ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0));
    // test date
    AbsoluteDate date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) TimeScale(org.orekit.time.TimeScale) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 14 with TimeScale

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

the class NumericalPropagatorTest method testParallelismIssue258.

@Test
public void testParallelismIssue258() throws OrekitException, InterruptedException, ExecutionException, FileNotFoundException {
    Utils.setDataRoot("regular-data:atmosphere:potential/grgs-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
    final double mu = GravityFieldFactory.getNormalizedProvider(2, 2).getMu();
    // Geostationary transfer orbit
    // semi major axis in meters
    final double a = 24396159;
    // eccentricity
    final double e = 0.72831215;
    // inclination
    final double i = FastMath.toRadians(7);
    // perigee argument
    final double omega = FastMath.toRadians(180);
    // right ascension of ascending node
    final double raan = FastMath.toRadians(261);
    // mean anomaly
    final double lM = 0;
    final Frame inertialFrame = FramesFactory.getEME2000();
    final TimeScale utc = TimeScalesFactory.getUTC();
    final AbsoluteDate initialDate = new AbsoluteDate(2003, 1, 1, 00, 00, 00.000, utc);
    final Orbit initialOrbit = new CartesianOrbit(new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu));
    final SpacecraftState initialState = new SpacecraftState(initialOrbit, 1000);
    // initialize the testing points
    final List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    final NumericalPropagator propagator = createPropagator(initialState, OrbitType.CARTESIAN, PositionAngle.TRUE);
    final double samplingStep = 10000.0;
    propagator.setMasterMode(samplingStep, (state, isLast) -> states.add(state));
    propagator.propagate(initialDate.shiftedBy(5 * samplingStep));
    // compute reference errors, using serial computation in a for loop
    final double[][] referenceErrors = new double[states.size() - 1][];
    for (int startIndex = 0; startIndex < states.size() - 1; ++startIndex) {
        referenceErrors[startIndex] = recomputeFollowing(startIndex, states);
    }
    final Consumer<SpacecraftState> checker = point -> {
        try {
            final int startIndex = states.indexOf(point);
            double[] errors = recomputeFollowing(startIndex, states);
            for (int k = 0; k < errors.length; ++k) {
                Assert.assertEquals(startIndex + " to " + (startIndex + k + 1), referenceErrors[startIndex][k], errors[k], 1.0e-9);
            }
        } catch (OrekitException oe) {
            Assert.fail(oe.getLocalizedMessage());
        }
    };
    // serial propagation using Stream
    states.stream().forEach(checker);
    // parallel propagation using parallelStream
    states.parallelStream().forEach(checker);
}
Also used : ParameterDriver(org.orekit.utils.ParameterDriver) CoreMatchers(org.hamcrest.CoreMatchers) ApsideDetector(org.orekit.propagation.events.ApsideDetector) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) ForceModel(org.orekit.forces.ForceModel) Frame(org.orekit.frames.Frame) DragForce(org.orekit.forces.drag.DragForce) IERSConventions(org.orekit.utils.IERSConventions) PVCoordinates(org.orekit.utils.PVCoordinates) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) GRGSFormatReader(org.orekit.forces.gravity.potential.GRGSFormatReader) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldEventDetector(org.orekit.propagation.events.FieldEventDetector) After(org.junit.After) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) ThirdBodyAttraction(org.orekit.forces.gravity.ThirdBodyAttraction) PositionAngle(org.orekit.orbits.PositionAngle) DateDetector(org.orekit.propagation.events.DateDetector) ParseException(java.text.ParseException) Utils(org.orekit.Utils) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FramesFactory(org.orekit.frames.FramesFactory) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) FileNotFoundException(java.io.FileNotFoundException) SHMFormatReader(org.orekit.forces.gravity.potential.SHMFormatReader) List(java.util.List) Stream(java.util.stream.Stream) MatcherAssert(org.hamcrest.MatcherAssert) DataProvidersManager(org.orekit.data.DataProvidersManager) RealFieldElement(org.hipparchus.RealFieldElement) EventDetector(org.orekit.propagation.events.EventDetector) Action(org.orekit.propagation.events.handlers.EventHandler.Action) SolarRadiationPressure(org.orekit.forces.radiation.SolarRadiationPressure) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) ContinueOnEvent(org.orekit.propagation.events.handlers.ContinueOnEvent) OrekitStepHandler(org.orekit.propagation.sampling.OrekitStepHandler) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) AbstractIntegratedPropagator(org.orekit.propagation.integration.AbstractIntegratedPropagator) TimeScale(org.orekit.time.TimeScale) Orbit(org.orekit.orbits.Orbit) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) ArrayList(java.util.ArrayList) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) IsotropicRadiationSingleCoefficient(org.orekit.forces.radiation.IsotropicRadiationSingleCoefficient) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) OrbitType(org.orekit.orbits.OrbitType) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) OrekitStepInterpolator(org.orekit.propagation.sampling.OrekitStepInterpolator) FastMath(org.hipparchus.util.FastMath) AdditionalEquations(org.orekit.propagation.integration.AdditionalEquations) Before(org.junit.Before) Constants(org.orekit.utils.Constants) DTM2000(org.orekit.forces.drag.atmosphere.DTM2000) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrekitMatchers(org.orekit.OrekitMatchers) IOException(java.io.IOException) Test(org.junit.Test) GravityFieldFactory(org.orekit.forces.gravity.potential.GravityFieldFactory) MarshallSolarActivityFutureEstimation(org.orekit.forces.drag.atmosphere.data.MarshallSolarActivityFutureEstimation) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) Field(org.hipparchus.Field) OrekitMessages(org.orekit.errors.OrekitMessages) EventHandler(org.orekit.propagation.events.handlers.EventHandler) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) OrekitException(org.orekit.errors.OrekitException) CelestialBodyFactory(org.orekit.bodies.CelestialBodyFactory) TimeScalesFactory(org.orekit.time.TimeScalesFactory) IsotropicDrag(org.orekit.forces.drag.IsotropicDrag) LocalizedCoreFormats(org.hipparchus.exception.LocalizedCoreFormats) Assert(org.junit.Assert) AbstractDetector(org.orekit.propagation.events.AbstractDetector) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) AbsoluteDate(org.orekit.time.AbsoluteDate) Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ArrayList(java.util.ArrayList) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) GRGSFormatReader(org.orekit.forces.gravity.potential.GRGSFormatReader) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 15 with TimeScale

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

the class DSSTPropagatorTest method testEphemerisDates.

@Test
public void testEphemerisDates() throws OrekitException {
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    AbsoluteDate initialDate = new AbsoluteDate("2015-07-01", tai);
    AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1);
    AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    KeplerianOrbit orbit = new KeplerianOrbit(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, initialDate, Constants.EIGEN5C_EARTH_MU);
    double[][] tol = DSSTPropagator.tolerances(1, orbit);
    Propagator prop = new DSSTPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
    prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(startDate, endDate);
    BoundedPropagator ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0));
    // test date
    AbsoluteDate date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Propagator(org.orekit.propagation.Propagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) TimeScale(org.orekit.time.TimeScale) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

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