use of org.orekit.forces.maneuvers.ConstantThrustManeuver in project Orekit by CS-SI.
the class AdapterPropagatorTest method getEphemeris.
private BoundedPropagator getEphemeris(final Orbit orbit, final double mass, final int nbOrbits, final AttitudeProvider law, final AbsoluteDate t0, final Vector3D dV, final double f, final double isp, final boolean sunAttraction, final boolean moonAttraction, final NormalizedSphericalHarmonicsProvider gravityField) throws OrekitException, ParseException, IOException {
SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
// add some dummy additional states
initialState = initialState.addAdditionalState("dummy 1", 1.25, 2.5);
initialState = initialState.addAdditionalState("dummy 2", 5.0);
// set up numerical propagator
final double dP = 1.0;
double[][] tolerances = NumericalPropagator.tolerances(dP, orbit, orbit.getType());
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tolerances[0], tolerances[1]);
integrator.setInitialStepSize(orbit.getKeplerianPeriod() / 100.0);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "dummy 2";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[] { 5.0 };
}
});
propagator.setInitialState(initialState);
propagator.setAttitudeProvider(law);
if (dV.getNorm() > 1.0e-6) {
// set up maneuver
final double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
final double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(t0.shiftedBy(-0.5 * dt), dt, f, isp, dV.normalize());
propagator.addForceModel(maneuver);
}
if (sunAttraction) {
propagator.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getSun()));
}
if (moonAttraction) {
propagator.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getMoon()));
}
if (gravityField != null) {
propagator.addForceModel(new HolmesFeatherstoneAttractionModel(FramesFactory.getGTOD(false), gravityField));
}
propagator.setEphemerisMode();
propagator.propagate(t0.shiftedBy(nbOrbits * orbit.getKeplerianPeriod()));
final BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
// both the initial propagator and generated ephemeris manage one of the two
// additional states, but they also contain unmanaged copies of the other one
Assert.assertFalse(propagator.isAdditionalStateManaged("dummy 1"));
Assert.assertTrue(propagator.isAdditionalStateManaged("dummy 2"));
Assert.assertFalse(ephemeris.isAdditionalStateManaged("dummy 1"));
Assert.assertTrue(ephemeris.isAdditionalStateManaged("dummy 2"));
Assert.assertEquals(2, ephemeris.getInitialState().getAdditionalState("dummy 1").length);
Assert.assertEquals(1, ephemeris.getInitialState().getAdditionalState("dummy 2").length);
return ephemeris;
}
Aggregations