Search in sources :

Example 16 with ConstantThrustManeuver

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;
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) ThirdBodyAttraction(org.orekit.forces.gravity.ThirdBodyAttraction) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) BoundedPropagator(org.orekit.propagation.BoundedPropagator) ConstantThrustManeuver(org.orekit.forces.maneuvers.ConstantThrustManeuver)

Aggregations

ConstantThrustManeuver (org.orekit.forces.maneuvers.ConstantThrustManeuver)16 Test (org.junit.Test)15 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)15 LofOffset (org.orekit.attitudes.LofOffset)10 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)7 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)7 InertialProvider (org.orekit.attitudes.InertialProvider)7 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)6 CelestialBodyPointed (org.orekit.attitudes.CelestialBodyPointed)6 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)4 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)4 SpacecraftState (org.orekit.propagation.SpacecraftState)4 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)3 Orbit (org.orekit.orbits.Orbit)3 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)3 AbsoluteDate (org.orekit.time.AbsoluteDate)3 DateComponents (org.orekit.time.DateComponents)3 TimeComponents (org.orekit.time.TimeComponents)3 Arrays (java.util.Arrays)2 Field (org.hipparchus.Field)2