Ejemplo n.º 1
0
  @Test
  public void testEventDetectionBug() throws OrekitException, IOException, ParseException {

    TimeScale utc = TimeScalesFactory.getUTC();
    AbsoluteDate initialDate = new AbsoluteDate(2005, 1, 1, 0, 0, 0.0, utc);
    double duration = 100000.;
    AbsoluteDate endDate = new AbsoluteDate(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)));
    Orbit geo =
        new CartesianOrbit(
            new PVCoordinates(new Vector3D(rApogee, 0., 0.), new Vector3D(0., vApogee, 0.)),
            EME2000,
            initialDate,
            mu);

    duration = geo.getKeplerianPeriod();
    endDate = new AbsoluteDate(initialDate, duration);

    // Numerical Integration
    final double minStep = 0.001;
    final double maxStep = 1000;
    final double initStep = 60;
    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};

    AdaptiveStepsizeIntegrator integrator =
        new DormandPrince853Integrator(minStep, maxStep, absTolerance, relTolerance);
    integrator.setInitialStepSize(initStep);

    // Numerical propagator based on the integrator
    propagator = new NumericalPropagator(integrator);
    double mass = 1000.;
    SpacecraftState initialState = new SpacecraftState(geo, mass);
    propagator.setInitialState(initialState);
    propagator.setOrbitType(OrbitType.CARTESIAN);

    // Set the events Detectors
    ApsideDetector event1 = new ApsideDetector(geo);
    propagator.addEventDetector(event1);

    // Set the propagation mode
    propagator.setSlaveMode();

    // Propagate
    SpacecraftState finalState = propagator.propagate(endDate);

    // we should stop long before endDate
    Assert.assertTrue(endDate.durationFrom(finalState.getDate()) > 40000.0);
  }
Ejemplo n.º 2
0
  @Test
  public void testSpin() throws OrekitException {

    AbsoluteDate date =
        new AbsoluteDate(
            new DateComponents(1970, 01, 01),
            new TimeComponents(3, 25, 45.6789),
            TimeScalesFactory.getUTC());
    KeplerianOrbit orbit =
        new KeplerianOrbit(
            7178000.0,
            1.e-4,
            FastMath.toRadians(50.),
            FastMath.toRadians(10.),
            FastMath.toRadians(20.),
            FastMath.toRadians(30.),
            PositionAngle.MEAN,
            FramesFactory.getEME2000(),
            date,
            3.986004415e14);

    final AttitudeProvider law =
        new LofOffsetPointing(
            earthSpheric,
            new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.XYX, 0.1, 0.2, 0.3),
            Vector3D.PLUS_K);

    Propagator propagator = new KeplerianPropagator(orbit, law);

    double h = 0.01;
    SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
    SpacecraftState s0 = propagator.propagate(date);
    SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));

    // check spin is consistent with attitude evolution
    double errorAngleMinus =
        Rotation.distance(
            sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
    double evolutionAngleMinus =
        Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
    Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
    double errorAnglePlus =
        Rotation.distance(
            s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
    double evolutionAnglePlus =
        Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
    Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);

    Vector3D spin0 = s0.getAttitude().getSpin();
    Vector3D reference =
        AngularCoordinates.estimateRate(
            sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), 2 * h);
    Assert.assertTrue(spin0.getNorm() > 1.0e-3);
    Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 1.0e-10);
  }
 /** create {@link #cache} and {@link #data} with neighborsSize = 3 */
 @Before
 public void setUp() {
   data =
       Arrays.asList(
           date,
           date.shiftedBy(1),
           date.shiftedBy(2),
           date.shiftedBy(3),
           date.shiftedBy(4),
           date.shiftedBy(5));
   cache = new ImmutableTimeStampedCache<AbsoluteDate>(3, data);
 }
Ejemplo n.º 4
0
 @Test
 public void testStopEvent() throws OrekitException {
   final AbsoluteDate stopDate = initDate.shiftedBy(1000);
   CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.STOP);
   propagator.addEventDetector(new DateDetector(stopDate).withHandler(checking));
   Assert.assertEquals(1, propagator.getEventsDetectors().size());
   checking.assertEvent(false);
   final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200));
   checking.assertEvent(true);
   Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate), 1.0e-10);
   propagator.clearEventsDetectors();
   Assert.assertEquals(0, propagator.getEventsDetectors().size());
 }
