Search in sources :

Example 1 with ODEIntegrator

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

the class TimeStampedAngularCoordinatesTest method interpolationErrors.

private double[] interpolationErrors(final TimeStampedAngularCoordinates reference, double dt) throws OrekitException {
    final OrdinaryDifferentialEquation ode = new OrdinaryDifferentialEquation() {

        public int getDimension() {
            return 4;
        }

        public double[] computeDerivatives(final double t, final double[] q) {
            final double omegaX = reference.getRotationRate().getX() + t * reference.getRotationAcceleration().getX();
            final double omegaY = reference.getRotationRate().getY() + t * reference.getRotationAcceleration().getY();
            final double omegaZ = reference.getRotationRate().getZ() + t * reference.getRotationAcceleration().getZ();
            return new double[] { 0.5 * MathArrays.linearCombination(-q[1], omegaX, -q[2], omegaY, -q[3], omegaZ), 0.5 * MathArrays.linearCombination(q[0], omegaX, -q[3], omegaY, q[2], omegaZ), 0.5 * MathArrays.linearCombination(q[3], omegaX, q[0], omegaY, -q[1], omegaZ), 0.5 * MathArrays.linearCombination(-q[2], omegaX, q[1], omegaY, q[0], omegaZ) };
        }
    };
    final List<TimeStampedAngularCoordinates> complete = new ArrayList<TimeStampedAngularCoordinates>();
    ODEIntegrator integrator = new DormandPrince853Integrator(1.0e-6, 1.0, 1.0e-12, 1.0e-12);
    integrator.addStepHandler(new StepNormalizer(dt / 2000, new ODEFixedStepHandler() {

        public void handleStep(ODEStateAndDerivative state, boolean isLast) {
            final double t = state.getTime();
            final double[] q = state.getPrimaryState();
            complete.add(new TimeStampedAngularCoordinates(reference.getDate().shiftedBy(t), new Rotation(q[0], q[1], q[2], q[3], true), new Vector3D(1, reference.getRotationRate(), t, reference.getRotationAcceleration()), reference.getRotationAcceleration()));
        }
    }));
    double[] y = new double[] { reference.getRotation().getQ0(), reference.getRotation().getQ1(), reference.getRotation().getQ2(), reference.getRotation().getQ3() };
    integrator.integrate(ode, new ODEState(0, y), dt);
    List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
    sample.add(complete.get(0));
    sample.add(complete.get(complete.size() / 2));
    sample.add(complete.get(complete.size() - 1));
    double maxRotationError = 0;
    double maxRateError = 0;
    double maxAccelerationError = 0;
    for (TimeStampedAngularCoordinates acRef : complete) {
        TimeStampedAngularCoordinates interpolated = TimeStampedAngularCoordinates.interpolate(acRef.getDate(), AngularDerivativesFilter.USE_RRA, sample);
        double rotationError = Rotation.distance(acRef.getRotation(), interpolated.getRotation());
        double rateError = Vector3D.distance(acRef.getRotationRate(), interpolated.getRotationRate());
        double accelerationError = Vector3D.distance(acRef.getRotationAcceleration(), interpolated.getRotationAcceleration());
        maxRotationError = FastMath.max(maxRotationError, rotationError);
        maxRateError = FastMath.max(maxRateError, rateError);
        maxAccelerationError = FastMath.max(maxAccelerationError, accelerationError);
    }
    return new double[] { maxRotationError, maxRateError, maxAccelerationError };
}
Also used : ODEFixedStepHandler(org.hipparchus.ode.sampling.ODEFixedStepHandler) ArrayList(java.util.ArrayList) ODEState(org.hipparchus.ode.ODEState) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrdinaryDifferentialEquation(org.hipparchus.ode.OrdinaryDifferentialEquation) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) StepNormalizer(org.hipparchus.ode.sampling.StepNormalizer) ODEStateAndDerivative(org.hipparchus.ode.ODEStateAndDerivative)

Example 2 with ODEIntegrator

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

the class DSSTPropagator method afterIntegration.

/**
 * {@inheritDoc}
 */
@Override
protected void afterIntegration() throws OrekitException {
    // remove the special short periodics step handler if added before
    if (!isMeanOrbit()) {
        final List<ODEStepHandler> preserved = new ArrayList<ODEStepHandler>();
        final ODEIntegrator integrator = getIntegrator();
        for (final ODEStepHandler sp : integrator.getStepHandlers()) {
            if (!(sp instanceof ShortPeriodicsHandler)) {
                preserved.add(sp);
            }
        }
        // clear the list
        integrator.clearStepHandlers();
        // add back the step handlers that were important for the user
        for (final ODEStepHandler sp : preserved) {
            integrator.addStepHandler(sp);
        }
    }
}
Also used : ODEIntegrator(org.hipparchus.ode.ODEIntegrator) ArrayList(java.util.ArrayList) ODEStepHandler(org.hipparchus.ode.sampling.ODEStepHandler)

Example 3 with ODEIntegrator

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

the class PropagatorsParallelizerTest method buildNotInitializedNumerical.

