Search in sources :

Example 1 with ExpandableODE

use of org.hipparchus.ode.ExpandableODE in project Orekit by CS-SI.

the class AbstractIntegratedPropagator method createODE.

/**
 * Create an ODE with all equations.
 * @param integ numerical integrator to use for propagation.
 * @param mathInitialState initial state
 * @return a new ode
 * @exception OrekitException if initial state cannot be mapped
 */
private ExpandableODE createODE(final ODEIntegrator integ, final ODEState mathInitialState) throws OrekitException {
    final ExpandableODE ode = new ExpandableODE(new ConvertedMainStateEquations(getMainStateEquations(integ)));
    // secondary part of the ODE
    for (int i = 0; i < additionalEquations.size(); ++i) {
        final AdditionalEquations additional = additionalEquations.get(i);
        final SecondaryODE secondary = new ConvertedSecondaryStateEquations(additional, mathInitialState.getSecondaryStateDimension(i + 1));
        ode.addSecondaryEquations(secondary);
    }
    return ode;
}
Also used : ExpandableODE(org.hipparchus.ode.ExpandableODE) SecondaryODE(org.hipparchus.ode.SecondaryODE)

Example 2 with ExpandableODE

use of org.hipparchus.ode.ExpandableODE 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)

Aggregations

ExpandableODE (org.hipparchus.ode.ExpandableODE)2 MathRuntimeException (org.hipparchus.exception.MathRuntimeException)1 ODEState (org.hipparchus.ode.ODEState)1 ODEStateAndDerivative (org.hipparchus.ode.ODEStateAndDerivative)1 SecondaryODE (org.hipparchus.ode.SecondaryODE)1 OrekitException (org.orekit.errors.OrekitException)1 OrekitExceptionWrapper (org.orekit.errors.OrekitExceptionWrapper)1 Orbit (org.orekit.orbits.Orbit)1 SpacecraftState (org.orekit.propagation.SpacecraftState)1