Search in sources :

Example 31 with CircularOrbit

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

the class SmallManeuverAnalyticalModelTest method testJacobian.

@Test
public void testJacobian() throws OrekitException {
    Frame eme2000 = FramesFactory.getEME2000();
    Orbit leo = new CircularOrbit(7200000.0, -1.0e-2, 2.0e-3, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.3, PositionAngle.MEAN, eme2000, new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
    double mass = 5600.0;
    AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
    Vector3D dV0 = new Vector3D(-0.1, 0.2, 0.3);
    double f = 400.0;
    double isp = 315.0;
    for (OrbitType orbitType : OrbitType.values()) {
        for (PositionAngle positionAngle : PositionAngle.values()) {
            BoundedPropagator withoutManeuver = getEphemeris(orbitType.convertType(leo), mass, t0, Vector3D.ZERO, f, isp);
            SpacecraftState state0 = withoutManeuver.propagate(t0);
            SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(state0, eme2000, dV0, isp);
            Assert.assertEquals(t0, model.getDate());
            Vector3D[] velDirs = new Vector3D[] { Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.ZERO };
            double[] timeDirs = new double[] { 0, 0, 0, 1 };
            double h = 1.0;
            AbsoluteDate t1 = t0.shiftedBy(20.0);
            for (int i = 0; i < 4; ++i) {
                SmallManeuverAnalyticalModel[] models = new SmallManeuverAnalyticalModel[] { new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-4 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -4 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-3 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -3 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-2 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -2 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-1 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -1 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+1 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +1 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+2 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +2 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+3 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +3 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+4 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +4 * h, velDirs[i]), isp) };
                double[][] array = new double[models.length][6];
                Orbit orbitWithout = withoutManeuver.propagate(t1).getOrbit();
                // compute reference orbit gradient by finite differences
                double c = 1.0 / (840 * h);
                for (int j = 0; j < models.length; ++j) {
                    orbitType.mapOrbitToArray(models[j].apply(orbitWithout), positionAngle, array[j], null);
                }
                double[] orbitGradient = new double[6];
                for (int k = 0; k < orbitGradient.length; ++k) {
                    double d4 = array[7][k] - array[0][k];
                    double d3 = array[6][k] - array[1][k];
                    double d2 = array[5][k] - array[2][k];
                    double d1 = array[4][k] - array[3][k];
                    orbitGradient[k] = (-3 * d4 + 32 * d3 - 168 * d2 + 672 * d1) * c;
                }
                // analytical Jacobian to check
                double[][] jacobian = new double[6][4];
                model.getJacobian(orbitWithout, positionAngle, jacobian);
                for (int j = 0; j < orbitGradient.length; ++j) {
                    Assert.assertEquals(orbitGradient[j], jacobian[j][i], 1.6e-4 * FastMath.abs(orbitGradient[j]));
                }
            }
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) PositionAngle(org.orekit.orbits.PositionAngle) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrbitType(org.orekit.orbits.OrbitType) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Test(org.junit.Test)

Example 32 with CircularOrbit

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

the class RelativityTest method testAccelerationCircular.

/**
 * Check a nearly circular orbit.
 *
 * @throws OrekitException on error
 */
@Test
public void testAccelerationCircular() throws OrekitException {
    double gm = Constants.EIGEN5C_EARTH_MU;
    double re = Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
    Relativity relativity = new Relativity(gm);
    final CircularOrbit orbit = new CircularOrbit(re + 500e3, 0, 0, FastMath.toRadians(41.2), -1, 3, PositionAngle.TRUE, frame, date, gm);
    SpacecraftState state = new SpacecraftState(orbit);
    // action
    Vector3D acceleration = relativity.acceleration(state, relativity.getParameters());
    // verify
    // force is ~1e-8 so this give ~7 sig figs.
    double tol = 2e-10;
    PVCoordinates pv = state.getPVCoordinates();
    Vector3D p = pv.getPosition();
    Vector3D v = pv.getVelocity();
    Vector3D circularApproximation = p.normalize().scalarMultiply(gm / p.getNormSq() * 3 * v.getNormSq() / (c * c));
    Assert.assertEquals(0, acceleration.subtract(circularApproximation).getNorm(), tol);
    // check derivatives
    FieldSpacecraftState<DerivativeStructure> sDS = toDS(state, new LofOffset(state.getFrame(), LOFType.VVLH));
    FieldVector3D<DerivativeStructure> gradient = relativity.acceleration(sDS, relativity.getParameters(sDS.getDate().getField()));
    Assert.assertEquals(0, gradient.toVector3D().subtract(circularApproximation).getNorm(), tol);
    double r = p.getNorm();
    double s = v.getNorm();
    final double[] actualdx = gradient.getX().getAllDerivatives();
    final double x = p.getX();
    final double vx = v.getX();
    double expectedDxDx = gm / (c * c * r * r * r * r * r) * (-13 * x * x * s * s + 3 * r * r * s * s + 4 * r * r * vx * vx);
    Assert.assertEquals(expectedDxDx, actualdx[1], 2);
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) LofOffset(org.orekit.attitudes.LofOffset) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 33 with CircularOrbit

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

the class EventDetectorTest method testIssue108Analytical.

@Test
public void testIssue108Analytical() throws OrekitException {
    final TimeScale utc = 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 AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
    final double step = 60.0;
    final int n = 100;
    KeplerianPropagator propagator = new KeplerianPropagator(orbit);
    GCallsCounter counter = new GCallsCounter(100000.0, 1.0e-6, 20, new StopOnEvent<GCallsCounter>());
    propagator.addEventDetector(counter);
    propagator.setMasterMode(step, new OrekitFixedStepHandler() {

        public void handleStep(SpacecraftState currentState, boolean isLast) {
        }
    });
    propagator.propagate(date.shiftedBy(n * step));
    Assert.assertEquals(n + 1, counter.getCount());
}
Also used : Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) Test(org.junit.Test)

