use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldSpacecraftStateTest method doTestTransform.
private <T extends RealFieldElement<T>> void doTestTransform(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);
T mass = zero.add(2500);
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);
BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
double maxDP = 0;
double maxDV = 0;
double maxDA = 0;
for (double t = 0; t < orbit.getKeplerianPeriod().getReal(); t += 60) {
final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(zero.add(t)));
final Transform transform = state.toSpacecraftState().toTransform().getInverse();
PVCoordinates pv = transform.transformPVCoordinates(PVCoordinates.ZERO);
PVCoordinates dPV = new PVCoordinates(pv, state.getPVCoordinates().toPVCoordinates());
Vector3D mZDirection = transform.transformVector(Vector3D.MINUS_K);
double alpha = Vector3D.angle(mZDirection, state.getPVCoordinates().toPVCoordinates().getPosition());
maxDP = FastMath.max(maxDP, dPV.getPosition().getNorm());
maxDV = FastMath.max(maxDV, dPV.getVelocity().getNorm());
maxDA = FastMath.max(maxDA, FastMath.toDegrees(alpha));
}
Assert.assertEquals(0.0, maxDP, 1.0e-6);
Assert.assertEquals(0.0, maxDV, 1.0e-9);
Assert.assertEquals(0.0, maxDA, 1.0e-12);
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldSpacecraftStateTest method doTestAdditionalStates.
private <T extends RealFieldElement<T>> void doTestAdditionalStates(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);
T mass = zero.add(2500);
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);
BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(60));
T[] add = MathArrays.buildArray(field, 2);
add[0] = zero.add(1.);
add[1] = zero.add(2.);
final FieldSpacecraftState<T> extended = state.addAdditionalState("test-1", add).addAdditionalState("test-2", zero.add(42.0));
Assert.assertEquals(0, state.getAdditionalStates().size());
Assert.assertFalse(state.hasAdditionalState("test-1"));
try {
state.getAdditionalState("test-1");
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
Assert.assertEquals(oe.getParts()[0], "test-1");
}
try {
state.ensureCompatibleAdditionalStates(extended);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
}
try {
extended.ensureCompatibleAdditionalStates(state);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
}
try {
T[] kk = MathArrays.buildArray(field, 7);
extended.ensureCompatibleAdditionalStates(extended.addAdditionalState("test-2", kk));
Assert.fail("an exception should have been thrown");
} catch (MathIllegalStateException mise) {
Assert.assertEquals(LocalizedCoreFormats.DIMENSIONS_MISMATCH, mise.getSpecifier());
Assert.assertEquals(7, ((Integer) mise.getParts()[0]).intValue());
}
Assert.assertEquals(2, extended.getAdditionalStates().size());
Assert.assertTrue(extended.hasAdditionalState("test-1"));
Assert.assertTrue(extended.hasAdditionalState("test-2"));
Assert.assertEquals(1.0, extended.getAdditionalState("test-1")[0].getReal(), 1.0e-15);
Assert.assertEquals(2.0, extended.getAdditionalState("test-1")[1].getReal(), 1.0e-15);
Assert.assertEquals(42.0, extended.getAdditionalState("test-2")[0].getReal(), 1.0e-15);
// test various constructors
T[] dd = MathArrays.buildArray(field, 1);
dd[0] = zero.add(-6.0);
Map<String, T[]> map = new HashMap<String, T[]>();
map.put("test-3", dd);
FieldSpacecraftState<T> sO = new FieldSpacecraftState<>(state.getOrbit(), map);
Assert.assertEquals(-6.0, sO.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
FieldSpacecraftState<T> sOA = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), map);
Assert.assertEquals(-6.0, sOA.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
FieldSpacecraftState<T> sOM = new FieldSpacecraftState<>(state.getOrbit(), state.getMass(), map);
Assert.assertEquals(-6.0, sOM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
FieldSpacecraftState<T> sOAM = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), state.getMass(), map);
Assert.assertEquals(-6.0, sOAM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
FieldSpacecraftState<T> sFromDouble = new FieldSpacecraftState<>(field, sOAM.toSpacecraftState());
Assert.assertEquals(-6.0, sFromDouble.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldSpacecraftStateTest method doTestDatesConsistency.
private <T extends RealFieldElement<T>> void doTestDatesConsistency(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);
BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
new FieldSpacecraftState<>(orbit, attitudeLaw.getAttitude(orbit.shiftedBy(zero.add(10.0)), orbit.getDate().shiftedBy(10.0), orbit.getFrame()));
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldEcksteinHechlerPropagatorTest method doStopAtTargetDate.
private <T extends RealFieldElement<T>> void doStopAtTargetDate(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), date, 3.986004415e14);
FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, provider);
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
propagator.addEventDetector(new FieldNodeDetector<>(orbit, itrf).withHandler(new FieldContinueOnEvent<FieldNodeDetector<T>, T>()));
FieldAbsoluteDate<T> farTarget = orbit.getDate().shiftedBy(10000.0);
FieldSpacecraftState<T> propagated = propagator.propagate(farTarget);
Assert.assertEquals(0.0, FastMath.abs(farTarget.durationFrom(propagated.getDate()).getReal()), 1.0e-3);
}
use of org.orekit.orbits.FieldKeplerianOrbit in project Orekit by CS-SI.
the class FieldEcksteinHechlerPropagatorTest method doPropagatedKeplerian.
private <T extends RealFieldElement<T>> void doPropagatedKeplerian(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
// Definition of initial conditions with Keplerian parameters
// -----------------------------------------------------------
FieldAbsoluteDate<T> initDate = date.shiftedBy(584.);
FieldOrbit<T> initialOrbit = new FieldKeplerianOrbit<>(zero.add(7209668.0), zero.add(0.5e-4), zero.add(1.7), zero.add(2.1), zero.add(2.9), zero.add(6.2), PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, provider.getMu());
// Extrapolator definition
// -----------------------
FieldEcksteinHechlerPropagator<T> extrapolator = new FieldEcksteinHechlerPropagator<>(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC), zero.add(2000.0), provider);
// Extrapolation at a final date different from initial date
// ---------------------------------------------------------
// extrapolation duration in seconds
double delta_t = 100000.0;
FieldAbsoluteDate<T> extrapDate = initDate.shiftedBy(delta_t);
FieldSpacecraftState<T> finalOrbit = extrapolator.propagate(extrapDate);
Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate).getReal(), 1.0e-9);
// computation of M final orbit
T LM = finalOrbit.getLE().subtract(finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin())).add(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos()));
Assert.assertEquals(LM.getReal(), finalOrbit.getLM().getReal(), Utils.epsilonAngle);
// test of tan((LE - Lv)/2) :
Assert.assertEquals(FastMath.tan((finalOrbit.getLE().getReal() - finalOrbit.getLv().getReal()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()).getReal(), Utils.epsilonAngle);
// test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE)
// with ex and ey the same for initial and final orbit
T deltaM = finalOrbit.getLM().subtract(initialOrbit.getLM());
T deltaE = finalOrbit.getLE().subtract(initialOrbit.getLE());
T delta = finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin()).subtract(initialOrbit.getEquinoctialEx().multiply(initialOrbit.getLE().sin())).subtract(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos())).add(initialOrbit.getEquinoctialEy().multiply(initialOrbit.getLE().cos()));
Assert.assertEquals(deltaM.getReal(), deltaE.getReal() - delta.getReal(), Utils.epsilonAngle * FastMath.abs(deltaE.getReal() - delta.getReal()));
// for final orbit
T ex = finalOrbit.getEquinoctialEx();
T ey = finalOrbit.getEquinoctialEy();
T hx = finalOrbit.getHx();
T hy = finalOrbit.getHy();
T LE = finalOrbit.getLE();
T ex2 = ex.multiply(ex);
T ey2 = ey.multiply(ey);
T hx2 = hx.multiply(hx);
T hy2 = hy.multiply(hy);
T h2p1 = hx2.add(1).add(hy2);
T beta = ex2.negate().add(1.).subtract(ey2).sqrt().add(1).reciprocal();
T x3 = ex.negate().add(beta.negate().multiply(ey2).add(1).multiply(LE.cos())).add(beta.multiply(ex).multiply(ey).multiply(LE.sin()));
T y3 = ey.negate().add(beta.negate().multiply(ex2).add(1).multiply(LE.sin())).add(beta.multiply(ex).multiply(ey).multiply(LE.cos()));
FieldVector3D<T> U = new FieldVector3D<>(hx2.subtract(hy2).add(1.).divide(h2p1), hx.multiply(2).multiply(hy).divide(h2p1), hy.multiply(-2.).divide(h2p1));
FieldVector3D<T> V = new FieldVector3D<>(hx.multiply(2.).multiply(hy).divide(h2p1), hy2.subtract(hx2).add(1.).divide(h2p1), hx.multiply(2).divide(h2p1));
FieldVector3D<T> r = new FieldVector3D<>(finalOrbit.getA(), new FieldVector3D<>(x3, U, y3, V));
Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm().getReal(), r.getNorm().getReal(), Utils.epsilonTest * r.getNorm().getReal());
}
Aggregations