Ejemplo n.º 5
0
  @Test
  public void testEphemerisGenerationIssue14() throws OrekitException, IOException {

    // Propagation of the initial at t + dt
    final double dt = 3200;
    propagator.getInitialState();

    propagator.setOrbitType(OrbitType.CARTESIAN);
    propagator.setEphemerisMode();
    propagator.propagate(initDate.shiftedBy(dt));
    final BoundedPropagator ephemeris1 = propagator.getGeneratedEphemeris();
    Assert.assertEquals(initDate, ephemeris1.getMinDate());
    Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMaxDate());

    propagator.getPVCoordinates(initDate.shiftedBy(2 * dt), FramesFactory.getEME2000());
    propagator.getPVCoordinates(initDate.shiftedBy(-2 * dt), FramesFactory.getEME2000());

    // the new propagations should not have changed ephemeris1
    Assert.assertEquals(initDate, ephemeris1.getMinDate());
    Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMaxDate());

    final BoundedPropagator ephemeris2 = propagator.getGeneratedEphemeris();
    Assert.assertEquals(initDate.shiftedBy(-2 * dt), ephemeris2.getMinDate());
    Assert.assertEquals(initDate.shiftedBy(2 * dt), ephemeris2.getMaxDate());

    // generating ephemeris2 should not have changed ephemeris1
    Assert.assertEquals(initDate, ephemeris1.getMinDate());
    Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMaxDate());
  }
Ejemplo n.º 6
0
  private double[] derivativesErrors(
      PVCoordinatesProvider provider, AbsoluteDate date, Frame frame, OneAxisEllipsoid model)
      throws OrekitException {
    List<TimeStampedPVCoordinates> pvList = new ArrayList<TimeStampedPVCoordinates>();
    List<TimeStampedPVCoordinates> groundPVList = new ArrayList<TimeStampedPVCoordinates>();
    for (double dt = -0.25; dt <= 0.25; dt += 0.125) {
      TimeStampedPVCoordinates shiftedPV = provider.getPVCoordinates(date.shiftedBy(dt), frame);
      Vector3D p = model.projectToGround(shiftedPV.getPosition(), shiftedPV.getDate(), frame);
      pvList.add(shiftedPV);
      groundPVList.add(
          new TimeStampedPVCoordinates(shiftedPV.getDate(), p, Vector3D.ZERO, Vector3D.ZERO));
    }
    TimeStampedPVCoordinates computed =
        model.projectToGround(
            TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, pvList),
            frame);
    TimeStampedPVCoordinates reference =
        TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, groundPVList);

    TimeStampedPVCoordinates pv0 = provider.getPVCoordinates(date, frame);
    Vector3D p0 = pv0.getPosition();
    Vector3D v0 = pv0.getVelocity();
    Vector3D a0 = pv0.getAcceleration();

    return new double[] {
      Vector3D.distance(computed.getPosition(), reference.getPosition()) / p0.getNorm(),
      Vector3D.distance(computed.getVelocity(), reference.getVelocity()) / v0.getNorm(),
      Vector3D.distance(computed.getAcceleration(), reference.getAcceleration()) / a0.getNorm(),
    };
  }
  /**
   * check that the cache is immutable by changing the data passed in the constructor and returned
   * from methods.
   *
   * @throws TimeStampedCacheException
   */
  @Test
  public void testImmutable() throws TimeStampedCacheException {
    // setup
    List<AbsoluteDate> actuals;
    List<AbsoluteDate> expecteds = new ArrayList<AbsoluteDate>(data);
    AbsoluteDate different = date.shiftedBy(-50);

    // actions + verify

    // check constructor
    data.set(0, different);
    Assert.assertArrayEquals(cache.getAll().toArray(), expecteds.toArray());

    // check getAll
    actuals = cache.getAll();
    try {
      actuals.set(0, different);
    } catch (UnsupportedOperationException e) {
      // exception ok
    }
    Assert.assertArrayEquals(cache.getAll().toArray(), expecteds.toArray());

    // check getNeighbors
    actuals = cache.getNeighbors(date);
    try {
      actuals.set(0, different);
    } catch (UnsupportedOperationException e) {
      // exception ok
    }
    Assert.assertArrayEquals(cache.getAll().toArray(), expecteds.toArray());
  }