Example 34 with CircularOrbit

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

the class EcksteinHechlerConverterTest method checkFit.

protected void checkFit(final Orbit orbit, final double duration, final double stepSize, final double threshold, final boolean positionOnly, final double expectedRMS) throws OrekitException {
    // shift position by 3m
    CircularOrbit modified = new CircularOrbit(new TimeStampedPVCoordinates(orbit.getDate(), new Vector3D(1, orbit.getPVCoordinates().getPosition(), 3.0, Vector3D.PLUS_J), orbit.getPVCoordinates().getVelocity()), orbit.getFrame(), orbit.getMu());
    Propagator p = new EcksteinHechlerPropagator(modified, provider);
    List<SpacecraftState> sample = new ArrayList<SpacecraftState>();
    for (double dt = 0; dt < duration; dt += stepSize) {
        sample.add(p.propagate(modified.getDate().shiftedBy(dt)));
    }
    UnnormalizedSphericalHarmonics harmonics = provider.onDate(orbit.getDate());
    PropagatorBuilder builder = new EcksteinHechlerPropagatorBuilder(orbit, provider.getAe(), provider.getMu(), provider.getTideSystem(), harmonics.getUnnormalizedCnm(2, 0), harmonics.getUnnormalizedCnm(3, 0), harmonics.getUnnormalizedCnm(4, 0), harmonics.getUnnormalizedCnm(5, 0), harmonics.getUnnormalizedCnm(6, 0), OrbitType.CIRCULAR, PositionAngle.TRUE, 1.0);
    FiniteDifferencePropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, threshold, 1000);
    fitter.convert(sample, positionOnly);
    Assert.assertEquals(expectedRMS, fitter.getRMS(), 0.01 * expectedRMS);
    EcksteinHechlerPropagator prop = (EcksteinHechlerPropagator) fitter.getAdaptedPropagator();
    Orbit fitted = prop.getInitialState().getOrbit();
    final double eps = 1.0e-12;
    Assert.assertEquals(modified.getPVCoordinates().getPosition().getX(), fitted.getPVCoordinates().getPosition().getX(), eps * modified.getPVCoordinates().getPosition().getX());
    Assert.assertEquals(modified.getPVCoordinates().getPosition().getY(), fitted.getPVCoordinates().getPosition().getY(), eps * modified.getPVCoordinates().getPosition().getY());
    Assert.assertEquals(modified.getPVCoordinates().getPosition().getZ(), fitted.getPVCoordinates().getPosition().getZ(), eps * modified.getPVCoordinates().getPosition().getZ());
    Assert.assertEquals(modified.getPVCoordinates().getVelocity().getX(), fitted.getPVCoordinates().getVelocity().getX(), eps * modified.getPVCoordinates().getVelocity().getX());
    Assert.assertEquals(modified.getPVCoordinates().getVelocity().getY(), fitted.getPVCoordinates().getVelocity().getY(), -eps * modified.getPVCoordinates().getVelocity().getY());
    Assert.assertEquals(modified.getPVCoordinates().getVelocity().getZ(), fitted.getPVCoordinates().getVelocity().getZ(), -eps * modified.getPVCoordinates().getVelocity().getZ());
}
Also used : Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) ArrayList(java.util.ArrayList) UnnormalizedSphericalHarmonics(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator)

