use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class JacobianPropagatorConverter method getModel.
/**
* {@inheritDoc}
*/
protected MultivariateJacobianFunction getModel() {
return new MultivariateJacobianFunction() {
/**
* {@inheritDoc}
*/
public Pair<RealVector, RealMatrix> value(final RealVector point) throws IllegalArgumentException, OrekitExceptionWrapper {
try {
final RealVector value = new ArrayRealVector(getTargetSize());
final RealMatrix jacobian = MatrixUtils.createRealMatrix(getTargetSize(), point.getDimension());
final NumericalPropagator prop = builder.buildPropagator(point.toArray());
final int stateSize = isOnlyPosition() ? 3 : 6;
final ParameterDriversList orbitalParameters = builder.getOrbitalParametersDrivers();
final PartialDerivativesEquations pde = new PartialDerivativesEquations("pde", prop);
final ParameterDriversList propagationParameters = pde.getSelectedParameters();
prop.setInitialState(pde.setInitialJacobians(prop.getInitialState()));
final JacobiansMapper mapper = pde.getMapper();
final List<SpacecraftState> sample = getSample();
for (int i = 0; i < sample.size(); ++i) {
final int row = i * stateSize;
if (prop.getInitialState().getDate().equals(sample.get(i).getDate())) {
// use initial state and Jacobians
fillRows(value, jacobian, row, prop.getInitialState(), stateSize, orbitalParameters, propagationParameters, mapper);
} else {
// use a date detector to pick up state and Jacobians
prop.addEventDetector(new DateDetector(sample.get(i).getDate()).withHandler(new EventHandler<DateDetector>() {
/**
* {@inheritDoc}
*/
@Override
public Action eventOccurred(final SpacecraftState state, final DateDetector detector, final boolean increasing) throws OrekitException {
fillRows(value, jacobian, row, state, stateSize, orbitalParameters, propagationParameters, mapper);
return row + stateSize >= getTargetSize() ? Action.STOP : Action.CONTINUE;
}
}));
}
}
prop.propagate(sample.get(sample.size() - 1).getDate().shiftedBy(10.0));
return new Pair<RealVector, RealMatrix>(value, jacobian);
} catch (OrekitException ex) {
throw new OrekitExceptionWrapper(ex);
}
}
};
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class ImpulseManeuverTest method testBackward.
@Test
public void testBackward() throws OrekitException {
final AbsoluteDate iniDate = new AbsoluteDate(2003, 5, 1, 17, 30, 0.0, TimeScalesFactory.getUTC());
final Orbit initialOrbit = new KeplerianOrbit(7e6, 1.0e-4, FastMath.toRadians(98.5), FastMath.toRadians(87.0), FastMath.toRadians(216.1807), FastMath.toRadians(319.779), PositionAngle.MEAN, FramesFactory.getEME2000(), iniDate, Constants.EIGEN5C_EARTH_MU);
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC));
DateDetector dateDetector = new DateDetector(iniDate.shiftedBy(-300));
Vector3D deltaV = new Vector3D(12.0, 1.0, -4.0);
final double isp = 300;
ImpulseManeuver<DateDetector> maneuver = new ImpulseManeuver<DateDetector>(dateDetector, deltaV, isp).withMaxCheck(3600.0).withThreshold(1.0e-6);
propagator.addEventDetector(maneuver);
SpacecraftState finalState = propagator.propagate(initialOrbit.getDate().shiftedBy(-900));
Assert.assertTrue(finalState.getMass() > propagator.getInitialState().getMass());
Assert.assertTrue(finalState.getDate().compareTo(propagator.getInitialState().getDate()) < 0);
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class PropagatorsParallelizerTest method testStopOnLateEvent.
@Test
public void testStopOnLateEvent() throws OrekitException {
final AbsoluteDate startDate = orbit.getDate();
final AbsoluteDate endDate = startDate.shiftedBy(3600.0);
final AbsoluteDate stopDate = startDate.shiftedBy(900.0);
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 PropagatorsParallelizerTest method testEarlyStop.
@Test
public void testEarlyStop() 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 RuntimeException("boo!");
}));
try {
new PropagatorsParallelizer(propagators, (interpolators, isLast) -> {
}).propagate(startDate, endDate);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertNotNull(oe.getCause());
Assert.assertTrue(oe.getCause() instanceof RuntimeException);
Assert.assertEquals(LocalizedCoreFormats.SIMPLE_MESSAGE, oe.getSpecifier());
Assert.assertTrue(((String) oe.getParts()[0]).endsWith("boo!"));
}
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class KeplerianPropagatorTest 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);
KeplerianPropagator propagator = new KeplerianPropagator(orbit);
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