Search in sources :

Example 11 with BoundedPropagator

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

the class NumericalPropagatorTest method testEventAtBeginningOfEphemeris.

/**
 * test for issue #238
 */
@Test
public void testEventAtBeginningOfEphemeris() throws OrekitException {
    // setup
    // choose duration that will round up when expressed as a double
    AbsoluteDate end = initDate.shiftedBy(100).shiftedBy(3 * FastMath.ulp(100.0) / 4);
    propagator.setEphemerisMode();
    propagator.propagate(end);
    BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    CountingHandler handler = new CountingHandler();
    // events directly on propagation start date are not triggered,
    // so move the event date slightly after
    AbsoluteDate eventDate = initDate.shiftedBy(FastMath.ulp(100.0) / 10.0);
    DateDetector detector = new DateDetector(10, 1e-9, eventDate).withHandler(handler);
    // propagation works fine w/o event detector, but breaks with it
    ephemeris.addEventDetector(detector);
    // action + verify
    // propagate forward
    Assert.assertEquals(ephemeris.propagate(end).getDate().durationFrom(end), 0.0, 0.0);
    // propagate backward
    Assert.assertEquals(ephemeris.propagate(initDate).getDate().durationFrom(initDate), 0.0, 0.0);
    Assert.assertEquals(2, handler.eventCount);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 12 with BoundedPropagator

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

the class NumericalPropagatorTest method testEphemerisModeWithHandler.

@Test
public void testEphemerisModeWithHandler() throws OrekitException {
    // setup
    AbsoluteDate end = initDate.shiftedBy(90 * 60);
    // action
    final List<SpacecraftState> states = new ArrayList<>();
    propagator.setEphemerisMode((interpolator, isLast) -> states.add(interpolator.getCurrentState()));
    propagator.propagate(end);
    final BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    // verify
    // got some data
    Assert.assertTrue(states.size() > 10);
    for (SpacecraftState state : states) {
        PVCoordinates actual = ephemeris.propagate(state.getDate()).getPVCoordinates();
        Assert.assertThat(actual, OrekitMatchers.pvIs(state.getPVCoordinates()));
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) ArrayList(java.util.ArrayList) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 13 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator 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)

Example 14 with BoundedPropagator

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

the class DSSTPropagatorTest method testEphemeris.

@Test
public void testEphemeris() throws OrekitException {
    SpacecraftState state = getGEOState();
    setDSSTProp(state);
    // Set ephemeris mode
    dsstProp.setEphemerisMode();
    // Propagation of the initial state at t + 10 days
    final double dt = 2. * Constants.JULIAN_DAY;
    dsstProp.propagate(state.getDate().shiftedBy(5. * dt));
    // Get ephemeris
    BoundedPropagator ephem = dsstProp.getGeneratedEphemeris();
    // Propagation of the initial state with ephemeris at t + 2 days
    final SpacecraftState s = ephem.propagate(state.getDate().shiftedBy(dt));
    // Check results
    final double n = FastMath.sqrt(state.getMu() / state.getA()) / state.getA();
    Assert.assertEquals(state.getA(), s.getA(), 0.);
    Assert.assertEquals(state.getEquinoctialEx(), s.getEquinoctialEx(), 0.);
    Assert.assertEquals(state.getEquinoctialEy(), s.getEquinoctialEy(), 0.);
    Assert.assertEquals(state.getHx(), s.getHx(), 0.);
    Assert.assertEquals(state.getHy(), s.getHy(), 0.);
    Assert.assertEquals(state.getLM() + n * dt, s.getLM(), 1.5e-14);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Test(org.junit.Test)

Example 15 with BoundedPropagator

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

the class DSSTPropagatorTest method testEphemerisGeneration.

@Test
public void testEphemerisGeneration() throws OrekitException {
    Utils.setDataRoot("regular-data:potential/icgem-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("^eigen-6s-truncated$", false));
    UnnormalizedSphericalHarmonicsProvider nshp = GravityFieldFactory.getUnnormalizedProvider(8, 8);
    Orbit orbit = new KeplerianOrbit(13378000, 0.05, 0, 0, FastMath.PI, 0, PositionAngle.MEAN, FramesFactory.getTOD(false), new AbsoluteDate(2003, 5, 6, TimeScalesFactory.getUTC()), nshp.getMu());
    double period = orbit.getKeplerianPeriod();
    double[][] tolerance = DSSTPropagator.tolerances(1.0, orbit);
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(period / 100, period * 100, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(10 * period);
    DSSTPropagator propagator = new DSSTPropagator(integrator, false);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getGTOD(false));
    CelestialBody sun = CelestialBodyFactory.getSun();
    CelestialBody moon = CelestialBodyFactory.getMoon();
    propagator.addForceModel(new DSSTZonal(nshp, 8, 7, 17));
    propagator.addForceModel(new DSSTTesseral(earth.getBodyFrame(), Constants.WGS84_EARTH_ANGULAR_VELOCITY, nshp, 8, 8, 4, 12, 8, 8, 4));
    propagator.addForceModel(new DSSTThirdBody(sun));
    propagator.addForceModel(new DSSTThirdBody(moon));
    propagator.addForceModel(new DSSTAtmosphericDrag(new HarrisPriester(sun, earth), 2.1, 180));
    propagator.addForceModel(new DSSTSolarRadiationPressure(1.2, 180, sun, earth.getEquatorialRadius()));
    propagator.setInterpolationGridToMaxTimeGap(0.5 * Constants.JULIAN_DAY);
    // direct generation of states
    propagator.setInitialState(new SpacecraftState(orbit, 45.0), false);
    final List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    propagator.setMasterMode(600, (currentState, isLast) -> states.add(currentState));
    propagator.propagate(orbit.getDate().shiftedBy(30 * Constants.JULIAN_DAY));
    // ephemeris generation
    propagator.setInitialState(new SpacecraftState(orbit, 45.0), false);
    propagator.setEphemerisMode();
    propagator.propagate(orbit.getDate().shiftedBy(30 * Constants.JULIAN_DAY));
    BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    double maxError = 0;
    for (final SpacecraftState state : states) {
        final SpacecraftState fromEphemeris = ephemeris.propagate(state.getDate());
        final double error = Vector3D.distance(state.getPVCoordinates().getPosition(), fromEphemeris.getPVCoordinates().getPosition());
        maxError = FastMath.max(maxError, error);
    }
    Assert.assertEquals(0.0, maxError, 1.0e-10);
}
Also used : HarrisPriester(org.orekit.forces.drag.atmosphere.HarrisPriester) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) 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) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DSSTZonal(org.orekit.propagation.semianalytical.dsst.forces.DSSTZonal) ArrayList(java.util.ArrayList) DSSTTesseral(org.orekit.propagation.semianalytical.dsst.forces.DSSTTesseral) DSSTAtmosphericDrag(org.orekit.propagation.semianalytical.dsst.forces.DSSTAtmosphericDrag) AbsoluteDate(org.orekit.time.AbsoluteDate) DSSTSolarRadiationPressure(org.orekit.propagation.semianalytical.dsst.forces.DSSTSolarRadiationPressure) SpacecraftState(org.orekit.propagation.SpacecraftState) DSSTThirdBody(org.orekit.propagation.semianalytical.dsst.forces.DSSTThirdBody) UnnormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider) CelestialBody(org.orekit.bodies.CelestialBody) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Test(org.junit.Test)

Aggregations

BoundedPropagator (org.orekit.propagation.BoundedPropagator)50 Test (org.junit.Test)44 AbsoluteDate (org.orekit.time.AbsoluteDate)41 SpacecraftState (org.orekit.propagation.SpacecraftState)32 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)20 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)19 Frame (org.orekit.frames.Frame)16 CartesianOrbit (org.orekit.orbits.CartesianOrbit)15 CircularOrbit (org.orekit.orbits.CircularOrbit)15 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)14 OrekitException (org.orekit.errors.OrekitException)12 PVCoordinates (org.orekit.utils.PVCoordinates)10 Propagator (org.orekit.propagation.Propagator)9 TimeScale (org.orekit.time.TimeScale)9 LofOffset (org.orekit.attitudes.LofOffset)8 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6