Mercurial > repos > public > sbplib
view +time/+rk/rungekutta.m @ 1037:2d7ba44340d0 feature/burgers1d
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 18 Jan 2019 09:02:02 +0100 |
parents | c6fcee3fcf1b |
children |
line wrap: on
line source
% Takes one time step of size dt using the rungekutta method % starting from v_0 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