In [1]:
from cutiepy import *
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

Rabi Oscillations

Simulating the Full Hamiltonian

$\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]:
initial_state = basis(2, 0)
initial_state


Out[2]:
$$\text{Ket }{| {{0}}_{{\tiny N\normalsize 2}} \rangle} \text{ on the space }\mathbb{C}^{2}\text{ with numerical content: }$$ $$\begin{equation*}\left(\begin{array}{*{11}c}1.0\\0.0\\\end{array}\right)\end{equation*}$$

In [3]:
ω0 = 1
Δ = 0.002
Ω = 0.005
ts = 2*np.pi/Ω*np.linspace(0,1,40)
H = ω0/2 * sigmaz() + Ω * sigmax() * sin((ω0+Δ)*t)
H


Out[3]:
$${\left( {{0.5}\tiny\times\normalsize{\hat{σ}_{z}}}+{{0.005}\tiny\times\normalsize{\operatorname{sin}\left( {{{1.002}\tiny\times\normalsize{t}}} \right)}\tiny\times\normalsize{\hat{σ}_{x}}} \right)}$$

In [4]:
res = sesolve(H, initial_state, ts)


Generating cython code...
Compiling cython code...
Running cython code...
Starting at 10/20 13:55:17.
Finishing at 10/20 13:55:17.
Total time: 0 seconds.
Formatting the output...

In [5]:
σz_expect = expect(sigmaz(), res)

In [6]:
plt.plot(ts*Ω/np.pi, σz_expect, 'r.', label='numerical result')
Ωp = (Ω**2+Δ**2)**0.5
plt.plot(ts*Ω/np.pi, 1-(Ω/Ωp)**2*2*np.sin(Ωp*ts/2)**2, 'b-',
         label=r'$1-2(\Omega^\prime/\Omega)^2\sin^2(\Omega^\prime t/2)$')
plt.title(r'$\langle\sigma_z\rangle$-vs-$t\Omega/\pi$ at '
          r'$\Delta/\Omega=%.2f$, $\omega_0/\Omega=%.2f$'%(Δ/Ω, ω0/Ω))
plt.ylim(-1,1)
plt.legend(loc=3);


With Rotating Wave Approximation

$\hat{H}^\prime = e^{i\hat{H}_0 t}\hat{H} e^{-i\hat{H}_0 t} \approx \frac{\Delta}{2} \hat{\sigma}_z + \frac{\Omega}{2} \hat{\sigma}_x$


In [7]:
Hp = Δ/2 * sigmaz() + Ω/2 * sigmax()
Hp


Out[7]:
$${\left( {{0.0025}\tiny\times\normalsize{\hat{σ}_{x}}}+{{0.001}\tiny\times\normalsize{\hat{σ}_{z}}} \right)}$$

In [8]:
res = sesolve(Hp, initial_state, ts)


Generating cython code...
Compiling cython code...
Running cython code...
Starting at 10/20 13:55:25.
Finishing at 10/20 13:55:25.
Total time: 0 seconds.
Formatting the output...

In [9]:
σz_expect = expect(sigmaz(), res)

In [10]:
plt.plot(ts*Ω/np.pi, σz_expect, 'r.', label='numerical result')
Ωp = (Ω**2+Δ**2)**0.5
plt.plot(ts*Ω/np.pi, 1-(Ω/Ωp)**2*2*np.sin(Ωp*ts/2)**2, 'b-',
         label=r'$1-2(\Omega^\prime/\Omega)^2\sin^2(\Omega^\prime t/2)$')
plt.title(r'$\langle\sigma_z\rangle$-vs-$t\Omega/\pi$ at '
          r'$\Delta/\Omega=%.2f$ in RWA'%(Δ/Ω))
plt.ylim(-1,1)
plt.legend(loc=3);


Coherent State in a Harmonic Oscillator

$|\alpha\rangle$ evolving under $\hat{H} = \hat{n}$


In [11]:
N_cutoff = 40
α = 2.5
initial_state = coherent(N_cutoff, α)
initial_state


Out[11]:
$$\text{Ket }{| {{\tiny\alpha\normalsize 2.50}}_{{\tiny N\normalsize 40}} \rangle} \text{ on the space }\mathbb{C}^{40}\text{ with numerical content: }$$ $$\begin{equation*}\left(\begin{array}{*{11}c}0.044\\0.110\\0.194\\0.280\\0.350\\\vdots\\3.661\times10^{-08}\\1.525\times10^{-08}\\6.270\times10^{-09}\\2.543\times10^{-09}\\1.018\times10^{-09}\\\end{array}\right)\end{equation*}$$

In [12]:
H = num(N_cutoff)
H