Ejemplo n.º 8
0
 @Test
 public void testResetStateEvent() throws OrekitException {
   final AbsoluteDate resetDate = initDate.shiftedBy(1000);
   CheckingHandler<DateDetector> checking =
       new CheckingHandler<DateDetector>(Action.RESET_STATE) {
         public SpacecraftState resetState(DateDetector detector, SpacecraftState oldState) {
           return new SpacecraftState(
               oldState.getOrbit(), oldState.getAttitude(), oldState.getMass() - 200.0);
         }
       };
   propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking));
   checking.assertEvent(false);
   final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200));
   checking.assertEvent(true);
   Assert.assertEquals(initialState.getMass() - 200, finalState.getMass(), 1.0e-10);
 }
Ejemplo n.º 9
0
  @Test
  public void testCartesian() throws OrekitException {

    // Propagation of the initial at t + dt
    final double dt = 3200;
    propagator.setOrbitType(OrbitType.CARTESIAN);
    final PVCoordinates finalState =
        propagator.propagate(initDate.shiftedBy(dt)).getPVCoordinates();
    final Vector3D pFin = finalState.getPosition();
    final Vector3D vFin = finalState.getVelocity();

    // Check results
    final PVCoordinates reference = initialState.shiftedBy(dt).getPVCoordinates();
    final Vector3D pRef = reference.getPosition();
    final Vector3D vRef = reference.getVelocity();
    Assert.assertEquals(0, pRef.subtract(pFin).getNorm(), 2e-4);
    Assert.assertEquals(0, vRef.subtract(vFin).getNorm(), 7e-8);

    try {
      propagator.getGeneratedEphemeris();
      Assert.fail("an exception should have been thrown");
    } catch (IllegalStateException ise) {
      // expected
    }
  }
Ejemplo n.º 10
0
  @Test
  public void testFrance() throws OrekitException {

    final BodyShape earth =
        new OneAxisEllipsoid(
            Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            Constants.WGS84_EARTH_FLATTENING,
            FramesFactory.getITRF(IERSConventions.IERS_2010, true));

    GeographicZoneDetector d =
        new GeographicZoneDetector(20.0, 1.e-3, earth, buildFrance(), FastMath.toRadians(0.5))
            .withHandler(new ContinueOnEvent<GeographicZoneDetector>());

    Assert.assertEquals(20.0, d.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(1.0e-3, d.getThreshold(), 1.0e-15);
    Assert.assertEquals(0.5, FastMath.toDegrees(d.getMargin()), 1.0e-15);
    Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, d.getMaxIterationCount());

    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 EquinoctialOrbit(
            new PVCoordinates(position, velocity),
            FramesFactory.getEME2000(),
            date,
            Constants.EIGEN5C_EARTH_MU);

    Propagator propagator =
        new EcksteinHechlerPropagator(
            orbit,
            Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS,
            Constants.EIGEN5C_EARTH_MU,
            Constants.EIGEN5C_EARTH_C20,
            Constants.EIGEN5C_EARTH_C30,
            Constants.EIGEN5C_EARTH_C40,
            Constants.EIGEN5C_EARTH_C50,
            Constants.EIGEN5C_EARTH_C60);

    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(d));

    propagator.propagate(date.shiftedBy(10 * Constants.JULIAN_DAY));
    Assert.assertEquals(26, logger.getLoggedEvents().size());
  }