private NumericalPropagator buildNotInitializedNumerical() throws OrekitException {
    OrbitType type = OrbitType.CARTESIAN;
    double minStep = 0.001;
    double maxStep = 300;
    double[][] tolerances = NumericalPropagator.tolerances(10.0, orbit, type);
    ODEIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tolerances[0], tolerances[1]);
    NumericalPropagator numericalPropagator = new NumericalPropagator(integrator);
    ForceModel gravity = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), normalizedGravityField);
    numericalPropagator.addForceModel(gravity);
    return numericalPropagator;
}
Also used : ForceModel(org.orekit.forces.ForceModel) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)

Example 4 with ODEIntegrator

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

the class DSSTPropagator method beforeIntegration.

/**
 * Method called just before integration.
 * <p>
 * The default implementation does nothing, it may be specialized in subclasses.
 * </p>
 * @param initialState initial state
 * @param tEnd target date at which state should be propagated
 * @exception OrekitException if hook cannot be run
 */
@Override
protected void beforeIntegration(final SpacecraftState initialState, final AbsoluteDate tEnd) throws OrekitException {
    // compute common auxiliary elements
    final AuxiliaryElements aux = new AuxiliaryElements(initialState.getOrbit(), I);
    // check if only mean elements must be used
    final boolean meanOnly = isMeanOrbit();
    // initialize all perturbing forces
    final List<ShortPeriodTerms> shortPeriodTerms = new ArrayList<ShortPeriodTerms>();
    for (final DSSTForceModel force : forceModels) {
        shortPeriodTerms.addAll(force.initialize(aux, meanOnly));
    }
    mapper.setShortPeriodTerms(shortPeriodTerms);
    // if required, insert the special short periodics step handler
    if (!meanOnly) {
        final ShortPeriodicsHandler spHandler = new ShortPeriodicsHandler(forceModels);
        final Collection<ODEStepHandler> stepHandlers = new ArrayList<ODEStepHandler>();
        stepHandlers.add(spHandler);
        final ODEIntegrator integrator = getIntegrator();
        final Collection<ODEStepHandler> existing = integrator.getStepHandlers();
        stepHandlers.addAll(existing);
        integrator.clearStepHandlers();
        // add back the existing handlers after the short periodics one
        for (final ODEStepHandler sp : stepHandlers) {
            integrator.addStepHandler(sp);
        }
    }
}
Also used : ShortPeriodTerms(org.orekit.propagation.semianalytical.dsst.forces.ShortPeriodTerms) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) ArrayList(java.util.ArrayList) ODEStepHandler(org.hipparchus.ode.sampling.ODEStepHandler) DSSTForceModel(org.orekit.propagation.semianalytical.dsst.forces.DSSTForceModel) AuxiliaryElements(org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements)

Example 5 with ODEIntegrator

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

the class MarshallSolarActivityFutureEstimationTest method getNumericalPropagator.

/**
 * Configure a numerical propagator.
 *
 * @param sun   Sun.
 * @param earth Earth.
 * @param ic    initial condition.
 * @return a propagator.
 * @throws OrekitException on error.
 */
private NumericalPropagator getNumericalPropagator(CelestialBody sun, OneAxisEllipsoid earth, SpacecraftState ic) throws OrekitException {
    // some non-integer step size to induce truncation error in flux interpolation
    final ODEIntegrator integrator = new ClassicalRungeKuttaIntegrator(120 + 0.1);
    NumericalPropagator propagator = new NumericalPropagator(integrator);
    DTM2000InputParameters flux = getFlux();
    final Atmosphere atmosphere = new DTM2000(flux, sun, earth);
    final IsotropicDrag satellite = new IsotropicDrag(1, 3.2);
    propagator.addForceModel(new DragForce(atmosphere, satellite));
    propagator.setInitialState(ic);
    propagator.setOrbitType(OrbitType.CARTESIAN);
    return propagator;
}
Also used : IsotropicDrag(org.orekit.forces.drag.IsotropicDrag) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) Atmosphere(org.orekit.forces.drag.atmosphere.Atmosphere) DragForce(org.orekit.forces.drag.DragForce) DTM2000(org.orekit.forces.drag.atmosphere.DTM2000) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) DTM2000InputParameters(org.orekit.forces.drag.atmosphere.DTM2000InputParameters)

Aggregations

ODEIntegrator (org.hipparchus.ode.ODEIntegrator)7 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)4 ArrayList (java.util.ArrayList)3 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)2 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)2 ODEState (org.hipparchus.ode.ODEState)2 ODEStateAndDerivative (org.hipparchus.ode.ODEStateAndDerivative)2 OrdinaryDifferentialEquation (org.hipparchus.ode.OrdinaryDifferentialEquation)2 ODEFixedStepHandler (org.hipparchus.ode.sampling.ODEFixedStepHandler)2 ODEStepHandler (org.hipparchus.ode.sampling.ODEStepHandler)2 StepNormalizer (org.hipparchus.ode.sampling.StepNormalizer)2 DragForce (org.orekit.forces.drag.DragForce)2 IsotropicDrag (org.orekit.forces.drag.IsotropicDrag)2 DTM2000 (org.orekit.forces.drag.atmosphere.DTM2000)2 HolmesFeatherstoneAttractionModel (org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)2 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)2 ClassicalRungeKuttaIntegrator (org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator)1 Test (org.junit.Test)1 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)1 ForceModel (org.orekit.forces.ForceModel)1