use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldEventDetectorTest method doTestIssue108Numerical.
private <T extends RealFieldElement<T>> void doTestIssue108Numerical(Field<T> field) throws OrekitException {
final T zero = field.getZero();
final TimeScale utc = TimeScalesFactory.getUTC();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
final T step = zero.add(60.0);
final int n = 100;
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, new ClassicalRungeKuttaFieldIntegrator<>(field, step));
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.resetInitialState(new FieldSpacecraftState<>(orbit));
GCallsCounter<T> counter = new GCallsCounter<>(zero.add(100000.0), zero.add(1.0e-6), 20, new FieldStopOnEvent<GCallsCounter<T>, T>());
propagator.addEventDetector(counter);
propagator.propagate(date.shiftedBy(step.multiply(n)));
Assert.assertEquals(n + 1, counter.getCount());
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldEventDetectorTest method doTestNoisyGFunction.
private <T extends RealFieldElement<T>> void doTestNoisyGFunction(Field<T> field) throws OrekitException {
final T zero = field.getZero();
// initial conditions
Frame eme2000 = FramesFactory.getEME2000();
TimeScale utc = TimeScalesFactory.getUTC();
FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2011, 5, 11, utc);
FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, 2032, 10, 17, utc);
@SuppressWarnings("unchecked") FieldAbsoluteDate<T>[] interruptDates = (FieldAbsoluteDate<T>[]) Array.newInstance(FieldAbsoluteDate.class, 1);
interruptDates[0] = new FieldAbsoluteDate<>(field, 2032, 10, 18, utc);
FieldAbsoluteDate<T> targetDate = new FieldAbsoluteDate<>(field, 2211, 5, 11, utc);
FieldKeplerianPropagator<T> k1 = new FieldKeplerianPropagator<>(new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(4008462.4706055815), zero.add(-3155502.5373837613), zero.add(-5044275.9880020910)), new FieldVector3D<>(zero.add(-5012.9298276860990), zero.add(1920.3567095973078), zero.add(-5172.7403501801580))), eme2000, initialDate, Constants.WGS84_EARTH_MU));
FieldKeplerianPropagator<T> k2 = new FieldKeplerianPropagator<>(new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(4008912.4039522274), zero.add(-3155453.3125615157), zero.add(-5044297.6484738905)), new FieldVector3D<>(zero.add(-5012.5883854112530), zero.add(1920.6332221785074), zero.add(-5172.2177085540500))), eme2000, initialDate, Constants.WGS84_EARTH_MU));
k2.addEventDetector(new FieldCloseApproachDetector<>(zero.add(2015.243454166727), zero.add(0.0001), 100, new FieldContinueOnEvent<FieldCloseApproachDetector<T>, T>(), k1));
k2.addEventDetector(new FieldDateDetector<>(zero.add(Constants.JULIAN_DAY), zero.add(1.0e-6), interruptDates));
FieldSpacecraftState<T> s = k2.propagate(startDate, targetDate);
Assert.assertEquals(0.0, interruptDates[0].durationFrom(s.getDate()).getReal(), 1.1e-6);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldNodeDetectorTest method doTestIssue158.
private <T extends RealFieldElement<T>> void doTestIssue158(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
T a = zero.add(3.0e7);
T e1 = zero.add(0.8);
T e2 = zero.add(1.0e-4);
T i = zero.add(1.0);
T pa = zero.add(1.5 * FastMath.PI);
T raan = zero.add(5.0);
T m = zero.add(0);
Frame frame = FramesFactory.getEME2000();
double mu = Constants.EIGEN5C_EARTH_MU;
// highly eccentric, inclined orbit
final FieldKeplerianOrbit<T> orbit1 = new FieldKeplerianOrbit<>(a, e1, i, pa, raan, m, PositionAngle.MEAN, frame, date, mu);
FieldEventDetector<T> detector1 = new FieldNodeDetector<>(orbit1, orbit1.getFrame());
T t1 = orbit1.getKeplerianPeriod();
Assert.assertEquals(t1.getReal() / 28.82, detector1.getMaxCheckInterval().getReal(), t1.getReal() / 10000);
// nearly circular, inclined orbit
final FieldKeplerianOrbit<T> orbit2 = new FieldKeplerianOrbit<>(a, e2, i, pa, raan, m, PositionAngle.MEAN, frame, date, mu);
FieldEventDetector<T> detector2 = new FieldNodeDetector<>(orbit2, orbit2.getFrame());
T t2 = orbit2.getKeplerianPeriod();
Assert.assertEquals(t1.getReal(), t2.getReal(), t1.getReal() / 10000);
Assert.assertEquals(t2.getReal() / 3, detector2.getMaxCheckInterval().getReal(), t2.getReal() / 10000);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldNodeDetectorTest method doTestIssue138.
private <T extends RealFieldElement<T>> void doTestIssue138(Field<T> field) throws OrekitException {
T zero = field.getZero();
T a = zero.add(800000 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS);
T e = zero.add(0.0001);
T i = zero.add(FastMath.toRadians(98));
T w = zero.add(-90);
T raan = zero;
T v = zero;
Frame inertialFrame = FramesFactory.getEME2000();
FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2014, 01, 01, 0, 0, 0, TimeScalesFactory.getUTC());
FieldAbsoluteDate<T> finalDate = initialDate.shiftedBy(5000);
FieldKeplerianOrbit<T> initialOrbit = new FieldKeplerianOrbit<>(a, e, i, w, raan, v, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(initialOrbit, zero.add(1000));
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(initialOrbit);
// Define 2 instances of NodeDetector:
FieldEventDetector<T> rawDetector = new FieldNodeDetector<>(zero.add(1e-6), initialState.getOrbit(), initialState.getFrame()).withHandler(new FieldContinueOnEvent<FieldNodeDetector<T>, T>());
FieldEventsLogger<T> logger1 = new FieldEventsLogger<>();
FieldEventDetector<T> node1 = logger1.monitorDetector(rawDetector);
FieldEventsLogger<T> logger2 = new FieldEventsLogger<>();
FieldEventDetector<T> node2 = logger2.monitorDetector(rawDetector);
propagator.addEventDetector(node1);
propagator.addEventDetector(node2);
// First propagation
propagator.setEphemerisMode();
propagator.propagate(finalDate);
Assert.assertEquals(2, logger1.getLoggedEvents().size());
Assert.assertEquals(2, logger2.getLoggedEvents().size());
logger1.clearLoggedEvents();
logger2.clearLoggedEvents();
FieldBoundedPropagator<T> postpro = propagator.getGeneratedEphemeris();
// Post-processing
postpro.addEventDetector(node1);
postpro.addEventDetector(node2);
postpro.propagate(finalDate);
Assert.assertEquals(2, logger1.getLoggedEvents().size());
Assert.assertEquals(2, logger2.getLoggedEvents().size());
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldEclipseDetectorTest method doTestInsideOcculted.
private <T extends RealFieldElement<T>> void doTestInsideOcculted(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.560), zero.add(-25767.25680));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.8479685), zero.add(942.7809215), zero.add(7435.922231));
FieldAbsoluteDate<T> iniDate = new FieldAbsoluteDate<>(field, 1969, 7, 28, 4, 0, 0.0, TimeScalesFactory.getTT());
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getGCRF(), iniDate, mu);
FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(orbit);
double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
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, 0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(field.getZero().add(60));
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
sun = CelestialBodyFactory.getSun();
earth = CelestialBodyFactory.getEarth();
sunRadius = 696000000.;
earthRadius = 6400000.;
FieldEclipseDetector<T> e = new FieldEclipseDetector<>(field.getZero().add(60.), field.getZero().add(1.e-3), sun, sunRadius, earth, earthRadius);
Vector3D p = sun.getPVCoordinates(AbsoluteDate.J2000_EPOCH, FramesFactory.getGCRF()).getPosition();
FieldSpacecraftState<T> s = new FieldSpacecraftState<>(new FieldCartesianOrbit<>(new TimeStampedFieldPVCoordinates<>(FieldAbsoluteDate.getJ2000Epoch(field), new FieldPVCoordinates<>(new FieldVector3D<>(field.getOne(), field.getZero(), field.getZero()).add(p), new FieldVector3D<>(field.getZero(), field.getZero(), field.getOne()))), FramesFactory.getGCRF(), mu));
Assert.assertEquals(FastMath.PI, e.g(s).getReal(), 1.0e-15);
}
Aggregations