Ejemplo n.º 11
0
  @Test
  public void testEphemerisDatesBackward() throws OrekitException {
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    AbsoluteDate initialDate = new AbsoluteDate("2015-07-05", tai);
    AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1);
    AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    KeplerianOrbit orbit =
        new KeplerianOrbit(
            600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            0,
            0,
            0,
            0,
            0,
            PositionAngle.TRUE,
            eci,
            initialDate,
            mu);
    double[][] tol = NumericalPropagator.tolerances(1, orbit, OrbitType.CARTESIAN);
    Propagator prop =
        new NumericalPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
    prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));

    // action
    prop.setEphemerisMode();
    prop.propagate(endDate, startDate);
    BoundedPropagator ephemeris = prop.getGeneratedEphemeris();

    // verify
    TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(
        actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0));
    MatcherAssert.assertThat(
        actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0));
    MatcherAssert.assertThat(
        ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(
        ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0));
    // test date
    AbsoluteDate date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0);
  }
Ejemplo n.º 12
0
  @Test
  public void testKepler() throws OrekitException {

    // Propagation of the initial at t + dt
    final double dt = 3200;
    final SpacecraftState finalState =
        propagator.propagate(initDate.shiftedBy(-60), initDate.shiftedBy(dt));

    // Check results
    final double n =
        FastMath.sqrt(initialState.getMu() / initialState.getA()) / initialState.getA();
    Assert.assertEquals(initialState.getA(), finalState.getA(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10);
    Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1.0e-10);
    Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1.0e-10);
    Assert.assertEquals(initialState.getLM() + n * dt, finalState.getLM(), 2.0e-9);
  }
Ejemplo n.º 13
0
 /**
  * Approximate an already fitted model to polynomial only terms.
  *
  * <p>This method is mainly used in order to combine the large amplitude long periods with the
  * secular part as a new approximate polynomial model over some time range. This should be used
  * rather than simply extracting the polynomial coefficients from {@link #getFittedParameters()}
  * when some periodic terms amplitudes are large (for example Sun resonance effects on local solar
  * time in sun synchronous orbits). In theses cases, the pure polynomial secular part in the
  * coefficients may be far from the mean model.
  *
  * @param combinedDegree desired degree for the combined polynomial
  * @param combinedReference desired reference date for the combined polynomial
  * @param meanDegree degree of polynomial secular part to consider
  * @param meanHarmonics number of harmonics terms to consider
  * @param start start date of the approximation time range
  * @param end end date of the approximation time range
  * @param step sampling step
  * @return coefficients of the approximate polynomial (in increasing degree order), using the user
  *     provided reference date
  */
 public double[] approximateAsPolynomialOnly(
     final int combinedDegree,
     final AbsoluteDate combinedReference,
     final int meanDegree,
     final int meanHarmonics,
     final AbsoluteDate start,
     final AbsoluteDate end,
     final double step) {
   final List<WeightedObservedPoint> points = new ArrayList<WeightedObservedPoint>();
   for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(step)) {
     points.add(
         new WeightedObservedPoint(
             1.0,
             date.durationFrom(combinedReference),
             meanValue(date, meanDegree, meanHarmonics)));
   }
   return PolynomialCurveFitter.create(combinedDegree).fit(points);
 }
Ejemplo n.º 14
0
 @Test
 public void testContinueEvent() throws OrekitException {
   final AbsoluteDate resetDate = initDate.shiftedBy(1000);
   CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.CONTINUE);
   propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking));
   final double dt = 3200;
   checking.assertEvent(false);
   final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
   checking.assertEvent(true);
   final double n =
       FastMath.sqrt(initialState.getMu() / initialState.getA()) / initialState.getA();
   Assert.assertEquals(initialState.getA(), finalState.getA(), 1.0e-10);
   Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10);
   Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10);
   Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1.0e-10);
   Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1.0e-10);
   Assert.assertEquals(initialState.getLM() + n * dt, finalState.getLM(), 6.0e-10);
 }
