Search in sources :

Example 6 with MathRuntimeException

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);
    }
}
Also used : ExpandableODE(org.hipparchus.ode.ExpandableODE) SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) Orbit(org.orekit.orbits.Orbit) OrekitException(org.orekit.errors.OrekitException) ODEState(org.hipparchus.ode.ODEState) ODEStateAndDerivative(org.hipparchus.ode.ODEStateAndDerivative)

Example 7 with MathRuntimeException

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();
    }
}
Also used : MathRuntimeException(org.hipparchus.exception.MathRuntimeException) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) OrekitException(org.orekit.errors.OrekitException) ProcessEstimate(org.hipparchus.filtering.kalman.ProcessEstimate)

Example 8 with MathRuntimeException

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);
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) AbsoluteDate(org.orekit.time.AbsoluteDate) OrekitStepInterpolator(org.orekit.propagation.sampling.OrekitStepInterpolator)

Example 9 with MathRuntimeException

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());
}
Also used : MathRuntimeException(org.hipparchus.exception.MathRuntimeException) Test(org.junit.Test)

Example 10 with MathRuntimeException

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);
}
Also used : MathRuntimeException(org.hipparchus.exception.MathRuntimeException) Test(org.junit.Test)

Aggregations

MathRuntimeException (org.hipparchus.exception.MathRuntimeException)11 OrekitException (org.orekit.errors.OrekitException)8 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)5 BracketingNthOrderBrentSolver (org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver)5 GeodeticPoint (org.orekit.bodies.GeodeticPoint)5 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)4 OrekitExceptionWrapper (org.orekit.errors.OrekitExceptionWrapper)4 SpacecraftState (org.orekit.propagation.SpacecraftState)4 UnivariateSolver (org.hipparchus.analysis.solvers.UnivariateSolver)3 RealFieldUnivariateFunction (org.hipparchus.analysis.RealFieldUnivariateFunction)2 FieldBracketingNthOrderBrentSolver (org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver)2 FieldLine (org.hipparchus.geometry.euclidean.threed.FieldLine)2 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)2 Line (org.hipparchus.geometry.euclidean.threed.Line)2 Test (org.junit.Test)2 FieldGeodeticPoint (org.orekit.bodies.FieldGeodeticPoint)2 FieldTransform (org.orekit.frames.FieldTransform)2 Frame (org.orekit.frames.Frame)2 Transform (org.orekit.frames.Transform)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2