0
$\begingroup$

The Schrodinger equation for time-dependent Hamiltonian is

$$i\hbar\frac{d}{dt}\psi(t) = H(t)\psi(t) \, .$$

I try to implement solve the Schrodinger equation for time-dependent Hamiltonian in ODE 45. However, because the Hamiltonian $H(t)$ is dependent on time, I do not know how to do interpolation in ode45. Can you give me some hints?

psi0 = [0 1];
H = [1 0;0 1]*cos(t); %this is wrong, I do not know how to implement this and pass it to ode45
hbar = 1;
t    = [0:1:100];
[T, psi] = ode45(dpsi, t, psi);
function dpsi = f(t, psi, H, psi0)
dpsi = (1/i)*H*psi;
$\endgroup$
  • $\begingroup$ Try the MATLAB ODE function ode15s instead of ode45, mathworks.com/help/matlab/ref/ode15s.html. You can specifiy a time-dependent "mass" matrix with ode15s. $\endgroup$ – Bill Greene Jun 23 '16 at 0:07
  • $\begingroup$ Thanks. I also heard that mass matrix can be defined for ode45 by adding extra row. Is that true? $\endgroup$ – Ka-Wa Yip Jun 23 '16 at 3:08
  • 1
    $\begingroup$ @kww why do you think there is a need to explicitly pass $H(t)$ into your ode45 call? You can just have the definition for $H(t)$ inside your function "dpsi". dpsi receives the current time stamp as one of its parameters. $\endgroup$ – okrzysik Jun 23 '16 at 7:13
  • 1
    $\begingroup$ Apparently I misunderstood your question. I thought you were looking for a convenient way to deal with the $ih$ term in your equation. Mass matrix would be useful for that. But after more careful reading, I am not sure what your question is. I have no experience with Schrodinger equation and your post doesn't provide much information. Is $\psi$ a vector of length two? $\endgroup$ – Bill Greene Jun 26 '16 at 12:04
  • 1
    $\begingroup$ I'm voting to close this question because it's a cross-post of stackoverflow.com/questions/37981618/…, and cross-posting is frowned upon. $\endgroup$ – Geoff Oxberry Jul 21 '16 at 21:43
1
$\begingroup$

Possibly this is what you want?

function schrodingerEqn
psi0 = [0 1];
hbar = 1;
t    = [0:1:100];
fh = @(t, psi) f(t, psi, hbar);
[T, psi] = ode45(fh, t, psi0);
figure; plot(T, real(psi(:,2)));
end

function dpsi = f(t, psi, hbar)
dpsi = 1/(hbar*i)*[1 0;0 1]*cos(t)*psi;
end
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.