Controlling the current of a cell - Extracting model dynamics (for example DAE) directly from the CasADi-solver

I am trying to control the current of a cell for a fast charging situation, while avoiding the plating (anode potential at the surface of the separator needs to be greater than 0V). In order to apply this in a control, I need to integrate the system dynamics of the cell in the optimization problem (for example the DAE that describes the cell dynamics). I thought of extracting this directly from the CasADi solver, as this is already computed when solving the model itself. How can I extract this? In this case do I need to define the model equations by myself?