use of org.hipparchus.ode.ODEIntegrator in project Orekit by CS-SI.
the class TimeStampedAngularCoordinatesTest method interpolationErrors.
private double[] interpolationErrors(final TimeStampedAngularCoordinates reference, double dt) throws OrekitException {
final OrdinaryDifferentialEquation ode = new OrdinaryDifferentialEquation() {
public int getDimension() {
return 4;
}
public double[] computeDerivatives(final double t, final double[] q) {
final double omegaX = reference.getRotationRate().getX() + t * reference.getRotationAcceleration().getX();
final double omegaY = reference.getRotationRate().getY() + t * reference.getRotationAcceleration().getY();
final double omegaZ = reference.getRotationRate().getZ() + t * reference.getRotationAcceleration().getZ();
return new double[] { 0.5 * MathArrays.linearCombination(-q[1], omegaX, -q[2], omegaY, -q[3], omegaZ), 0.5 * MathArrays.linearCombination(q[0], omegaX, -q[3], omegaY, q[2], omegaZ), 0.5 * MathArrays.linearCombination(q[3], omegaX, q[0], omegaY, -q[1], omegaZ), 0.5 * MathArrays.linearCombination(-q[2], omegaX, q[1], omegaY, q[0], omegaZ) };
}
};
final List<TimeStampedAngularCoordinates> complete = new ArrayList<TimeStampedAngularCoordinates>();
ODEIntegrator integrator = new DormandPrince853Integrator(1.0e-6, 1.0, 1.0e-12, 1.0e-12);
integrator.addStepHandler(new StepNormalizer(dt / 2000, new ODEFixedStepHandler() {
public void handleStep(ODEStateAndDerivative state, boolean isLast) {
final double t = state.getTime();
final double[] q = state.getPrimaryState();
complete.add(new TimeStampedAngularCoordinates(reference.getDate().shiftedBy(t), new Rotation(q[0], q[1], q[2], q[3], true), new Vector3D(1, reference.getRotationRate(), t, reference.getRotationAcceleration()), reference.getRotationAcceleration()));
}
}));
double[] y = new double[] { reference.getRotation().getQ0(), reference.getRotation().getQ1(), reference.getRotation().getQ2(), reference.getRotation().getQ3() };
integrator.integrate(ode, new ODEState(0, y), dt);
List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
sample.add(complete.get(0));
sample.add(complete.get(complete.size() / 2));
sample.add(complete.get(complete.size() - 1));
double maxRotationError = 0;
double maxRateError = 0;
double maxAccelerationError = 0;
for (TimeStampedAngularCoordinates acRef : complete) {
TimeStampedAngularCoordinates interpolated = TimeStampedAngularCoordinates.interpolate(acRef.getDate(), AngularDerivativesFilter.USE_RRA, sample);
double rotationError = Rotation.distance(acRef.getRotation(), interpolated.getRotation());
double rateError = Vector3D.distance(acRef.getRotationRate(), interpolated.getRotationRate());
double accelerationError = Vector3D.distance(acRef.getRotationAcceleration(), interpolated.getRotationAcceleration());
maxRotationError = FastMath.max(maxRotationError, rotationError);
maxRateError = FastMath.max(maxRateError, rateError);
maxAccelerationError = FastMath.max(maxAccelerationError, accelerationError);
}
return new double[] { maxRotationError, maxRateError, maxAccelerationError };
}
use of org.hipparchus.ode.ODEIntegrator in project Orekit by CS-SI.
the class DSSTPropagator method afterIntegration.
/**
* {@inheritDoc}
*/
@Override
protected void afterIntegration() throws OrekitException {
// remove the special short periodics step handler if added before
if (!isMeanOrbit()) {
final List<ODEStepHandler> preserved = new ArrayList<ODEStepHandler>();
final ODEIntegrator integrator = getIntegrator();
for (final ODEStepHandler sp : integrator.getStepHandlers()) {
if (!(sp instanceof ShortPeriodicsHandler)) {
preserved.add(sp);
}
}
// clear the list
integrator.clearStepHandlers();
// add back the step handlers that were important for the user
for (final ODEStepHandler sp : preserved) {
integrator.addStepHandler(sp);
}
}
}
use of org.hipparchus.ode.ODEIntegrator in project Orekit by CS-SI.
the class PropagatorsParallelizerTest method buildNotInitializedNumerical.
private NumericalPropagator buildNotInitializedNumerical() throws OrekitException {
OrbitType type = OrbitType.CARTESIAN;
double minStep = 0.001;
double maxStep = 300;
double[][] tolerances = NumericalPropagator.tolerances(10.0, orbit, type);
ODEIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tolerances[0], tolerances[1]);
NumericalPropagator numericalPropagator = new NumericalPropagator(integrator);
ForceModel gravity = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), normalizedGravityField);
numericalPropagator.addForceModel(gravity);
return numericalPropagator;
}
use of org.hipparchus.ode.ODEIntegrator in project Orekit by CS-SI.
the class DSSTPropagator method beforeIntegration.
/**
* Method called just before integration.
* <p>
* The default implementation does nothing, it may be specialized in subclasses.
* </p>
* @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
final List<ShortPeriodTerms> shortPeriodTerms = new ArrayList<ShortPeriodTerms>();
for (final DSSTForceModel force : forceModels) {
shortPeriodTerms.addAll(force.initialize(aux, meanOnly));
}
mapper.setShortPeriodTerms(shortPeriodTerms);
// if required, insert the special short periodics step handler
if (!meanOnly) {
final ShortPeriodicsHandler spHandler = new ShortPeriodicsHandler(forceModels);
final Collection<ODEStepHandler> stepHandlers = new ArrayList<ODEStepHandler>();
stepHandlers.add(spHandler);
final ODEIntegrator integrator = getIntegrator();
final Collection<ODEStepHandler> existing = integrator.getStepHandlers();
stepHandlers.addAll(existing);
integrator.clearStepHandlers();
// add back the existing handlers after the short periodics one
for (final ODEStepHandler sp : stepHandlers) {
integrator.addStepHandler(sp);
}
}
}
use of org.hipparchus.ode.ODEIntegrator in project Orekit by CS-SI.
the class MarshallSolarActivityFutureEstimationTest method getNumericalPropagator.
/**
* Configure a numerical propagator.
*
* @param sun Sun.
* @param earth Earth.
* @param ic initial condition.
* @return a propagator.
* @throws OrekitException on error.
*/
private NumericalPropagator getNumericalPropagator(CelestialBody sun, OneAxisEllipsoid earth, SpacecraftState ic) throws OrekitException {
// some non-integer step size to induce truncation error in flux interpolation
final ODEIntegrator integrator = new ClassicalRungeKuttaIntegrator(120 + 0.1);
NumericalPropagator propagator = new NumericalPropagator(integrator);
DTM2000InputParameters flux = getFlux();
final Atmosphere atmosphere = new DTM2000(flux, sun, earth);
final IsotropicDrag satellite = new IsotropicDrag(1, 3.2);
propagator.addForceModel(new DragForce(atmosphere, satellite));
propagator.setInitialState(ic);
propagator.setOrbitType(OrbitType.CARTESIAN);
return propagator;
}
Aggregations