Using qutip.mesolve() to calculate the time evolved Hamiltonian with time dependent variable

540 views Asked by At

I'm trying to find the time evolution of some initial state with a time dependent hailtonian where also the z variable (gradient of time evolution) is time dependent. Usually the qutip.mesolve() function can be used for this when the z variable is a constant and the Hamiltonian is defined as follows:

def hamiltonian_t(t,args):
          """ evaluate the hamiltonian at time t. """
          H0 = args[0]
          Hp = args[1]
          z  = args[2]
          return (1-t*z)*H0 + t*z*Hp 

This is a Hamiltonian that evolves from H0 to Hp. I then use qt.mesolve(hamiltonian_t,psi_init,tlist,[],[],H_args) with args = (H0,Hp,z).

But for the current problem with the time dependent z variable I have tried to define the Hamiltonian as follows:

def hamiltonian_t(tz,args):
          """ evaluate the hamiltonian at time t. """
          H0 = args[0]
          Hp = args[1]
          t  = tz[0]
          z  = tz[1]
          return (1-t*z)*H0 + t*z*Hp 

Here args = (H0,Hp) for some H0 and Hp. I then tried using qt.mesolve(hamiltonian_t,psi_init,tz,[],[],H_args) to calculate the time evolution where tz=[(tlist[0],z[0]),...,(tlist[-1],z[-1])]. I'm receiving the error TypeError: 'float' object is not subscriptable at the line t = tz[0]. I don't understand why I get this error because the input for tz is a list of tuples not floats. The mesolve function should then take every list element and evaluate the Hamiltonian, at least that's what I thought it did.

This function usually works for finding the time evolution when I have args = (H0,Hp,z) for some H0, Hp and z and I use qt.mesolve(hamiltonian_t,psi_init,tlist,[],[],H_args) , but my problem involves a z variable that is different for each t in tlist. Can anybody please help me define this function properly so that qutip.mesolve() can use the corresponding z for each time in tlist and calculate the time evolution?

0

There are 0 answers