comparison +time/+expint/Magnus_4.m @ 510:71908bbce2e1 feature/quantumTriangles

tried to add 4th order magnus integrator which does not work
author Ylva Rydin <ylva.rydin@telia.com>
date Fri, 02 Jun 2017 17:46:01 +0200
parents
children 4ef2d2a493f1
comparison
equal deleted inserted replaced
509:566304a5733e 510:71908bbce2e1
1 % Takes one time step of size k using a fourth order magnus integrator
2 % starting from v_0 and where the function F(v,t) gives the
3 % time derivatives.
4 function v = Magnus_4(v,D, t , k)
5
6 if isa(D,'function_handle')
7 % v = krylov(k*D(t +k/2*t),v);
8 c1 = 1/2 - sqrt(3)/6;
9 c2 = 1/2 + sqrt(3)/6;
10
11 A1 = D(t +c1*k);
12 A2 = D(t + c2*k);
13 Omega = k/2*(A1 + A2) + sqrt(3)*k^2/12*(A1*A2-A2*A1);
14 v = expm(Omega)*v;
15 else
16 %v = krylov(k*D,v);
17 v = expm(k*D)*v;
18 end
19
20 end