Ejemplo n.º 15
0
  /** check propagation succeeds when two events are within the tolerance of each other. */
  @Test
  public void testCloseEventDates() throws PropagationException {
    // setup
    DateDetector d1 =
        new DateDetector(10, 1, initDate.shiftedBy(15))
            .withHandler(new ContinueOnEvent<DateDetector>());
    DateDetector d2 =
        new DateDetector(10, 1, initDate.shiftedBy(15.5))
            .withHandler(new ContinueOnEvent<DateDetector>());
    propagator.addEventDetector(d1);
    propagator.addEventDetector(d2);

    // action
    AbsoluteDate end = initDate.shiftedBy(30);
    SpacecraftState actual = propagator.propagate(end);

    // verify
    Assert.assertEquals(actual.getDate().durationFrom(end), 0.0, 0.0);
  }
  /** {@inheritDoc} */
  public void init(final SpacecraftState s0, final AbsoluteDate t) {

    // delegate to raw detector
    rawDetector.init(s0, t);

    // initialize events triggering logic
    forward = t.compareTo(s0.getDate()) >= 0;
    extremeT = forward ? AbsoluteDate.PAST_INFINITY : AbsoluteDate.FUTURE_INFINITY;
    extremeG = Double.NaN;
    Arrays.fill(transformers, Transformer.UNINITIALIZED);
    Arrays.fill(updates, extremeT);
  }
Ejemplo n.º 17
0
  /**
   * Compute the differential effect of J2 on an orbit.
   *
   * @param orbit1 original orbit at t₁, without differential J2
   * @return orbit at t₁, always taking the effect into account
   */
  private Orbit updateOrbit(final Orbit orbit1) {

    // convert current orbital state to equinoctial elements
    final EquinoctialOrbit original = (EquinoctialOrbit) OrbitType.EQUINOCTIAL.convertType(orbit1);

    // compute differential effect
    final AbsoluteDate date = original.getDate();
    final double dt = date.durationFrom(referenceDate);
    final double dPaRaan = (dPaDot + dRaanDot) * dt;
    final double cPaRaan = FastMath.cos(dPaRaan);
    final double sPaRaan = FastMath.sin(dPaRaan);
    final double dRaan = dRaanDot * dt;
    final double cRaan = FastMath.cos(dRaan);
    final double sRaan = FastMath.sin(dRaan);

    final double ex = original.getEquinoctialEx() * cPaRaan - original.getEquinoctialEy() * sPaRaan;
    final double ey = original.getEquinoctialEx() * sPaRaan + original.getEquinoctialEy() * cPaRaan;
    final double hx = original.getHx() * cRaan - original.getHy() * sRaan;
    final double hy = original.getHx() * sRaan + original.getHy() * cRaan;
    final double lambda = original.getLv() + dPaRaan;

    // build updated orbit
    final EquinoctialOrbit updated =
        new EquinoctialOrbit(
            original.getA(),
            ex,
            ey,
            hx,
            hy,
            lambda,
            PositionAngle.TRUE,
            original.getFrame(),
            date,
            original.getMu());

    // convert to required type
    return orbit1.getType().convertType(updated);
  }
Ejemplo n.º 18
0
    public void handleStep(OrekitStepInterpolator interpolator, boolean isLast)
        throws PropagationException {
      try {
        if (pickUpDate == null) {
          // we want to pick up the Jacobians at the end of last step
          if (isLast) {
            interpolator.setInterpolatedDate(interpolator.getCurrentDate());
          }
        } else {
          // we want to pick up some intermediate Jacobians
          double dt0 = pickUpDate.durationFrom(interpolator.getPreviousDate());
          double dt1 = pickUpDate.durationFrom(interpolator.getCurrentDate());
          if (dt0 * dt1 > 0) {
            // the current step does not cover the pickup date
            return;
          } else {
            interpolator.setInterpolatedDate(pickUpDate);
          }
        }

        Assert.assertEquals(1, interpolator.getInterpolatedState().getAdditionalStates().size());
        Assert.assertTrue(
            interpolator
                .getInterpolatedState()
                .getAdditionalStates()
                .containsKey(mapper.getName()));
        SpacecraftState state = interpolator.getInterpolatedState();
        mapper.getStateJacobian(state, dYdY0);
        mapper.getParametersJacobian(state, dYdP);

      } catch (PropagationException pe) {
        throw pe;
      } catch (OrekitException oe) {
        throw new PropagationException(oe);
      }
    }
