Solving time-dependent Schrodinger equation using MATLAB ode45

后端 未结 1 995
独厮守ぢ
独厮守ぢ 2021-01-29 00:52

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

相关标签:
1条回答
  • 2021-01-29 01:15

    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:

    0 讨论(0)
提交回复
热议问题