Mercurial > repos > public > sbplib
view +time/+rk/rungekutta.m @ 916:d1c1615bd1a5 feature/timesteppers
Add comment in butcherTableau about rk4-3/8 being irreducible.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 26 Nov 2018 16:08:54 -0800 |
parents | 8732d6bd9890 |
children | 878652b22157 |
line wrap: on
line source
% Takes one time step of size dt using the rungekutta method % starting from @arg v and where the function F(v,t) gives the % time derivatives. coeffs is a struct holding the RK coefficients % for the specific method. function v = rungekutta(v, t , dt, F, coeffs) % Compute the intermediate stages k k = zeros(length(v), coeffs.s); for i = 1:coeffs.s u = v; for j = 1:i-1 u = u + dt*coeffs.a(i,j)*k(:,j); end k(:,i) = F(u,t+coeffs.c(i)*dt); end % Compute the updated solution as a linear combination % of the intermediate stages. for i = 1:coeffs.s v = v + dt*coeffs.b(i)*k(:,i); end end