コード例 #1
0
def main_routine(arg, c):
    start_time = time.time()
    #Extract MPI paramteres
    mpi_size = c.Get_size()
    mpi_rank = c.Get_rank()
    #Define simulation paramteres
    L = arg.L
    J = 1.0
    mu0 = arg.mu0
    dJ = arg.delJ * J
    T = arg.T
    cyc = arg.cyc
    num_conf = arg.num_conf
    nT = 2 * cyc
    num_sub = 10  #number of subsystem
    list_sub = 10 * np.arange(1, num_sub + 1)
    save_data = True
    if nT < 40:
        num_CC_samples = cyc
    else:
        num_CC_samples = 20
    '''
		#########################################  Main Code  ##############################################
	'''
    #Initial correlation matrix
    HH_start = ham(J, dJ, L, np.zeros(L))
    CC_0 = alternate_occupy(L)
    #Initialize the storage matrices
    fname = "WDIR/Mar8/Data/SQ_ALT_ANDERSON_L_%d_dJ_%g_mu0_%g_T_%g_cyc_%d_ncnf_%g_" % (
        L, dJ, mu0, T, cyc, num_conf * mpi_size)
    #m_energy = np.zeros((num_conf,nT))
    #m_nbar = np.zeros((num_conf,nT))
    m_imb = np.zeros((num_conf, nT))
    #m_absb_energy = np.zeros((num_conf,nT))
    m_diag = np.zeros((num_conf, nT, L))
    #m_curr = np.zeros((num_conf,nT,L))
    #m_excit = np.zeros((num_conf,L))
    m_entropy = np.zeros((num_conf, nT, num_sub))
    #m_CC = np.zeros((num_conf,num_CC_samples,L,L),dtype=complex)
    #m_mu = np.zeros((num_conf,L))
    #tlist = []
    '''
		#########################################  Loop over configurations and time  ##############################################
	'''
    for k in range(num_conf):
        mu_array = np.random.uniform(-mu0, mu0, L)
        #m_mu[k,:] = mu_array.copy()
        #Define two Hamiltonians
        #Hamiltonian with (J+dJ)
        HH_h = ham(J, dJ, L, mu_array)
        v_eps_h, DD_h = np.linalg.eigh(HH_h)
        EE_h = np.diag(np.exp(-1j * 0.5 * T * v_eps_h))
        UU_h = np.dot(np.conj(DD_h), np.dot(EE_h, DD_h.T))
        #Hamiltonian with (J-dJ)
        HH_l = ham(J, -dJ, L, mu_array)
        v_eps_l, DD_l = np.linalg.eigh(HH_l)
        EE_l = np.diag(np.exp(-1j * 0.5 * T * v_eps_l))
        UU_l = np.dot(np.conj(DD_l), np.dot(EE_l, DD_l.T))
        #initialize correlation matrix to the ground state of HH_start
        CC_t = CC_0.copy()
        #j=0
        for i in range(nT):
            #if i in np.linspace(2,nT-1,num_CC_samples,endpoint=True):
            #	m_CC[k,j,:,:] = CC_t.copy()
            #	j = j+1
            #	tlist.append(i*T/2)
            #Calculate Hamiltonian
            #m_nbar[k,i] = np.trace(CC_t).real
            m_imb[k, i] = func.imbalance(np.diag(CC_t).real)
            m_diag[k, i, :] = np.diag(CC_t).real
            for ent_iter in range(num_sub):
                ent, eig_ent = func.vonNeumann_entropy(
                    CC_t[0:list_sub[ent_iter], 0:list_sub[ent_iter]])
                m_entropy[k, i, ent_iter] = ent
            if i % 2 == 0:
                #m_energy[k,i] = np.sum(np.multiply(HH_h,CC_t)).real
                # m_absb_energy[k,i] = (m_energy[k,i] - m_energy[k,0])
                #m_curr[k,i,:] = func.charge_current(J+dJ,0.,CC_t)
                CC_next = np.dot(np.conj(UU_h.T), np.dot(CC_t, UU_h))
            else:
                #m_energy[k,i] = np.sum(np.multiply(HH_l,CC_t)).real
                # m_absb_energy[k,i] = (m_energy[k,i] - m_energy[k,0])
                #m_curr[k,i,:] = func.charge_current(J-dJ,0.,CC_t)
                CC_next = np.dot(np.conj(UU_l.T), np.dot(CC_t, UU_l))
            CC_t = CC_next.copy()

        #m_absb_energy[k,:] = func.absorbed_energy(m_energy[k,:],HH_h)
        #m_excit[k,:] = func.energy_excitations(v_eps_h,DD_h,CC_t)
    '''
		############################	Gather the data to be saved 	##################################################
	'''
    #recv_energy = None
    #recv_nbar = None
    recv_imb = None
    #recv_absb_energy = None
    recv_diag = None
    #recv_curr = None
    #recv_excit = None
    recv_entropy = None
    #recv_CC = None
    #recv_mu = None
    if mpi_rank == 0:
        #recv_energy = np.empty([mpi_size,num_conf,nT])
        #recv_nbar = np.empty([mpi_size,num_conf,nT])
        recv_imb = np.empty([mpi_size, num_conf, nT])
        #recv_absb_energy = np.empty([mpi_size,num_conf,nT])
        recv_diag = np.empty([mpi_size, num_conf, nT, L])
        #recv_curr = np.empty([mpi_size,num_conf,nT,L])
        #recv_excit = np.empty([mpi_size,num_conf,L])
        recv_entropy = np.empty([mpi_size, num_conf, nT, num_sub])
        #recv_CC = np.empty([mpi_size,num_conf,num_CC_samples,L,L],dtype=complex)
        #recv_mu = np.empty([mpi_size,num_conf,L])
    #c.Gather(m_energy,recv_energy,root=0)
    #c.Gather(m_nbar,recv_nbar,root=0)
    c.Gather(m_imb, recv_imb, root=0)
    #c.Gather(m_absb_energy,recv_absb_energy,root=0)
    c.Gather(m_diag, recv_diag, root=0)
    #c.Gather(m_curr,recv_curr,root=0)
    #c.Gather(m_excit,recv_excit,root=0)
    c.Gather(m_entropy, recv_entropy, root=0)
    #c.Gather(m_CC,recv_CC,root=0)
    #c.Gather(m_mu,recv_mu,root=0)
    if mpi_rank == 0:
        recv_diag = np.mean(recv_diag, (0, 1))
        #recv_curr = np.mean(recv_curr,(0,1))
        if save_data == True:
            #np.save(fname+"tlist.npy",tlist)
            #np.save(fname+"energy.npy",recv_energy)
            #np.save(fname+"nbar.npy",recv_nbar)
            np.save(fname + "imb.npy", recv_imb)
            #np.save(fname+"absb.npy",recv_absb_energy)
            np.save(fname + "diag.npy", recv_diag)
            #np.save(fname+"curr.npy",recv_curr)
            #np.save(fname+"excit.npy",recv_excit)
            np.save(fname + "entropy.npy", recv_entropy)
            #np.save(fname+"CC.npy",recv_CC)
            #np.save(fname+"mu.npy",recv_mu)
            print("Data files saved at : %s" % fname)
    end_time = time.time()
    print('Time taken by rank %d : %g seconds' %
          (mpi_rank, end_time - start_time))
