<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 QuTiP  example
Step1:  Two-level system
Step2:  Harmonic oscillator
Step3:  Zero temperature
Step4:  Finite temperature
Step5:  Storing states instead of expectation values
Step6:  Atom-Cavity
Step7:  Weak coupling
Step8:  In the weak coupling regime there is no significant difference between the Lindblad master equation and the Bloch-Redfield master equation.
Strong coupling
Step9:  In the strong coupling regime there are some corrections to the Lindblad master equation that is due to the fact system eigenstates are hybridized states with both atomic and cavity contributions.
Versions
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from qutip import *
Explanation: QuTiP  example: Bloch-Redfield Master Equation
End of explanation
delta = 0.0 * 2 * np.pi
epsilon = 0.5 * 2 * np.pi
gamma = 0.25
times = np.linspace(0, 10, 100)
H = delta/2 * sigmax() + epsilon/2 * sigmaz()
H
psi0 = (2 * basis(2, 0) + basis(2, 1)).unit()
c_ops = [np.sqrt(gamma) * sigmam()]
a_ops = [sigmax()]
e_ops = [sigmax(), sigmay(), sigmaz()]
result_me = mesolve(H, psi0, times, c_ops, e_ops)
result_brme = brmesolve(H, psi0, times, a_ops, e_ops, spectra_cb=[lambda w : gamma * (w > 0)])
plot_expectation_values([result_me, result_brme]);
b = Bloch()
b.add_points(result_me.expect, meth='l')
b.add_points(result_brme.expect, meth='l')
b.make_sphere()
Explanation: Two-level system
End of explanation
N = 10
w0 = 1.0 * 2 * np.pi
g = 0.05 * w0
kappa = 0.15
times = np.linspace(0, 25, 1000)
a = destroy(N)
H = w0 * a.dag() * a + g * (a + a.dag())
# start in a superposition state
psi0 = ket2dm((basis(N, 4) + basis(N, 2) + basis(N,0)).unit())
c_ops = [np.sqrt(kappa) * a]
a_ops = [[a + a.dag(),lambda w : kappa * (w > 0)]]
e_ops = [a.dag() * a, a + a.dag()]
Explanation: Harmonic oscillator
End of explanation
result_me = mesolve(H, psi0, times, c_ops, e_ops)
result_brme = brmesolve(H, psi0, times, a_ops, e_ops)
plot_expectation_values([result_me, result_brme]);
Explanation: Zero temperature
End of explanation
times = np.linspace(0, 25, 250)
n_th = 1.5
c_ops = [np.sqrt(kappa * (n_th + 1)) * a, np.sqrt(kappa * n_th) * a.dag()]
result_me = mesolve(H, psi0, times, c_ops, e_ops)
w_th = w0/np.log(1 + 1/n_th)
def S_w(w):
    if w >= 0:
        return (n_th + 1) * kappa
    else:
        return (n_th + 1) * kappa * np.exp(w / w_th)
    
a_ops = [[a + a.dag(),S_w]]
result_brme = brmesolve(H, psi0, times, a_ops, e_ops)
plot_expectation_values([result_me, result_brme]);
Explanation: Finite temperature
End of explanation
result_me = mesolve(H, psi0, times, c_ops, [])
result_brme = brmesolve(H, psi0, times, a_ops, [])
n_me = expect(a.dag() * a, result_me.states)
n_brme = expect(a.dag() * a, result_brme.states)
fig, ax = plt.subplots()
ax.plot(times, n_me, label='me')
ax.plot(times, n_brme, label='brme')
ax.legend()
ax.set_xlabel("t");
Explanation: Storing states instead of expectation values
End of explanation
N = 10
a = tensor(destroy(N), identity(2))
sm = tensor(identity(N), destroy(2))
psi0 = ket2dm(tensor(basis(N, 1), basis(2, 0)))
e_ops = [a.dag() * a, sm.dag() * sm]
Explanation: Atom-Cavity
End of explanation
w0 = 1.0 * 2 * np.pi
g = 0.05 * 2 * np.pi
kappa = 0.05
times = np.linspace(0, 5 * 2 * np.pi / g, 1000)
a_ops = [[(a + a.dag()),lambda w : kappa*(w > 0)]]
c_ops = [np.sqrt(kappa) * a]
H = w0 * a.dag() * a + w0 * sm.dag() * sm + g * (a + a.dag()) * (sm + sm.dag())
result_me = mesolve(H, psi0, times, c_ops, e_ops)
result_brme = brmesolve(H, psi0, times, a_ops, e_ops)
plot_expectation_values([result_me, result_brme]);
Explanation: Weak coupling
End of explanation
w0 = 1.0 * 2 * np.pi
g = 0.75 * 2 * np.pi
kappa = 0.05
times = np.linspace(0, 5 * 2 * np.pi / g, 1000)
c_ops = [np.sqrt(kappa) * a]
H = w0 * a.dag() * a + w0 * sm.dag() * sm + g * (a + a.dag()) * (sm + sm.dag())
result_me = mesolve(H, psi0, times, c_ops, e_ops)
result_brme = brmesolve(H, psi0, times, a_ops, e_ops)
plot_expectation_values([result_me, result_brme]);
Explanation: In the weak coupling regime there is no significant difference between the Lindblad master equation and the Bloch-Redfield master equation.
Strong coupling
End of explanation
from qutip.ipynbtools import version_table
version_table()
Explanation: In the strong coupling regime there are some corrections to the Lindblad master equation that is due to the fact system eigenstates are hybridized states with both atomic and cavity contributions.
Versions
End of explanation
<END_TASK>