use of org.orekit.propagation.events.DateDetector 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.propagation.events.DateDetector in project Orekit by CS-SI.
the class DSSTPropagatorTest method testStopEvent.
@Test
public void testStopEvent() throws OrekitException {
SpacecraftState state = getLEOState();
setDSSTProp(state);
final AbsoluteDate stopDate = state.getDate().shiftedBy(1000);
CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.STOP);
dsstProp.addEventDetector(new DateDetector(stopDate).withHandler(checking));
checking.assertEvent(false);
final SpacecraftState finalState = dsstProp.propagate(state.getDate().shiftedBy(3200));
checking.assertEvent(true);
Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate), 1.0e-10);
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class DSSTPropagatorTest method testContinueEvent.
@Test
public void testContinueEvent() throws OrekitException {
SpacecraftState state = getLEOState();
setDSSTProp(state);
final AbsoluteDate resetDate = state.getDate().shiftedBy(1000);
CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.CONTINUE);
dsstProp.addEventDetector(new DateDetector(resetDate).withHandler(checking));
final double dt = 3200;
checking.assertEvent(false);
final SpacecraftState finalState = dsstProp.propagate(state.getDate().shiftedBy(dt));
checking.assertEvent(true);
final double n = FastMath.sqrt(state.getMu() / state.getA()) / state.getA();
Assert.assertEquals(state.getA(), finalState.getA(), 1.0e-10);
Assert.assertEquals(state.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10);
Assert.assertEquals(state.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10);
Assert.assertEquals(state.getHx(), finalState.getHx(), 1.0e-10);
Assert.assertEquals(state.getHy(), finalState.getHy(), 1.0e-10);
Assert.assertEquals(state.getLM() + n * dt, finalState.getLM(), 6.0e-10);
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class OrekitStepHandlerTest method testIsInterpolated.
/**
* Check {@link OrekitStepInterpolator#isPreviousStateInterpolated()} and {@link
* OrekitStepInterpolator#isCurrentStateInterpolated()}.
*
* @throws OrekitException on error.
*/
@Test
public void testIsInterpolated() throws OrekitException {
// setup
NumericalPropagator propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(60));
AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
Frame eci = FramesFactory.getGCRF();
SpacecraftState ic = new SpacecraftState(new KeplerianOrbit(6378137 + 500e3, 1e-3, 0, 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EIGEN5C_EARTH_MU));
propagator.setInitialState(ic);
propagator.setOrbitType(OrbitType.CARTESIAN);
// detector triggers half way through second step
DateDetector detector = new DateDetector(date.shiftedBy(90)).withHandler(new ContinueOnEvent<>());
propagator.addEventDetector(detector);
// action and verify
Queue<Boolean> expected = new ArrayDeque<>(Arrays.asList(false, false, false, true, true, false));
propagator.setMasterMode(new OrekitStepHandler() {
@Override
public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) {
assertEquals(expected.poll(), interpolator.isPreviousStateInterpolated());
assertEquals(expected.poll(), interpolator.isCurrentStateInterpolated());
}
});
final AbsoluteDate end = date.shiftedBy(120);
assertEquals(end, propagator.propagate(end).getDate());
}
use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.
the class JacobianPropagatorConverter method getObjectiveFunction.
/**
* {@inheritDoc}
*/
protected MultivariateVectorFunction getObjectiveFunction() {
return new MultivariateVectorFunction() {
/**
* {@inheritDoc}
*/
public double[] value(final double[] arg) throws IllegalArgumentException, OrekitExceptionWrapper {
try {
final double[] value = new double[getTargetSize()];
final NumericalPropagator prop = builder.buildPropagator(arg);
final int stateSize = isOnlyPosition() ? 3 : 6;
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
fillRows(value, row, prop.getInitialState());
} else {
// use a date detector to pick up states
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, row, state);
return row + stateSize >= getTargetSize() ? Action.STOP : Action.CONTINUE;
}
}));
}
}
prop.propagate(sample.get(sample.size() - 1).getDate().shiftedBy(10.0));
return value;
} catch (OrekitException ex) {
throw new OrekitExceptionWrapper(ex);
}
}
};
}
Aggregations