Incorrect copy of the additional state when adding an IntegratedEphemeris to a propagator
Hello, I think that I found a bug in the ephemeris state provider after a numerical propagation with several additional equations which have more than one additional parameter. Indeed this function in the inner class LocalGenerator of the IntegratedEphemeris class combines all additional states and returns only the relevant part of the array.
public double[] getAdditionalState(final SpacecraftState state) {
// extract the part of the interpolated array corresponding to the additional state
final double[] combined = getInterpolatedState(state.getDate()).getSecondaryState(1);
return Arrays.copyOfRange(combined, index, index + dimension);
}
My concern is that the index is not correct if the previous additional state has a dimension greater than one. The result is that the additional states are mixed and incorrect when the state is retrieved from the ephemeris.
I think that changing these lines:
// set up providers to map the final elements of the model array to additional states
for (int i = 0; i < equations.length; ++i) {
addAdditionalStateProvider(new LocalGenerator(equations[i], i, dimensions[i]));
}
by these :
int currentIndex=0;
for (int i = 0; i < equations.length; ++i) {
addAdditionalStateProvider(new LocalGenerator(equations[i], currentIndex, dimensions[i]));
currentIndex+=dimensions[i];
}
}
solves the issue
Edited by Theo Nguyen