Calculate an Qobjevo operator of qutip

112 Views Asked by At

I define a time-dependent operator in the form of an Qobjevo and pass it to sesolve() to solve for Schrodinger's equation. Below is an MWE.

from qutip import *
import numpy as np

tlist = np.linspace(0, np.pi / 2)
H = [
    sigmaz(),
    [sigmax(), 'cos(t)']
]
psi0 = basis(2, 1)
result = sesolve(H, psi0, tlist)

Now I want to check the time-dependent Hamiltonian at given times in tlist. How do I get a list of Hamiltonians, each at time tlist[i]? Which qutip function can I refer to?

2

There are 2 best solutions below

0
glS On

You could simply define a function returning the Hamiltonian at each time step:

def h(t):
    return sigmaz() + np.cos(t) * sigmax()
0
lzcostademoraes On

To access to the states of the evolution you use:

psi_t = result.state

which gives you a list of the time evolved states. A list of qObject of the Hamiltonian is:

sx,sy,sz = sigmax,sigmay,sigmaz
Ht = [sz + np.cos(t)*sx for t in tlist]

or a list oa arrays:

sx,sy,sz = sigmax,sigmay,sigmaz
Ht = [sz.full() + np.cos(t)*sx.full() for t in tlist]