use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class FieldKeplerianOrbitTest method doTestNonKeplerianHyperbolicDerivatives.
private <T extends RealFieldElement<T>> void doTestNonKeplerianHyperbolicDerivatives(final Field<T> field) throws OrekitException {
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, "2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final FieldVector3D<T> position = new FieldVector3D<>(field.getZero().add(224267911.905821), field.getZero().add(290251613.109399), field.getZero().add(45534292.777492));
final FieldVector3D<T> velocity = new FieldVector3D<>(field.getZero().add(-1494.068165293), field.getZero().add(1124.771027677), field.getZero().add(526.915286134));
final FieldVector3D<T> acceleration = new FieldVector3D<>(field.getZero().add(-0.001295920501), field.getZero().add(-0.002233045187), field.getZero().add(-0.000349906292));
final TimeStampedFieldPVCoordinates<T> pv = new TimeStampedFieldPVCoordinates<>(date, position, velocity, acceleration);
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(pv, frame, mu);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot().getReal(), 9.6e-8);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot().getReal(), 2.8e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot().getReal(), 3.6e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot().getReal(), 1.4e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot().getReal(), 9.4e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot().getReal(), 5.6e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot().getReal(), 9.0e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot().getReal(), 1.8e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot().getReal(), 1.8e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot().getReal(), 3.6e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getPerigeeArgument()), orbit.getPerigeeArgumentDot().getReal(), 9.4e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getRightAscensionOfAscendingNode()), orbit.getRightAscensionOfAscendingNodeDot().getReal(), 1.1e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getTrueAnomaly()), orbit.getTrueAnomalyDot().getReal(), 1.4e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEccentricAnomaly()), orbit.getEccentricAnomalyDot().getReal(), 9.2e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getMeanAnomaly()), orbit.getMeanAnomalyDot().getReal(), 1.4e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.TRUE)), orbit.getAnomalyDot(PositionAngle.TRUE).getReal(), 1.4e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.ECCENTRIC)), orbit.getAnomalyDot(PositionAngle.ECCENTRIC).getReal(), 9.2e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.MEAN)), orbit.getAnomalyDot(PositionAngle.MEAN).getReal(), 1.4e-15);
}
use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest 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());
}
};
EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, wrongLaw, provider);
propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class NRLMSISE00Test method doTestDoubleMethod.
private void doTestDoubleMethod(NRLMSISE00 atm, RandomGenerator random, String methodName, double absTolerance, double relTolerance) throws OrekitException {
try {
// Common data for all cases
final int doy = 172;
final double sec = 29000.;
final double lat = 60.;
final double lon = -70.;
final double hl = 16.;
final double f107a = 149.;
final double f107 = 150.;
double[] ap = { 4., 100., 100., 100., 100., 100., 100. };
Method methodD = getOutputClass().getDeclaredMethod(methodName, double[].class);
methodD.setAccessible(true);
Method methodF = getFieldOutputClass().getDeclaredMethod(methodName, double[].class);
methodF.setAccessible(true);
double[] p = new double[150];
Object output = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
Object fieldOutput = createFieldOutput(Decimal64Field.getInstance(), atm, doy, sec, lat, lon, hl, f107a, f107, ap);
double maxAbsoluteError = 0;
double maxRelativeError = 0;
for (int i = 0; i < 100; ++i) {
for (int k = 0; k < p.length; ++k) {
p[k] = random.nextDouble();
}
double resDouble = ((Double) methodD.invoke(output, p)).doubleValue();
double resField = ((RealFieldElement<?>) methodF.invoke(fieldOutput, p)).getReal();
maxAbsoluteError = FastMath.max(maxAbsoluteError, FastMath.abs(resDouble - resField));
maxRelativeError = FastMath.max(maxRelativeError, FastMath.abs((resDouble - resField) / resDouble));
}
Assert.assertEquals(0.0, maxAbsoluteError, absTolerance);
if (maxAbsoluteError != 0.0) {
Assert.assertEquals(0.0, maxRelativeError, relTolerance);
}
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Assert.fail(e.getLocalizedMessage());
}
}
use of org.hipparchus.RealFieldElement 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.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class FieldEcksteinHechlerPropagatorTest method doWrongAttitude.
private <T extends RealFieldElement<T>> void doWrongAttitude(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(1.0e10), zero.add(1.0e-4), zero.add(1.0e-2), zero, zero, zero, PositionAngle.TRUE, FramesFactory.getEME2000(), date, 3.986004415e14);
final DummyLocalizable gasp = new DummyLocalizable("gasp");
AttitudeProvider wrongLaw = new AttitudeProvider() {
private static final long serialVersionUID = 1L;
@Override
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException(gasp, new RuntimeException());
}
@Override
public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
throw new OrekitException(gasp, new RuntimeException());
}
};
try {
FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, wrongLaw, provider);
propagator.propagate(date.shiftedBy(10.0));
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertSame(gasp, oe.getSpecifier());
}
}
Aggregations