diff +time/+expint/Magnus_mp.m @ 505:49bc2929dfb1 feature/quantumTriangles

Added the midpont magnus exponential integrator
author Ylva Rydin <ylva.rydin@telia.com>
date Thu, 18 May 2017 11:44:29 +0200
parents
children 566304a5733e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+time/+expint/Magnus_mp.m	Thu May 18 11:44:29 2017 +0200
@@ -0,0 +1,14 @@
+% Takes one time step of size k using the magnus midpoinr
+% starting from v_0 and where the function F(v,t) gives the
+% time derivatives.
+function v = Magnus_mp(v,D, t , k)
+
+if isa(D,'function_handle')
+   % v = krylov(k*D(t +k/2*t),v);
+   v = expm(k*D(t +k/2*t))*v;
+else
+   %v = krylov(k*D,v);
+   v = expm(k*D)*v;
+end
+
+end
\ No newline at end of file