Search in sources :

Example 11 with AdditionalStateProvider

use of org.orekit.propagation.AdditionalStateProvider in project Orekit by CS-SI.

the class AdapterPropagatorTest method testEccentricOrbit.

@Test
public void testEccentricOrbit() throws OrekitException, ParseException, IOException {
    Orbit heo = new KeplerianOrbit(90000000.0, 0.92, FastMath.toRadians(98.0), FastMath.toRadians(12.3456), FastMath.toRadians(123.456), FastMath.toRadians(1.23456), PositionAngle.MEAN, FramesFactory.getEME2000(), 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 = heo.getDate().shiftedBy(1000.0);
    Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
    double f = 20.0;
    double isp = 315.0;
    double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
    double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
    BoundedPropagator withoutManeuver = getEphemeris(heo, mass, 5, new LofOffset(heo.getFrame(), LOFType.LVLH), t0, Vector3D.ZERO, f, isp, false, false, null);
    BoundedPropagator withManeuver = getEphemeris(heo, mass, 5, new LofOffset(heo.getFrame(), LOFType.LVLH), t0, dV, f, isp, false, false, null);
    // we set up a model that reverts the maneuvers
    AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver);
    AdapterPropagator.DifferentialEffect effect = new SmallManeuverAnalyticalModel(adapterPropagator.propagate(t0), dV.negate(), isp);
    adapterPropagator.addEffect(effect);
    adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() {

        public String getName() {
            return "dummy 3";
        }

        public double[] getAdditionalState(SpacecraftState state) {
            return new double[3];
        }
    });
    // the adapted propagators do not manage the additional states from the reference,
    // they simply forward them
    Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1"));
    Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2"));
    Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3"));
    for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t.shiftedBy(300.0)) {
        PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, heo.getFrame());
        PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, heo.getFrame());
        double revertError = Vector3D.distance(pvWithout.getPosition(), pvReverted.getPosition());
        Assert.assertEquals(0, revertError, 2.5e-5 * heo.getA());
        Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length);
        Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length);
        Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length);
    }
}
Also used : Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) 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) SmallManeuverAnalyticalModel(org.orekit.forces.maneuvers.SmallManeuverAnalyticalModel) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) BoundedPropagator(org.orekit.propagation.BoundedPropagator) LofOffset(org.orekit.attitudes.LofOffset) Test(org.junit.Test)

Example 12 with AdditionalStateProvider

use of org.orekit.propagation.AdditionalStateProvider in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method testNonSerializableStateProvider.

@Test
public void testNonSerializableStateProvider() throws OrekitException, IOException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(154.);
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    Frame eme2000 = FramesFactory.getEME2000();
    Vector3D pole = itrf.getTransformTo(eme2000, date).transformVector(Vector3D.PLUS_K);
    Frame poleAligned = new Frame(FramesFactory.getEME2000(), new Transform(date, new Rotation(pole, Vector3D.PLUS_K)), "pole aligned", true);
    CircularOrbit initial = new CircularOrbit(7208669.8179538045, 1.3740461966386876E-4, -3.2364250248363356E-5, FastMath.toRadians(97.40236024565775), FastMath.toRadians(166.15873160992115), FastMath.toRadians(90.1282370098961), PositionAngle.MEAN, poleAligned, date, provider.getMu());
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(initial, provider);
    // this serialization should work
    new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(propagator);
    propagator.addAdditionalStateProvider(new AdditionalStateProvider() {

        public String getName() {
            return "not serializable";
        }

        public double[] getAdditionalState(SpacecraftState state) {
            return new double[] { 0 };
        }
    });
    try {
        // this serialization should not work
        new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(propagator);
        Assert.fail("an exception should have been thrown");
    } catch (NotSerializableException nse) {
    // expected
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) NotSerializableException(java.io.NotSerializableException) CircularOrbit(org.orekit.orbits.CircularOrbit) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) Test(org.junit.Test)

Example 13 with AdditionalStateProvider

use of org.orekit.propagation.AdditionalStateProvider in project Orekit by CS-SI.

the class EphemerisTest method testAdditionalStates.

@Test
public void testAdditionalStates() throws OrekitException {
    final String name1 = "dt0";
    final String name2 = "dt1";
    propagator.setAttitudeProvider(new LofOffset(inertialFrame, LOFType.VVLH));
    List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    for (double dt = 0; dt >= -1200; dt -= 60.0) {
        final SpacecraftState original = propagator.propagate(initDate.shiftedBy(dt));
        final SpacecraftState expanded = original.addAdditionalState(name2, original.getDate().durationFrom(finalDate));
        states.add(expanded);
    }
    final Propagator ephem = new Ephemeris(states, 2);
    ephem.addAdditionalStateProvider(new AdditionalStateProvider() {

        public String getName() {
            return name1;
        }

        public double[] getAdditionalState(SpacecraftState state) {
            return new double[] { state.getDate().durationFrom(initDate) };
        }
    });
    final String[] additional = ephem.getManagedAdditionalStates();
    Arrays.sort(additional);
    Assert.assertEquals(2, additional.length);
    Assert.assertEquals(name1, ephem.getManagedAdditionalStates()[0]);
    Assert.assertEquals(name2, ephem.getManagedAdditionalStates()[1]);
    Assert.assertTrue(ephem.isAdditionalStateManaged(name1));
    Assert.assertTrue(ephem.isAdditionalStateManaged(name2));
    Assert.assertFalse(ephem.isAdditionalStateManaged("not managed"));
    SpacecraftState s = ephem.propagate(initDate.shiftedBy(-270.0));
    Assert.assertEquals(-270.0, s.getAdditionalState(name1)[0], 1.0e-15);
    Assert.assertEquals(-86670.0, s.getAdditionalState(name2)[0], 1.0e-15);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) Propagator(org.orekit.propagation.Propagator) ArrayList(java.util.ArrayList) LofOffset(org.orekit.attitudes.LofOffset) Test(org.junit.Test)

Aggregations

AdditionalStateProvider (org.orekit.propagation.AdditionalStateProvider)13 SpacecraftState (org.orekit.propagation.SpacecraftState)11 Test (org.junit.Test)8 AbsoluteDate (org.orekit.time.AbsoluteDate)7 ArrayList (java.util.ArrayList)5 OrekitException (org.orekit.errors.OrekitException)5 CircularOrbit (org.orekit.orbits.CircularOrbit)5 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)5 BoundedPropagator (org.orekit.propagation.BoundedPropagator)5 NotSerializableException (java.io.NotSerializableException)4 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)4 LofOffset (org.orekit.attitudes.LofOffset)4 Orbit (org.orekit.orbits.Orbit)4 DateComponents (org.orekit.time.DateComponents)4 Serializable (java.io.Serializable)3 SmallManeuverAnalyticalModel (org.orekit.forces.maneuvers.SmallManeuverAnalyticalModel)3 TimeComponents (org.orekit.time.TimeComponents)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2