Search in sources :

Example 56 with OrbitType

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

the class PartialDerivativesTest method testPropagationTypesElliptical.

@Test
public void testPropagationTypesElliptical() throws OrekitException {
    NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(5, 5);
    ForceModel gravityField = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
    Orbit initialOrbit = new KeplerianOrbit(8000000.0, 0.01, 0.1, 0.7, 0, 1.2, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, provider.getMu());
    double dt = 900;
    double dP = 0.001;
    for (OrbitType orbitType : OrbitType.values()) {
        for (PositionAngle angleType : PositionAngle.values()) {
            // compute state Jacobian using PartialDerivatives
            NumericalPropagator propagator = setUpPropagator(initialOrbit, dP, orbitType, angleType, gravityField);
            PartialDerivativesEquations partials = new PartialDerivativesEquations("partials", propagator);
            final SpacecraftState initialState = partials.setInitialJacobians(new SpacecraftState(initialOrbit));
            propagator.setInitialState(initialState);
            final JacobiansMapper mapper = partials.getMapper();
            PickUpHandler pickUp = new PickUpHandler(mapper, null);
            propagator.setMasterMode(pickUp);
            propagator.propagate(initialState.getDate().shiftedBy(dt));
            double[][] dYdY0 = pickUp.getdYdY0();
            // compute reference state Jacobian using finite differences
            double[][] dYdY0Ref = new double[6][6];
            AbstractIntegratedPropagator propagator2 = setUpPropagator(initialOrbit, dP, orbitType, angleType, gravityField);
            double[] steps = NumericalPropagator.tolerances(1000000 * dP, initialOrbit, orbitType)[0];
            for (int i = 0; i < 6; ++i) {
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -4 * steps[i], i));
                SpacecraftState sM4h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -3 * steps[i], i));
                SpacecraftState sM3h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -2 * steps[i], i));
                SpacecraftState sM2h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -1 * steps[i], i));
                SpacecraftState sM1h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 1 * steps[i], i));
                SpacecraftState sP1h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 2 * steps[i], i));
                SpacecraftState sP2h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 3 * steps[i], i));
                SpacecraftState sP3h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 4 * steps[i], i));
                SpacecraftState sP4h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                fillJacobianColumn(dYdY0Ref, i, orbitType, angleType, steps[i], sM4h, sM3h, sM2h, sM1h, sP1h, sP2h, sP3h, sP4h);
            }
            for (int i = 0; i < 6; ++i) {
                for (int j = 0; j < 6; ++j) {
                    double error = FastMath.abs((dYdY0[i][j] - dYdY0Ref[i][j]) / dYdY0Ref[i][j]);
                    Assert.assertEquals(0, error, 6.0e-2);
                }
            }
        }
    }
}
Also used : ForceModel(org.orekit.forces.ForceModel) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) PositionAngle(org.orekit.orbits.PositionAngle) AbstractIntegratedPropagator(org.orekit.propagation.integration.AbstractIntegratedPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 57 with OrbitType

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

the class PartialDerivativesTest method testPropagationTypesHyperbolic.

@Test
public void testPropagationTypesHyperbolic() throws OrekitException {
    NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(5, 5);
    ForceModel gravityField = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
    Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(-1551946.0, 708899.0, 6788204.0), new Vector3D(-9875.0, -3941.0, -1845.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, provider.getMu());
    double dt = 900;
    double dP = 0.001;
    for (OrbitType orbitType : new OrbitType[] { OrbitType.KEPLERIAN, OrbitType.CARTESIAN }) {
        for (PositionAngle angleType : PositionAngle.values()) {
            // compute state Jacobian using PartialDerivatives
            NumericalPropagator propagator = setUpPropagator(initialOrbit, dP, orbitType, angleType, gravityField);
            PartialDerivativesEquations partials = new PartialDerivativesEquations("partials", propagator);
            final SpacecraftState initialState = partials.setInitialJacobians(new SpacecraftState(initialOrbit));
            propagator.setInitialState(initialState);
            final JacobiansMapper mapper = partials.getMapper();
            PickUpHandler pickUp = new PickUpHandler(mapper, null);
            propagator.setMasterMode(pickUp);
            propagator.propagate(initialState.getDate().shiftedBy(dt));
            double[][] dYdY0 = pickUp.getdYdY0();
            // compute reference state Jacobian using finite differences
            double[][] dYdY0Ref = new double[6][6];
            AbstractIntegratedPropagator propagator2 = setUpPropagator(initialOrbit, dP, orbitType, angleType, gravityField);
            double[] steps = NumericalPropagator.tolerances(1000000 * dP, initialOrbit, orbitType)[0];
            for (int i = 0; i < 6; ++i) {
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -4 * steps[i], i));
                SpacecraftState sM4h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -3 * steps[i], i));
                SpacecraftState sM3h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -2 * steps[i], i));
                SpacecraftState sM2h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, -1 * steps[i], i));
                SpacecraftState sM1h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 1 * steps[i], i));
                SpacecraftState sP1h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 2 * steps[i], i));
                SpacecraftState sP2h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 3 * steps[i], i));
                SpacecraftState sP3h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                propagator2.resetInitialState(shiftState(initialState, orbitType, angleType, 4 * steps[i], i));
                SpacecraftState sP4h = propagator2.propagate(initialState.getDate().shiftedBy(dt));
                fillJacobianColumn(dYdY0Ref, i, orbitType, angleType, steps[i], sM4h, sM3h, sM2h, sM1h, sP1h, sP2h, sP3h, sP4h);
            }
            for (int i = 0; i < 6; ++i) {
                for (int j = 0; j < 6; ++j) {
                    double error = FastMath.abs((dYdY0[i][j] - dYdY0Ref[i][j]) / dYdY0Ref[i][j]);
                    Assert.assertEquals(0, error, 1.0e-3);
                }
            }
        }
    }
}
Also used : ForceModel(org.orekit.forces.ForceModel) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) PositionAngle(org.orekit.orbits.PositionAngle) PVCoordinates(org.orekit.utils.PVCoordinates) AbstractIntegratedPropagator(org.orekit.propagation.integration.AbstractIntegratedPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 58 with OrbitType

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

the class DSSTPropagatorTest method getLEOStatePropagatedBy30Minutes.

private SpacecraftState getLEOStatePropagatedBy30Minutes() throws IllegalArgumentException, OrekitException {
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    // Spring equinoxe 21st mars 2003 1h00m
    final AbsoluteDate initialDate = new AbsoluteDate(new DateComponents(2003, 03, 21), new TimeComponents(1, 0, 0.), TimeScalesFactory.getUTC());
    final CartesianOrbit osculatingOrbit = new CartesianOrbit(new PVCoordinates(position, velocity), FramesFactory.getTOD(IERSConventions.IERS_1996, false), initialDate, Constants.WGS84_EARTH_MU);
    // Adaptive step integrator
    // with a minimum step of 0.001 and a maximum step of 1000
    double minStep = 0.001;
    double maxstep = 1000.0;
    double positionTolerance = 10.0;
    OrbitType propagationType = OrbitType.EQUINOCTIAL;
    double[][] tolerances = NumericalPropagator.tolerances(positionTolerance, osculatingOrbit, propagationType);
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxstep, tolerances[0], tolerances[1]);
    NumericalPropagator propagator = new NumericalPropagator(integrator);
    propagator.setOrbitType(propagationType);
    NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(5, 5);
    ForceModel holmesFeatherstone = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
    propagator.addForceModel(holmesFeatherstone);
    propagator.setInitialState(new SpacecraftState(osculatingOrbit));
    return propagator.propagate(new AbsoluteDate(initialDate, 1800.));
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) ForceModel(org.orekit.forces.ForceModel) DSSTForceModel(org.orekit.propagation.semianalytical.dsst.forces.DSSTForceModel) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)

