Mercurial > repos > public > sbplib
comparison +time/+rk/rungekutta_4.m @ 846:c6fcee3fcf1b feature/burgers1d
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 20 Sep 2018 17:51:19 +0200 |
parents | +time/+rk4/rungekutta_4.m@48b6fb693025 |
children |
comparison
equal
deleted
inserted
replaced
845:1e057b0f2fed | 846:c6fcee3fcf1b |
---|---|
1 % Takes one time step of size dt using the rungekutta method | |
2 % starting from v_0 and where the function F(v,t) gives the | |
3 % time derivatives. | |
4 function v = rungekutta_4(v, t , dt, F) | |
5 k1 = F(v ,t ); | |
6 k2 = F(v+0.5*dt*k1,t+0.5*dt); | |
7 k3 = F(v+0.5*dt*k2,t+0.5*dt); | |
8 k4 = F(v+ dt*k3,t+ dt); | |
9 v = v + (1/6)*(k1+2*(k2+k3)+k4)*dt; | |
10 end |