use of org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator in project Orekit by CS-SI.
the class EventsLoggerTest method setUp.
@Before
public void setUp() {
try {
Utils.setDataRoot("regular-data");
mu = 3.9860047e14;
final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
iniDate = new AbsoluteDate(1969, 7, 28, 4, 0, 0.0, TimeScalesFactory.getTT());
final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), iniDate, mu);
initialState = new SpacecraftState(orbit);
double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(60);
propagator = new NumericalPropagator(integrator);
propagator.setInitialState(initialState);
count = 0;
umbraDetector = buildDetector(true);
penumbraDetector = buildDetector(false);
} catch (OrekitException oe) {
Assert.fail(oe.getLocalizedMessage());
}
}
use of org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator in project Orekit by CS-SI.
the class AttitudesSequenceTest method testResetDuringTransitionBackward.
@Test
public void testResetDuringTransitionBackward() throws OrekitException {
// Initial state definition : date, orbit
final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
final AttitudesSequence attitudesSequence = new AttitudesSequence();
final double transitionTime = 250.0;
final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
final List<AbsoluteDate> nadirToTarget = new ArrayList<>();
attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, (previous, next, state) -> nadirToTarget.add(state.getDate()));
final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
propagator.setAttitudeProvider(attitudesSequence);
attitudesSequence.registerSwitchEvents(propagator);
propagator.propagate(initialDate.shiftedBy(6000));
// check that if we restart a backward propagation from an intermediate state
// we properly get an interpolated attitude despite we missed the event trigger
final AbsoluteDate midTransition = nadirToTarget.get(0).shiftedBy(0.5 * transitionTime);
SpacecraftState state = propagator.propagate(midTransition.shiftedBy(+60), midTransition);
Rotation nadirR = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
Rotation targetR = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
final double reorientationAngle = Rotation.distance(nadirR, targetR);
Assert.assertEquals(0.5 * reorientationAngle, Rotation.distance(state.getAttitude().getRotation(), targetR), 0.03 * reorientationAngle);
}
use of org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator in project Orekit by CS-SI.
the class AdapterPropagatorTest method getEphemeris.
private BoundedPropagator getEphemeris(final Orbit orbit, final double mass, final int nbOrbits, final AttitudeProvider law, final AbsoluteDate t0, final Vector3D dV, final double f, final double isp, final boolean sunAttraction, final boolean moonAttraction, final NormalizedSphericalHarmonicsProvider gravityField) throws OrekitException, ParseException, IOException {
SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
// add some dummy additional states
initialState = initialState.addAdditionalState("dummy 1", 1.25, 2.5);
initialState = initialState.addAdditionalState("dummy 2", 5.0);
// set up numerical propagator
final double dP = 1.0;
double[][] tolerances = NumericalPropagator.tolerances(dP, orbit, orbit.getType());
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tolerances[0], tolerances[1]);
integrator.setInitialStepSize(orbit.getKeplerianPeriod() / 100.0);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "dummy 2";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[] { 5.0 };
}
});
propagator.setInitialState(initialState);
propagator.setAttitudeProvider(law);
if (dV.getNorm() > 1.0e-6) {
// set up maneuver
final double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
final double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(t0.shiftedBy(-0.5 * dt), dt, f, isp, dV.normalize());
propagator.addForceModel(maneuver);
}
if (sunAttraction) {
propagator.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getSun()));
}
if (moonAttraction) {
propagator.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getMoon()));
}
if (gravityField != null) {
propagator.addForceModel(new HolmesFeatherstoneAttractionModel(FramesFactory.getGTOD(false), gravityField));
}
propagator.setEphemerisMode();
propagator.propagate(t0.shiftedBy(nbOrbits * orbit.getKeplerianPeriod()));
final BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
// both the initial propagator and generated ephemeris manage one of the two
// additional states, but they also contain unmanaged copies of the other one
Assert.assertFalse(propagator.isAdditionalStateManaged("dummy 1"));
Assert.assertTrue(propagator.isAdditionalStateManaged("dummy 2"));
Assert.assertFalse(ephemeris.isAdditionalStateManaged("dummy 1"));
Assert.assertTrue(ephemeris.isAdditionalStateManaged("dummy 2"));
Assert.assertEquals(2, ephemeris.getInitialState().getAdditionalState("dummy 1").length);
Assert.assertEquals(1, ephemeris.getInitialState().getAdditionalState("dummy 2").length);
return ephemeris;
}
use of org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator in project Orekit by CS-SI.
the class DSSTPropagation method createDSSTProp.
/**
* Set up the DSST Propagator
*
* @param orbit initial orbit
* @param mass S/C mass (kg)
* @param initialIsOsculating if initial orbital elements are osculating
* @param outputIsOsculating if we want to output osculating parameters
* @param fixedStepSize step size for fixed step integrator (s)
* @param minStep minimum step size, if step is not fixed (s)
* @param maxStep maximum step size, if step is not fixed (s)
* @param dP position tolerance for step size control, if step is not fixed (m)
* @param shortPeriodCoefficients list of short periodic coefficients
* to output (null means no coefficients at all, empty list means all
* possible coefficients)
* @throws OrekitException
*/
private DSSTPropagator createDSSTProp(final Orbit orbit, final double mass, final boolean initialIsOsculating, final boolean outputIsOsculating, final double fixedStepSize, final double minStep, final double maxStep, final double dP, final List<String> shortPeriodCoefficients) throws OrekitException {
AbstractIntegrator integrator;
if (fixedStepSize > 0.) {
integrator = new ClassicalRungeKuttaIntegrator(fixedStepSize);
} else {
final double[][] tol = DSSTPropagator.tolerances(dP, orbit);
integrator = new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]);
((AdaptiveStepsizeIntegrator) integrator).setInitialStepSize(10. * minStep);
}
DSSTPropagator dsstProp = new DSSTPropagator(integrator, !outputIsOsculating);
dsstProp.setInitialState(new SpacecraftState(orbit, mass), initialIsOsculating);
dsstProp.setSelectedCoefficients(shortPeriodCoefficients == null ? null : new HashSet<String>(shortPeriodCoefficients));
return dsstProp;
}
use of org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator in project Orekit by CS-SI.
the class DSSTPropagation method createNumProp.
/**
* Create the numerical propagator
*
* @param orbit initial orbit
* @param mass S/C mass (kg)
* @throws OrekitException
*/
private NumericalPropagator createNumProp(final Orbit orbit, final double mass) throws OrekitException {
final double[][] tol = NumericalPropagator.tolerances(1.0, orbit, orbit.getType());
final double minStep = 1.e-3;
final double maxStep = 1.e+3;
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]);
integrator.setInitialStepSize(100.);
NumericalPropagator numProp = new NumericalPropagator(integrator);
numProp.setInitialState(new SpacecraftState(orbit, mass));
return numProp;
}
Aggregations