use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class AttitudesSequenceTest method testTooShortTransition.
@Test
public void testTooShortTransition() {
double threshold = 1.5;
double transitionTime = 0.5;
try {
new AttitudesSequence().addSwitchingCondition(new InertialProvider(Rotation.IDENTITY), new InertialProvider(Rotation.IDENTITY), new DateDetector(1000.0, threshold, AbsoluteDate.J2000_EPOCH), true, false, transitionTime, AngularDerivativesFilter.USE_R, null);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.TOO_SHORT_TRANSITION_TIME_FOR_ATTITUDES_SWITCH, oe.getSpecifier());
Assert.assertEquals(transitionTime, ((Double) oe.getParts()[0]).doubleValue(), 1.0e-10);
Assert.assertEquals(threshold, ((Double) oe.getParts()[1]).doubleValue(), 1.0e-10);
}
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class PropagatorsParallelizerTest method testOrekitException.
@Test
public void testOrekitException() throws OrekitException {
final AbsoluteDate startDate = orbit.getDate();
final AbsoluteDate endDate = startDate.shiftedBy(3600.0);
List<Propagator> propagators = Arrays.asList(buildEcksteinHechler(), buildNumerical());
propagators.get(0).addEventDetector(new DateDetector(startDate.shiftedBy(900.0)).withHandler((state, detector, increasing) -> {
throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "inTest");
}));
try {
new PropagatorsParallelizer(propagators, (interpolators, isLast) -> {
}).propagate(startDate, endDate);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertNull(oe.getCause());
Assert.assertEquals(LocalizedCoreFormats.SIMPLE_MESSAGE, oe.getSpecifier());
Assert.assertEquals("inTest", (String) oe.getParts()[0]);
}
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class PropagatorsParallelizerTest method testStopOnEarlyEvent.
@Test
public void testStopOnEarlyEvent() throws OrekitException {
final AbsoluteDate startDate = orbit.getDate();
final AbsoluteDate endDate = startDate.shiftedBy(3600.0);
final AbsoluteDate stopDate = startDate.shiftedBy(0.01);
List<Propagator> propagators = Arrays.asList(buildEcksteinHechler(), buildNumerical());
propagators.get(0).addEventDetector(new DateDetector(stopDate).withHandler(new StopOnEvent<>()));
List<SpacecraftState> results = new PropagatorsParallelizer(propagators, (interpolators, isLast) -> {
}).propagate(startDate, endDate);
Assert.assertEquals(2, results.size());
Assert.assertEquals(0.0, results.get(0).getDate().durationFrom(stopDate), 1.0e-15);
Assert.assertEquals(0.0, results.get(1).getDate().durationFrom(stopDate), 1.0e-15);
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method testIssue224Backward.
@Test
public void testIssue224Backward() throws OrekitException, IOException, ClassNotFoundException {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(154.);
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
Frame eme2000 = FramesFactory.getEME2000();
Vector3D pole = itrf.getTransformTo(eme2000, date).transformVector(Vector3D.PLUS_K);
Frame poleAligned = new Frame(FramesFactory.getEME2000(), new Transform(date, new Rotation(pole, Vector3D.PLUS_K)), "pole aligned", true);
CircularOrbit initial = new CircularOrbit(7208669.8179538045, 1.3740461966386876E-4, -3.2364250248363356E-5, FastMath.toRadians(97.40236024565775), FastMath.toRadians(166.15873160992115), FastMath.toRadians(90.1282370098961), PositionAngle.MEAN, poleAligned, date, provider.getMu());
EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(initial, new LofOffset(poleAligned, LOFType.VVLH), 1000.0, provider);
propagator.addAdditionalStateProvider(new SevenProvider());
propagator.setEphemerisMode();
// Impulsive burns
final AbsoluteDate burn1Date = initial.getDate().shiftedBy(-200);
ImpulseManeuver<DateDetector> impulsiveBurn1 = new ImpulseManeuver<DateDetector>(new DateDetector(burn1Date), new Vector3D(0.0, 500.0, 0.0), 320);
propagator.addEventDetector(impulsiveBurn1);
final AbsoluteDate burn2Date = initial.getDate().shiftedBy(-300);
ImpulseManeuver<DateDetector> impulsiveBurn2 = new ImpulseManeuver<DateDetector>(new DateDetector(burn2Date), new Vector3D(0.0, 500.0, 0.0), 320);
propagator.addEventDetector(impulsiveBurn2);
propagator.propagate(initial.getDate().shiftedBy(-400));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(propagator.getGeneratedEphemeris());
Assert.assertTrue(bos.size() > 2950);
Assert.assertTrue(bos.size() < 3050);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
BoundedPropagator ephemeris = (BoundedPropagator) ois.readObject();
ephemeris.setMasterMode(10, new OrekitFixedStepHandler() {
public void handleStep(SpacecraftState currentState, boolean isLast) {
if (currentState.getDate().durationFrom(burn1Date) > 0.001) {
Assert.assertEquals(97.402, FastMath.toDegrees(currentState.getI()), 1.0e-3);
} else if (currentState.getDate().durationFrom(burn1Date) < -0.001 && currentState.getDate().durationFrom(burn2Date) > 0.001) {
Assert.assertEquals(98.164, FastMath.toDegrees(currentState.getI()), 1.0e-3);
} else if (currentState.getDate().durationFrom(burn2Date) < -0.001) {
Assert.assertEquals(99.273, FastMath.toDegrees(currentState.getI()), 1.0e-3);
}
}
});
ephemeris.propagate(ephemeris.getMinDate());
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method date.
@Test
public void date() throws OrekitException {
final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, provider);
final AbsoluteDate stopDate = AbsoluteDate.J2000_EPOCH.shiftedBy(500.0);
propagator.addEventDetector(new DateDetector(stopDate));
AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
SpacecraftState propagated = propagator.propagate(farTarget);
Assert.assertEquals(0, stopDate.durationFrom(propagated.getDate()), 1.0e-10);
}
Aggregations