/** * 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); } } }
/** * 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()); }