Search in sources :

Example 61 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestPropagationTypesHyperbolic.

private <T extends RealFieldElement<T>> void doTestPropagationTypesHyperbolic(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    FieldSpacecraftState<T> state = new FieldSpacecraftState<>(new FieldKeplerianOrbit<>(zero.add(-10000000.0), zero.add(2.5), zero.add(0.3), zero, zero, zero, 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 FieldPVCoordinates<T> pv = state.getPVCoordinates();
    final T dP = zero.add(0.001);
    final T dV = dP.multiply(state.getMu()).divide(pv.getPosition().getNormSq().multiply(pv.getVelocity().getNorm()));
    final FieldPVCoordinates<T> pvcM = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.MEAN, propagator);
    final FieldPVCoordinates<T> pvkM = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN, propagator);
    final FieldPVCoordinates<T> pvcE = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC, propagator);
    final FieldPVCoordinates<T> pvkE = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC, propagator);
    final FieldPVCoordinates<T> pvcT = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.TRUE, propagator);
    final FieldPVCoordinates<T> pvkT = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE, propagator);
    Assert.assertEquals(0, pvcM.getPosition().subtract(pvkT.getPosition()).getNorm().getReal() / dP.getReal(), 0.3);
    Assert.assertEquals(0, pvcM.getVelocity().subtract(pvkT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.4);
    Assert.assertEquals(0, pvkM.getPosition().subtract(pvkT.getPosition()).getNorm().getReal() / dP.getReal(), 0.2);
    Assert.assertEquals(0, pvkM.getVelocity().subtract(pvkT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.3);
    Assert.assertEquals(0, pvcE.getPosition().subtract(pvkT.getPosition()).getNorm().getReal() / dP.getReal(), 0.3);
    Assert.assertEquals(0, pvcE.getVelocity().subtract(pvkT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.4);
    Assert.assertEquals(0, pvkE.getPosition().subtract(pvkT.getPosition()).getNorm().getReal() / dP.getReal(), 0.009);
    Assert.assertEquals(0, pvkE.getVelocity().subtract(pvkT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.006);
    Assert.assertEquals(0, pvcT.getPosition().subtract(pvkT.getPosition()).getNorm().getReal() / dP.getReal(), 0.3);
    Assert.assertEquals(0, pvcT.getVelocity().subtract(pvkT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.4);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) ForceModel(org.orekit.forces.ForceModel) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)

Example 62 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestKepler.

private <T extends RealFieldElement<T>> void doTestKepler(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    FieldSpacecraftState<T> initialState;
    FieldNumericalPropagator<T> propagator;
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    // Propagation of the initial at t + dt
    final double dt = 3200;
    final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(-60), initDate.shiftedBy(dt));
    // Check results
    final double n = FastMath.sqrt(initialState.getMu() / initialState.getA().getReal()) / initialState.getA().getReal();
    Assert.assertEquals(initialState.getA().getReal(), finalState.getA().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEx().getReal(), finalState.getEquinoctialEx().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEy().getReal(), finalState.getEquinoctialEy().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getHx().getReal(), finalState.getHx().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getHy().getReal(), finalState.getHy().getReal(), 1.0e-10);
    Assert.assertEquals(initialState.getLM().getReal() + n * dt, finalState.getLM().getReal(), 2.0e-9);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType)

Example 63 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method createPropagator.

private <T extends RealFieldElement<T>> FieldNumericalPropagator<T> createPropagator(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = FieldNumericalPropagator.tolerances(zero.add(0.001), orbit, type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    return propagator;
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType)

Example 64 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class KeplerianPropagatorTest method testNoDerivatives.

@Test
public void testNoDerivatives() throws OrekitException {
    for (OrbitType type : OrbitType.values()) {
        // create an initial orbit with non-Keplerian acceleration
        final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, TimeScalesFactory.getUTC());
        final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
        final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
        final Vector3D keplerAcceleration = new Vector3D(-mu / position.getNormSq(), position.normalize());
        final Vector3D nonKeplerAcceleration = new Vector3D(0.001, 0.002, 0.003);
        final Vector3D acceleration = keplerAcceleration.add(nonKeplerAcceleration);
        final TimeStampedPVCoordinates pva = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
        final Orbit initial = type.convertType(new CartesianOrbit(pva, FramesFactory.getEME2000(), mu));
        Assert.assertEquals(type, initial.getType());
        // the derivatives are available at this stage
        checkDerivatives(initial, true);
        KeplerianPropagator propagator = new KeplerianPropagator(initial);
        Assert.assertEquals(type, propagator.getInitialState().getOrbit().getType());
        // non-Keplerian derivatives are explicitly removed when building the Keplerian-only propagator
        checkDerivatives(propagator.getInitialState().getOrbit(), false);
        PVCoordinates initPV = propagator.getInitialState().getOrbit().getPVCoordinates();
        Assert.assertEquals(nonKeplerAcceleration.getNorm(), Vector3D.distance(acceleration, initPV.getAcceleration()), 2.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(keplerAcceleration, initPV.getAcceleration()), 4.0e-15);
        double dt = 0.2 * initial.getKeplerianPeriod();
        Orbit orbit = propagator.propagateOrbit(initial.getDate().shiftedBy(dt));
        Assert.assertEquals(type, orbit.getType());
        // at the end, we don't have non-Keplerian derivatives
        checkDerivatives(orbit, false);
        // using shiftedBy on the initial orbit, non-Keplerian derivatives would have been preserved
        checkDerivatives(initial.shiftedBy(dt), true);
    }
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) OrbitType(org.orekit.orbits.OrbitType) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 65 with OrbitType

use of org.orekit.orbits.OrbitType in project Orekit by CS-SI.

the class FieldKeplerianPropagator method fixState.

/**
 * Fix state to use a specified mu and remove derivatives.
 * <p>
 * This ensures the propagation model (which is based on calling
 * {@link Orbit#shiftedBy(double)}) is Keplerian only and uses a specified mu.
 * </p>
 * @param orbit orbit to fix
 * @param attitude current attitude
 * @param mass current mass
 * @param mu gravity coefficient to use
 * @return fixed orbit
 */
private FieldSpacecraftState<T> fixState(final FieldOrbit<T> orbit, final FieldAttitude<T> attitude, final T mass, final double mu) {
    final OrbitType type = orbit.getType();
    final T[] stateVector = MathArrays.buildArray(mass.getField(), 6);
    type.mapOrbitToArray(orbit, PositionAngle.TRUE, stateVector, null);
    final FieldOrbit<T> fixedOrbit = type.mapArrayToOrbit(stateVector, null, PositionAngle.TRUE, orbit.getDate(), mu, orbit.getFrame());
    return new FieldSpacecraftState<>(fixedOrbit, attitude, mass);
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) OrbitType(org.orekit.orbits.OrbitType)

Aggregations

OrbitType (org.orekit.orbits.OrbitType)69 Test (org.junit.Test)39 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)38 SpacecraftState (org.orekit.propagation.SpacecraftState)35 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)31 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)29 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)28 Orbit (org.orekit.orbits.Orbit)28 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)27 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)25 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)24 Frame (org.orekit.frames.Frame)23 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)23 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)21 AbsoluteDate (org.orekit.time.AbsoluteDate)17 PVCoordinates (org.orekit.utils.PVCoordinates)17 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)16 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)15 CartesianOrbit (org.orekit.orbits.CartesianOrbit)15 PositionAngle (org.orekit.orbits.PositionAngle)15