@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);
 }
  @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);
  }
Example #3
0
    /**
     * Compute mean state from osculating state.
     *
     * <p>Compute in a DSST sense the mean state corresponding to the input osculating state.
     *
     * <p>The computing is done through a fixed-point iteration process.
     *
     * @param osculating initial osculating state
     * @return mean state
     * @throws OrekitException if the underlying computation of short periodic variation fails
     */
    private Orbit computeMeanOrbit(final SpacecraftState osculating) throws OrekitException {

      // rough initialization of the mean parameters
      EquinoctialOrbit meanOrbit = new EquinoctialOrbit(osculating.getOrbit());

      // threshold for each parameter
      final double epsilon = 1.0e-13;
      final double thresholdA = epsilon * (1 + FastMath.abs(meanOrbit.getA()));
      final double thresholdE = epsilon * (1 + meanOrbit.getE());
      final double thresholdAngles = epsilon * FastMath.PI;

      int i = 0;
      while (i++ < 200) {

        final SpacecraftState meanState =
            new SpacecraftState(meanOrbit, osculating.getAttitude(), osculating.getMass());
        // recompute the osculating parameters from the current mean parameters
        final EquinoctialOrbit rebuilt = (EquinoctialOrbit) computeOsculatingOrbit(meanState);

        // adapted parameters residuals
        final double deltaA = osculating.getA() - rebuilt.getA();
        final double deltaEx = osculating.getEquinoctialEx() - rebuilt.getEquinoctialEx();
        final double deltaEy = osculating.getEquinoctialEy() - rebuilt.getEquinoctialEy();
        final double deltaHx = osculating.getHx() - rebuilt.getHx();
        final double deltaHy = osculating.getHy() - rebuilt.getHy();
        final double deltaLm = MathUtils.normalizeAngle(osculating.getLM() - rebuilt.getLM(), 0.0);

        // check convergence
        if ((FastMath.abs(deltaA) < thresholdA)
            && (FastMath.abs(deltaEx) < thresholdE)
            && (FastMath.abs(deltaEy) < thresholdE)
            && (FastMath.abs(deltaLm) < thresholdAngles)) {
          return meanOrbit;
        }

        // update mean parameters
        meanOrbit =
            new EquinoctialOrbit(
                meanOrbit.getA() + deltaA,
                meanOrbit.getEquinoctialEx() + deltaEx,
                meanOrbit.getEquinoctialEy() + deltaEy,
                meanOrbit.getHx() + deltaHx,
                meanOrbit.getHy() + deltaHy,
                meanOrbit.getLM() + deltaLm,
                PositionAngle.MEAN,
                meanOrbit.getFrame(),
                meanOrbit.getDate(),
                meanOrbit.getMu());
      }

      throw new PropagationException(OrekitMessages.UNABLE_TO_COMPUTE_DSST_MEAN_PARAMETERS, i);
    }