How to output values of forces during a propagation

Hi all,

I want to get the values of forces, especially the drag one, during the propagation, and I’m a little lost.

One method I thought is to call getAllForceModels() and then to call acceleration() on my DragForce model. However if I want that force value to be stored over a timespan (ephemeris-like), I would need to loop over propagate() as I’m doing this on propagator outside of the propagate() function.

I think there may be more efficient ways to retrieve those informations as it is already computed during the propagation. It seems that making my own AdditionalDataProvider could do the trick to store the computed forces inside the SpacecraftState :thinking: Am I in the right direction, or is there a more efficient and direct approach to retrieve those forces that the propagator is already computing ?

Thanks

Hi there,

Sounds like you could use a custom OrekitStepHandler.
Link it to the drag force, evaluate it at each step and store. This works for pretty much any time series you can think ok

Cheers,
Romain

Thanks for this suggestion Romain ! In the meantime I wrote something based on AdditionalDataProvider, I found more inspiration when I understood it was previously named AdditionalStateProvider :smiley:

Here is a python solution:

class DragForceProvider(PythonAdditionalDataProvider):

    def __init__(self, drag_force_model):
        super().__init__()
        self._drag_force_model = drag_force_model
        self._name = "drag_force"

    def getName(self)->str:
        return self._name

    def yields(self, state)->bool:
        return False

    def getAdditionalData(self, state)->Vector3D:
        drag_acceleration = self._drag_force_model.acceleration(state, self._drag_force_model.getParameters())
        mass = state.getMass()
        return drag_acceleration.scalarMultiply(mass)

    def update(self, state)->SpacecraftState:
        return state.addAdditionalData(self.getName(), self.getAdditionalData(state))

I don’t know if a solution based on OrekitStepHandler might run faster :thinking: