When doing propagation, we can set up additional states one at a time, by registering several AdditionalStateProvider
instances that manage one additional state each. In the case of numerical propagators, we also have AdditionalDerivativesProvider
which manages differential equations.
In some cases, this may be insufficient or inefficient. I have one case where I need not to set up an additional state, but to modify the orbit itself, preserving the additional states.
I managed to do the former by creating a proxy propagator that extends AbstractAnalyticalPropagator
wrapping a regular propagator and implementing propagateOrbit
in such a way it calls propagate
on the wrapped propagator, extract the orbit, patch it, and let AbstractAnalyticalPropagator
finish building the state. This does allow modifying the orbit, but it does not preserve the additional states, since propagateOrbit
just returns an orbit.
I could perhaps have the proxy propagator set up a bunch of AdditionalStateProvider
too and extract the additional states one by one to add them. This would however imply either calling the propagate
method from the wrapped propagator several times (once for the orbit and once for each additional state), or setting up some fancy cache with lazy evaluation, and in all cases it would require knowing beforehand which states are in the wrapped propagator to set up additional states providers. This seems weird and inefficient.
I would like to be able to patch states directly in one go.
I see two ways to do it (both requiring API change, so it would have to wait for 13.0).
The first way would be to revamp the AdditionalStateProvider interface so instead of just returning the additional state it would build the new SpacecraftState. Currently, these providers are used in a loop that handle yields between providers. At the core of this loop, when a provider is apply, the state is updated by a single line:
updated = updated.addAdditionalState(provider.getName(), provider.getAdditionalState(updated));
This could be replaced by:
updated = provider.update(updated);
With such a change, one additional state provider could manage several states at once, and it could change the orbit, the attitude and the mass too.
Another way to achieve the same result would be to add a new dedicated interface (say StatePostProcessor
) and a corresponding addStatePostprocessor
method in Propagator
. We could reproduce the yield
mechanism too if users want to add several postprocessors.
I would prefer the first way, i.e. changing AdditionalStateProvider
because it is straightforward to do and simpler for users.
What do you think?