use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class NumericalPropagatorTest method testPropagationTypesHyperbolic.
@Test
public void testPropagationTypesHyperbolic() throws OrekitException, ParseException, IOException {
SpacecraftState state = new SpacecraftState(new KeplerianOrbit(-10000000.0, 2.5, 0.3, 0, 0, 0.0, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu));
ForceModel gravityField = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getNormalizedProvider(5, 5));
propagator.addForceModel(gravityField);
// Propagation of the initial at t + dt
final PVCoordinates pv = state.getPVCoordinates();
final double dP = 0.001;
final double dV = state.getMu() * dP / (pv.getPosition().getNormSq() * pv.getVelocity().getNorm());
final PVCoordinates pvcM = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.MEAN);
final PVCoordinates pvkM = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN);
final PVCoordinates pvcE = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC);
final PVCoordinates pvkE = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC);
final PVCoordinates pvcT = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.TRUE);
final PVCoordinates pvkT = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE);
Assert.assertEquals(0, pvcM.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3);
Assert.assertEquals(0, pvcM.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4);
Assert.assertEquals(0, pvkM.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.2);
Assert.assertEquals(0, pvkM.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.3);
Assert.assertEquals(0, pvcE.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3);
Assert.assertEquals(0, pvcE.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4);
Assert.assertEquals(0, pvkE.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.009);
Assert.assertEquals(0, pvkE.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.006);
Assert.assertEquals(0, pvcT.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3);
Assert.assertEquals(0, pvcT.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4);
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class NumericalPropagatorTest method testResetStateEvent.
@Test
public void testResetStateEvent() throws OrekitException {
final AbsoluteDate resetDate = initDate.shiftedBy(1000);
CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.RESET_STATE) {
public SpacecraftState resetState(DateDetector detector, SpacecraftState oldState) {
return new SpacecraftState(oldState.getOrbit(), oldState.getAttitude(), oldState.getMass() - 200.0);
}
};
propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking));
checking.assertEvent(false);
final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200));
checking.assertEvent(true);
Assert.assertEquals(initialState.getMass() - 200, finalState.getMass(), 1.0e-10);
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class NumericalPropagatorTest method doTestShift.
private static void doTestShift(final CartesianOrbit orbit, final OrbitType orbitType, final PositionAngle angleType, final boolean withDerivatives, final double error60s, final double error120s, final double error300s, final double error600s, final double error900s) throws OrekitException {
Utils.setDataRoot("regular-data:atmosphere:potential/grgs-format");
GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
final NumericalPropagator np = createPropagator(new SpacecraftState(orbit), orbitType, angleType);
// the reference date for shifts is set at 60s, so the propagator can provide derivatives if needed
// (derivatives are not available in the initial orbit)
final AbsoluteDate reference = orbit.getDate().shiftedBy(60.0);
final ShiftChecker checker = new ShiftChecker(withDerivatives, orbitType, angleType, error60s, error120s, error300s, error600s, error900s);
np.addEventDetector(new DateDetector(30.0, 1.0e-9, reference, reference.shiftedBy(60.0), reference.shiftedBy(120.0), reference.shiftedBy(300.0), reference.shiftedBy(600.0), reference.shiftedBy(900.0)).withHandler(checker));
np.propagate(reference.shiftedBy(1000.0));
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class NumericalPropagatorTest method testResetAdditionalStateEvent.
@Test
public void testResetAdditionalStateEvent() throws OrekitException {
propagator.addAdditionalEquations(new AdditionalEquations() {
public String getName() {
return "linear";
}
public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
pDot[0] = 1.0;
return null;
}
});
propagator.setInitialState(propagator.getInitialState().addAdditionalState("linear", 1.5));
CheckingHandler<AdditionalStateLinearDetector> checking = new CheckingHandler<AdditionalStateLinearDetector>(Action.RESET_STATE) {
public SpacecraftState resetState(AdditionalStateLinearDetector detector, SpacecraftState oldState) throws OrekitException {
return oldState.addAdditionalState("linear", oldState.getAdditionalState("linear")[0] * 2);
}
};
propagator.addEventDetector(new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking));
final double dt = 3200;
checking.assertEvent(false);
final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
checking.assertEvent(true);
Assert.assertEquals(dt + 4.5, finalState.getAdditionalState("linear")[0], 1.0e-8);
Assert.assertEquals(dt, finalState.getDate().durationFrom(initDate), 1.0e-8);
}
use of org.orekit.propagation.SpacecraftState in project Orekit by CS-SI.
the class NumericalPropagatorTest method testAdditionalStateEvent.
@Test
public void testAdditionalStateEvent() throws OrekitException {
propagator.addAdditionalEquations(new AdditionalEquations() {
public String getName() {
return "linear";
}
public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
pDot[0] = 1.0;
return new double[7];
}
});
try {
propagator.addAdditionalEquations(new AdditionalEquations() {
public String getName() {
return "linear";
}
public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
pDot[0] = 1.0;
return new double[7];
}
});
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(oe.getSpecifier(), OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE);
}
try {
propagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "linear";
}
public double[] getAdditionalState(SpacecraftState state) {
return null;
}
});
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(oe.getSpecifier(), OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE);
}
propagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "constant";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[] { 1.0 };
}
});
Assert.assertTrue(propagator.isAdditionalStateManaged("linear"));
Assert.assertTrue(propagator.isAdditionalStateManaged("constant"));
Assert.assertFalse(propagator.isAdditionalStateManaged("non-managed"));
Assert.assertEquals(2, propagator.getManagedAdditionalStates().length);
propagator.setInitialState(propagator.getInitialState().addAdditionalState("linear", 1.5));
CheckingHandler<AdditionalStateLinearDetector> checking = new CheckingHandler<AdditionalStateLinearDetector>(Action.STOP);
propagator.addEventDetector(new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking));
final double dt = 3200;
checking.assertEvent(false);
final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
checking.assertEvent(true);
Assert.assertEquals(3.0, finalState.getAdditionalState("linear")[0], 1.0e-8);
Assert.assertEquals(1.5, finalState.getDate().durationFrom(initDate), 1.0e-8);
}
Aggregations