Mercurial > repos > public > sbplib
annotate +time/+expint/Magnus_4.m @ 511:57f3493f851b feature/quantumTriangles
Added sqrt of Ji in the right places, not sure about the interfaces, will not test it properly now
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Thu, 08 Jun 2017 10:33:36 +0200 |
parents | 71908bbce2e1 |
children | 4ef2d2a493f1 |
rev | line source |
---|---|
510
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
1 % Takes one time step of size k using a fourth order magnus integrator |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
2 % starting from v_0 and where the function F(v,t) gives the |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
3 % time derivatives. |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
4 function v = Magnus_4(v,D, t , k) |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
5 |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
6 if isa(D,'function_handle') |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
7 % v = krylov(k*D(t +k/2*t),v); |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
8 c1 = 1/2 - sqrt(3)/6; |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
9 c2 = 1/2 + sqrt(3)/6; |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
10 |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
11 A1 = D(t +c1*k); |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
12 A2 = D(t + c2*k); |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
13 Omega = k/2*(A1 + A2) + sqrt(3)*k^2/12*(A1*A2-A2*A1); |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
14 v = expm(Omega)*v; |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
15 else |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
16 %v = krylov(k*D,v); |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
17 v = expm(k*D)*v; |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
18 end |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
19 |
71908bbce2e1
tried to add 4th order magnus integrator which does not work
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff
changeset
|
20 end |