In [1]:

from cutiepy import *
import qutip
import numpy as np
cutiepy.interactive.INTERACTIVE = False



# Rabi Oscillations

$\hat{H} = \hat{H}_0 + \Omega \sin((\omega_0+\Delta)t) \hat{\sigma}_x$

$\hat{H}_0 = \frac{\omega_0}{2}\hat{\sigma}_z$



In [2]:

#setup
ω0 = 1
Δ = 0.002
Ω = 0.005
ts = 2*np.pi/Ω*np.linspace(0,1,40)




In [3]:

#cutiepy
initial_state = basis(2, 0)
H = ω0/2 * sigmaz() + Ω * sigmax() * sin((ω0+Δ)*t)
%time res = sesolve(H, initial_state, ts)
%time res = sesolve(H, initial_state, ts)
res[-1]




CPU times: user 1.53 s, sys: 20 ms, total: 1.55 s
Wall time: 5.53 s
CPU times: user 48 ms, sys: 0 ns, total: 48 ms
Wall time: 47.1 ms

Out[3]:

$$\text{Anonymous }\text{Ket }{| {\tiny\boxed{{K}_{14640332...}}\normalsize}_{} \rangle} \text{ on the space }\mathbb{C}^{2}\text{ with numerical content: }$$
$$\begin{equation*}\left(\begin{array}{*{11}c}(-0.384+0.896j)\\(0.068+0.212j)\\\end{array}\right)\end{equation*}$$




In [4]:

#qutip
initial_state = qutip.basis(2, 0)
H = [ω0/2 * qutip.sigmaz(), [Ω * qutip.sigmax(), 'sin(%f*t)'%(ω0+Δ)]]
opts = qutip.Options(rhs_reuse=True)
%time res = qutip.sesolve(H, initial_state, ts, [], options=opts)
%time res = qutip.sesolve(H, initial_state, ts, [], options=opts)
res.states[-1]




CPU times: user 704 ms, sys: 20 ms, total: 724 ms
Wall time: 2.14 s
CPU times: user 196 ms, sys: 0 ns, total: 196 ms
Wall time: 196 ms

Out[4]:

Quantum object: dims = [[2], [1]], shape = [2, 1], type = ket\begin{equation*}\left(\begin{array}{*{11}c}(-0.384+0.896j)\\(0.068+0.212j)\\\end{array}\right)\end{equation*}



# Jaynes-Cummings Revival

$\hat{H} = \hat{H}_0 + \hat{H}^\prime$

$\hat{H}_0 = \omega \hat{n} + \omega \frac{1}{2} \hat{\sigma}_z$

$\hat{H}^\prime = g (\hat{\sigma}_+\hat{a} + \hat{\sigma}_-\hat{a}^\dagger)$



In [5]:

#setup
ω = 1
g = 0.1
N_cutoff = 40
alpha = 4
ts = 50/g*np.linspace(0,1,8000)




In [6]:

#cutiepy
H0 = ω*(tensor(num(N_cutoff), identity(2)) + 0.5 * tensor(identity(N_cutoff), sigmaz()))
Hp = g*(tensor(destroy(N_cutoff),sigmap()) + tensor(create(N_cutoff), sigmam()))
coh = tensor(coherent(N_cutoff, alpha), basis(2,0))
%time res = sesolve(H0 + Hp, coh, ts)
%time res = sesolve(H0 + Hp, coh, ts)




CPU times: user 3.47 s, sys: 88 ms, total: 3.56 s
Wall time: 7.38 s
CPU times: user 1.68 s, sys: 40 ms, total: 1.72 s
Wall time: 1.7 s




In [7]:

#qutip
H0 = ω*(qutip.tensor(
qutip.num(N_cutoff),
qutip.identity(2))
+0.5*qutip.tensor(
qutip.identity(N_cutoff),
qutip.sigmaz()))
Hp = g*(qutip.tensor(
qutip.destroy(N_cutoff),
qutip.sigmap())
+qutip.tensor(
qutip.create(N_cutoff),
qutip.sigmam()))
coh = qutip.tensor(qutip.coherent(N_cutoff, alpha), qutip.basis(2,0))
opts = qutip.Options(rhs_reuse=True)
%time res = qutip.sesolve(H0 + Hp, coh, ts, [], options=opts)
%time res = qutip.sesolve(H0 + Hp, coh, ts, [], options=opts)




CPU times: user 7.96 s, sys: 264 ms, total: 8.23 s
Wall time: 7.92 s
CPU times: user 8 s, sys: 0 ns, total: 8 s
Wall time: 7.99 s