In [1]:
%pylab inline
In [2]:
from qutip import *
In [3]:
def visualize(result):
fig, ax = subplots(figsize=(12,6))
for idx, e in enumerate(result.expect):
ax.plot(result.times, e, label="%d" % idx)
ax.legend()
Consider two coupled qubits:
In [4]:
H0 = -2*pi*(tensor(sigmaz(), identity(2)) + tensor(identity(2), sigmaz()))
Hint = 2*pi*0.1 * tensor(sigmax(), sigmax())
H = H0 + Hint
In [5]:
H
Out[5]:
In [6]:
energy_level_diagram([H], figsize=(6,6), show_ylabels=True);
If the highest energy state is not initially occupied, and if we neglect thermal excitations, it will never be occupied, and therefore not really necessary to include in a calculation of for example the dynamics of the three lowest states.
In [7]:
psi_gg = tensor(basis(2, 0), basis(2, 0))
psi_eg = tensor(basis(2, 1), basis(2, 0))
psi_ge = tensor(basis(2, 0), basis(2, 1))
psi_ee = tensor(basis(2, 1), basis(2, 1))
c_op1 = tensor(destroy(2), identity(2))
c_op2 = tensor(identity(2), destroy(2))
In [8]:
psi0 = psi_eg
In [9]:
tlist = linspace(0, 15, 100)
result = mesolve(H, psi0, tlist,
[sqrt(0.1) * c_op1, sqrt(0.25) * c_op2],
[ket2dm(psi_gg), ket2dm(psi_ge), ket2dm(psi_eg), ket2dm(psi_ee)])
In [10]:
visualize(result)
Note that the fourth state is not included in the dynamics at all. So...
In [11]:
# We are only interested in these states
keep_states = [0, 1, 2]
# or equivalently, not interested in these states
remove_states = [3]
In [12]:
H_sub = H.eliminate_states(remove_states)
H_sub
Out[12]:
In [13]:
H_sub = H.extract_states(keep_states)
H_sub
Out[13]:
In [14]:
energy_level_diagram([H_sub], figsize=(6,6), show_ylabels=True);
In [15]:
psi0_sub = psi0.extract_states(keep_states, normalize=True)
psi0_sub
Out[15]:
In [16]:
c_op1_sub = c_op1.extract_states(keep_states)
c_op2_sub = c_op2.extract_states(keep_states)
In [17]:
psi_gg_sub = psi_gg.extract_states(keep_states)
psi_eg_sub = psi_eg.extract_states(keep_states)
psi_ge_sub = psi_ge.extract_states(keep_states)
In [18]:
tlist = linspace(0, 15, 100)
result = mesolve(H_sub, psi0_sub, tlist,
[sqrt(0.1) * c_op1_sub, sqrt(0.25) * c_op2_sub],
[ket2dm(psi_gg_sub), ket2dm(psi_ge_sub), ket2dm(psi_eg_sub)])
In [19]:
visualize(result)
Voila! Same results with fewer quantum states in the calculation, and therefore potentially more efficient.
In [20]:
from qutip.ipynbtools import version_table
version_table()
Out[20]: