This notebook uses sympy to symbolically solve the Schrödinger equation for a two-level system, resulting in the exact analytic expressions for the complex amplitudes and the population dynamics of Rabi cycling.
The particular variation in this notebook is for a Hamiltonian written in Terms of Pauli matrices, specifically a drift Hamiltonian of $\Delta \hat{S}_z$ where $\hat{S}_z = \frac{1}{2} \hat{\sigma}_z$, so that the energy levels are symmetric around zero. This symmetry eliminates the global phase induced otherwise, and thus leads to a simpler expression.
from sympy import Function, symbols, sqrt, Eq, Abs, exp, cos, sin, Matrix, dsolve, solve
from sympy import I as 𝕚
g = Function('g')
e = Function('e')
t = symbols('t', positive=True)
Δ = symbols('Delta', real=True)
Ω0 = symbols('Ω_0', real=True)
Ω = symbols('Omega', real=True)
Ĥ = Matrix([
[ -Δ/2, -Ω0/2],
[-Ω0/2, Δ/2]
])
Ĥ
TDSE_system = [
g(t).diff(t) + 𝕚 * (Ĥ[0,0] * g(t) + Ĥ[0,1] * e(t)),
e(t).diff(t) + 𝕚 * (Ĥ[1,0]* g(t) + Ĥ[1,1] * e(t)),
]
sols_gen = dsolve(TDSE_system, [g(t), e(t)])
effective_rabi_freq = {
Ω: sqrt(Δ**2 + Ω0**2)
}
Eq(Ω, effective_rabi_freq[Ω])
find_Ω = {
effective_rabi_freq[Ω]: Ω
}
sols_gen[0].subs(find_Ω)
sols_gen[1].subs(find_Ω)
boundary_conditions = {
t: 0,
g(t): 1,
e(t) : 0,
}
find_Ω0sq = {
Ω**2 - Δ**2: Ω0**2
}
C1, C2 = symbols("C1, C2")
_integration_constants = solve(
[sol.subs(find_Ω).subs(boundary_conditions) for sol in sols_gen],
[C1, C2]
)
integration_constants = {
k: v.subs(find_Ω0sq)
for (k, v) in _integration_constants.items()
}
Eq(C1, integration_constants[C1])
Eq(C2, integration_constants[C2])
def simplify_sol_g(sol_g):
rhs = (
sol_g
.rhs
.rewrite(sin)
.expand()
.collect(𝕚)
.subs(effective_rabi_freq)
.simplify()
.subs(find_Ω)
)
return Eq(sol_g.lhs, rhs)
sol_g = simplify_sol_g(sols_gen[0].subs(find_Ω).subs(integration_constants))
sol_g
sol_e = (
sols_gen[1]
.subs(find_Ω)
.subs(integration_constants)
.expand()
.rewrite(sin)
.expand()
)
sol_e
pop_e = (sol_e.rhs * sol_e.rhs.conjugate()).rewrite(sin).expand()
Eq(Abs(e(t))**2, pop_e)