Example 35 with CircularOrbit

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

the class EcksteinHechlerPropagator method writeReplace.

/**
 * Replace the instance with a data transfer object for serialization.
 * @return data transfer object that will be serialized
 * @exception NotSerializableException if an additional state provider is not serializable
 */
private Object writeReplace() throws NotSerializableException {
    try {
        // managed states providers
        final List<AdditionalStateProvider> serializableProviders = new ArrayList<AdditionalStateProvider>();
        for (final AdditionalStateProvider provider : getAdditionalStateProviders()) {
            if (provider instanceof Serializable) {
                serializableProviders.add(provider);
            } else {
                throw new NotSerializableException(provider.getClass().getName());
            }
        }
        // states transitions
        final AbsoluteDate[] transitionDates;
        final CircularOrbit[] allOrbits;
        final double[] allMasses;
        final SortedSet<TimeSpanMap.Transition<EHModel>> transitions = models.getTransitions();
        if (transitions.size() == 1 && transitions.first().getBefore() == transitions.first().getAfter()) {
            // the single entry is a dummy one, without a real transition
            // we ignore it completely
            transitionDates = null;
            allOrbits = null;
            allMasses = null;
        } else {
            transitionDates = new AbsoluteDate[transitions.size()];
            allOrbits = new CircularOrbit[transitions.size() + 1];
            allMasses = new double[transitions.size() + 1];
            int i = 0;
            for (final TimeSpanMap.Transition<EHModel> transition : transitions) {
                if (i == 0) {
                    // model before the first transition
                    allOrbits[i] = transition.getBefore().mean;
                    allMasses[i] = transition.getBefore().mass;
                }
                transitionDates[i] = transition.getDate();
                allOrbits[++i] = transition.getAfter().mean;
                allMasses[i] = transition.getAfter().mass;
            }
        }
        return new DataTransferObject(getInitialState().getOrbit(), initialModel.mass, referenceRadius, mu, ck0, getAttitudeProvider(), transitionDates, allOrbits, allMasses, serializableProviders.toArray(new AdditionalStateProvider[serializableProviders.size()]));
    } catch (OrekitException orekitException) {
        // this should never happen
        throw new OrekitInternalError(null);
    }
}
Also used : OrekitInternalError(org.orekit.errors.OrekitInternalError) Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) AbsoluteDate(org.orekit.time.AbsoluteDate) NotSerializableException(java.io.NotSerializableException) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) CircularOrbit(org.orekit.orbits.CircularOrbit) TimeSpanMap(org.orekit.utils.TimeSpanMap) OrekitException(org.orekit.errors.OrekitException)

Aggregations

CircularOrbit (org.orekit.orbits.CircularOrbit)63 AbsoluteDate (org.orekit.time.AbsoluteDate)47 Test (org.junit.Test)41 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)34 SpacecraftState (org.orekit.propagation.SpacecraftState)26 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)22 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)21 PVCoordinates (org.orekit.utils.PVCoordinates)21 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)15 Frame (org.orekit.frames.Frame)15 DateComponents (org.orekit.time.DateComponents)15 GeodeticPoint (org.orekit.bodies.GeodeticPoint)12 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)12 OrekitException (org.orekit.errors.OrekitException)11 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)11 ArrayList (java.util.ArrayList)9 Before (org.junit.Before)9 BoundedPropagator (org.orekit.propagation.BoundedPropagator)9