Search in sources :

Example 6 with DormandPrince853FieldIntegrator

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

the class FieldNumericalPropagatorTest method doTestStopEvent.

private <T extends RealFieldElement<T>> void doTestStopEvent(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    final FieldAbsoluteDate<T> stopDate = initDate.shiftedBy(1000);
    CheckingHandler<FieldDateDetector<T>, T> checking = new CheckingHandler<FieldDateDetector<T>, T>(Action.STOP);
    propagator.addEventDetector(new FieldDateDetector<>(stopDate).withHandler(checking));
    Assert.assertEquals(1, propagator.getEventsDetectors().size());
    checking.assertEvent(false);
    final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(3200));
    checking.assertEvent(true);
    Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate).getReal(), 1.0e-10);
    propagator.clearEventsDetectors();
    Assert.assertEquals(0, propagator.getEventsDetectors().size());
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldDateDetector(org.orekit.propagation.events.FieldDateDetector) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType)

Example 7 with DormandPrince853FieldIntegrator

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

the class FieldNumericalPropagatorTest method doTestResetDerivativesEvent.

private <T extends RealFieldElement<T>> void doTestResetDerivativesEvent(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    final FieldAbsoluteDate<T> resetDate = initDate.shiftedBy(1000);
    CheckingHandler<FieldDateDetector<T>, T> checking = new CheckingHandler<FieldDateDetector<T>, T>(Action.RESET_DERIVATIVES);
    propagator.addEventDetector(new FieldDateDetector<>(resetDate).withHandler(checking));
    final double dt = 3200;
    checking.assertEvent(false);
    Assert.assertEquals(0.0, propagator.getInitialState().getDate().durationFrom(initDate).getReal(), 1.0e-10);
    propagator.setResetAtEnd(true);
    final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(dt));
    Assert.assertEquals(dt, propagator.getInitialState().getDate().durationFrom(initDate).getReal(), 1.0e-10);
    checking.assertEvent(true);
    final double n = FastMath.sqrt(initialState.getMu() / initialState.getA().getReal()) / initialState.getA().getReal();
    Assert.assertEquals(initialState.getA().getReal(), finalState.getA().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEx().getReal(), finalState.getEquinoctialEx().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEy().getReal(), finalState.getEquinoctialEy().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getHx().getReal(), finalState.getHx().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getHy().getReal(), finalState.getHy().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getLM().getReal() + n * dt, finalState.getLM().getReal(), 6.0e-10);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldDateDetector(org.orekit.propagation.events.FieldDateDetector) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType)

Example 8 with DormandPrince853FieldIntegrator

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

the class FieldNumericalPropagatorTest method createPropagator.

private static <T extends RealFieldElement<T>> FieldNumericalPropagator<T> createPropagator(FieldSpacecraftState<T> spacecraftState, OrbitType orbitType, PositionAngle angleType) throws OrekitException {
    final Field<T> field = spacecraftState.getDate().getField();
    final T zero = field.getZero();
    final double minStep = 0.001;
    final double maxStep = 120.0;
    final T positionTolerance = zero.add(0.1);
    final int degree = 20;
    final int order = 20;
    final double spacecraftArea = 1.0;
    final double spacecraftDragCoefficient = 2.0;
    final double spacecraftReflectionCoefficient = 2.0;
    // propagator main configuration
    final double[][] tol = FieldNumericalPropagator.tolerances(positionTolerance, spacecraftState.getOrbit(), orbitType);
    final FieldODEIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, tol[0], tol[1]);
    final FieldNumericalPropagator<T> np = new FieldNumericalPropagator<>(field, integrator);
    np.setOrbitType(orbitType);
    np.setPositionAngleType(angleType);
    np.setInitialState(spacecraftState);
    // Earth gravity field
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final NormalizedSphericalHarmonicsProvider harmonicsGravityProvider = GravityFieldFactory.getNormalizedProvider(degree, order);
    np.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), harmonicsGravityProvider));
    // Sun and Moon attraction
    np.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getSun()));
    np.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getMoon()));
    // atmospheric drag
    MarshallSolarActivityFutureEstimation msafe = new MarshallSolarActivityFutureEstimation("Jan2000F10-edited-data\\.txt", MarshallSolarActivityFutureEstimation.StrengthLevel.AVERAGE);
    DataProvidersManager.getInstance().feed(msafe.getSupportedNames(), msafe);
    DTM2000 atmosphere = new DTM2000(msafe, CelestialBodyFactory.getSun(), earth);
    np.addForceModel(new DragForce(atmosphere, new IsotropicDrag(spacecraftArea, spacecraftDragCoefficient)));
    // solar radiation pressure
    np.addForceModel(new SolarRadiationPressure(CelestialBodyFactory.getSun(), earth.getEquatorialRadius(), new IsotropicRadiationSingleCoefficient(spacecraftArea, spacecraftReflectionCoefficient)));
    return np;
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) IsotropicDrag(org.orekit.forces.drag.IsotropicDrag) DTM2000(org.orekit.forces.drag.atmosphere.DTM2000) SolarRadiationPressure(org.orekit.forces.radiation.SolarRadiationPressure) MarshallSolarActivityFutureEstimation(org.orekit.forces.drag.atmosphere.data.MarshallSolarActivityFutureEstimation) ThirdBodyAttraction(org.orekit.forces.gravity.ThirdBodyAttraction) DragForce(org.orekit.forces.drag.DragForce) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) IsotropicRadiationSingleCoefficient(org.orekit.forces.radiation.IsotropicRadiationSingleCoefficient)