Ejemplo n.º 19
0
  /**
   * Compute the transform at some date.
   *
   * @param date date at which the transform is desired
   * @return computed transform at specified date
   */
  public Transform getTransform(final AbsoluteDate date) {

    // compute parameters evolution since reference epoch
    final double dt = date.durationFrom(epoch);
    final Vector3D dR = new Vector3D(1, rotationVector, dt, rotationRate);

    // build translation part
    final Transform translationTransform = new Transform(date, cartesian.shiftedBy(dt));

    // build rotation part
    final double angle = dR.getNorm();
    final Transform rotationTransform =
        new Transform(
            date,
            (angle < Precision.SAFE_MIN) ? Rotation.IDENTITY : new Rotation(dR, angle),
            rotationRate);

    // combine both parts
    return new Transform(date, translationTransform, rotationTransform);
  }
Ejemplo n.º 20
0
  @Test(expected = OrekitException.class)
  public void testException() throws OrekitException {
    propagator.setMasterMode(
        new OrekitStepHandler() {
          private int countDown = 3;
          private AbsoluteDate previousCall = null;

          public void init(SpacecraftState s0, AbsoluteDate t) {}

          public void handleStep(OrekitStepInterpolator interpolator, boolean isLast)
              throws PropagationException {
            if (previousCall != null) {
              Assert.assertTrue(interpolator.getInterpolatedDate().compareTo(previousCall) < 0);
            }
            if (--countDown == 0) {
              throw new PropagationException(LocalizedFormats.SIMPLE_MESSAGE, "dummy error");
            }
          }
        });
    propagator.propagate(initDate.shiftedBy(-3600));
  }
Ejemplo n.º 21
0
  @Test
  public void testResetAdditionalStateEvent() throws OrekitException {
    propagator.addAdditionalEquations(
        new AdditionalEquations() {

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

          public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
            pDot[0] = 1.0;
            return null;
          }
        });
    propagator.setInitialState(propagator.getInitialState().addAdditionalState("linear", 1.5));

    CheckingHandler<AdditionalStateLinearDetector> checking =
        new CheckingHandler<AdditionalStateLinearDetector>(Action.RESET_STATE) {
          public SpacecraftState resetState(
              AdditionalStateLinearDetector detector, SpacecraftState oldState)
              throws OrekitException {
            return oldState.addAdditionalState(
                "linear", oldState.getAdditionalState("linear")[0] * 2);
          }
        };

    propagator.addEventDetector(
        new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking));

    final double dt = 3200;
    checking.assertEvent(false);
    final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
    checking.assertEvent(true);
    Assert.assertEquals(dt + 4.5, finalState.getAdditionalState("linear")[0], 1.0e-8);
    Assert.assertEquals(dt, finalState.getDate().durationFrom(initDate), 1.0e-8);
  }
Ejemplo n.º 22
0
 /**
  * Add a fitting point.
  *
  * @param date date of the point
  * @param osculatingValue osculating value
  */
 public void addPoint(final AbsoluteDate date, final double osculatingValue) {
   observedPoints.add(
       new WeightedObservedPoint(1.0, date.durationFrom(reference), osculatingValue));
 }
Ejemplo n.º 23
0
 /**
  * Get mean second derivative, truncated to first components.
  *
  * @param date current date
  * @param degree degree of polynomial secular part
  * @param harmonics number of harmonics terms to consider
  * @return mean second derivative at current date
  */
 public double meanSecondDerivative(
     final AbsoluteDate date, final int degree, final int harmonics) {
   return truncatedSecondDerivative(degree, harmonics, date.durationFrom(reference), fitted);
 }
Ejemplo n.º 24
0
 /**
  * Get fitted osculating second derivative.
  *
  * @param date current date
  * @return osculating second derivative at current date
  */
 public double osculatingSecondDerivative(final AbsoluteDate date) {
   return truncatedSecondDerivative(
       secularDegree, pulsations.length, date.durationFrom(reference), fitted);
 }
