Beispiel #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 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);
 }
  private double[] stateToArray(
      SpacecraftState state, OrbitType orbitType, PositionAngle angleType, boolean withMass) {
    double[] array = new double[withMass ? 7 : 6];
    switch (orbitType) {
      case CARTESIAN:
        {
          CartesianOrbit cart = (CartesianOrbit) orbitType.convertType(state.getOrbit());
          array[0] = cart.getPVCoordinates().getPosition().getX();
          array[1] = cart.getPVCoordinates().getPosition().getY();
          array[2] = cart.getPVCoordinates().getPosition().getZ();
          array[3] = cart.getPVCoordinates().getVelocity().getX();
          array[4] = cart.getPVCoordinates().getVelocity().getY();
          array[5] = cart.getPVCoordinates().getVelocity().getZ();
        }
        break;
      case CIRCULAR:
        {
          CircularOrbit circ = (CircularOrbit) orbitType.convertType(state.getOrbit());
          array[0] = circ.getA();
          array[1] = circ.getCircularEx();
          array[2] = circ.getCircularEy();
          array[3] = circ.getI();
          array[4] = circ.getRightAscensionOfAscendingNode();
          array[5] = circ.getAlpha(angleType);
        }
        break;
      case EQUINOCTIAL:
        {
          EquinoctialOrbit equ = (EquinoctialOrbit) orbitType.convertType(state.getOrbit());
          array[0] = equ.getA();
          array[1] = equ.getEquinoctialEx();
          array[2] = equ.getEquinoctialEy();
          array[3] = equ.getHx();
          array[4] = equ.getHy();
          array[5] = equ.getL(angleType);
        }
        break;
      case KEPLERIAN:
        {
          KeplerianOrbit kep = (KeplerianOrbit) orbitType.convertType(state.getOrbit());
          array[0] = kep.getA();
          array[1] = kep.getE();
          array[2] = kep.getI();
          array[3] = kep.getPerigeeArgument();
          array[4] = kep.getRightAscensionOfAscendingNode();
          array[5] = kep.getAnomaly(angleType);
        }
        break;
    }

    if (withMass) {
      array[6] = state.getMass();
    }

    return array;
  }
  /** {@inheritDoc} */
  public SpacecraftState apply(final SpacecraftState state1) {

    if (state1.getDate().compareTo(referenceDate) <= 0 && !applyBefore) {
      // the orbit change has not occurred yet, don't change anything
      return state1;
    }

    return new SpacecraftState(
        updateOrbit(state1.getOrbit()), state1.getAttitude(), state1.getMass());
  }
Beispiel #5
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);
    }
Beispiel #6
0
    /** {@inheritDoc} */
    @Override
    public void mapStateToArray(final SpacecraftState state, final double[] y)
        throws OrekitException {

      final Orbit meanOrbit;
      if (!initialIsOsculating) {
        // the state is considered to be already a mean state
        meanOrbit = state.getOrbit();
      } else {
        // the state is considered to be an osculating state
        meanOrbit = computeMeanState(state, forceModels).getOrbit();
      }

      OrbitType.EQUINOCTIAL.mapOrbitToArray(meanOrbit, PositionAngle.MEAN, y);
      y[6] = state.getMass();
    }
  /** {@inheritDoc} */
  public FieldVector3D<DerivativeStructure> accelerationDerivatives(
      final SpacecraftState s, final String paramName) throws OrekitException {

    complainIfNotSupported(paramName);
    final AbsoluteDate date = s.getDate();
    final Frame frame = s.getFrame();
    final Vector3D position = s.getPVCoordinates().getPosition();
    final Vector3D sunSatVector =
        position.subtract(sun.getPVCoordinates(date, frame).getPosition());
    final double r2 = sunSatVector.getNormSq();

    // compute flux
    final double rawP = kRef * getLightningRatio(position, frame, date) / r2;
    final Vector3D flux = new Vector3D(rawP / FastMath.sqrt(r2), sunSatVector);

    return spacecraft.radiationPressureAcceleration(
        date, frame, position, s.getAttitude().getRotation(), s.getMass(), flux, paramName);
  }
  /** {@inheritDoc} */
  public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder)
      throws OrekitException {

    final AbsoluteDate date = s.getDate();
    final Frame frame = s.getFrame();
    final Vector3D position = s.getPVCoordinates().getPosition();
    final Vector3D sunSatVector =
        position.subtract(sun.getPVCoordinates(date, frame).getPosition());
    final double r2 = sunSatVector.getNormSq();

    // compute flux
    final double rawP = kRef * getLightningRatio(position, frame, date) / r2;
    final Vector3D flux = new Vector3D(rawP / FastMath.sqrt(r2), sunSatVector);

    final Vector3D acceleration =
        spacecraft.radiationPressureAcceleration(
            date, frame, position, s.getAttitude().getRotation(), s.getMass(), flux);

    // provide the perturbing acceleration to the derivatives adder
    adder.addAcceleration(acceleration, s.getFrame());
  }