use of org.hipparchus.exception.MathRuntimeException in project Orekit by CS-SI.
the class AbstractIntegratedPropagator method propagate.
/**
* Propagation with or without event detection.
* @param tEnd target date to which orbit should be propagated
* @param activateHandlers if true, step and event handlers should be activated
* @return state at end of propagation
* @exception OrekitException if orbit cannot be propagated
*/
protected SpacecraftState propagate(final AbsoluteDate tEnd, final boolean activateHandlers) throws OrekitException {
try {
if (getInitialState().getDate().equals(tEnd)) {
// don't extrapolate
return getInitialState();
}
// space dynamics view
stateMapper = createMapper(getInitialState().getDate(), stateMapper.getMu(), stateMapper.getOrbitType(), stateMapper.getPositionAngleType(), stateMapper.getAttitudeProvider(), getInitialState().getFrame());
// set propagation orbit type
final Orbit initialOrbit = stateMapper.getOrbitType().convertType(getInitialState().getOrbit());
if (Double.isNaN(getMu())) {
setMu(initialOrbit.getMu());
}
if (getInitialState().getMass() <= 0.0) {
throw new OrekitException(OrekitMessages.SPACECRAFT_MASS_BECOMES_NEGATIVE, getInitialState().getMass());
}
integrator.clearEventHandlers();
// set up events added by user
setUpUserEventDetectors();
// convert space flight dynamics API to math API
final ODEState mathInitialState = createInitialState(getInitialIntegrationState());
final ExpandableODE mathODE = createODE(integrator, mathInitialState);
equationsMapper = mathODE.getMapper();
// initialize mode handler
if (modeHandler != null) {
modeHandler.initialize(activateHandlers, tEnd);
}
// mathematical integration
final ODEStateAndDerivative mathFinalState;
try {
beforeIntegration(getInitialState(), tEnd);
mathFinalState = integrator.integrate(mathODE, mathInitialState, tEnd.durationFrom(getInitialState().getDate()));
afterIntegration();
} catch (OrekitExceptionWrapper oew) {
throw oew.getException();
}
// get final state
SpacecraftState finalState = stateMapper.mapArrayToState(stateMapper.mapDoubleToDate(mathFinalState.getTime(), tEnd), mathFinalState.getPrimaryState(), mathFinalState.getPrimaryDerivative(), meanOrbit);
finalState = updateAdditionalStates(finalState);
for (int i = 0; i < additionalEquations.size(); ++i) {
final double[] secondary = mathFinalState.getSecondaryState(i + 1);
finalState = finalState.addAdditionalState(additionalEquations.get(i).getName(), secondary);
}
if (resetAtEnd) {
resetInitialState(finalState);
setStartDate(finalState.getDate());
}
return finalState;
} catch (MathRuntimeException mre) {
throw OrekitException.unwrap(mre);
}
}
use of org.hipparchus.exception.MathRuntimeException in project Orekit by CS-SI.
the class KalmanEstimator method estimationStep.
/**
* Process a single measurement.
* <p>
* Update the filter with the new measurement by calling the estimate method.
* </p>
* @param observedMeasurement the measurement to process
* @return estimated propagator
* @throws OrekitException if an error occurred during the estimation
*/
public NumericalPropagator estimationStep(final ObservedMeasurement<?> observedMeasurement) throws OrekitException {
try {
final ProcessEstimate estimate = filter.estimationStep(decorate(observedMeasurement));
processModel.finalizeEstimation(observedMeasurement, estimate);
if (observer != null) {
observer.evaluationPerformed(processModel);
}
return processModel.getEstimatedPropagator();
} catch (MathRuntimeException mrte) {
throw new OrekitException(mrte);
} catch (OrekitExceptionWrapper oew) {
throw oew.getException();
}
}
use of org.hipparchus.exception.MathRuntimeException 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);
}
}
use of org.hipparchus.exception.MathRuntimeException in project Orekit by CS-SI.
the class TimeStampedCacheExceptionTest method testUnwrapMathRuntimeExceptionNeedsCreation.
@Test
public void testUnwrapMathRuntimeExceptionNeedsCreation() {
MathRuntimeException base = new MathRuntimeException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE, AbsoluteDate.MODIFIED_JULIAN_EPOCH);
TimeStampedCacheException unwraped = TimeStampedCacheException.unwrap(base);
Assert.assertSame(base, unwraped.getCause());
}
use of org.hipparchus.exception.MathRuntimeException in project Orekit by CS-SI.
the class TimeStampedCacheExceptionTest method testUnwrapMathRuntimeExceptionSimpleExtraction.
@Test
public void testUnwrapMathRuntimeExceptionSimpleExtraction() {
TimeStampedCacheException base = new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE, AbsoluteDate.MODIFIED_JULIAN_EPOCH);
MathRuntimeException intermediate = new MathRuntimeException(base, base.getSpecifier(), base.getParts());
TimeStampedCacheException unwraped = TimeStampedCacheException.unwrap(intermediate);
Assert.assertNull(unwraped.getCause());
Assert.assertSame(base, unwraped);
}
Aggregations