Out[12]:
$$\text{Operator }{\hat{{n}}_{{40}}} \text{ on the space }\mathbb{C}^{40}\text{ with numerical content: }$$ $$\begin{equation*}\left(\begin{array}{*{11}c}0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 1.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 2.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 3.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 4.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \vdots & \vdots\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 35.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 36.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 37.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 38.0 & 0.0\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 39.0\\\end{array}\right)\end{equation*}$$

In [13]:
ts = 2*np.pi*np.linspace(0,1,41)
res = sesolve(H, initial_state, ts)
a = destroy(N_cutoff)
a_expect = expect(a, res, keep_complex=True)


Generating cython code...
Compiling cython code...
Running cython code...
Starting at 10/20 13:55:38.
Finishing at 10/20 13:55:38.
Total time: 0 seconds.
Formatting the output...

In [14]:
plt.figure(figsize=(4,4))
plt.plot(np.real(a_expect), np.imag(a_expect), 'b-')
for t, alpha in list(zip(ts,a_expect))[:40:4]:
    plt.plot(np.real(alpha), np.imag(alpha), 'r.')
    plt.text(np.real(alpha), np.imag(alpha), r'$t=%.1f\pi$'%(t/np.pi), fontsize=14)
plt.title(r'$\langle\hat{a}\rangle$-vs-$t$')
plt.ylabel(r'$\mathcal{I}(\alpha)$')
plt.xlabel(r'$\mathcal{R}(\alpha)$');


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 [15]:
ω = 1
g = 0.1
ts = np.pi/g*np.linspace(0,1,150)
N_cutoff = 50
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()))
H0 + Hp


Out[15]:
$${\left( {{0.5}\tiny\times\normalsize{{\hat{{I}}_{{50}}}\tiny\otimes\normalsize{\hat{σ}_{z}}}}+{{0.1}\tiny\times\normalsize{\left( {{\hat{{a^\dagger}}_{{50}}}\tiny\otimes\normalsize{\hat{σ}_{-}}}+{{\hat{{a}}_{{50}}}\tiny\otimes\normalsize{\hat{σ}_{+}}} \right)}}+{{\hat{{n}}_{{50}}}\tiny\otimes\normalsize{\hat{{I}}_{{2}}}} \right)}$$

Definite Photon State


In [16]:
n = 3
n_p = tensor(basis(N_cutoff,n), basis(2,0))
np1_m = tensor(basis(N_cutoff,n+1), basis(2,1))
n_p


Out[16]:
$${|{3}_{\tiny N\normalsize 50},{0}_{\tiny N\normalsize 2}\rangle}$$

In [17]:
res = sesolve(H0 + Hp, n_p, ts)


Generating cython code...
Compiling cython code...
Running cython code...
Starting at 10/20 13:56:05.
Finishing at 10/20 13:56:05.
Total time: 0 seconds.
Formatting the output...

In [18]:
ovlps = overlap([n_p, np1_m], res)
plt.plot(ts*g/np.pi, np.abs(ovlps)**2)
plt.legend([r'$|%d,+\rangle$'%n, r'$|%d,-\rangle$'%(n+1)])
plt.title(r'Population-vs-$gt/\pi$');



In [19]:
n = 8
n_p = tensor(basis(N_cutoff,n), basis(2,0))
np1_m = tensor(basis(N_cutoff,n+1), basis(2,1))
res = sesolve(H0 + Hp, n_p, ts)
ovlps = overlap([n_p, np1_m], res)
plt.plot(ts*g/np.pi, np.abs(ovlps)**2)
plt.legend([r'$|%d,+\rangle$'%n, r'$|%d,-\rangle$'%(n+1)])
plt.title(r'Population-vs-$gt/\pi$');


Generating cython code...
Compiling cython code...
Running cython code...
Starting at 10/20 13:56:12.
Finishing at 10/20 13:56:13.
Total time: 0 seconds.
Formatting the output...

Coherent State


In [20]:
alpha = 5
coh = tensor(coherent(N_cutoff, alpha), basis(2,0))
coh


Out[20]:
$${|{\tiny\alpha\normalsize 5.00}_{\tiny N\normalsize 50},{0}_{\tiny N\normalsize 2}\rangle}$$

In [21]:
ts = 80/g*np.linspace(0,1,4000)
res = sesolve(H0 + Hp, coh, ts)
inversion = expect(tensor(identity(N_cutoff), sigmaz()), res)


Generating cython code...
Compiling cython code...
Running cython code...
Starting at 10/20 13:56:21.
Finishing at 10/20 13:56:26.
Total time: 5 seconds.
Formatting the output...

In [22]:
plt.plot(ts*g, inversion)
plt.title(r'$\langle \hat{\sigma}_z \rangle$-vs-$gt$');