use of org.orekit.propagation.analytical.FieldKeplerianPropagator 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.propagation.analytical.FieldKeplerianPropagator 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.propagation.analytical.FieldKeplerianPropagator 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.propagation.analytical.FieldKeplerianPropagator 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.propagation.analytical.FieldKeplerianPropagator in project Orekit by CS-SI.
the class FixedRateTest method doTestSpin.
private <T extends RealFieldElement<T>> void doTestSpin(final Field<T> field) throws OrekitException {
final T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
final T rate = zero.add(2 * FastMath.PI / (12 * 60));
AttitudeProvider law = new FixedRate(new Attitude(date.toAbsoluteDate(), FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate.getReal(), Vector3D.PLUS_K), Vector3D.ZERO));
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7178000.0), zero.add(1.e-4), zero.add(FastMath.toRadians(50.)), zero.add(FastMath.toRadians(10.)), zero.add(FastMath.toRadians(20.)), zero.add(FastMath.toRadians(30.)), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
FieldPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, law);
T h = zero.add(0.01);
FieldSpacecraftState<T> sMinus = propagator.propagate(date.shiftedBy(h.negate()));
FieldSpacecraftState<T> s0 = propagator.propagate(date);
FieldSpacecraftState<T> sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = FieldRotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation()).getReal();
double evolutionAngleMinus = FieldRotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation()).getReal();
Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
double errorAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(h.negate()).getAttitude().getRotation()).getReal();
double evolutionAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation()).getReal();
Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);
FieldVector3D<T> spin0 = s0.getAttitude().getSpin();
FieldVector3D<T> reference = FieldAngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), h.multiply(2));
Assert.assertEquals(0.0, spin0.subtract(reference).getNorm().getReal(), 1.0e-14);
}
Aggregations