use of org.orekit.orbits.FieldCartesianOrbit in project Orekit by CS-SI.
the class AbstractForceModelTest method toDS.
protected FieldSpacecraftState<DerivativeStructure> toDS(final SpacecraftState state, final AttitudeProvider attitudeProvider) throws OrekitException {
final Vector3D p = state.getPVCoordinates().getPosition();
final Vector3D v = state.getPVCoordinates().getVelocity();
final Vector3D a = state.getPVCoordinates().getAcceleration();
DSFactory factory = new DSFactory(6, 1);
Field<DerivativeStructure> field = factory.getDerivativeField();
final FieldAbsoluteDate<DerivativeStructure> fDate = new FieldAbsoluteDate<>(field, state.getDate());
final TimeStampedFieldPVCoordinates<DerivativeStructure> fPVA = new TimeStampedFieldPVCoordinates<>(fDate, new FieldVector3D<>(factory.variable(0, p.getX()), factory.variable(1, p.getY()), factory.variable(2, p.getZ())), new FieldVector3D<>(factory.variable(3, v.getX()), factory.variable(4, v.getY()), factory.variable(5, v.getZ())), new FieldVector3D<>(factory.constant(a.getX()), factory.constant(a.getY()), factory.constant(a.getZ())));
final FieldCartesianOrbit<DerivativeStructure> orbit = new FieldCartesianOrbit<>(fPVA, state.getFrame(), state.getMu());
final FieldAttitude<DerivativeStructure> attitude = attitudeProvider.getAttitude(orbit, orbit.getDate(), orbit.getFrame());
return new FieldSpacecraftState<>(orbit, attitude, field.getZero().add(state.getMass()));
}
use of org.orekit.orbits.FieldCartesianOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestEphemerisDatesBackward.
private <T extends RealFieldElement<T>> void doTestEphemerisDatesBackward(Field<T> field) throws OrekitException {
T zero = field.getZero();
// setup
TimeScale tai = TimeScalesFactory.getTAI();
FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-05", tai);
FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
Frame eci = FramesFactory.getGCRF();
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
OrbitType type = OrbitType.CARTESIAN;
double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
prop.setOrbitType(type);
prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
// action
prop.setEphemerisMode();
prop.propagate(endDate, startDate);
FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
// verify
TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
// test date
FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
use of org.orekit.orbits.FieldCartesianOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestEphemerisDates.
private <T extends RealFieldElement<T>> void doTestEphemerisDates(Field<T> field) throws OrekitException {
T zero = field.getZero();
// setup
TimeScale tai = TimeScalesFactory.getTAI();
FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-01", tai);
FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
Frame eci = FramesFactory.getGCRF();
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
OrbitType type = OrbitType.CARTESIAN;
double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
prop.setOrbitType(type);
prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
// action
prop.setEphemerisMode();
prop.propagate(startDate, endDate);
FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
// verify
TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
// test date
FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
use of org.orekit.orbits.FieldCartesianOrbit in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testJounceIsAccelerationSecondDerivative.
@Test
public void testJounceIsAccelerationSecondDerivative() throws OrekitException {
final FieldCartesianOrbit<Decimal64> orbit = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(-4947831.), new Decimal64(-3765382.), new Decimal64(-3708221.)), new FieldVector3D<>(new Decimal64(-2079.), new Decimal64(5291.), new Decimal64(-7842.))), FramesFactory.getEME2000(), FieldAbsoluteDate.getJ2000Epoch(Decimal64Field.getInstance()), Constants.EIGEN5C_EARTH_MU);
FieldPVCoordinates<FieldDerivativeStructure<Decimal64>> fv = orbit.getPVCoordinates().toDerivativeStructurePV(2);
FieldVector3D<Decimal64> numericalJounce = differentiate(orbit, o -> {
FieldVector3D<FieldDerivativeStructure<Decimal64>> a = o.getPVCoordinates().toDerivativeStructurePV(1).getAcceleration();
return new FieldVector3D<>(a.getX().getPartialDerivative(1), a.getY().getPartialDerivative(1), a.getZ().getPartialDerivative(1));
});
Assert.assertEquals(numericalJounce.getX().getReal(), fv.getAcceleration().getX().getPartialDerivative(2).getReal(), 1.0e-15);
Assert.assertEquals(numericalJounce.getY().getReal(), fv.getAcceleration().getY().getPartialDerivative(2).getReal(), 1.0e-15);
Assert.assertEquals(numericalJounce.getZ().getReal(), fv.getAcceleration().getZ().getPartialDerivative(2).getReal(), 1.0e-15);
}
use of org.orekit.orbits.FieldCartesianOrbit in project Orekit by CS-SI.
the class DSConverter method getState.
/**
* Get the state with the number of parameters consistent with force model.
* @param forceModel force model
* @return state with the number of parameters consistent with force model
*/
public FieldSpacecraftState<DerivativeStructure> getState(final ForceModel forceModel) {
// count the required number of parameters
int nbParams = 0;
for (final ParameterDriver driver : forceModel.getParametersDrivers()) {
if (driver.isSelected()) {
++nbParams;
}
}
// fill in intermediate slots
while (dsStates.size() < nbParams + 1) {
dsStates.add(null);
}
if (dsStates.get(nbParams) == null) {
// it is the first time we need this number of parameters
// we need to create the state
final DSFactory factory = new DSFactory(freeStateParameters + nbParams, 1);
final FieldSpacecraftState<DerivativeStructure> s0 = dsStates.get(0);
// orbit
final FieldPVCoordinates<DerivativeStructure> pv0 = s0.getPVCoordinates();
final FieldOrbit<DerivativeStructure> dsOrbit = new FieldCartesianOrbit<>(new TimeStampedFieldPVCoordinates<>(s0.getDate().toAbsoluteDate(), extend(pv0.getPosition(), factory), extend(pv0.getVelocity(), factory), extend(pv0.getAcceleration(), factory)), s0.getFrame(), s0.getMu());
// attitude
final FieldAngularCoordinates<DerivativeStructure> ac0 = s0.getAttitude().getOrientation();
final FieldAttitude<DerivativeStructure> dsAttitude = new FieldAttitude<>(s0.getAttitude().getReferenceFrame(), new TimeStampedFieldAngularCoordinates<>(dsOrbit.getDate(), extend(ac0.getRotation(), factory), extend(ac0.getRotationRate(), factory), extend(ac0.getRotationAcceleration(), factory)));
// mass
final DerivativeStructure dsM = extend(s0.getMass(), factory);
dsStates.set(nbParams, new FieldSpacecraftState<>(dsOrbit, dsAttitude, dsM));
}
return dsStates.get(nbParams);
}
Aggregations