Search in sources :

Example 16 with OrekitStepInterpolator

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);
}
Also used : KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) OrekitStepHandler(org.orekit.propagation.sampling.OrekitStepHandler) OrekitStepInterpolator(org.orekit.propagation.sampling.OrekitStepInterpolator) Test(org.junit.Test)

Example 17 with OrekitStepInterpolator

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

Aggregations

OrekitStepInterpolator (org.orekit.propagation.sampling.OrekitStepInterpolator)17 SpacecraftState (org.orekit.propagation.SpacecraftState)14 AbsoluteDate (org.orekit.time.AbsoluteDate)14 OrekitException (org.orekit.errors.OrekitException)10 ArrayList (java.util.ArrayList)9 Max (org.hipparchus.stat.descriptive.rank.Max)8 Median (org.hipparchus.stat.descriptive.rank.Median)8 Context (org.orekit.estimation.Context)8 Propagator (org.orekit.propagation.Propagator)8 NumericalPropagatorBuilder (org.orekit.propagation.conversion.NumericalPropagatorBuilder)8 ChronologicalComparator (org.orekit.time.ChronologicalComparator)8 Mean (org.hipparchus.stat.descriptive.moment.Mean)5 OrekitStepHandler (org.orekit.propagation.sampling.OrekitStepHandler)5 Test (org.junit.Test)4 RangeTroposphericDelayModifier (org.orekit.estimation.measurements.modifiers.RangeTroposphericDelayModifier)4 Min (org.hipparchus.stat.descriptive.rank.Min)3 BoundedPropagator (org.orekit.propagation.BoundedPropagator)3 StateFunction (org.orekit.utils.StateFunction)3 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)3 MathRuntimeException (org.hipparchus.exception.MathRuntimeException)2