Search in sources :

Example 11 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class ConstantThrustManeuverTest method testForwardAndBackward.

@Test
public void testForwardAndBackward() throws OrekitException {
    final double isp = 318;
    final double mass = 2500;
    final double a = 24396159;
    final double e = 0.72831215;
    final double i = FastMath.toRadians(7);
    final double omega = FastMath.toRadians(180);
    final double OMEGA = FastMath.toRadians(261);
    final double lv = 0;
    final double duration = 3653.99;
    final double f = 420;
    final double delta = FastMath.toRadians(-7.4978);
    final double alpha = FastMath.toRadians(351);
    final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
    final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
    final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
    final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
    Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
    Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);
    double[][] tol = NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
    AdaptiveStepsizeIntegrator integrator1 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator1.setInitialStepSize(60);
    final NumericalPropagator propagator1 = new NumericalPropagator(integrator1);
    propagator1.setInitialState(initialState);
    propagator1.setAttitudeProvider(law);
    propagator1.addForceModel(maneuver);
    final SpacecraftState finalState = propagator1.propagate(fireDate.shiftedBy(3800));
    AdaptiveStepsizeIntegrator integrator2 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator2.setInitialStepSize(60);
    final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
    propagator2.setInitialState(finalState);
    propagator2.setAttitudeProvider(law);
    propagator2.addForceModel(maneuver);
    final SpacecraftState recoveredState = propagator2.propagate(orbit.getDate());
    final Vector3D refPosition = initialState.getPVCoordinates().getPosition();
    final Vector3D recoveredPosition = recoveredState.getPVCoordinates().getPosition();
    Assert.assertEquals(0.0, Vector3D.distance(refPosition, recoveredPosition), 30.0);
    Assert.assertEquals(initialState.getMass(), recoveredState.getMass(), 1.5e-10);
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) InertialProvider(org.orekit.attitudes.InertialProvider) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 12 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class ConstantThrustManeuverTest method testJacobianVs80Implementation.

@Test
public void testJacobianVs80Implementation() throws OrekitException {
    final double isp = 318;
    final double mass = 2500;
    final double a = 24396159;
    final double e = 0.72831215;
    final double i = FastMath.toRadians(7);
    final double omega = FastMath.toRadians(180);
    final double OMEGA = FastMath.toRadians(261);
    final double lv = 0;
    final double duration = 3653.99;
    final double f = 420;
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
    final AttitudeProvider law = new LofOffset(orbit.getFrame(), LOFType.VVLH);
    final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
    final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
    final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
    // before maneuver (Jacobian wrt. state is zero)
    checkStateJacobianVs80Implementation(initialState, maneuver, law, 1.0e-50, false);
    // in maneuver
    SpacecraftState startState = initialState.shiftedBy(fireDate.durationFrom(initDate));
    maneuver.getEventsDetectors().findFirst().get().eventOccurred(startState, true);
    SpacecraftState midState = startState.shiftedBy(duration / 2.0);
    checkStateJacobianVs80Implementation(midState, maneuver, law, 1.0e-20, false);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeComponents(org.orekit.time.TimeComponents) LofOffset(org.orekit.attitudes.LofOffset) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 13 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class SmallManeuverAnalyticalModelTest method getEphemeris.

private BoundedPropagator getEphemeris(final Orbit orbit, final double mass, final AbsoluteDate t0, final Vector3D dV, final double f, final double isp) throws OrekitException {
    AttitudeProvider law = new LofOffset(orbit.getFrame(), LOFType.LVLH);
    final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
    // 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.setOrbitType(orbit.getType());
    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, dt, f, isp, dV.normalize());
        propagator.addForceModel(maneuver);
    }
    propagator.setEphemerisMode();
    propagator.propagate(t0.shiftedBy(5 * orbit.getKeplerianPeriod()));
    return propagator.getGeneratedEphemeris();
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Example 14 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method wrongAttitude.

@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
    KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 5918362126173997016L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }

        public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }
    };
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, wrongLaw, provider);
    propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) RealFieldElement(org.hipparchus.RealFieldElement) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 15 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class FieldKeplerianPropagatorTest method doTestWrappedAttitudeException.

private <T extends RealFieldElement<T>> void doTestWrappedAttitudeException(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }

        public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }
    });
    propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAttitude(org.orekit.attitudes.FieldAttitude) Attitude(org.orekit.attitudes.Attitude) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldAttitude(org.orekit.attitudes.FieldAttitude) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Aggregations

AttitudeProvider (org.orekit.attitudes.AttitudeProvider)36 Test (org.junit.Test)29 AbsoluteDate (org.orekit.time.AbsoluteDate)21 LofOffset (org.orekit.attitudes.LofOffset)20 SpacecraftState (org.orekit.propagation.SpacecraftState)17 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)16 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)15 ConstantThrustManeuver (org.orekit.forces.maneuvers.ConstantThrustManeuver)15 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)14 InertialProvider (org.orekit.attitudes.InertialProvider)13 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)12 Orbit (org.orekit.orbits.Orbit)12 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)10 OrekitException (org.orekit.errors.OrekitException)10 CartesianOrbit (org.orekit.orbits.CartesianOrbit)10 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)9 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)9 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)8 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)8 DateComponents (org.orekit.time.DateComponents)8