use of org.hipparchus.ode.nonstiff.DormandPrince853Integrator in project Orekit by CS-SI.
the class NodeDetectorTest method testIssue138.
@Test
public void testIssue138() throws OrekitException {
double a = 800000 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
double e = 0.0001;
double i = FastMath.toRadians(98);
double w = -90;
double raan = 0;
double v = 0;
Frame inertialFrame = FramesFactory.getEME2000();
AbsoluteDate initialDate = new AbsoluteDate(2014, 01, 01, 0, 0, 0, TimeScalesFactory.getUTC());
AbsoluteDate finalDate = initialDate.shiftedBy(5000);
KeplerianOrbit initialOrbit = new KeplerianOrbit(a, e, i, w, raan, v, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
SpacecraftState initialState = new SpacecraftState(initialOrbit, 1000);
double[][] tol = NumericalPropagator.tolerances(10, initialOrbit, initialOrbit.getType());
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setInitialState(initialState);
// Define 2 instances of NodeDetector:
EventDetector rawDetector = new NodeDetector(1e-6, initialState.getOrbit(), initialState.getFrame()).withHandler(new ContinueOnEvent<NodeDetector>());
EventsLogger logger1 = new EventsLogger();
EventDetector node1 = logger1.monitorDetector(rawDetector);
EventsLogger logger2 = new EventsLogger();
EventDetector node2 = logger2.monitorDetector(rawDetector);
propagator.addEventDetector(node1);
propagator.addEventDetector(node2);
// First propagation
propagator.setEphemerisMode();
propagator.propagate(finalDate);
Assert.assertEquals(2, logger1.getLoggedEvents().size());
Assert.assertEquals(2, logger2.getLoggedEvents().size());
logger1.clearLoggedEvents();
logger2.clearLoggedEvents();
BoundedPropagator postpro = propagator.getGeneratedEphemeris();
// Post-processing
postpro.addEventDetector(node1);
postpro.addEventDetector(node2);
postpro.propagate(finalDate);
Assert.assertEquals(2, logger1.getLoggedEvents().size());
Assert.assertEquals(2, logger2.getLoggedEvents().size());
}
use of org.hipparchus.ode.nonstiff.DormandPrince853Integrator in project Orekit by CS-SI.
the class IntegratedEphemerisTest method setUp.
@Before
public void setUp() {
Utils.setDataRoot("regular-data:potential/icgem-format");
GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("eigen-6s-truncated", true));
// Definition of initial conditions with position and velocity
Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
double mu = 3.9860047e14;
AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, mu);
// Numerical propagator definition
double[] absTolerance = { 0.0001, 1.0e-11, 1.0e-11, 1.0e-8, 1.0e-8, 1.0e-8, 0.001 };
double[] relTolerance = { 1.0e-8, 1.0e-8, 1.0e-8, 1.0e-9, 1.0e-9, 1.0e-9, 1.0e-7 };
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 500, absTolerance, relTolerance);
integrator.setInitialStepSize(100);
numericalPropagator = new NumericalPropagator(integrator);
}
use of org.hipparchus.ode.nonstiff.DormandPrince853Integrator in project Orekit by CS-SI.
the class SolarBodyTest method testPropagationVsEphemeris.
@Test
public void testPropagationVsEphemeris() throws OrekitException {
Utils.setDataRoot("regular-data");
// Creation of the celestial bodies of the solar system
final CelestialBody sun = CelestialBodyFactory.getSun();
final CelestialBody mercury = CelestialBodyFactory.getMercury();
final CelestialBody venus = CelestialBodyFactory.getVenus();
final CelestialBody earth = CelestialBodyFactory.getEarth();
final CelestialBody mars = CelestialBodyFactory.getMars();
final CelestialBody jupiter = CelestialBodyFactory.getJupiter();
final CelestialBody saturn = CelestialBodyFactory.getSaturn();
final CelestialBody uranus = CelestialBodyFactory.getUranus();
final CelestialBody neptune = CelestialBodyFactory.getNeptune();
final CelestialBody pluto = CelestialBodyFactory.getPluto();
// Starting and end dates
final AbsoluteDate startingDate = new AbsoluteDate(2000, 1, 2, TimeScalesFactory.getUTC());
AbsoluteDate endDate = startingDate.shiftedBy(30 * Constants.JULIAN_DAY);
final Frame icrf = FramesFactory.getICRF();
// fake orbit around negligible point mass at solar system barycenter
double negligibleMu = 1.0e-3;
SpacecraftState initialState = new SpacecraftState(new CartesianOrbit(venus.getPVCoordinates(startingDate, icrf), icrf, startingDate, negligibleMu));
// Creation of the numerical propagator
final double[][] tol = NumericalPropagator.tolerances(1000, initialState.getOrbit(), OrbitType.CARTESIAN);
AbstractIntegrator dop1 = new DormandPrince853Integrator(1.0, 1.0e5, tol[0], tol[1]);
NumericalPropagator propag = new NumericalPropagator(dop1);
propag.setOrbitType(OrbitType.CARTESIAN);
propag.setInitialState(initialState);
propag.setMu(negligibleMu);
// Creation of the ForceModels
propag.addForceModel(new BodyAttraction(sun));
propag.addForceModel(new BodyAttraction(mercury));
propag.addForceModel(new BodyAttraction(earth));
propag.addForceModel(new BodyAttraction(mars));
propag.addForceModel(new BodyAttraction(jupiter));
propag.addForceModel(new BodyAttraction(saturn));
propag.addForceModel(new BodyAttraction(uranus));
propag.addForceModel(new BodyAttraction(neptune));
propag.addForceModel(new BodyAttraction(pluto));
// checks are done within the step handler
propag.setMasterMode(1000.0, new OrekitFixedStepHandler() {
public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
// propagated position should remain within 1400m of ephemeris for one month
Vector3D propagatedP = currentState.getPVCoordinates(icrf).getPosition();
Vector3D ephemerisP = venus.getPVCoordinates(currentState.getDate(), icrf).getPosition();
Assert.assertEquals(0, Vector3D.distance(propagatedP, ephemerisP), 1400.0);
}
});
propag.propagate(startingDate, endDate);
}
use of org.hipparchus.ode.nonstiff.DormandPrince853Integrator in project Orekit by CS-SI.
the class AttitudesSequenceTest method testResetDuringTransitionForward.
@Test
public void testResetDuringTransitionForward() 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 forward 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(), nadirR), 0.03 * reorientationAngle);
}
use of org.hipparchus.ode.nonstiff.DormandPrince853Integrator in project Orekit by CS-SI.
the class AttitudesSequenceTest method testOutOfSyncCalls.
@Test
public void testOutOfSyncCalls() 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 Handler nadirToTarget = new Handler(nadirPointing, targetPointing);
attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, nadirToTarget);
final Handler targetToNadir = new Handler(targetPointing, nadirPointing);
attitudesSequence.addSwitchingCondition(targetPointing, nadirPointing, eventDetector, false, true, transitionTime, AngularDerivativesFilter.USE_RR, targetToNadir);
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.setMasterMode(10, (state, isLast) -> {
Attitude nadirAttitude = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
Attitude targetAttitude = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
Attitude stateAttitude = state.getAttitude();
if (nadirToTarget.dates.isEmpty() || state.getDate().durationFrom(nadirToTarget.dates.get(0)) < 0) {
// we are stabilized in nadir pointing, before first switch
checkEqualAttitudes(nadirAttitude, stateAttitude);
} else if (state.getDate().durationFrom(nadirToTarget.dates.get(0)) <= transitionTime) {
// we are in transition from nadir to target
checkBetweenAttitudes(nadirAttitude, targetAttitude, stateAttitude);
} else if (targetToNadir.dates.isEmpty() || state.getDate().durationFrom(targetToNadir.dates.get(0)) < 0) {
// we are stabilized in target pointing between the two switches
checkEqualAttitudes(targetAttitude, stateAttitude);
} else if (state.getDate().durationFrom(targetToNadir.dates.get(0)) <= transitionTime) {
// we are in transition from target to nadir
checkBetweenAttitudes(targetAttitude, nadirAttitude, stateAttitude);
} else {
// we are stabilized back in nadir pointing, after second switch
checkEqualAttitudes(nadirAttitude, stateAttitude);
}
});
propagator.propagate(initialDate.shiftedBy(6000));
}
Aggregations