Example 59 with OrbitType

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

the class FieldNumericalPropagatorTest method doTestAdditionalStateEvent.

private <T extends RealFieldElement<T>> void doTestAdditionalStateEvent(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);
    propagator.addAdditionalEquations(new FieldAdditionalEquations<T>() {

        public String getName() {
            return "linear";
        }

        public T[] computeDerivatives(FieldSpacecraftState<T> s, T[] pDot) {
            pDot[0] = zero.add(1.0);
            return MathArrays.buildArray(field, 7);
        }
    });
    try {
        propagator.addAdditionalEquations(new FieldAdditionalEquations<T>() {

            public String getName() {
                return "linear";
            }

            public T[] computeDerivatives(FieldSpacecraftState<T> s, T[] pDot) {
                pDot[0] = zero.add(1.0);
                return MathArrays.buildArray(field, 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 FieldAdditionalStateProvider<T>() {

            public String getName() {
                return "linear";
            }

            public T[] getAdditionalState(FieldSpacecraftState<T> 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 FieldAdditionalStateProvider<T>() {

        public String getName() {
            return "constant";
        }

        public T[] getAdditionalState(FieldSpacecraftState<T> state) {
            T[] ret = MathArrays.buildArray(field, 1);
            ret[0] = zero.add(1.0);
            return ret;
        }
    });
    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", zero.add(1.5)));
    CheckingHandler<AdditionalStateLinearDetector<T>, T> checking = new CheckingHandler<AdditionalStateLinearDetector<T>, T>(Action.STOP);
    propagator.addEventDetector(new AdditionalStateLinearDetector<T>(zero.add(10.0), zero.add(1.0e-8)).withHandler(checking));
    final double dt = 3200;
    checking.assertEvent(false);
    final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(dt));
    checking.assertEvent(true);
    Assert.assertEquals(3.0, finalState.getAdditionalState("linear")[0].getReal(), 1.0e-8);
    Assert.assertEquals(1.5, finalState.getDate().durationFrom(initDate).getReal(), 1.0e-8);
}
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) OrekitException(org.orekit.errors.OrekitException)

Example 60 with OrbitType

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

the class FieldNumericalPropagatorTest method doTestEventDetectionBug.

private <T extends RealFieldElement<T>> void doTestEventDetectionBug(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    TimeScale utc = TimeScalesFactory.getUTC();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2005, 1, 1, 0, 0, 0.0, utc);
    T duration = zero.add(100000.0);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(initialDate, duration);
    // Initialization of the frame EME2000
    Frame EME2000 = FramesFactory.getEME2000();
    // Initial orbit
    double a = 35786000. + 6378137.0;
    double e = 0.70;
    double rApogee = a * (1 + e);
    double vApogee = FastMath.sqrt(mu * (1 - e) / (a * (1 + e)));
    FieldOrbit<T> geo = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(rApogee), zero, zero), new FieldVector3D<>(zero, zero.add(vApogee), zero)), EME2000, initialDate, mu);
    duration = geo.getKeplerianPeriod();
    endDate = new FieldAbsoluteDate<>(initialDate, duration);
    // Numerical Integration
    final double minStep = 0.001;
    final double maxStep = 1000;
    final double initStep = 60;
    final OrbitType type = OrbitType.EQUINOCTIAL;
    final double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
    final double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, absTolerance, relTolerance);
    integrator.setInitialStepSize(zero.add(initStep));
    // Numerical propagator based on the integrator
    FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    T mass = field.getZero().add(1000.0);
    FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(geo, mass);
    propagator.setInitialState(initialState);
    propagator.setOrbitType(OrbitType.CARTESIAN);
    // Set the events Detectors
    FieldApsideDetector<T> event1 = new FieldApsideDetector<>(geo);
    propagator.addEventDetector(event1);
    // Set the propagation mode
    propagator.setSlaveMode();
    // Propagate
    FieldSpacecraftState<T> finalState = propagator.propagate(endDate);
    // we should stop long before endDate
    Assert.assertTrue(endDate.durationFrom(finalState.getDate()).getReal() > 40000.0);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) Frame(org.orekit.frames.Frame) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldApsideDetector(org.orekit.propagation.events.FieldApsideDetector) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

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