Solving time-dependent Schrodinger equation using MATLAB ode45

元气小坏坏 提交于 2019-12-31 06:05:05

问题


The Schrodinger equation for a time-dependent Hamiltonian is:

I try to implement a solver for the Schrodinger equation for a time-dependent Hamiltonian in ode45. 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;

I also try to come up with a solution of matrix interpolation in MATLAB: Interpolation that involve a matrix.


回答1:


H is just an identity matrix in your case, so we can just multiply it with the psi vector to get back the psi vector itself. Then, we bring i*hbar to the right-hand-side of the equation so that the final equation is in a form that ode45 accepts. Finally, we use the following code to solve for psi:

function schrodinger_equation

  psi0 = [0;1];
  hbar = 1;
  t = [0 100];
  [T,psi] = ode45(@(t,psi)dpsi(t,psi,hbar),t,psi0);

  for i = 1:length(psi0)
    figure
    plot(T,real(psi(:,i)),T,imag(psi(:,i)))
    xlabel('t')
    ylabel('Re(\psi) or Im(\psi)')
    title(['\psi_0 = ' num2str(psi0(i))])
    legend('Re(\psi)','Im(\psi)','Location','best')
  end

end

function rhs = dpsi(t,psi,hbar)
  rhs = 1/(1i*hbar)*cos(t).*ones(2,1);
end

Note that I have plotted the two components of psi separately and for each such plot, I have also plotted the real and imaginary components separately. Here are the plots for two different values of psi0:



来源:https://stackoverflow.com/questions/37981618/solving-time-dependent-schrodinger-equation-using-matlab-ode45

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!