Generate an ephemeris after a propagation with multiple Additional Derivative Providers (V11.1)

Hello!
I would like to upgrade my application to Orekit V11.1 and I get the following error when I try to retrieve an ephemeris after a propagation with multiple additional derivative providers… (It seems to work well however if there is only one provider)

java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1

   at org.hipparchus.ode.ODEState.getSecondaryState(ODEState.java:156)
   at org.orekit.propagation.integration.IntegratedEphemeris$LocalGenerator.getAdditionalState(IntegratedEphemeris.java:291)
   at org.orekit.propagation.AbstractPropagator.updateAdditionalStates(AbstractPropagator.java:232)
   at org.orekit.propagation.integration.IntegratedEphemeris.getInitialState(IntegratedEphemeris.java:261)
   at org.orekit.propagation.AbstractPropagator.propagate(AbstractPropagator.java:263)

Here is the test :

public void testAdditionalDerivatives() {

        Orbit initialOrbit = createInitialOrbit();
        NumericalPropagatorBuilder builder = new NumericalPropagatorBuilder(initialOrbit, new DormandPrince853IntegratorBuilder(0.02, 0.2, 1.), PositionAngle.TRUE, 10);
        NumericalPropagator propagator = builder.buildPropagator(builder.getSelectedNormalizedParameters());

        IntStream.range(0, 2).mapToObj(i -> new EmptyDerivativeProvider("test_provider_"+i, new double[]{0.0})).forEach(provider -> addDerivativeProvider(propagator, provider));

        EphemerisGenerator generator = propagator.getEphemerisGenerator();
        propagator.propagate(initialOrbit.getDate().shiftedBy(600));
        BoundedPropagator ephemeris = generator.getGeneratedEphemeris();
        ephemeris.propagate(initialOrbit.getDate().shiftedBy(300));
    }

private void addDerivativeProvider(NumericalPropagator propagator, EmptyDerivativeProvider provider) {
        SpacecraftState initialState = propagator.getInitialState();
        propagator.setInitialState(initialState.addAdditionalState(provider.getName(), provider.getInitialState()));
        propagator.addAdditionalDerivativesProvider(provider);
    }

And here is an empty provider for test purposes:

public class EmptyDerivativeProvider implements AdditionalDerivativesProvider {

        private final String name;
        private final double[] state;

        public EmptyDerivativeProvider(String name, double[] state) {
            this.name = name;
            this.state = state;
        }

        @Override
        public double[] derivatives(SpacecraftState s) {
            return new double[getDimension()];
        }

        @Override
        public String getName() {
            return name;
        }

        @Override
        public int getDimension() {
            return state.length;
        }

        public double[] getInitialState() {
            return state;
        }
    }

Do you know if there is anything that is not correctly initialized ?
Thanks a lot for your time :slight_smile:

It is a bug!
I am working on it.

I have created issue 919
referencing this bug.

I have fixed it and pushed the fix to the develop branch.

Thank you very much for the fix, it helps a lot!
Do you think that it could be included in the 11.2 release or do you have any idea of the date for the next one?

I think it will be in the upcoming 11.1.2, which should be available really soon.

ok, it’s really nice, thanks angain!

Hello,

I am opening the topic again because I think that there is still a bug when the additional equations have more than one dimension. (The values of the additional parameters are mixed and incorrect if there is an additional equation and a covariance matrix propagation at the same time for example)

I created the #issue 925, with a solution that I found.

Thank you in advance for the fix!