use of org.orekit.time.AbsoluteDate 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.time.AbsoluteDate 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.time.AbsoluteDate in project Orekit by CS-SI.
the class NumericalPropagatorTest method testStopEvent.
@Test
public void testStopEvent() throws OrekitException {
final AbsoluteDate stopDate = initDate.shiftedBy(1000);
CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.STOP);
propagator.addEventDetector(new DateDetector(stopDate).withHandler(checking));
Assert.assertEquals(1, propagator.getEventsDetectors().size());
checking.assertEvent(false);
final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200));
checking.assertEvent(true);
Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate), 1.0e-10);
propagator.clearEventsDetectors();
Assert.assertEquals(0, propagator.getEventsDetectors().size());
}
use of org.orekit.time.AbsoluteDate in project Orekit by CS-SI.
the class DSSTPropagatorTest method testIssue364.
@Test
public void testIssue364() throws OrekitException {
Utils.setDataRoot("regular-data");
AbsoluteDate date = new AbsoluteDate("2003-06-18T00:00:00.000", TimeScalesFactory.getUTC());
CircularOrbit orbit = new CircularOrbit(7389068.5, 0.0, 0.0, 1.709573, 1.308398, 0, PositionAngle.MEAN, FramesFactory.getTOD(IERSConventions.IERS_2010, false), date, Constants.WGS84_EARTH_MU);
SpacecraftState osculatingState = new SpacecraftState(orbit, 1116.2829);
List<DSSTForceModel> dsstForceModels = new ArrayList<DSSTForceModel>();
dsstForceModels.add(new DSSTThirdBody(CelestialBodyFactory.getMoon()));
dsstForceModels.add(new DSSTThirdBody(CelestialBodyFactory.getSun()));
SpacecraftState meanState = DSSTPropagator.computeMeanState(osculatingState, null, dsstForceModels);
Assert.assertEquals(0.421, osculatingState.getA() - meanState.getA(), 1.0e-3);
Assert.assertEquals(-5.23e-8, osculatingState.getEquinoctialEx() - meanState.getEquinoctialEx(), 1.0e-10);
Assert.assertEquals(15.22e-8, osculatingState.getEquinoctialEy() - meanState.getEquinoctialEy(), 1.0e-10);
Assert.assertEquals(-3.15e-8, osculatingState.getHx() - meanState.getHx(), 1.0e-10);
Assert.assertEquals(2.83e-8, osculatingState.getHy() - meanState.getHy(), 1.0e-10);
Assert.assertEquals(15.96e-8, osculatingState.getLM() - meanState.getLM(), 1.0e-10);
}
use of org.orekit.time.AbsoluteDate 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);
}
Aggregations