use of org.orekit.propagation.sampling.OrekitStepInterpolator in project Orekit by CS-SI.
the class KeplerianPropagatorTest method variableStep.
@Test
public void variableStep() 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 double step = orbit.getKeplerianPeriod() / 100;
propagator.setMasterMode(new OrekitStepHandler() {
private AbsoluteDate previous;
public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws OrekitException {
if ((previous != null) && !isLast) {
Assert.assertEquals(step, interpolator.getCurrentState().getDate().durationFrom(previous), 1.0e-10);
}
previous = interpolator.getCurrentState().getDate();
}
});
AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
propagator.propagate(farTarget);
}
use of org.orekit.propagation.sampling.OrekitStepInterpolator in project Orekit by CS-SI.
the class AbstractAnalyticalPropagator method propagate.
/**
* {@inheritDoc}
*/
public SpacecraftState propagate(final AbsoluteDate start, final AbsoluteDate target) throws OrekitException {
try {
lastPropagationStart = start;
final double dt = target.durationFrom(start);
final double epsilon = FastMath.ulp(dt);
SpacecraftState state = updateAdditionalStates(basicPropagate(start));
// evaluate step size
final double stepSize;
if (getMode() == MASTER_MODE) {
if (Double.isNaN(getFixedStepSize())) {
stepSize = FastMath.copySign(state.getKeplerianPeriod() / 100, dt);
} else {
stepSize = FastMath.copySign(getFixedStepSize(), dt);
}
} else {
stepSize = dt;
}
// initialize event detectors
for (final EventState<?> es : eventsStates) {
es.init(state, target);
}
// initialize step handler
if (getStepHandler() != null) {
getStepHandler().init(state, target);
}
// iterate over the propagation range
statesInitialized = false;
isLastStep = false;
do {
// go ahead one step size
final SpacecraftState previous = state;
AbsoluteDate t = previous.getDate().shiftedBy(stepSize);
if ((dt == 0) || ((dt > 0) ^ (t.compareTo(target) <= 0)) || (FastMath.abs(target.durationFrom(t)) <= epsilon)) {
// current step exceeds target
// or is target to within double precision
t = target;
}
final SpacecraftState current = updateAdditionalStates(basicPropagate(t));
final OrekitStepInterpolator interpolator = new BasicStepInterpolator(dt >= 0, previous, current);
// accept the step, trigger events and step handlers
state = acceptStep(interpolator, target, epsilon);
} while (!isLastStep);
// return the last computed state
lastPropagationEnd = state.getDate();
setStartDate(state.getDate());
return state;
} catch (MathRuntimeException mrte) {
throw OrekitException.unwrap(mrte);
}
}
Aggregations