use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestWrongAttitude.
private <T extends RealFieldElement<T>> void doTestWrongAttitude(Field<T> field) throws OrekitException {
T zero = field.getZero();
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(), new FieldAbsoluteDate<>(field), 3.986004415e14);
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(new DummyLocalizable("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(new DummyLocalizable("gasp"), new RuntimeException());
}
};
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, wrongLaw);
propagator.propagate(new FieldAbsoluteDate<>(field).shiftedBy(10.0));
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method testTuple.
@Test
public void testTuple() throws OrekitException {
AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
KeplerianOrbit k0 = new KeplerianOrbit(7209668.0, 0.5e-4, 1.7, 2.1, 2.9, 6.2, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
TimeStampedPVCoordinates pv0 = k0.getPVCoordinates();
TimeStampedPVCoordinates pv1 = new TimeStampedPVCoordinates(pv0.getDate(), pv0.getPosition(), pv0.getVelocity().add(new Vector3D(2.0, pv0.getVelocity().normalize())));
KeplerianOrbit k1 = new KeplerianOrbit(pv1, k0.getFrame(), k0.getMu());
FieldOrbit<Tuple> twoOrbits = new FieldKeplerianOrbit<>(new Tuple(k0.getA(), k1.getA()), new Tuple(k0.getE(), k1.getE()), new Tuple(k0.getI(), k1.getI()), new Tuple(k0.getPerigeeArgument(), k1.getPerigeeArgument()), new Tuple(k0.getRightAscensionOfAscendingNode(), k1.getRightAscensionOfAscendingNode()), new Tuple(k0.getMeanAnomaly(), k1.getMeanAnomaly()), PositionAngle.MEAN, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(initDate, new Tuple(0.0, 0.0)), mu);
Field<Tuple> field = twoOrbits.getDate().getField();
FieldPropagator<Tuple> propagator = new FieldKeplerianPropagator<>(twoOrbits);
Min minTangential = new Min();
Max maxTangential = new Max();
Min minRadial = new Min();
Max maxRadial = new Max();
propagator.setMasterMode(field.getZero().add(10.0), (s, isLast) -> {
FieldVector3D<Tuple> p = s.getPVCoordinates().getPosition();
FieldVector3D<Tuple> v = s.getPVCoordinates().getVelocity();
Vector3D p0 = new Vector3D(p.getX().getComponent(0), p.getY().getComponent(0), p.getZ().getComponent(0));
Vector3D v0 = new Vector3D(v.getX().getComponent(0), v.getY().getComponent(0), v.getZ().getComponent(0));
Vector3D t = v0.normalize();
Vector3D r = Vector3D.crossProduct(v0, Vector3D.crossProduct(p0, v0)).normalize();
Vector3D p1 = new Vector3D(p.getX().getComponent(1), p.getY().getComponent(1), p.getZ().getComponent(1));
double dT = Vector3D.dotProduct(p1.subtract(p0), t);
double dR = Vector3D.dotProduct(p1.subtract(p0), r);
minTangential.increment(dT);
maxTangential.increment(dT);
minRadial.increment(dR);
maxRadial.increment(dR);
});
propagator.propagate(twoOrbits.getDate().shiftedBy(Constants.JULIAN_DAY / 8));
Assert.assertEquals(-72525.685, minTangential.getResult(), 1.0e-3);
Assert.assertEquals(926.046, maxTangential.getResult(), 1.0e-3);
Assert.assertEquals(-92.800, minRadial.getResult(), 1.0e-3);
Assert.assertEquals(7739.532, maxRadial.getResult(), 1.0e-3);
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldSpacecraftStateTest method doTestFramesConsistency.
// (expected=IllegalArgumentException.class)
private <T extends RealFieldElement<T>> void doTestFramesConsistency(final Field<T> field) throws OrekitException {
T zero = field.getZero();
T a = zero.add(rOrbit.getA());
T e = zero.add(rOrbit.getE());
T i = zero.add(rOrbit.getI());
T pa = zero.add(1.9674147913622104);
T raan = zero.add(FastMath.toRadians(261));
T lv = zero.add(0);
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
new FieldSpacecraftState<>(orbit, new FieldAttitude<>(orbit.getDate(), FramesFactory.getGCRF(), FieldRotation.getIdentity(field), FieldVector3D.getZero(field), FieldVector3D.getZero(field)));
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldSpacecraftStateTest method doTestFieldVsReal.
private <T extends RealFieldElement<T>> void doTestFieldVsReal(final Field<T> field) throws OrekitException {
T zero = field.getZero();
double mu = 3.9860047e14;
T a_f = zero.add(150000);
T e_f = zero.add(0);
T i_f = zero.add(0);
T pa_f = zero.add(0);
T raan_f = zero.add(0);
T m_f = zero.add(0);
FieldAbsoluteDate<T> t_f = new FieldAbsoluteDate<>(field);
double a_r = a_f.getReal();
double e_r = e_f.getReal();
double i_r = i_f.getReal();
double pa_r = pa_f.getReal();
double raan_r = raan_f.getReal();
double m_r = m_f.getReal();
AbsoluteDate t_r = t_f.toAbsoluteDate();
KeplerianOrbit kep_r = new KeplerianOrbit(a_r, e_r, i_r, pa_r, raan_r, m_r, PositionAngle.ECCENTRIC, FramesFactory.getEME2000(), t_r, mu);
FieldKeplerianOrbit<T> kep_f = new FieldKeplerianOrbit<>(a_f, e_f, i_f, pa_f, raan_f, m_f, PositionAngle.ECCENTRIC, FramesFactory.getEME2000(), t_f, mu);
SpacecraftState ScS_r = new SpacecraftState(kep_r);
FieldSpacecraftState<T> ScS_f = new FieldSpacecraftState<>(kep_f);
for (double dt = 0; dt < 500; dt += 100) {
SpacecraftState control_r = ScS_r.shiftedBy(dt);
FieldSpacecraftState<T> control_f = ScS_f.shiftedBy(zero.add(dt));
Assert.assertEquals(control_r.getA(), control_f.getA().getReal(), 1e-10);
Assert.assertEquals(control_r.getE(), control_f.getE().getReal(), 1e-10);
Assert.assertEquals(control_r.getEquinoctialEx(), control_f.getEquinoctialEx().getReal(), 1e-10);
Assert.assertEquals(control_r.getEquinoctialEy(), control_f.getEquinoctialEy().getReal(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getPosition().getX(), control_f.getPVCoordinates().toPVCoordinates().getPosition().getX(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getPosition().getY(), control_f.getPVCoordinates().toPVCoordinates().getPosition().getY(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getPosition().getZ(), control_f.getPVCoordinates().toPVCoordinates().getPosition().getZ(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getVelocity().getX(), control_f.getPVCoordinates().toPVCoordinates().getVelocity().getX(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getVelocity().getY(), control_f.getPVCoordinates().toPVCoordinates().getVelocity().getY(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getVelocity().getZ(), control_f.getPVCoordinates().toPVCoordinates().getVelocity().getZ(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getAcceleration().getX(), control_f.getPVCoordinates().toPVCoordinates().getAcceleration().getX(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getAcceleration().getY(), control_f.getPVCoordinates().toPVCoordinates().getAcceleration().getY(), 1e-10);
Assert.assertEquals(control_r.getPVCoordinates().getAcceleration().getZ(), control_f.getPVCoordinates().toPVCoordinates().getAcceleration().getZ(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getOrientation().getRotation().getQ0(), control_f.getAttitude().getOrientation().getRotation().getQ0().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getOrientation().getRotation().getQ1(), control_f.getAttitude().getOrientation().getRotation().getQ1().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getOrientation().getRotation().getQ2(), control_f.getAttitude().getOrientation().getRotation().getQ2().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getOrientation().getRotation().getQ3(), control_f.getAttitude().getOrientation().getRotation().getQ3().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getSpin().getAlpha(), control_f.getAttitude().getSpin().getAlpha().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getSpin().getDelta(), control_f.getAttitude().getSpin().getDelta().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getSpin().getNorm(), control_f.getAttitude().getSpin().getNorm().getReal(), 1e-10);
Assert.assertEquals(control_r.getAttitude().getReferenceFrame().isPseudoInertial(), control_f.getAttitude().getReferenceFrame().isPseudoInertial());
Assert.assertEquals(control_r.getAttitude().getDate().durationFrom(AbsoluteDate.J2000_EPOCH), control_f.getAttitude().getDate().durationFrom(AbsoluteDate.J2000_EPOCH).getReal(), 1e-10);
}
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldSpacecraftStateTest method doTestDateConsistencyClose.
/**
* Check orbit and attitude dates can be off by a few ulps. I see this when using
* FixedRate attitude provider.
*/
private <T extends RealFieldElement<T>> void doTestDateConsistencyClose(final Field<T> field) throws OrekitException {
// setup
T zero = field.getZero();
T one = field.getOne();
T a = zero.add(rOrbit.getA());
T e = zero.add(rOrbit.getE());
T i = zero.add(rOrbit.getI());
T pa = zero.add(1.9674147913622104);
T raan = zero.add(FastMath.toRadians(261));
T lv = zero.add(0);
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
FieldKeplerianOrbit<T> orbit10Shifts = orbit;
for (int ii = 0; ii < 10; ii++) {
orbit10Shifts = orbit10Shifts.shiftedBy(zero.add(0.1));
}
final FieldOrbit<T> orbit1Shift = orbit.shiftedBy(one);
BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
FieldAttitude<T> shiftedAttitude = attitudeLaw.getAttitude(orbit1Shift, orbit1Shift.getDate(), orbit.getFrame());
// verify dates are very close, but not equal
Assert.assertNotEquals(shiftedAttitude.getDate(), orbit10Shifts.getDate());
Assert.assertEquals(shiftedAttitude.getDate().durationFrom(orbit10Shifts.getDate()).getReal(), 0, Precision.EPSILON);
// action + verify no exception is thrown
new FieldSpacecraftState<>(orbit10Shifts, shiftedAttitude);
}
Aggregations