Problem with post-processing event detection
We found a strange behaviour when adding 2 instances of the same event detector to a propagator generated by a previous Ephemeris mode propagation.
A simple example to illustrate this issue:
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 node1 = new NodeDetector(1e-6,initialState.getOrbit(), initialState.getFrame()){
private static final long serialVersionUID = -5495471556543226249L;
public Action eventOccurred(final SpacecraftState s, final boolean increasing)
throws OrekitException {
System.out.println("node crossing - detector1: Date ="+s.getDate()+" / Z inertial = "+s.getPVCoordinates().getPosition().getZ());
return Action.CONTINUE;
}
};
EventDetector node2 = new NodeDetector(1e-6,initialState.getOrbit(), initialState.getFrame()){
private static final long serialVersionUID = -7979764548288236088L;
public Action eventOccurred(final SpacecraftState s, final boolean increasing)
throws OrekitException {
System.out.println("node crossing - detector2: Date ="+s.getDate()+" / Z inertial = "+s.getPVCoordinates().getPosition().getZ());
return Action.CONTINUE;
};
};
propagator.addEventDetector(node1);
propagator.addEventDetector(node2);
// First propagation
propagator.setEphemerisMode();
System.out.println("StartDate = "+initialDate+" / End Date = "+finalDate);
propagator.propagate(finalDate);
BoundedPropagator postpro = propagator.getGeneratedEphemeris();
// Post-processing
System.out.println("Post-processing: ");
postpro.addEventDetector(node1);
postpro.addEventDetector(node2);
postpro.propagate(finalDate);
The console output is:
StartDate = 2014-01-01T00:00:00.000 / End Date = 2014-01-01T01:23:20.000
node crossing - detector1: Date =2014-01-01T00:32:40.476 / Z inertial = 8.669672720972587E-8
node crossing - detector2: Date =2014-01-01T00:32:40.476 / Z inertial = 8.669672720972587E-8
node crossing - detector1: Date =2014-01-01T01:23:07.027 / Z inertial = -3.9502712349237726E-8
node crossing - detector2: Date =2014-01-01T01:23:07.027 / Z inertial = -3.9502712349237726E-8
Post-processing:
node crossing - detector1: Date =2014-01-01T00:32:40.476 / Z inertial = 0.007229913089589053
node crossing - detector1: Date =2014-01-01T01:23:07.027 / Z inertial = -3.9502712349237726E-8
node crossing - detector2: Date =2014-01-01T01:23:20.000 / Z inertial = -95730.44875635671
No issue during the first propagation, but during the second one, detector2 only returns the final SpacecraftState.
I also tried to run the second propagation in MasterMode, with a FixedStepHandler =>detector2 will go through eventOccurred() for each step, instead of each node.
(from redmine: issue id 138, created on 2013-05-31, closed on 2013-05-31)