I have an equation system, constructed as $$\begin{split} \partial_tA&=f_1(A)\cdot f_2(B)\\ \partial_tB&=f_3(B)\cdot\partial_tf_4(A) \end{split}$$ with $f_1,\,f_2,\,f_4$ and $f_3$ nonlinear functions. One idea I had was to use the forward difference for $\partial_tf_4(A)$, i.e. $$\partial_tf_{4,(n)}(A)=\frac{f_{4,(n-1)}-f_{4,(n-2)}}{dt}$$ For that approach I would have to store the last two results for $f_4(A)$. Are there other approaches which can be used to solve this situation?
1 Answer
Its better to compute the time derivative as:
$$d_tf_4(A) =d_Af_4(A)\,d_tA $$ and rearrange your system of ODEs to have: $$ \left[\begin{matrix}1 & 0\\ -f_3(B)d_Af_4(A) & 1\end{matrix}\right]d_t\left[\begin{matrix}{A\\B}\end{matrix}\right]=\left[\begin{matrix}f_1(A)f_2(B)\\ 0\end{matrix}\right]$$ Which is shortly written with $\vec{W} = (A, B)^{T}$ $$M(\vec{W})d_t\vec{W}=\vec{F}(\vec{W})$$
The easiest way to solve it is applying the $\theta$ methods:
$$\frac{\vec{W}^{n+1}-\vec{W}^{n}}{\Delta t}=\theta M^{-1}(\vec{W}^{n+1})\vec{F}(\vec{W}^{n+1})+(1-\theta)M^{-1}(\vec{W}^{n})\vec{F}(\vec{W}^{n})$$ For $\theta=0$ you obtain the explicit Euler scheme, and for $\theta=1$ the implicit one. For $\theta=1/2$ you obtain a second order scheme in time (Crack-Nicholson method).
Tha two last proposed values for $\theta$ lead you with a nonlinear scheme for $\vec{W}^{n+1}$ that requires some iterative method to be solved.
Be careful with the singularity given by $\mathrm{det}{M}=0$ if any.