def spin_photon_entropy_cons(dtype, symm, Sent_args): Ntot = L if symm: basis = photon_basis(spin_basis_1d, L, Ntot=Ntot, kblock=0, pblock=1) else: basis = photon_basis(spin_basis_1d, L, Ntot=Ntot) # spin x_field = [[-1.0, i] for i in range(L)] z_field = [[-1.0, i] for i in range(L)] J_nn = [[-1.0, i, (i + 1) % L] for i in range(L)] # spin-photon absorb = [[-0.5 * 1.0 / np.sqrt(Ntot), i] for i in range(L)] emit = [[-0.5 * np.conj(1.0) / np.sqrt(Ntot), i] for i in range(L)] # photon ph_energy = [[11.0 / L, i] for i in range(L)] static = [["zz|", J_nn], ["z|", z_field], ["x|", x_field], ["x|-", absorb], ["x|+", emit], ["I|n", ph_energy]] H = hamiltonian(static, [], L, dtype=np.float64, basis=basis, check_herm=False, check_symm=False, check_pcon=False) # diagonalise H E, V = H.eigh() psi0 = V[:, 0] rho0 = np.outer(psi0.conj(), psi0) rho_d = rho0 Ed, Vd = np.linalg.eigh(rho_d) S_pure = _ent_entropy(psi0, basis, **Sent_args) S_DM = _ent_entropy(rho0, basis, **Sent_args) S_DMd = _ent_entropy({'V_rho': Vd, 'rho_d': abs(Ed)}, basis, **Sent_args) S_all = _ent_entropy({'V_states': V}, basis, **Sent_args) return (S_pure, S_DM, S_DMd, S_all)
def spin_photon_entropy(dtype, symm, Sent_args): Nph = 6 if symm: basis = photon_basis(spin_basis_1d, L, Nph=Nph, kblock=0, pblock=1) else: basis = photon_basis(spin_basis_1d, L, Nph=Nph) # spin x_field = [[-1.0, i] for i in range(L)] z_field = [[-1.0, i] for i in range(L)] J_nn = [[-1.0, i, (i + 1) % L] for i in range(L)] # spin-photon absorb = [[-0.5 * 1.0 / np.sqrt(Nph), i] for i in range(L)] emit = [[-0.5 * np.conj(1.0) / np.sqrt(Nph), i] for i in range(L)] # photon ph_energy = [[11.0 / L, i] for i in range(L)] static = [["zz|", J_nn], ["z|", z_field], ["x|", x_field], ["x|-", absorb], ["x|+", emit], ["I|n", ph_energy]] H = hamiltonian(static, [], L, dtype=np.float64, basis=basis, check_herm=False, check_symm=False) # diagonalise H E, V = H.eigh() psi0 = V[:, 0] rho0 = np.outer(psi0.conj(), psi0) rho_d = rho0 Ed, Vd = np.linalg.eigh(rho_d) S_pure = ent_entropy(psi0, basis, **Sent_args) S_DM = ent_entropy(rho0, basis, **Sent_args) S_DMd = ent_entropy({"V_rho": Vd, "rho_d": abs(Ed)}, basis, **Sent_args) S_all = ent_entropy({"V_states": V}, basis, **Sent_args) return (S_pure, S_DM, S_DMd, S_all)
def spin_photon_Nsite_DM(N, coupling, Nph_tot=10, state='ferro', decouple=0, photon_state=0,coherent=False, t_max=10.00,t_steps=100, obs_photon=5, vect='x', omega=0.5, J_zz=0.0, J_xx=0.0, J_xy=0.0, J_z=0.0, J_x=0.0, return_state_DM=False, periodic=True, init_state=None): ##### define Boson model parameters ##### Nph_tot=Nph_tot # maximum photon occupation Nph=1.0# mean number of photons in initial state L=N; Omega=omega # drive frequency A=coupling # spin-photon coupling strength (drive amplitude) Delta=0.0 # difference between atom energy levels ph_energy=[[Omega]] # photon energy loss=[[0.2]] # emission term at_energy=[[Delta,i] for i in range(L)] # atom energy if type(decouple) == int: absorb=[[A / np.sqrt(N-decouple),i] for i in range(0, L-decouple)] # absorption term emit=[[A/ np.sqrt(N-decouple),i] for i in range(0, L-decouple)] # emission term elif type(decouple) == tuple: absorb=[[A / np.sqrt(len(decouple)),i] for i in decouple] # absorption term emit=[[A/ np.sqrt(len(decouple)),i] for i in decouple] # emission term else: ValueError('Improper input for decouple variable'); return -1; ##### define Boson model parameters ##### if periodic==True: boundary = L; else: boundary = L-1; H_zz = [[J_zz,i,(i+1)%L] for i in range(boundary)] # PBC H_xx = [[J_xx,i,(i+1)%L] for i in range(boundary)] # PBC H_xy = [[J_xy,i,(i+1)%L] for i in range(boundary)] # PBC H_z = [[J_z,i] for i in range(L)] # PBC H_x = [[J_x,i] for i in range(L)] # PBC psi_atom = get_product_state(N,state=state,vect=vect); # define static and dynamics lists static=[["|n",ph_energy],["x|-",absorb],["x|+",emit],["z|",at_energy], ["+-|",H_xy],["-+|",H_xy],["zz|",H_zz], ["z|",H_z],["x|",H_x]] dynamic=[] # compute atom-photon basis basis=photon_basis(spin_basis_1d,L=N,Nph=Nph_tot) atom_basis=spin_basis_1d(L=N) H=hamiltonian(static,dynamic,dtype=np.float64,basis=basis,check_herm=False) # compute atom-photon Hamiltonian H if type(init_state) == tuple: H_zz = [[init_state[0],i,(i+1)%L] for i in range(boundary)] # PBC H_xy = [[0,i,(i+1)%L] for i in range(boundary)] # PBC H_z = [[0,i] for i in range(L)] # PBC H_x = [[init_state[1],i] for i in range(L)] # PBC static=[["+-",H_xy],["-+",H_xy],["zz",H_zz], ["z",H_z],["x",H_x]]; init_Spin_Hamiltonian = hamiltonian(static,dynamic,dtype=np.float64,basis=spin_basis_1d(N),check_herm=False) psi_atom = get_ground_state(N,init_Spin_Hamiltonian); if coherent==False: psi_boson=np.zeros([Nph_tot+1]); psi_boson[photon_state]=1 else: psi_boson = coherent_state(np.sqrt(photon_state), Nph_tot+1) psi=np.kron(psi_atom,psi_boson) ##### calculate time evolution ##### obs_args={"basis":basis,"check_herm":False,"check_symm":False} t = np.linspace(0, t_max, t_steps); psi_t = H.evolve(psi, 0.0, t); a = hamiltonian([["|-", [[1.0 ]] ]],[],dtype=np.float64,**obs_args); n=hamiltonian([["|n", [[1.0 ]] ]],[],dtype=np.float64,**obs_args); a_psi = a.dot(psi); a_psi_t = H.evolve(a_psi, 0.0, t); g2_0 = n.expt_value(a_psi_t); n_t = n.expt_value(psi_t); g2_0 = g2_0 / (n_t[0] * n_t); g2_0 = np.real(g2_0); ##### define observables ##### # define GLOBAL observables parameters n_t=hamiltonian([["|n", [[1.0 ]] ]],[],dtype=np.float64,**obs_args) nn_t=hamiltonian([["|nn", [[1.0 ]] ]],[],dtype=np.float64,**obs_args) z_tot_t = hamiltonian([["z|", [[1.0,i] for i in range(L)] ]],[],dtype=np.float64,**obs_args); x_tot_t = hamiltonian([["x|", [[1.0,i] for i in range(L)] ]],[],dtype=np.float64,**obs_args); zz_tot_t = hamiltonian([["zz|", [[1.0,i,(i+1)%L] for i in range(boundary)] ]],[],dtype=np.float64,**obs_args); xx_tot_t = hamiltonian([["xx|", [[1.0,i,(i+1)%L] for i in range(boundary)] ]],[],dtype=np.float64,**obs_args); Obs_dict = {"n":n_t,"nn":nn_t,"z_tot":z_tot_t, "x_tot":x_tot_t, "zz_tot":zz_tot_t, "xx_tot":xx_tot_t}; for i in range(N): for j in range(i+1, N): stringz = "z%1dz%1d" % (i, j); stringx = "x%1dx%1d" % (i, j); zz_ham = hamiltonian([["zz|", [[1.0,i,j]] ]],[],dtype=np.float64,**obs_args); xx_ham = hamiltonian([["xx|", [[1.0,i,j]] ]],[],dtype=np.float64,**obs_args); Obs_dict.update({stringz:zz_ham, stringx, xx_ham}); Obs_t = obs_vs_time(psi_t,t,Obs_dict); ####### Number of times to sample the cavity state, could sample at every time so num = 1 ############### Sent = np.zeros_like(t); AC_ent = np.zeros_like(t); num = t_steps//obs_photon print(num) obs_pht_t = t[::num]; obs_pht_ray = np.zeros([len(obs_pht_t), Nph_tot+1, Nph_tot+1]); spin_subsys_dm = np.zeros([len(t), 2**(N//2), 2**(N//2)]) pairwise_concurrence = np.zeros([len(t), N, N]); for i in range(len(t)): dictionary = basis.ent_entropy(psi_t.T[i],sub_sys_A='particles',return_rdm='both'); AC_ent[i]=dictionary["Sent_A"]; spin_dm = dictionary["rdm_A"]; photon_dm = dictionary["rdm_B"]; dict_atom_subsys = atom_basis.ent_entropy(spin_dm,sub_sys_A=range(N//2),return_rdm='both'); Sent[i]=N//2 * dict_atom_subsys['Sent_A']; spin_subsys_dm[i]=dict_atom_subsys['rdm_A']; for j in range(N): for k in range(j+1, N): two_spin_dict = atom_basis.ent_entropy(spin_dm,sub_sys_A=(j,k),return_rdm='both'); two_spin_dm = two_spin_dict['rdm_A']; two_spin_conc = concurrence(two_spin_dm); pairwise_concurrence[i,j,k] = two_spin_conc; if t[i] in obs_pht_t: obs_pht_ray[i//num] = photon_dm if return_state_DM==False: return t, AC_ent, Sent, Obs_t, obs_pht_ray, g2_0, pairwise_concurrence; else: return t, AC_ent, Sent, Obs_t, obs_pht_ray, g2_0, pairwise_concurrence, spin_subsys_dm;
import sys, os qspin_path = os.path.join(os.getcwd(), "../") sys.path.insert(0, qspin_path) from quspin.basis import photon_basis, spin_basis_1d import numpy as np L = 4 Nph = 10 omega = 1.0 np.random.seed() basis = photon_basis(spin_basis_1d, L, Ntot=Nph) basis_full = photon_basis(spin_basis_1d, L, Nph=Nph) psi = np.random.uniform(-1, 1, size=( basis.Ns, 1)) + 1j * np.random.uniform(-1, 1, size=(basis.Ns, 1)) psi /= np.linalg.norm(psi, axis=0) psis = np.random.uniform(-1, 1, size=( basis.Ns, 100)) + 1j * np.random.uniform(-1, 1, size=(basis.Ns, 100)) psis /= np.linalg.norm(psi, axis=0) psi_full = basis.get_vec(psi, sparse=False) psis_full = basis.get_vec(psis, sparse=False) n_state = 10 psis = np.exp(-1j * np.random.uniform( -np.pi, np.pi, size=(basis.Ns, n_state))) / np.sqrt(basis.Ns) psis_full = basis.get_vec(psis, full_part=False, sparse=False)
Nph = Nph_tot / 2 # mean number of photons in initial coherent state Omega = 3.5 # drive frequency A = 0.8 # spin-photon coupling strength (drive amplitude) Delta = 1.0 # difference between atom energy levels # ##### set up photon-atom Hamiltonian ##### # define operator site-coupling lists ph_energy = [[Omega]] # photon energy at_energy = [[Delta, 0]] # atom energy absorb = [[A / (2.0 * np.sqrt(Nph)), 0]] # absorption term emit = [[A / (2.0 * np.sqrt(Nph)), 0]] # emission term # define static and dynamics lists static = [["|n", ph_energy], ["x|-", absorb], ["x|+", emit], ["z|", at_energy]] dynamic = [] # compute atom-photon basis basis = photon_basis(spin_basis_1d, L=1, Nph=Nph_tot) # compute atom-photon Hamiltonian H H = hamiltonian(static, dynamic, dtype=np.float64, basis=basis) # ##### set up semi-classical Hamiltonian ##### # define operators dipole_op = [[A, 0]] # define periodic drive and its parameters def drive(t, Omega): return np.cos(Omega * t) drive_args = [Omega] # define semi-classical static and dynamic lists