Example 9 with DormandPrince853FieldIntegrator

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

the class FieldNumericalPropagatorTest method propagateInType.

private <T extends RealFieldElement<T>> FieldPVCoordinates<T> propagateInType(FieldSpacecraftState<T> state, T dP, OrbitType type, PositionAngle angle, FieldNumericalPropagator<T> propagator) throws OrekitException {
    T zero = dP.getField().getZero();
    final T dt = zero.add(3200);
    final double minStep = 0.001;
    final double maxStep = 1000;
    double[][] tol = NumericalPropagator.tolerances(dP.getReal(), state.getOrbit().toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(zero.getField(), minStep, maxStep, tol[0], tol[1]);
    FieldNumericalPropagator<T> newPropagator = new FieldNumericalPropagator<>(zero.getField(), integrator);
    newPropagator.setOrbitType(type);
    newPropagator.setPositionAngleType(angle);
    newPropagator.setInitialState(state);
    for (ForceModel force : propagator.getAllForceModels()) {
        newPropagator.addForceModel(force);
    }
    return newPropagator.propagate(state.getDate().shiftedBy(dt)).getPVCoordinates();
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) ForceModel(org.orekit.forces.ForceModel)

Example 10 with DormandPrince853FieldIntegrator

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

the class FieldNumericalPropagatorTest method doTestException.

private <T extends RealFieldElement<T>> void doTestException(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    propagator.setMasterMode(new FieldOrekitStepHandler<T>() {

        private int countDown = 3;

        private FieldAbsoluteDate<T> previousCall = null;

        public void init(FieldSpacecraftState<T> s0, FieldAbsoluteDate<T> t) {
        }

        public void handleStep(FieldOrekitStepInterpolator<T> interpolator, boolean isLast) throws OrekitException {
            if (previousCall != null) {
                System.out.println(interpolator.getCurrentState().getDate().compareTo(previousCall) < 0);
            }
            if (--countDown == 0) {
                throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "dummy error");
            }
        }
    });
    propagator.propagate(initDate.shiftedBy(-3600));
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType) OrekitException(org.orekit.errors.OrekitException)

Aggregations

DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)32 OrbitType (org.orekit.orbits.OrbitType)27 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)20 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)17 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)14 Frame (org.orekit.frames.Frame)14 SpacecraftState (org.orekit.propagation.SpacecraftState)14 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)13 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)13 FieldEquinoctialOrbit (org.orekit.orbits.FieldEquinoctialOrbit)13 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)13 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)13 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)12 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)12 Test (org.junit.Test)12 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)12 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)12 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)12 PVCoordinates (org.orekit.utils.PVCoordinates)12 GaussianRandomGenerator (org.hipparchus.random.GaussianRandomGenerator)7