#!/usr/bin/env python # coding: utf-8 # # Lecture 4 - Correlation functions # # Author: J. R. Johansson (robert@riken.jp), https://jrjohansson.github.io/ # # This lecture series was developed by J.R. Johannson. The original lecture notebooks are available [here](https://github.com/jrjohansson/qutip-lectures). # # This is a slightly modified version of the lectures, to work with the current release of QuTiP. You can find these lectures as a part of the [qutip-tutorials repository](https://github.com/qutip/qutip-tutorials). This lecture and other tutorial notebooks are indexed at the [QuTiP Tutorial webpage](https://qutip.org/tutorials.html). # In[1]: import matplotlib.pyplot as plt import numpy as np from qutip import (about, coherent_dm, correlation_2op_2t, destroy, fock_dm, mesolve, qeye, steadystate, tensor) get_ipython().run_line_magic('matplotlib', 'inline') # ## First-order coherence function # # # Consider an oscillator that is interacting with a thermal environment. If the oscillator initially is in a coherent state, it will gradually decay to a thermal (incoherent) state. The amount of coherence can be quantified using the first-order optical coherence function # #
, calculate the Leggett-Garg correlation. """ N, M = c_mat.shape lg_mat = np.zeros([N // 2, M // 2], dtype=complex) lg_vec = np.zeros(N // 2, dtype=complex) # c_mat(i, j) =# LG =+-for i in range(N // 2): lg_vec[i] = 2 * c_mat[0, i] - c_mat[0, 2 * i] for j in range(M // 2): lg_mat[i, j] = c_mat[0, i] + c_mat[i, j] - c_mat[0, i + j] return lg_mat, lg_vec # ### Example: Leggett-Garg inequality for two coupled resonators (optomechanical system) # # # References: # # * [N. Lambert, J.R. Johansson, F. Nori, Phys. Rev. B 82, 245421 (2011)](http://dx.doi.org/10.1103/PhysRevB.84.245421). # In[8]: wc = 1.0 * 2 * np.pi # cavity frequency wa = 1.0 * 2 * np.pi # resonator frequency g = 0.3 * 2 * np.pi # coupling strength kappa = 0.075 # cavity dissipation rate gamma = 0.005 # resonator dissipation rate Na = Nc = 3 # number of cavity fock states n_th = 0.0 # avg number of thermal bath excitation tlist = np.linspace(0, 7.5, 251) tlist_sub = tlist[0:int((len(tlist) / 2))] # In[9]: # start with an excited resonator rho0 = tensor(fock_dm(Na, 0), fock_dm(Nc, 1)) a = tensor(qeye(Nc), destroy(Na)) c = tensor(destroy(Nc), qeye(Na)) na = a.dag() * a nc = c.dag() * c H = wa * na + wc * nc - g * (a + a.dag()) * (c + c.dag()) # In[10]: # measurement operator on resonator Q = na # photon number resolving detector # fock-state |1> detector # Q = tensor(qeye(Nc), 2 * fock_dm(Na, 1) - qeye(Na)) # click or no-click detector # Q = tensor(qeye(Nc), qeye(Na) - 2 * fock_dm(Na, 0)) # In[11]: c_op_list = [] rate = kappa * (1 + n_th) if rate > 0.0: c_op_list.append(np.sqrt(rate) * c) rate = kappa * n_th if rate > 0.0: c_op_list.append(np.sqrt(rate) * c.dag()) rate = gamma * (1 + n_th) if rate > 0.0: c_op_list.append(np.sqrt(rate) * a) rate = gamma * n_th if rate > 0.0: c_op_list.append(np.sqrt(rate) * a.dag()) # ### Calculate the correlation function $\langle Q(t_1+t_2)Q(t_1)\rangle$ # # Using the regression theorem, and QuTiP function `correlation`. # In[12]: corr_mat = correlation_2op_2t(H, rho0, tlist, tlist, c_op_list, Q, Q) # ### Calculate the Leggett-Garg correlation # In[13]: LG_tt, LG_t = leggett_garg(corr_mat) # ### Plot results # In[14]: fig, axes = plt.subplots(1, 2, figsize=(12, 4)) axes[0].pcolor(tlist, tlist, abs(corr_mat), edgecolors="none") axes[0].set_xlabel(r"$t_1 + t_2$") axes[0].set_ylabel(r"$t_1$") axes[0].autoscale(tight=True) axes[1].pcolor(tlist_sub, tlist_sub, abs(LG_tt), edgecolors="none") axes[1].set_xlabel(r"$t_1$") axes[1].set_ylabel(r"$t_2$") axes[1].autoscale(tight=True) fig, axes = plt.subplots(1, 1, figsize=(12, 4)) axes.plot(tlist_sub, np.diag(np.real(LG_tt)), label=r"$\tau = t_1 = t_2$") axes.plot(tlist_sub, np.ones(tlist_sub.shape), "k", label=r"quantum boundary") axes.fill_between( tlist_sub, np.diag(np.real(LG_tt)), 1, where=(np.diag(np.real(LG_tt)) > 1), color="green", alpha=0.5, ) axes.set_xlim([0, max(tlist_sub)]) axes.legend(loc=0) axes.set_xlabel(r"$\tau$", fontsize=18) axes.set_ylabel(r"LG($\tau$)", fontsize=18); # ### Software versions # In[15]: about()