use of org.orekit.time.FieldAbsoluteDate 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);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method createEllipticOrbit.
private static <T extends RealFieldElement<T>> FieldCartesianOrbit<T> createEllipticOrbit(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, "2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(6896874.444705), zero.add(1956581.072644), zero.add(-147476.245054));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(166.816407662), zero.add(-1106.783301861), zero.add(-7372.745712770));
final TimeStampedFieldPVCoordinates<T> pv = new TimeStampedFieldPVCoordinates<>(date, position, velocity, FieldVector3D.getZero(field));
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
return new FieldCartesianOrbit<>(pv, frame, mu);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class KeplerianPropagatorTest method tesWrapedAttitudeException.
@Test(expected = OrekitException.class)
public void tesWrapedAttitudeException() 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, new AttitudeProvider() {
private static final long serialVersionUID = 1L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
});
propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class KeplerianPropagatorTest method wrongAttitude.
@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
AttitudeProvider wrongLaw = new AttitudeProvider() {
private static final long serialVersionUID = 5918362126173997016L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
};
KeplerianPropagator propagator = new KeplerianPropagator(orbit, wrongLaw);
propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FieldEventDetectorTest method doTestWrappedException.
private <T extends RealFieldElement<T>> void doTestWrappedException(Field<T> field) throws OrekitException {
final T zero = field.getZero();
final Throwable dummyCause = new RuntimeException();
try {
// initial conditions
Frame eme2000 = FramesFactory.getEME2000();
TimeScale utc = TimeScalesFactory.getUTC();
final FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2011, 5, 11, utc);
final FieldAbsoluteDate<T> exceptionDate = initialDate.shiftedBy(3600.0);
FieldKeplerianPropagator<T> k = 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));
k.addEventDetector(new FieldDateDetector<T>(initialDate.shiftedBy(Constants.JULIAN_DAY)) {
@Override
public T g(final FieldSpacecraftState<T> s) throws OrekitException {
final T dt = s.getDate().durationFrom(exceptionDate);
if (dt.abs().getReal() < 1.0) {
throw new OrekitException(dummyCause, LocalizedCoreFormats.SIMPLE_MESSAGE, "dummy");
}
return dt;
}
});
k.propagate(initialDate.shiftedBy(Constants.JULIAN_YEAR));
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertSame(dummyCause, oe.getCause());
}
}
Aggregations