def _pseudo_inverse_dense(L, rhoss, method='direct', **pseudo_args): """ Internal function for computing the pseudo inverse of an Liouvillian using dense matrix methods. See pseudo_inverse for details. """ if method == 'direct': rho_vec = np.transpose(mat2vec(rhoss.full())) tr_mat = tensor([identity(n) for n in L.dims[0][0]]) tr_vec = np.transpose(mat2vec(tr_mat.full())) N = np.prod(L.dims[0][0]) I = np.identity(N * N) P = np.kron(np.transpose(rho_vec), tr_vec) Q = I - P LIQ = np.linalg.solve(L.full(), Q) R = np.dot(Q, LIQ) return Qobj(R, dims=L.dims) elif method == 'numpy': return Qobj(np.linalg.pinv(L.full()), dims=L.dims) elif method == 'scipy': return Qobj(la.pinv(L.full()), dims=L.dims) elif method == 'scipy2': return Qobj(la.pinv2(L.full()), dims=L.dims) else: raise ValueError("Unsupported method '%s'. Use 'direct' or 'numpy'" % method)
def test_vec_to_eigbasis(): "BR Tools : vector to eigenbasis" dimension = 10 for _ in range(50): H = qutip.rand_herm(dimension, 0.5) basis = H.eigenstates()[1] R = qutip.rand_dm(dimension, 0.5) target = qutip.mat2vec(R.transform(basis).full()).ravel() flat_vector = qutip.mat2vec(R.full()).ravel() calculated = _test_vec_to_eigbasis(H.full('F'), flat_vector) np.testing.assert_allclose(target, calculated, atol=1e-12)
def test_eigvec_to_fockbasis(): "BR Tools : eigvector to fockbasis" dimension = 10 for _ in range(50): H = qutip.rand_herm(dimension, 0.5) basis = H.eigenstates()[1] R = qutip.rand_dm(dimension, 0.5) target = qutip.mat2vec(R.full()).ravel() _eigenvalues = np.empty((dimension, ), dtype=np.float64) evecs_zheevr = _test_zheevr(H.full('F'), _eigenvalues) flat_eigenvectors = qutip.mat2vec(R.transform(basis).full()).ravel() calculated = _test_eigvec_to_fockbasis(flat_eigenvectors, evecs_zheevr, dimension) np.testing.assert_allclose(target, calculated, atol=1e-12)
def test_vector_roundtrip(): "BR Tools : vector roundtrip transform" dimension = 10 for _ in range(50): H = qutip.rand_herm(dimension, 0.5).full('F') vector = qutip.mat2vec(qutip.rand_dm(dimension, 0.5).full()).ravel() assert np.allclose(vector, _test_vector_roundtrip(H, vector))
def _pseudo_inverse_dense(L, rhoss, w=None, **pseudo_args): """ Internal function for computing the pseudo inverse of an Liouvillian using dense matrix methods. See pseudo_inverse for details. """ rho_vec = np.transpose(mat2vec(rhoss.full())) tr_mat = tensor([identity(n) for n in L.dims[0][0]]) tr_vec = np.transpose(mat2vec(tr_mat.full())) N = np.prod(L.dims[0][0]) I = np.identity(N * N) P = np.kron(np.transpose(rho_vec), tr_vec) Q = I - P if w is None: L = L else: L = 1.0j*w*spre(tr_mat)+L if pseudo_args['method'] == 'direct': try: LIQ = np.linalg.solve(L.full(), Q) except: LIQ = np.linalg.lstsq(L.full(), Q)[0] R = np.dot(Q, LIQ) return Qobj(R, dims=L.dims) elif pseudo_args['method'] == 'numpy': return Qobj(np.dot(Q, np.dot(np.linalg.pinv(L.full()), Q)), dims=L.dims) elif pseudo_args['method'] == 'scipy': # return Qobj(la.pinv(L.full()), dims=L.dims) return Qobj(np.dot(Q, np.dot(la.pinv(L.full()), Q)), dims=L.dims) elif pseudo_args['method'] == 'scipy2': # return Qobj(la.pinv2(L.full()), dims=L.dims) return Qobj(np.dot(Q, np.dot(la.pinv2(L.full()), Q)), dims=L.dims) else: raise ValueError("Unsupported method '%s'. Use 'direct' or 'numpy'" % method)
def testMatrixVecMat(self): """ Superoperator: Conversion matrix to vector to matrix """ M = scipy.rand(10, 10) V = mat2vec(M) M2 = vec2mat(V) assert_(la.norm(M - M2) == 0.0)
def testVecMatVec(self): """ Superoperator: Conversion vector to matrix to vector """ V = scipy.rand(100) # a row vector M = vec2mat(V) V2 = mat2vec(M).T # mat2vec returns a column vector assert_(norm(V - V2) == 0.0)
def testMatrixVecMat(self): """ Superoperator: Conversion matrix to vector to matrix """ M = scipy.rand(10, 10) V = mat2vec(M) M2 = vec2mat(V) assert_(norm(M - M2) == 0.0)
def testVecMatVec(self): """ Superoperator: Conversion vector to matrix to vector """ V = scipy.rand(100) # a row vector M = vec2mat(V) V2 = mat2vec(M).T # mat2vec returns a column vector assert_(la.norm(V - V2) == 0.0)
def testVecMatIndexCompability(self): """ Superoperator: Compatibility between matrix/vector and corresponding index conversions. """ N = 10 M = scipy.rand(N, N) V = mat2vec(M) for I in range(N * N): i, j = vec2mat_index(N, I) assert_(V[I][0] == M[i, j])
def two_tone(vg, listening=False, use_pinv=True): phi, wd = vg H = make_H(phi, Omega, wd * nvec, 0.0) if listening: final_state = steadystate(H, c_op_list) return expect(a, final_state) L = liouvillian(H, c_op_list) #tr_mat = tensor([qeye(n) for n in L.dims[0][0]]) #N = prod(L.dims[0][0]) A = L.full() #tr_vec = transpose(mat2vec(tr_mat.full())) rho_ss = steadystate(L) rho = transpose(mat2vec(rho_ss.full())) #P = kron(transpose(rho), tr_vec) #Q = I - P w = wp - wd if 1: D, U = eig(A) Uinv = inv(U) #spectrum = zeros(len(wlist)) #for idx, w in enumerate(wlist): if 1: if use_pinv: MMR = pinv(-1.0j * w * I + A) #MMR = A*MMR*inv(A) elif use_pinv == 1: MMR = dot(Q, solve(-1.0j * w * I + A, Q)) else: MMR = diag(1.0 / (1.0j * w * diag(I) + diag(D))) Lint = U * MMR * Uinv #Chi_temp[i,j] += (1/theta_steps)*1j*trace(reshape(tm_l*Lint*(p_l - p_r)*rho_ss_c,dim,dim)) #rho_tr=transpose(rho) #p1=dot(b_sup, rho_tr) #p2=dot(rho_tr, b_sup) #s = dot(tr_vec, # dot(a_sup, dot(MMR, p1-p2))) s1 = dot(tr_vec, dot(a_sup, dot(MMR, dot(b_sup, transpose(rho))))) s2 = dot(tr_vec, dot(b_sup, dot(MMR, dot(a_sup, transpose(rho))))) s = s1 - s2 #spectrum[idx] = return -2 * real(s[0, 0]) return spectrum
def _spectrum_pi(H, wlist, c_ops, a_op, b_op, use_pinv=False): """ Internal function for calculating the spectrum of the correlation function :math:`\left<A(\\tau)B(0)\\right>`. """ #print issuper(H) L = H if issuper(H) else liouvillian(H, c_ops) tr_mat = tensor([qeye(n) for n in L.dims[0][0]]) N = prod(L.dims[0][0]) A = L.full() b = spre(b_op).full() a = spre(a_op).full() tr_vec = transpose(mat2vec(tr_mat.full())) rho_ss = steadystate(L) rho = transpose(mat2vec(rho_ss.full())) I = identity(N * N) P = kron(transpose(rho), tr_vec) Q = I - P spectrum = zeros(len(wlist)) for idx, w in enumerate(wlist): if use_pinv: MMR = pinv(-1.0j * w * I + A) else: MMR = dot(Q, solve(-1.0j * w * I + A, Q)) s = dot(tr_vec, dot(a, dot(MMR, dot(b, transpose(rho))))) spectrum[idx] = -2 * real(s[0, 0]) return spectrum
p_r=spost(p)#.full() print p_l.shape #raise Exception p_l_m_p_r=p_l-p_r #tm_l=spre(a).full() nvec=arange(N) Ecvec=-Ec*(6.0*nvec**2+6.0*nvec+3.0)/12.0 Omega_op=[0.5*Omega*(a*exp(-1.0j*theta)+adag*exp(1.0j*theta)) for theta in [0.0]] tr_mat = tensor(qeye(N)) #N = np.prod(L.dims[0][0]) tr_vec = transpose(mat2vec(tr_mat.full())) p_sup = spre(p)#.full() a_sup = spre(a)#.full() I=identity(N*N) Idiag=diag(I) # Excitation (at T>0). #Lindblad_deph = 0.5*gamma_phi*(kron(conj(tdiag),tdiag) -... # 0.5*kron(Itot,ctranspose(tdiag)*tdiag) -... # 0.5*kron(transpose(tdiag)*conj(tdiag),Itot)); print "yo" #print eye(N).shape
def find_expect(phi=0.1, Omega_vec=3.0, wd=wd, use_pinv=True): Ej = (phi**2)/(8*Ec) #Ejmax*absolute(cos(pi*phi)) #; % Josephson energy as function of Phi. wTvec = -Ej + sqrt(8.0*Ej*Ec)*(nvec+0.5)+Ecvec #wdvec=nvec*sqrt(8.0*Ej*Ec) #wdvec=nvec*wd wT = wTvec-wdvec transmon_levels = Qobj(diag(wT[range(N)])) H=transmon_levels +Omega_vec #- 0.5j*(Omega_true*adag - conj(Omega_true)*a) L=liouvillian(H, c_op_list) #ends at same thing as L = H_comm + Lindblad_tm ; rho_ss = steadystate(L) #same as rho_ss_c but that's in column vector form tr_mat = tensor([qeye(n) for n in L.dims[0][0]]) #N = prod(L.dims[0][0]) A = L.full() #D, U= L.eigenstates() #print D.shape, D #print diag(D) b = spre(p).full()-spost(p).full() a2 = spre(a).full() tr_vec = transpose(mat2vec(tr_mat.full())) rho = transpose(mat2vec(rho_ss.full())) I = identity(N * N) P = kron(transpose(rho), tr_vec) Q = I - P #wp=4.9 #w=-(wp-wd) spectrum = zeros(len(wlist2), dtype=complex) for idx, w in enumerate(wlist2): if use_pinv: MMR = pinv(-1.0j * w * I + A) #eig(MMR)[0] is equiv to Dint else: MMR = dot(Q, solve(-1.0j * w * I + A, Q)) #print diag(1.0/(1j*(wp-wd)*ones(N**2)+D)) #Dint = diag(1./(1i*(wp-wd)*diag(eye(dim^2)) + diag(D))) #print 1.0/(1j*(wp-wd)*ones(N**2)+D) #Dint = diag(1./(1i*(wp-wd)*diag(eye(dim^2)) + diag(D))) #U2=squeeze([u.full() for u in U]).transpose() #Dint=eig(MMR)[0] #print "MMR", eig(MMR)[1] #print "Umult", U2*Dint*inv(U2) s = dot(tr_vec, dot(a2, dot(MMR, dot(b, transpose(rho))))) #spectrum[idx] = -2 * real(s[0, 0]) spectrum[idx]=1j*s[0][0] #matches Chi_temp result #(1/theta_steps) return spectrum #final_state = steadystate(H, c_op_list) #print H.shape #print dir(H) #U,D = eig(H.full()) #print D #Uinv = Qobj(inv(D)) #U=Qobj(D) # Doing the chi integral (gives the susceptibility) #Dint = 1.0/(1.0j*(wp-wd)) #Qobj(1.0/(1.0j*(wp-wd)*diag(qeye(N**2))))# + diag(D)))) #Hint = H.expm() #U*H*Uinv #Chi_temp(i,j) += (1.0/theta_steps)*1j*trace(reshape(tm_l*Lint*(p_l - p_r)*rho_ss_c,dim,dim)) #exp1=correlation_2op_1t(H, None, wlist2, c_op_list, a, p, solver="es") #exp2=correlation_2op_1t(H, None, wlist2, c_op_list, p, a, solver="es", reverse=True) #exp1=correlation_2op_1t(H, None, wlist2, c_op_list, a, p_l-p_r, solver="es") #exp1=correlation_ss(H, wlist2, c_op_list, a, p) #exp2=correlation_ss(H, wlist2, c_op_list, p, a, reverse=True) exp1=spectrum(H, wlist2, c_op_list, a, p, solver="pi", use_pinv=False) exp2=spectrum(H, wlist2, c_op_list, p, a, solver="pi", use_pinv=False) return exp1-exp2 return expect( a, final_state) #tm_l
def two_tone(vg): phi, wd=vg Ej = Ejmax*absolute(cos(pi*phi))#(phi**2)/(8*Ec) # #; % Josephson energy as function of Phi. wTvec = -Ej + sqrt(8.0*Ej*Ec)*(nvec+0.5)+Ecvec wdvec=nvec*wd wT = wTvec-wdvec transmon_levels = Qobj(diag(wT[range(N)])) for Om in Omega_op: H = transmon_levels + Om exp1=spectrum(H, wlist2, c_op_list, a, p, solver="pi", use_pinv=False) exp2=spectrum(H, wlist2, c_op_list, p, a, solver="pi", use_pinv=False) return exp1-exp2 #H_comm = -1j*(kron(It,H) - kron(transpose(H),It)); #L = H_comm + Lindblad_tm + Lindblad_tp #+ Lindblad_deph; #print L #L2 = [reshape(eye(N),1,N**2); L]; %Add the condition trace(rho) = 1 #rho_ss = L2\[1;zeros(dim^2,1)]; % Steady state density matrix #rho_ss_c = rho_ss; %Column vector form L = liouvillian(H, c_op_list) #D, V=L.eigenstates() #print "D", D.shape #print "V", V.shape #print L.diag() #print L.diag().shape #raise Exception A = L.full() rho_ss = steadystate(L) rho = transpose(mat2vec(rho_ss.full())) P = kron(transpose(rho), tr_vec) Q = I - P if 1: w=wp-wd #MMR = pinv(-1.0j * w * I + A) MMR = dot(Q, solve(-1.0j * w * I + A, Q)) #Lexp=L.expm() #MMR=Lexp*MMR*Lexp.dag() # MMR = np.dot(Q, np.linalg.solve(-1.0j * w * I + A, Q)) #print p_l.shape #print p_l #print transpose(rho).shape #print dot(p_l.full(), transpose(rho)) s = dot(tr_vec, dot(tm_l, dot(MMR, dot(p_l_m_p_r, transpose(rho))))) return -2 * real(s[0, 0]) D,U = eig(L.full()) Uinv = inv(U) Dint = diag(1.0/(1.0j*(wp-wd)*Idiag + diag(D))) Lint = U*Dint*Uinv #H_comm = -1.0j*(kron(It,H) - kron(transpose(H),It)) #print H #print H.shape, H.full().shape #print H_comm, H_comm.shape #L = H_comm + Lindblad_tm + Lindblad_tp + Lindblad_deph #p_l=spre(p) #p_r=spost(p) #tm_l=spre(a) #print L.shape, A.shape, #print dir(L) #print L.eigenenergies().shape #print L.eigenstates()#.shape #L2 = [reshape(eye(dim),1,dim^2);L]; %Add the condition trace(rho) = 1 #rho_ss = L2\[1;zeros(dim^2,1)]; % Steady state density matrix #rho_ss_c = rho_ss; %Column vector form #print "tm_l", tm_l.full().shape #print "Lint", Lint.shape #print "pl", p_l.full().shape #print "pr", p_r.full().shape #print rho.shape, to_super(rho_ss).full().shape #print "rho", to_super(rho_ss) #rho_ss.full().shape #rho.shape #print (tm_l.full()*Lint*(p_l.full() - p_r.full())*rho).shape #raise Exception return 1j*trace(tm_l*Lint*(p_l_m_p_r)*rho_ss)
def hsolve(H, psi0, tlist, Q, gam, lam0, Nc, N, w_th, options=None): """ Function to solve for an open quantum system using the hierarchy model. Parameters ---------- H: Qobj The system hamiltonian. psi0: Qobj Initial state of the system. tlist: List. Time over which system evolves. Q: Qobj The coupling between system and bath. gam: Float Bath cutoff frequency. lam0: Float Coupling strength. Nc: Integer Cutoff parameter. N: Integer Number of matsubara terms. w_th: Float Temperature. options : :class:`qutip.Options` With options for the solver. Returns ------- output: Result System evolution. """ if options is None: options = Options() # Set up terms of the matsubara and tanimura boundaries # Parameters and hamiltonian hbar = 1. kb = 1. # Set by system dimensions = dims(H) Nsup = dimensions[0][0] * dimensions[0][0] unit = qeye(dimensions[0]) # Ntot is the total number of ancillary elements in the hierarchy Ntot = int(round(factorial(Nc+N) / (factorial(Nc) * factorial(N)))) c0 = (lam0 * gam * (_cot(gam * hbar / (2. * kb * w_th)) - (1j))) / hbar LD1 = (-2. * spre(Q) * spost(Q.dag()) + spre(Q.dag()*Q) + spost(Q.dag()*Q)) pref = ((2. * lam0 * kb * w_th / (gam * hbar)) - 1j * lam0) / hbar gj = 2 * np.pi * kb * w_th / hbar L12 = -pref * LD1 + (c0 / gam) * LD1 for i1 in range(1, N): num = (4 * lam0 * gam * kb * w_th * i1 * gj/((i1 * gj)**2 - gam**2)) ci = num / (hbar**2) L12 = L12 + (ci / gj) * LD1 # Setup liouvillian L = liouvillian(H, [L12]) Ltot = L.data unit = sp.eye(Ntot,format='csr') Lbig = sp.kron(unit, Ltot) rho0big1 = np.zeros((Nsup * Ntot), dtype=complex) # Prepare initial state: rhotemp = mat2vec(np.array(psi0.full(), dtype=complex)) for idx, element in enumerate(rhotemp): rho0big1[idx] = element[0] nstates, state2idx, idx2state = enr_state_dictionaries([Nc+1]*(N), Nc) for nlabelt in state_number_enumerate([Nc+1]*(N), Nc): nlabel = list(nlabelt) ntotalcheck = 0 for ncheck in range(N): ntotalcheck = ntotalcheck + nlabel[ncheck] current_pos = int(round(state2idx[tuple(nlabel)])) Ltemp = sp.lil_matrix((Ntot, Ntot)) Ltemp[current_pos, current_pos] = 1 Ltemp.tocsr() Lbig = Lbig + sp.kron(Ltemp, (-nlabel[0] * gam * spre(unit).data)) for kcount in range(1, N): counts = -nlabel[kcount] * kcount * gj * spre(unit).data Lbig = Lbig + sp.kron(Ltemp, counts) for kcount in range(N): if nlabel[kcount] >= 1: # find the position of the neighbour nlabeltemp = copy(nlabel) nlabel[kcount] = nlabel[kcount] - 1 current_pos2 = int(round(state2idx[tuple(nlabel)])) Ltemp = sp.lil_matrix((Ntot, Ntot)) Ltemp[current_pos, current_pos2] = 1 Ltemp.tocsr() # renormalized version: ci = (4 * lam0 * gam * kb * w_th * kcount * gj/((kcount * gj)**2 - gam**2)) / (hbar**2) if kcount == 0: Lbig = Lbig + sp.kron(Ltemp, (-1j * (np.sqrt(nlabeltemp[kcount] / abs(c0))) * ((c0) * spre(Q).data - (np.conj(c0)) * spost(Q).data))) if kcount > 0: ci = (4 * lam0 * gam * kb * w_th * kcount * gj/((kcount * gj)**2 - gam**2)) / (hbar**2) Lbig = Lbig + sp.kron(Ltemp, (-1j * (np.sqrt(nlabeltemp[kcount] / abs(ci))) * ((ci) * spre(Q).data - (np.conj(ci)) * spost(Q).data))) nlabel = copy(nlabeltemp) for kcount in range(N): if ntotalcheck <= (Nc-1): nlabeltemp = copy(nlabel) nlabel[kcount] = nlabel[kcount] + 1 current_pos3 = int(round(state2idx[tuple(nlabel)])) if current_pos3 <= (Ntot): Ltemp = sp.lil_matrix((Ntot, Ntot)) Ltemp[current_pos, current_pos3] = 1 Ltemp.tocsr() # renormalized if kcount == 0: Lbig = Lbig + sp.kron(Ltemp, -1j * (np.sqrt((nlabeltemp[kcount]+1) * abs(c0))) * (spre(Q) - spost(Q)).data) if kcount > 0: ci = (4 * lam0 * gam * kb * w_th * kcount * gj/((kcount * gj)**2 - gam**2)) / (hbar**2) Lbig = Lbig + sp.kron(Ltemp, -1j * (np.sqrt((nlabeltemp[kcount]+1) * abs(ci))) * (spre(Q) - spost(Q)).data) nlabel = copy(nlabeltemp) output = [] for element in rhotemp: output.append([]) r = scipy.integrate.ode(cy_ode_rhs) Lbig2 = Lbig.tocsr() r.set_f_params(Lbig2.data, Lbig2.indices, Lbig2.indptr) r.set_integrator('zvode', method=options.method, order=options.order, atol=options.atol, rtol=options.rtol, nsteps=options.nsteps, first_step=options.first_step, min_step=options.min_step, max_step=options.max_step) r.set_initial_value(rho0big1, tlist[0]) dt = tlist[1] - tlist[0] for t_idx, t in enumerate(tlist): r.integrate(r.t + dt) for idx, element in enumerate(rhotemp): output[idx].append(r.y[idx]) return output
def find_expect(phi=0.1, Omega_vec=3.0, wd=wd, use_pinv=True): Ej = (phi**2) / ( 8 * Ec ) #Ejmax*absolute(cos(pi*phi)) #; % Josephson energy as function of Phi. wTvec = -Ej + sqrt(8.0 * Ej * Ec) * (nvec + 0.5) + Ecvec #wdvec=nvec*sqrt(8.0*Ej*Ec) #wdvec=nvec*wd wT = wTvec - wdvec transmon_levels = Qobj(diag(wT[range(N)])) H = transmon_levels + Omega_vec #- 0.5j*(Omega_true*adag - conj(Omega_true)*a) L = liouvillian( H, c_op_list) #ends at same thing as L = H_comm + Lindblad_tm ; rho_ss = steadystate(L) #same as rho_ss_c but that's in column vector form tr_mat = tensor([qeye(n) for n in L.dims[0][0]]) #N = prod(L.dims[0][0]) A = L.full() #D, U= L.eigenstates() #print D.shape, D #print diag(D) b = spre(p).full() - spost(p).full() a2 = spre(a).full() tr_vec = transpose(mat2vec(tr_mat.full())) rho = transpose(mat2vec(rho_ss.full())) I = identity(N * N) P = kron(transpose(rho), tr_vec) Q = I - P #wp=4.9 #w=-(wp-wd) spectrum = zeros(len(wlist2), dtype=complex) for idx, w in enumerate(wlist2): if use_pinv: MMR = pinv(-1.0j * w * I + A) #eig(MMR)[0] is equiv to Dint else: MMR = dot(Q, solve(-1.0j * w * I + A, Q)) #print diag(1.0/(1j*(wp-wd)*ones(N**2)+D)) #Dint = diag(1./(1i*(wp-wd)*diag(eye(dim^2)) + diag(D))) #print 1.0/(1j*(wp-wd)*ones(N**2)+D) #Dint = diag(1./(1i*(wp-wd)*diag(eye(dim^2)) + diag(D))) #U2=squeeze([u.full() for u in U]).transpose() #Dint=eig(MMR)[0] #print "MMR", eig(MMR)[1] #print "Umult", U2*Dint*inv(U2) s = dot(tr_vec, dot(a2, dot(MMR, dot(b, transpose(rho))))) #spectrum[idx] = -2 * real(s[0, 0]) spectrum[idx] = 1j * s[0][0] #matches Chi_temp result #(1/theta_steps) return spectrum #final_state = steadystate(H, c_op_list) #print H.shape #print dir(H) #U,D = eig(H.full()) #print D #Uinv = Qobj(inv(D)) #U=Qobj(D) # Doing the chi integral (gives the susceptibility) #Dint = 1.0/(1.0j*(wp-wd)) #Qobj(1.0/(1.0j*(wp-wd)*diag(qeye(N**2))))# + diag(D)))) #Hint = H.expm() #U*H*Uinv #Chi_temp(i,j) += (1.0/theta_steps)*1j*trace(reshape(tm_l*Lint*(p_l - p_r)*rho_ss_c,dim,dim)) #exp1=correlation_2op_1t(H, None, wlist2, c_op_list, a, p, solver="es") #exp2=correlation_2op_1t(H, None, wlist2, c_op_list, p, a, solver="es", reverse=True) #exp1=correlation_2op_1t(H, None, wlist2, c_op_list, a, p_l-p_r, solver="es") #exp1=correlation_ss(H, wlist2, c_op_list, a, p) #exp2=correlation_ss(H, wlist2, c_op_list, p, a, reverse=True) exp1 = spectrum(H, wlist2, c_op_list, a, p, solver="pi", use_pinv=False) exp2 = spectrum(H, wlist2, c_op_list, p, a, solver="pi", use_pinv=False) return exp1 - exp2 return expect(a, final_state) #tm_l
wlist = linspace(-500.0, 500.0, 201) use_pinv=True tr_mat = tensor([qeye(n) for n in L.dims[0][0]]) N = prod(L.dims[0][0]) A = L.full() D, U= L.eigenstates() print D.shape, D print diag(D) b = spre(p).full()-spost(p).full() a = spre(a).full() tr_vec = transpose(mat2vec(tr_mat.full())) rho_ss = steadystate(L) rho = transpose(mat2vec(rho_ss.full())) I = identity(N * N) P = kron(transpose(rho), tr_vec) Q = I - P wp=4.9 w=-(wp-wd) MMR = pinv(-1.0j * w * I + A) #eig(MMR)[0] is equiv to Dint #MMR = pinv(-1.0j * w * I) # + A) MMR = dot(Q, solve(-1.0j * w * I + A, Q)) #MMR = pinv(-1.0j * w * I + D)
fexpt = parallel_map(find_expect, vg, progress_bar=True) fexpt = reshape(fexpt, (31, 101)) pcolormesh(phi_arr, sample_power_sim_dBm, absolute(fexpt), cmap="RdBu_r") show() #w01_vec(i) = wT_vec(2)- wT_vec(1); % Transition energies. #w12_vec(i) = wT_vec(3)- wT_vec(2); #w23_vec(i) = wT_vec(4)- wT_vec(3); #w34_vec(i) = wT_vec(5)- wT_vec(4); H = make_H(0.2, 190, 4000.0) print H L = liouvillian(H, c_op_list) print L tr_mat = tensor([qeye(n) for n in L.dims[0][0]]) print tr_mat tr_vec = transpose(mat2vec(tr_mat.full())) print tr_vec N = prod(L.dims[0][0]) print N A = L.full() a_sup = spre(a).full() b_sup = spre(p).full() D, U = eig(A) print "D", D I = identity(N * N) w = 3.0 MMR1 = pinv(-1.0j * w * I + A) print A * MMR1 * inv(A) print U * MMR1 * inv(U)