Ejemplo n.º 1
0
    /** {@inheritDoc} */
    @Override
    public double[] computeDerivatives(final SpacecraftState state) throws OrekitException {

      // compute common auxiliary elements
      final AuxiliaryElements aux = new AuxiliaryElements(state.getOrbit(), I);

      // initialize all perturbing forces
      for (final DSSTForceModel force : mapper.getForceModels()) {
        force.initializeStep(aux);
      }

      Arrays.fill(yDot, 0.0);

      // compute the contributions of all perturbing forces
      for (final DSSTForceModel forceModel : mapper.getForceModels()) {
        final double[] daidt = forceModel.getMeanElementRate(state);
        for (int i = 0; i < daidt.length; i++) {
          yDot[i] += daidt[i];
        }
      }

      // finalize derivatives by adding the Kepler contribution
      final EquinoctialOrbit orbit =
          (EquinoctialOrbit) OrbitType.EQUINOCTIAL.convertType(state.getOrbit());
      orbit.addKeplerContribution(PositionAngle.MEAN, getMu(), yDot);

      return yDot.clone();
    }
Ejemplo n.º 2
0
  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;
  }
Ejemplo n.º 3
0
  /**
   * Method called just before integration.
   *
   * <p>The default implementation does nothing, it may be specialized in subclasses.
   *
   * @param initialState initial state
   * @param tEnd target date at which state should be propagated
   * @exception OrekitException if hook cannot be run
   */
  @Override
  protected void beforeIntegration(final SpacecraftState initialState, final AbsoluteDate tEnd)
      throws OrekitException {

    // compute common auxiliary elements
    final AuxiliaryElements aux = new AuxiliaryElements(initialState.getOrbit(), I);

    // check if only mean elements must be used
    final boolean meanOnly = isMeanOrbit();

    // initialize all perturbing forces
    for (final DSSTForceModel force : mapper.getForceModels()) {
      force.initialize(aux, meanOnly);
    }

    // if required, insert the special short periodics step handler
    if (!meanOnly) {
      final InterpolationGrid grid =
          new VariableStepInterpolationGrid(INTERPOLATION_POINTS_PER_STEP);
      final ShortPeriodicsHandler spHandler = new ShortPeriodicsHandler(grid);
      final Collection<StepHandler> stepHandlers = new ArrayList<StepHandler>();
      stepHandlers.add(spHandler);
      final AbstractIntegrator integrator = getIntegrator();
      final Collection<StepHandler> existing = integrator.getStepHandlers();
      stepHandlers.addAll(existing);

      integrator.clearStepHandlers();

      // add back the existing handlers after the short periodics one
      for (final StepHandler sp : stepHandlers) {
        integrator.addStepHandler(sp);
      }
    }
  }
Ejemplo n.º 4
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());
  }