Ejemplo n.º 25
0
  @Test
  public void testJacobianIssue18() throws OrekitException {

    // Body mu
    final double mu = 3.9860047e14;

    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);

    double[] absTolerance = {0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001};
    double[] relTolerance = {1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7};
    AdaptiveStepsizeIntegrator integrator =
        new DormandPrince853Integrator(0.001, 1000, absTolerance, relTolerance);
    integrator.setInitialStepSize(60);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);

    propagator.setAttitudeProvider(law);
    propagator.addForceModel(maneuver);

    propagator.setOrbitType(OrbitType.CARTESIAN);
    PartialDerivativesEquations PDE = new PartialDerivativesEquations("derivatives", propagator);
    PDE.selectParamAndStep("thrust", Double.NaN);
    Assert.assertEquals(3, PDE.getAvailableParameters().size());
    Assert.assertEquals("central attraction coefficient", PDE.getAvailableParameters().get(0));
    Assert.assertEquals("thrust", PDE.getAvailableParameters().get(1));
    Assert.assertEquals("flow rate", PDE.getAvailableParameters().get(2));
    propagator.setInitialState(PDE.setInitialJacobians(initialState, 7, 1));

    final AbsoluteDate finalDate = fireDate.shiftedBy(3800);
    final SpacecraftState finalorb = propagator.propagate(finalDate);
    Assert.assertEquals(0, finalDate.durationFrom(finalorb.getDate()), 1.0e-11);
  }
Ejemplo n.º 26
0
 /** {@inheritDoc} */
 public TimeStampedPVCoordinates getPVCoordinates(
     final AbsoluteDate otherDate, final Frame otherFrame) throws OrekitException {
   return shiftedBy(otherDate.durationFrom(getDate())).getPVCoordinates(otherFrame);
 }
  /** {@inheritDoc} */
  public double g(final SpacecraftState s) throws OrekitException {

    final double rawG = rawDetector.g(s);
    final boolean isEnabled = enabler.eventIsEnabled(s, rawDetector, rawG);
    if (Double.isNaN(extremeG)) {
      extremeG = rawG;
    }

    // search which transformer should be applied to g
    if (forward) {
      final int last = transformers.length - 1;
      if (extremeT.compareTo(s.getDate()) < 0) {
        // we are at the forward end of the history

        // check if enabled status has changed
        final Transformer previous = transformers[last];
        final Transformer next = selectTransformer(previous, extremeG, isEnabled);
        if (next != previous) {
          // there is a status change somewhere between extremeT and t.
          // the new transformer is valid for t (this is how we have just computed
          // it above), but it is in fact valid on both sides of the change, so
          // it was already valid before t and even up to previous time. We store
          // the switch at extremeT for safety, to ensure the previous transformer
          // is not applied too close of the root
          System.arraycopy(updates, 1, updates, 0, last);
          System.arraycopy(transformers, 1, transformers, 0, last);
          updates[last] = extremeT;
          transformers[last] = next;
        }

        extremeT = s.getDate();
        extremeG = rawG;

        // apply the transform
        return next.transformed(rawG);

      } else {
        // we are in the middle of the history

        // select the transformer
        for (int i = last; i > 0; --i) {
          if (updates[i].compareTo(s.getDate()) <= 0) {
            // apply the transform
            return transformers[i].transformed(rawG);
          }
        }

        return transformers[0].transformed(rawG);
      }
    } else {
      if (s.getDate().compareTo(extremeT) < 0) {
        // we are at the backward end of the history

        // check if a new rough root has been crossed
        final Transformer previous = transformers[0];
        final Transformer next = selectTransformer(previous, extremeG, isEnabled);
        if (next != previous) {
          // there is a status change somewhere between extremeT and t.
          // the new transformer is valid for t (this is how we have just computed
          // it above), but it is in fact valid on both sides of the change, so
          // it was already valid before t and even up to previous time. We store
          // the switch at extremeT for safety, to ensure the previous transformer
          // is not applied too close of the root
          System.arraycopy(updates, 0, updates, 1, updates.length - 1);
          System.arraycopy(transformers, 0, transformers, 1, transformers.length - 1);
          updates[0] = extremeT;
          transformers[0] = next;
        }

        extremeT = s.getDate();
        extremeG = rawG;

        // apply the transform
        return next.transformed(rawG);

      } else {
        // we are in the middle of the history

        // select the transformer
        for (int i = 0; i < updates.length - 1; ++i) {
          if (s.getDate().compareTo(updates[i]) <= 0) {
            // apply the transform
            return transformers[i].transformed(rawG);
          }
        }

        return transformers[updates.length - 1].transformed(rawG);
      }
    }
  }
