[1]:
import quanguru as qg
import numpy as np
import matplotlib.pyplot as plt
import platform
17 - Jaynes-Cummings Dynamics#
The Jaynes-Cummings Hamiltonian is written as
where are raising/lowering operators for a two-level system,
are the Pauli spin operators with
,
and
are the creation and annihilation operators for the field mode, and
,
, and
are the cavity-field, qubit, and coupling (angular-) frequencies, respectively.
We will use the below parameters in our simulation
[2]:
# parameters for the Hamiltonian
qubitFreq = 1
cavityFreq = 1
couplingFreq = 0.25
cavityDim = 5
# parameters for the evolution
totalTime = 3*(np.pi/couplingFreq)
timeStep = 0.1
and we can describe the JC-Hamiltonian/system in QuanGuru as
[3]:
# Qubit for the JC model
QubitJC = qg.Qubit(frequency=qubitFreq)
# Cavity for the JC model
CavityJC = qg.Cavity(dimension=cavityDim, frequency=cavityFreq)
# JC model consists of a qubit and cavity
# and this is the 'free evolution' part of the JC-Hamiltonian
JCSystem = QubitJC + CavityJC
[4]:
# coupling part of the JC-Hamiltonian
# first term of the coupling
JCCouplingT1 = JCSystem.createTerm(
qSystem=[CavityJC, QubitJC],
operator=[qg.destroy, qg.sigmap])
# second term of the couplings
# first term of the coupling
JCCouplingT2 = JCSystem.createTerm(
qSystem=[QubitJC, CavityJC],
operator=[qg.sigmam, qg.create])
# combine the terms into a single term
JCCoupling = qg.QTerm(qSystem=JCSystem,
subSys=[JCCouplingT1, JCCouplingT2],
frequency=couplingFreq)
[5]:
JCSystem.simStepSize = timeStep
JCSystem.simTotalTime = totalTime
JCSystem.initialState = [1, 1]
freqSweep = JCSystem.simulation.Sweep.createSweep(
system=CavityJC,
sweepKey="frequency",
sweepMax=qubitFreq+cavityFreq,
sweepMin=qubitFreq-cavityFreq,
sweepStep=.025)
[6]:
compositeSZ = qg.compositeOp(qg.sigmaz(), dimA=cavityDim)
# calculate the desired results and store
def compute(sim, args):
stateJC = args[0]
sim.resultsDict['zJC'].append(qg.expectation(compositeSZ, stateJC))
JCSystem.simCompute = compute
IMPORTANT NOTE FOR WINDOWS USERS : MULTI-PROCESSING (p=True) DOES NOT WORK WITH NOTEBOOK
You can use a python script, but you will need to make sure that the critical parts of the code are under if __name__ == "__main__":
We are going to add further tutorials for this later.
[7]:
# do not store the states
JCSystem.simDelStates = True
# run the simulation
# p=True uses multi-processing for the sweep
JCSystem.runSimulation(p=(platform.system() != 'Windows'))
[7]:
[]
[8]:
Y, X = np.meshgrid(JCSystem.simulation.timeList, freqSweep.sweepList)
plt.pcolormesh(X, Y, JCSystem.simulation.resultsDict['zJC'])
plt.xlabel("Frequency $\omega_{c}$")
plt.ylabel("Time")
[8]:
Text(0, 0.5, 'Time')

[ ]: