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);
}
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()));
}
}
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);
}
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);
}
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);
}
Aggregations