Ejemplo n.º 28
0
  @Test
  public void testAdditionalStateEvent() throws OrekitException {
    propagator.addAdditionalEquations(
        new AdditionalEquations() {

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

          public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
            pDot[0] = 1.0;
            return new double[7];
          }
        });
    try {
      propagator.addAdditionalEquations(
          new AdditionalEquations() {

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

            public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
              pDot[0] = 1.0;
              return new double[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 AdditionalStateProvider() {
            public String getName() {
              return "linear";
            }

            public double[] getAdditionalState(SpacecraftState 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 AdditionalStateProvider() {
          public String getName() {
            return "constant";
          }

          public double[] getAdditionalState(SpacecraftState state) {
            return new double[] {1.0};
          }
        });
    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", 1.5));

    CheckingHandler<AdditionalStateLinearDetector> checking =
        new CheckingHandler<AdditionalStateLinearDetector>(Action.STOP);
    propagator.addEventDetector(
        new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking));

    final double dt = 3200;
    checking.assertEvent(false);
    final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
    checking.assertEvent(true);
    Assert.assertEquals(3.0, finalState.getAdditionalState("linear")[0], 1.0e-8);
    Assert.assertEquals(1.5, finalState.getDate().durationFrom(initDate), 1.0e-8);
  }
Ejemplo n.º 29
0
  @Test
  public void testEphemerisAdditionalState() throws OrekitException, IOException {

    // Propagation of the initial at t + dt
    final double dt = -3200;
    final double rate = 2.0;

    propagator.addAdditionalStateProvider(
        new AdditionalStateProvider() {
          public String getName() {
            return "squaredA";
          }

          public double[] getAdditionalState(SpacecraftState state) {
            return new double[] {state.getA() * state.getA()};
          }
        });
    propagator.addAdditionalEquations(
        new AdditionalEquations() {
          public String getName() {
            return "extra";
          }

          public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
            pDot[0] = rate;
            return null;
          }
        });
    propagator.setInitialState(propagator.getInitialState().addAdditionalState("extra", 1.5));

    propagator.setOrbitType(OrbitType.CARTESIAN);
    propagator.setEphemerisMode();
    propagator.propagate(initDate.shiftedBy(dt));
    final BoundedPropagator ephemeris1 = propagator.getGeneratedEphemeris();
    Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMinDate());
    Assert.assertEquals(initDate, ephemeris1.getMaxDate());
    try {
      ephemeris1.propagate(ephemeris1.getMinDate().shiftedBy(-10.0));
      Assert.fail("an exception should have been thrown");
    } catch (PropagationException pe) {
      Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier());
    }
    try {
      ephemeris1.propagate(ephemeris1.getMaxDate().shiftedBy(+10.0));
      Assert.fail("an exception should have been thrown");
    } catch (PropagationException pe) {
      Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier());
    }

    double shift = -60;
    SpacecraftState s = ephemeris1.propagate(initDate.shiftedBy(shift));
    Assert.assertEquals(2, s.getAdditionalStates().size());
    Assert.assertTrue(s.hasAdditionalState("squaredA"));
    Assert.assertTrue(s.hasAdditionalState("extra"));
    Assert.assertEquals(s.getA() * s.getA(), s.getAdditionalState("squaredA")[0], 1.0e-10);
    Assert.assertEquals(1.5 + shift * rate, s.getAdditionalState("extra")[0], 1.0e-10);

    try {
      ephemeris1.resetInitialState(s);
      Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
      Assert.assertEquals(OrekitMessages.NON_RESETABLE_STATE, oe.getSpecifier());
    }
  }