示例#1
0
  /**
   * Conversion from osculating to mean, orbit.
   *
   * <p>Compute osculating state <b>in a DSST sense</b>, corresponding to the mean SpacecraftState
   * in input, and according to the Force models taken into account.
   *
   * <p>Since the osculating state is obtained with the computation of short-periodic variation of
   * each force model, the resulting output will depend on the force models parametrized in input.
   *
   * <p>The computing is done through a fixed-point iteration process.
   *
   * @param osculating Osculating state to convert
   * @param forces Forces to take into account
   * @return mean state in a DSST sense
   * @throws OrekitException if computation of short periodics fails or iteration algorithm does not
   *     converge
   */
  public static SpacecraftState computeMeanState(
      final SpacecraftState osculating, final Collection<DSSTForceModel> forces)
      throws OrekitException {

    // Creation of a DSSTPropagator instance
    final AbstractIntegrator integrator = new ClassicalRungeKuttaIntegrator(43200.);
    final DSSTPropagator dsst = new DSSTPropagator(integrator, false);
    // Create the auxiliary object
    final AuxiliaryElements aux = new AuxiliaryElements(osculating.getOrbit(), I);

    // Set the force models
    for (final DSSTForceModel force : forces) {
      force.initialize(aux, false);
      dsst.addForceModel(force);
    }

    dsst.setInitialState(osculating, true);

    final Orbit meanOrbit = dsst.mapper.computeMeanOrbit(osculating);

    return new SpacecraftState(
        meanOrbit,
        osculating.getAttitude(),
        osculating.getMass(),
        osculating.getAdditionalStates());
  }
  @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());
    }
  }