# Runge-Kutta time stepping any comments?

**URL:** <https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860>\
**Category:** General Discussion\
**Created:** [January 1, 2024, 8:28pm UTC](https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860 "2024-01-01T20:28:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [January 1, 2024, 8:28pm UTC](https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860/1 "2024-01-01T20:28:10Z")

</div>

Most of all of the examples I’ve seen here use Euler but it is possible to  
do FEM along time and there is a lot of literature I found, mostly from years  
ago combining RK with FEM. Whatever happened to that ?

Thanks.

---

<div class="post-metadata">

**Author:** ![mathmerizing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/mathmerizing/32/1941_2.png) [@mathmerizing](https://community.freefem.org/u/mathmerizing)\
**Post date:** [January 2, 2024, 11:11am UTC](https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860/2 "2024-01-02T11:11:39Z")

</div>

Backward Euler discretizations are easier to implement and easier to proof mathematical statements.  
Nevertheless, in fluid mechanics many people use (Shifted) Crank-Nicolson, Fractional Step Theta, BDF2, or other complicated schemes for time discretization, because backward Euler would damp out the solution too much and would require a very small time step size. There is also a lot of research on RK, IRK, DIRK, … and this is also in my opinion a good option for time discretization. There are also some groups working on finite elements also for the time discretization, either full space-time FEM or tensor-product space-time FEM, but this can be a bit cumbersome to implement.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 2, 2024, 11:52am UTC](https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860/3 "2024-01-02T11:52:38Z")

</div>

Most of the methods you are mentioning are implemented inside PETSc TS [https://arxiv.org/pdf/1806.01437.pdf](https://arxiv.org/pdf/1806.01437.pdf) which is available within FreeFEM via `load "PETSc"` + `TSSolve()`.

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [January 2, 2024, 2:18pm UTC](https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860/4 "2024-01-02T14:18:06Z")

</div>

Thanks everyone. I guess in general I like to try to use Fourier or LaPlace methods  
and typically they seem to make intuitive sense with differential equations  
but they aren’t real good on discontinuities or shock. Right now however conservation  
of particles or energy seems to be a bigger concern. I did have a problem conserving  
integrated molecule densties ( total particles ) with adpative meshes too.

---

<div class="post-metadata">

**Author:** ![stergopilot](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@stergopilot](https://community.freefem.org/u/stergopilot)\
**Post date:** [April 29, 2024, 12:24pm UTC](https://community.freefem.org/t/runge-kutta-time-stepping-any-comments/2860/5 "2024-04-29T12:24:37Z")

</div>

I want to solve Navier-Stokes equation with Runge-Kutta method and characteristic Galerkin method. For example, the standard RK4 method is: y\_{n+1}=y\_n+\frac{h}{6}(K\_1+2K\_2+2K\_3+K\_4), K\_1=f(x\_n,y\_n), K\_2=f(x\_n+\frac{h}{2},x\_n+\frac{h}{2}K\_1),K\_3=f(x\_n+\frac{h}{2},x\_n+\frac{h}{2}K\_2),K\_4=f(x\_n+h,y\_n+hK\_3).  
In FreeFem++ manual, the convection operator `convect` can be used for the convection term: \begin{aligned} \frac{1}{\tau}\left(u^{n+1}-u^n \circ X^n\right)-\nu \Delta u^{n+1}+\nabla p^{n+1} & =0, \\ \nabla \cdot u^{n+1} & =0\end{aligned}.  
How do I combine them?
