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