use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class RelativityTest method RealFieldExpectErrorTest.
/**
*Same test as the previous one but not adding the ForceModel to the NumericalPropagator
* it is a test to validate the previous test.
* (to test if the ForceModel it's actually
* doing something in the Propagator and the FieldPropagator)
*/
@Test
public void RealFieldExpectErrorTest() throws OrekitException {
DSFactory factory = new DSFactory(6, 0);
DerivativeStructure a_0 = factory.variable(0, 7e7);
DerivativeStructure e_0 = factory.variable(1, 0.4);
DerivativeStructure i_0 = factory.variable(2, 85 * FastMath.PI / 180);
DerivativeStructure R_0 = factory.variable(3, 0.7);
DerivativeStructure O_0 = factory.variable(4, 0.5);
DerivativeStructure n_0 = factory.variable(5, 0.1);
Field<DerivativeStructure> field = a_0.getField();
DerivativeStructure zero = field.getZero();
FieldAbsoluteDate<DerivativeStructure> J2000 = new FieldAbsoluteDate<>(field);
Frame EME = FramesFactory.getEME2000();
FieldKeplerianOrbit<DerivativeStructure> FKO = new FieldKeplerianOrbit<>(a_0, e_0, i_0, R_0, O_0, n_0, PositionAngle.MEAN, EME, J2000, Constants.EIGEN5C_EARTH_MU);
FieldSpacecraftState<DerivativeStructure> initialState = new FieldSpacecraftState<>(FKO);
SpacecraftState iSR = initialState.toSpacecraftState();
OrbitType type = OrbitType.KEPLERIAN;
double[][] tolerance = NumericalPropagator.tolerances(0.001, FKO.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<DerivativeStructure> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
AdaptiveStepsizeIntegrator RIntegrator = new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
RIntegrator.setInitialStepSize(60);
FieldNumericalPropagator<DerivativeStructure> FNP = new FieldNumericalPropagator<>(field, integrator);
FNP.setOrbitType(type);
FNP.setInitialState(initialState);
NumericalPropagator NP = new NumericalPropagator(RIntegrator);
NP.setOrbitType(type);
NP.setInitialState(iSR);
final Relativity forceModel = new Relativity(Constants.EIGEN5C_EARTH_MU);
FNP.addForceModel(forceModel);
// NOT ADDING THE FORCE MODEL TO THE NUMERICAL PROPAGATOR NP.addForceModel(forceModel);
FieldAbsoluteDate<DerivativeStructure> target = J2000.shiftedBy(1000.);
FieldSpacecraftState<DerivativeStructure> finalState_DS = FNP.propagate(target);
SpacecraftState finalState_R = NP.propagate(target.toAbsoluteDate());
FieldPVCoordinates<DerivativeStructure> finPVC_DS = finalState_DS.getPVCoordinates();
PVCoordinates finPVC_R = finalState_R.getPVCoordinates();
Assert.assertEquals(0, Vector3D.distance(finPVC_DS.toPVCoordinates().getPosition(), finPVC_R.getPosition()), 8.0e-13 * finPVC_R.getPosition().getNorm());
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class ThirdBodyAttractionTest method testParameterDerivative.
@Test
public void testParameterDerivative() throws OrekitException {
final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06, -1.32931592294715829e+04);
final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03, -1.14097953925384523e+01);
final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel), FramesFactory.getGCRF(), new AbsoluteDate(2003, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()), Constants.EIGEN5C_EARTH_MU));
final CelestialBody moon = CelestialBodyFactory.getMoon();
final ThirdBodyAttraction forceModel = new ThirdBodyAttraction(moon);
Assert.assertTrue(forceModel.dependsOnPositionOnly());
final String name = moon.getName() + ThirdBodyAttraction.ATTRACTION_COEFFICIENT_SUFFIX;
checkParameterDerivative(state, forceModel, name, 1.0, 7.0e-15);
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class CartesianOrbitTest method testNumericalIssue135.
@Test
public void testNumericalIssue135() throws OrekitException {
Vector3D position = new Vector3D(-6.7884943832e7, -2.1423006112e7, -3.1603915377e7);
Vector3D velocity = new Vector3D(-4732.55, -2472.086, -3022.177);
PVCoordinates pvCoordinates = new PVCoordinates(position, velocity);
CartesianOrbit orbit = new CartesianOrbit(pvCoordinates, FramesFactory.getEME2000(), date, 324858598826460.);
testShift(orbit, new KeplerianOrbit(orbit), 6.0e-15);
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class CartesianOrbitTest method testCartesianToKeplerian.
@Test
public void testCartesianToKeplerian() {
Vector3D position = new Vector3D(-26655470.0, 29881667.0, -113657.0);
Vector3D velocity = new Vector3D(-1125.0, -1122.0, 195.0);
PVCoordinates pvCoordinates = new PVCoordinates(position, velocity);
double mu = 3.9860047e14;
CartesianOrbit p = new CartesianOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
KeplerianOrbit kep = new KeplerianOrbit(p);
Assert.assertEquals(22979265.3030773, p.getA(), Utils.epsilonTest * p.getA());
Assert.assertEquals(0.743502611664700, p.getE(), Utils.epsilonE * FastMath.abs(p.getE()));
Assert.assertEquals(0.122182096220906, p.getI(), Utils.epsilonAngle * FastMath.abs(p.getI()));
double pa = kep.getPerigeeArgument();
Assert.assertEquals(MathUtils.normalizeAngle(3.09909041016672, pa), pa, Utils.epsilonAngle * FastMath.abs(pa));
double raan = kep.getRightAscensionOfAscendingNode();
Assert.assertEquals(MathUtils.normalizeAngle(2.32231010979999, raan), raan, Utils.epsilonAngle * FastMath.abs(raan));
double m = kep.getMeanAnomaly();
Assert.assertEquals(MathUtils.normalizeAngle(3.22888977629034, m), m, Utils.epsilonAngle * FastMath.abs(FastMath.abs(m)));
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class CartesianOrbitTest method testCartesianToCartesian.
@Test
public void testCartesianToCartesian() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Vector3D position = new Vector3D(-29536113.0, 30329259.0, -100125.0);
Vector3D velocity = new Vector3D(-2194.0, -2141.0, -8.0);
PVCoordinates pvCoordinates = new PVCoordinates(position, velocity);
double mu = 3.9860047e14;
CartesianOrbit p = new CartesianOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
Assert.assertEquals(p.getPVCoordinates().getPosition().getX(), pvCoordinates.getPosition().getX(), Utils.epsilonTest * FastMath.abs(pvCoordinates.getPosition().getX()));
Assert.assertEquals(p.getPVCoordinates().getPosition().getY(), pvCoordinates.getPosition().getY(), Utils.epsilonTest * FastMath.abs(pvCoordinates.getPosition().getY()));
Assert.assertEquals(p.getPVCoordinates().getPosition().getZ(), pvCoordinates.getPosition().getZ(), Utils.epsilonTest * FastMath.abs(pvCoordinates.getPosition().getZ()));
Assert.assertEquals(p.getPVCoordinates().getVelocity().getX(), pvCoordinates.getVelocity().getX(), Utils.epsilonTest * FastMath.abs(pvCoordinates.getVelocity().getX()));
Assert.assertEquals(p.getPVCoordinates().getVelocity().getY(), pvCoordinates.getVelocity().getY(), Utils.epsilonTest * FastMath.abs(pvCoordinates.getVelocity().getY()));
Assert.assertEquals(p.getPVCoordinates().getVelocity().getZ(), pvCoordinates.getVelocity().getZ(), Utils.epsilonTest * FastMath.abs(pvCoordinates.getVelocity().getZ()));
Method initPV = CartesianOrbit.class.getDeclaredMethod("initPVCoordinates", new Class[0]);
initPV.setAccessible(true);
Assert.assertSame(p.getPVCoordinates(), initPV.invoke(p, new Object[0]));
}
Aggregations