コード例 #2
0
def main_routine(arg, c):
    start_time = time.time()
    #Extract MPI paramteres
    mpi_size = c.Get_size()
    mpi_rank = c.Get_rank()
    #Define simulation paramteres
    L = arg.L
    J = 1.0
    mu0 = arg.mu0
    A = arg.A
    w = arg.w
    num_steps = arg.num_steps
    num_period = arg.num_period
    num_conf = arg.num_conf
    nT = num_period * num_steps
    save_data = True
    dt = (2 * np.pi / w) / num_steps
    T = [n * dt for n in range(nT)]
    '''
		#########################################  Main Code  ##############################################
	'''
    #Initial correlation matrix
    HH_start = func.ham_anderson_insl_PBC(L, J, A, np.zeros(L))
    eps_start, DD_start = np.linalg.eigh(HH_start)
    CC_0 = ground_state(L // 2, HH_start)
    #Initialize the storage matrices
    fname = "WDIR/Feb25/Data/ANDERSON_L_%d_mu0_%g_w_%g_steps_%d_tf_%g_ncnf_%g_" % (
        L, mu0, w, num_steps, num_period, num_conf * mpi_size)
    m_energy = np.zeros((num_conf, nT))  #energy expectation value
    m_nbar = np.zeros((num_conf, nT))  #Average occupation
    m_imb = np.zeros((num_conf, nT))  #Imbalance
    m_absb_energy = np.zeros(
        (num_conf, nT))  #Absorbed energy as defined in ref
    m_diag = np.zeros((num_conf, nT, L))  #Diagonal of correlation matrix
    m_curr = np.zeros((num_conf, nT, L))  #Charge current
    m_excit = np.zeros((num_conf, L))  #Excitions as defined in ref
    '''
		#########################################  Loop over configurations and time  ##############################################
	'''
    for k in range(num_conf):
        mu_array = np.random.uniform(-mu0, mu0, L)
        UU_list = []
        HH_list = []
        for j in range(num_steps):
            phi = A * np.cos(w * T[j])
            HH = func.ham_anderson_insl_PBC(L, J, phi, mu_array)
            v_eps, DD = np.linalg.eigh(HH)
            EE = np.diag(np.exp(-1j * dt * v_eps))
            UU = np.dot(np.conj(DD), np.dot(EE, DD.T))
            UU_list.append(UU)
            HH_list.append(HH)
        CC_t = CC_0.copy()

        for i in range(nT):
            #Calculate Hamiltonian
            HH_now = HH_list[i % num_steps]
            UU_now = UU_list[i % num_steps]
            m_nbar[k, i] = np.trace(CC_t).real
            m_imb[k, i] = func.imbalance(np.diag(CC_t).real)
            m_diag[k, i, :] = np.diag(CC_t).real
            m_energy[k, i] = np.sum(np.multiply(HH_now, CC_t)).real
            m_absb_energy[k, i] = (m_energy[k, i] - m_energy[k, 0])
            m_curr[k, i, :] = func.charge_current(J, A * np.cos(w * T[i]),
                                                  CC_t)
            CC_next = np.dot(np.conj(UU_now.T), np.dot(CC_t, UU_now))

            CC_t = CC_next.copy()

        m_absb_energy[k, :] = m_absb_energy[k, :] / (
            0.5 * m_energy[k, -1] + 0.5 * m_energy[k, -2] - m_energy[k, 0])
        #calculate excitations at time=tf
        for m in range(L):
            if eps_start[m] < 0:
                m_excit[k, m] = 1.0 - np.dot(
                    DD_start.T, np.dot(CC_t, np.conj(DD_start)))[m, m].real
            else:
                m_excit[k, m] = np.dot(DD_start.T,
                                       np.dot(CC_t, np.conj(DD_start)))[m,
                                                                        m].real
    '''
		############################	Gather the data to be saved 	##################################################
	'''
    recv_energy = None
    recv_nbar = None
    recv_imb = None
    recv_absb_energy = None
    recv_diag = None
    recv_curr = None
    recv_excit = None
    if mpi_rank == 0:
        recv_energy = np.empty([mpi_size, num_conf, nT])
        recv_nbar = np.empty([mpi_size, num_conf, nT])
        recv_imb = np.empty([mpi_size, num_conf, nT])
        recv_absb_energy = np.empty([mpi_size, num_conf, nT])
        recv_diag = np.empty([mpi_size, num_conf, nT, L])
        recv_curr = np.empty([mpi_size, num_conf, nT, L])
        recv_excit = np.empty([mpi_size, num_conf, L])
    c.Gather(m_energy, recv_energy, root=0)
    c.Gather(m_nbar, recv_nbar, root=0)
    c.Gather(m_imb, recv_imb, root=0)
    c.Gather(m_absb_energy, recv_absb_energy, root=0)
    c.Gather(m_diag, recv_diag, root=0)
    c.Gather(m_curr, recv_curr, root=0)
    c.Gather(m_excit, recv_excit, root=0)
    if mpi_rank == 0:
        recv_diag = np.mean(recv_diag, (0, 1))
        recv_curr = np.mean(recv_curr, (0, 1))
        if save_data == True:
            np.save(fname + "energy.npy", recv_energy)
            np.save(fname + "nbar.npy", recv_nbar)
            np.save(fname + "imb.npy", recv_imb)
            np.save(fname + "absb.npy", recv_absb_energy)
            np.save(fname + "diag.npy", recv_diag)
            np.save(fname + "curr.npy", recv_curr)
            np.save(fname + "excit.npy", recv_excit)
            print("Files successfully saved at : ", fname)
    end_time = time.time()
    print('Time taken by rank %d : %g seconds' %
          (mpi_rank, end_time - start_time))
コード例 #3
0
def main_routine(arg, c, alpha):
    start_time = time.time()
    #Extract MPI paramteres
    mpi_size = c.Get_size()
    mpi_rank = c.Get_rank()
    #Define simulation paramteres
    L = arg.L
    J = 1.0
    mu_h = arg.mu_h
    mu_l = arg.mu_l
    delta = arg.delta
    T = arg.T
    cyc = arg.cyc
    num_conf = arg.num_conf
    nT = cyc
    #Hamiltonian paramteres
    sigma = 0.5 * (1. + np.sqrt(5.))
    list_sub = np.array([10, 30, 50, 70,
                         100])  #list of subsystems for entropy calculation
    num_sub = np.shape(list_sub)[
        0]  #number of subsystems for entropy calculation
    save_data = True
    '''
		#########################################  Main Code  ##############################################
	'''
    #Initial correlation matrix
    #data storing variables
    fname = "WDIR/Apr9/Data/ISING_ALT_L_%d_muh_%g_mul_%g_delta_%g_T_%g_cyc_%d_ncnf_%g_" % (
        L, mu_h, mu_l, delta, T, cyc, num_conf * mpi_size)
    m_diag = np.zeros((num_conf, nT, L))
    m_imb = np.zeros((num_conf, nT))
    m_entropy = np.zeros((num_conf, nT, num_sub))
    # m_mu = np.zeros((num_conf,L))
    # m_GG = np.zeros((num_conf,nT,2*L,2*L),dtype=complex)
    '''
		#########################################  Loop over configurations and time  ##############################################
	'''
    for k in range(num_conf):
        #Define onsite potential
        mu_array = np.asarray([
            np.cos(2 * np.pi * sigma * nsite + alpha[k]) for nsite in range(L)
        ])

        #Define two Hamiltonians
        #Hamiltonian with (J+dJ)
        HH_h = pf.ham(L, J, delta, mu_h * mu_array)
        UU_h, VV_h = pf.dynamics(HH_h, 0.5 * T)  #C(t+1) = UU*C*VV
        #Hamiltonian with (J-dJ)
        HH_l = pf.ham(L, J, delta, mu_l * mu_array)
        UU_l, VV_l = pf.dynamics(HH_l, 0.5 * T)  #C(t+1) = UU*C*VV
        #initialize correlation matrix to the alternate occupied half-filled state
        CC_0, FF_0 = pf.alt_initial_state(L)
        GG_t = pf.construct_G(CC_0, FF_0)
        UU = np.dot(UU_l, UU_h)
        VV = np.dot(VV_h, VV_l)
        #Initialize the state  to ground state of HH_h
        #GG_t = pf.ground_initial_state(L,HH_h)

        for i in range(nT):
            m_imb[k,
                  i] = methods.imbalance(np.diag(GG_t[L:2 * L, L:2 * L]).real)
            m_diag[k, i, :] = np.diag(GG_t[L:2 * L, L:2 * L]).real
            for ent_iter in range(num_sub):
                m_entropy[k, i, ent_iter] = pf.pairing_entropy(
                    GG_t, list_sub[ent_iter])
            GG_t = np.dot(UU, np.dot(GG_t, VV))
            #GG_t = GG_next.copy()
    '''
		############################	Gather the data to be saved 	##################################################
	'''
    recv_imb = None
    recv_diag = None
    recv_entropy = None
    recv_GG = None
    if mpi_rank == 0:
        recv_imb = np.empty([mpi_size, nT])
        recv_diag = np.empty([mpi_size, nT, L])
        recv_entropy = np.empty([mpi_size, nT, num_sub])
    c.Gather(np.mean(m_imb, 0), recv_imb, root=0)
    c.Gather(np.mean(m_diag, 0), recv_diag, root=0)
    c.Gather(np.mean(m_entropy, 0), recv_entropy, root=0)
    if mpi_rank == 0:
        recv_diag = np.mean(recv_diag, 0)
        recv_imb = np.mean(recv_imb, 0)
        recv_entropy = np.mean(recv_entropy, 0)
        if save_data == True:
            np.save(fname + "imb.npy", recv_imb)
            np.save(fname + "diag.npy", recv_diag)
            np.save(fname + "entropy.npy", recv_entropy)
            #np.save(fname+"mu.npy",recv_mu)
            print("Data files saved at : %s" % fname)
    end_time = time.time()
    print('Time taken by rank %d : %g seconds ' %
          (mpi_rank, end_time - start_time))