Search in sources :

Example 1 with FieldApsideDetector

use of org.orekit.propagation.events.FieldApsideDetector in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestEventDetectionBug.

private <T extends RealFieldElement<T>> void doTestEventDetectionBug(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    TimeScale utc = TimeScalesFactory.getUTC();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2005, 1, 1, 0, 0, 0.0, utc);
    T duration = zero.add(100000.0);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(initialDate, duration);
    // Initialization of the frame EME2000
    Frame EME2000 = FramesFactory.getEME2000();
    // Initial orbit
    double a = 35786000. + 6378137.0;
    double e = 0.70;
    double rApogee = a * (1 + e);
    double vApogee = FastMath.sqrt(mu * (1 - e) / (a * (1 + e)));
    FieldOrbit<T> geo = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(rApogee), zero, zero), new FieldVector3D<>(zero, zero.add(vApogee), zero)), EME2000, initialDate, mu);
    duration = geo.getKeplerianPeriod();
    endDate = new FieldAbsoluteDate<>(initialDate, duration);
    // Numerical Integration
    final double minStep = 0.001;
    final double maxStep = 1000;
    final double initStep = 60;
    final OrbitType type = OrbitType.EQUINOCTIAL;
    final double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
    final double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, absTolerance, relTolerance);
    integrator.setInitialStepSize(zero.add(initStep));
    // Numerical propagator based on the integrator
    FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    T mass = field.getZero().add(1000.0);
    FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(geo, mass);
    propagator.setInitialState(initialState);
    propagator.setOrbitType(OrbitType.CARTESIAN);
    // Set the events Detectors
    FieldApsideDetector<T> event1 = new FieldApsideDetector<>(geo);
    propagator.addEventDetector(event1);
    // Set the propagation mode
    propagator.setSlaveMode();
    // Propagate
    FieldSpacecraftState<T> finalState = propagator.propagate(endDate);
    // we should stop long before endDate
    Assert.assertTrue(endDate.durationFrom(finalState.getDate()).getReal() > 40000.0);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) Frame(org.orekit.frames.Frame) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldApsideDetector(org.orekit.propagation.events.FieldApsideDetector) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)1 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)1 Frame (org.orekit.frames.Frame)1 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)1 OrbitType (org.orekit.orbits.OrbitType)1 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)1 FieldApsideDetector (org.orekit.propagation.events.FieldApsideDetector)1 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)1 TimeScale (org.orekit.time.TimeScale)1