Ejemplo n.º 5
0
 /**
  * Launch the computation of short periodics coefficients.
  *
  * @param state input state
  * @throws OrekitException if the computation of a short periodic coefficient fails
  * @see {@link DSSTForceModel#computeShortPeriodicsCoefficients(AuxiliaryElements)}
  */
 private void computeShortPeriodicsCoefficients(final SpacecraftState state)
     throws OrekitException {
   final AuxiliaryElements aux = new AuxiliaryElements(state.getOrbit(), I);
   for (final DSSTForceModel forceModel : forceModels) {
     forceModel.initializeStep(aux);
     forceModel.computeShortPeriodicsCoefficients(state);
   }
 }
  /* (non-Javadoc)
   * @see org.orekit.propagation.sampling.OrekitFixedStepHandler#handleStep(org.orekit.propagation.SpacecraftState, boolean)
   */
  public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException {

    /** Create position vector. */
    D3Vector position =
        new D3Vector(
            "",
            "Position",
            "Position",
            "The orbital position of the satellite at the given time.",
            currentState.getOrbit().getPVCoordinates().getPosition().getX(),
            currentState.getOrbit().getPVCoordinates().getPosition().getY(),
            currentState.getOrbit().getPVCoordinates().getPosition().getZ());

    /** Create velocity vector. */
    D3Vector velocity =
        new D3Vector(
            "",
            "Velocity",
            "Velocity",
            "The orbital velocity of the satellite at the given time",
            currentState.getOrbit().getPVCoordinates().getVelocity().getX(),
            currentState.getOrbit().getPVCoordinates().getVelocity().getY(),
            currentState.getOrbit().getPVCoordinates().getVelocity().getZ());

    try {
      /** Create orbital state. */
      OrbitalState state =
          new OrbitalState(
              predictor.name,
              orbitalStateName,
              orbitalStateDescription,
              currentState.getDate().toDate(TimeScalesFactory.getUTC()).getTime(),
              datasetidentifier,
              satellite,
              position,
              velocity);

      /** Send the orbital state on the response stream. */
      predictor.addResult(state);
    } catch (OrekitException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 7
0
  /** {@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());
  }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
0
 /**
  * Simple constructor.
  *
  * <p>The {@code applyBefore} parameter is mainly used when the differential effect is associated
  * with a maneuver. In this case, the parameter must be set to {@code false}.
  *
  * @param original original state at reference date
  * @param directEffect direct effect changing the orbit
  * @param applyBefore if true, effect is applied both before and after reference date, if false it
  *     is only applied after reference date
  * @param referenceRadius reference radius of the Earth for the potential model (m)
  * @param mu central attraction coefficient (m³/s²)
  * @param j2 un-normalized zonal coefficient (about +1.08e-3 for Earth)
  * @exception OrekitException if direct effect cannot be applied
  */
 public J2DifferentialEffect(
     final SpacecraftState original,
     final AdapterPropagator.DifferentialEffect directEffect,
     final boolean applyBefore,
     final double referenceRadius,
     final double mu,
     final double j2)
     throws OrekitException {
   this(
       original.getOrbit(),
       directEffect.apply(original.shiftedBy(0.001)).getOrbit().shiftedBy(-0.001),
       applyBefore,
       referenceRadius,
       mu,
       j2);
 }
Ejemplo n.º 10
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();
    }
Ejemplo n.º 11
0
    /**
     * Compute osculating state from mean state.
     *
     * <p>Compute and add the short periodic variation to the mean {@link SpacecraftState}.
     *
     * @param meanState initial mean state
     * @return osculating state
     * @throws OrekitException if the computation of the short-periodic variation fails
     */
    private Orbit computeOsculatingOrbit(final SpacecraftState meanState) throws OrekitException {

      resetShortPeriodicsCoefficients();
      computeShortPeriodicsCoefficients(meanState);

      final double[] mean = new double[6];
      OrbitType.EQUINOCTIAL.mapOrbitToArray(meanState.getOrbit(), PositionAngle.MEAN, mean);
      final double[] y = mean.clone();
      for (final DSSTForceModel forceModel : this.forceModels) {

        final double[] shortPeriodic =
            forceModel.getShortPeriodicVariations(meanState.getDate(), mean);

        for (int i = 0; i < shortPeriodic.length; i++) {
          y[i] += shortPeriodic[i];
        }
      }
      return OrbitType.EQUINOCTIAL.mapArrayToOrbit(
          y, PositionAngle.MEAN, meanState.getDate(), meanState.getMu(), meanState.getFrame());
    }
Ejemplo n.º 12
0
  private PVCoordinates propagateInType(
      SpacecraftState state, double dP, OrbitType type, PositionAngle angle)
      throws PropagationException {

    final double dt = 3200;
    final double minStep = 0.001;
    final double maxStep = 1000;

    double[][] tol = NumericalPropagator.tolerances(dP, state.getOrbit(), type);
    AdaptiveStepsizeIntegrator integrator =
        new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]);
    NumericalPropagator newPropagator = new NumericalPropagator(integrator);
    newPropagator.setOrbitType(type);
    newPropagator.setPositionAngleType(angle);
    newPropagator.setInitialState(state);
    for (ForceModel force : propagator.getForceModels()) {
      newPropagator.addForceModel(force);
    }
    return newPropagator.propagate(state.getDate().shiftedBy(dt)).getPVCoordinates();
  }