def parity(state, **args):

    parity_state = state[::-1]

    index_ps = ff.get_index(parity_state, **args)

    return parity_state, index_ps
Exemplo n.º 2
0
def main():
    global part_index, prefix
    if not os.path.exists(directory):
        os.makedirs(directory)
    os.chdir(directory)

    download_task(av, start, end)
    part_index, prefix = get_index(av)
    rename_file(directory, part_index, prefix)
    print('Finish!')
Exemplo n.º 3
0
def inital_state(part_ind, **args):

    b_p_inp = args.get("parity_index")
    b_p = np.asarray(b_p_inp)
    DX = args.get("sim_sec_len")

    PARITY = args.get("parity")

    nn = args.get("nn")
    ll = args.get("ll")
    BASE_bose = args.get("BASE_bose")
    DIM_H = args.get("DIM_H")

    state = np.zeros(ll, dtype=np.int)

    for x in range(nn):
        state[part_ind[x]] += int(1)

    state_con = ff.FROM_bose_TO_bin(state, **args)
    state_ind = ff.get_index(state_con, **args)
    B = np.zeros(DIM_H, dtype=np.double)

    if PARITY == 'True':

        state_rev_ind = ham_par.parity(state_con, **args)[1]

        ind = min(state_ind, state_rev_ind)
        par_ind = b_p[ind]

        i_s = par_ind[0]
        i_a = par_ind[3] + DX

        if state_ind == state_rev_ind:

            B[i_s] = 1

        elif state_ind < state_rev_ind:

            B[i_s] = +np.sqrt(2) / 2
            B[i_a] = +np.sqrt(2) / 2

        elif state_ind > state_rev_ind:

            B[i_s] = +np.sqrt(2) / 2
            B[i_a] = -np.sqrt(2) / 2

    else:

        B[state_ind] += 1

    return B
def weight_2_ind(i,j,st,**args):

	B_bose 	 = args.get('BASE_bose')	#.......[3 0 0 0 0 0], numpy.ndarray

	peso   = int(1)
	uga    = B_bose[st]*1

	peso   *= uga[j]
	uga[j] -= int(1)

	peso   *= uga[i]+1
	uga[i] += int(1)

	ind = ff.get_index(ff.FROM_bose_TO_bin(uga,**args), **args)	

#	if peso > 0:
	return ind, np.sqrt(peso)
def weight_2_ind(i,j,st,**args):

	ll  	 = np.int(args.get("ll"))
	nn  	 = np.int(args.get("nn"))	
	B_bose 	 = args.get('BASE_bose')	#.......[3 0 0 0 0 0], numpy.ndarray

	peso   = 1
	uga    = B_bose[st]*1

	peso   *= uga[j]
	uga[j] -= 1

	peso   *= uga[i]+1
	uga[i] += 1

	ind = ff.get_index(ff.FROM_bose_TO_bin(uga,**args), **args)	

	if peso > 0:
		return ind, np.sqrt(peso)
	else:
		return ind, 0
def evaluate_ham(i, **args):

    #...... Parameter: BC, t, U, DIM_H, nn, ll

    nn = args.get("nn")
    ll = args.get("ll")
    BC = args.get("BC")
    t = args.get("t")
    bar = args.get("bar")

    #...... Functions in ham.py: action_hopping, action_interactions
    #...... Fundamental tables:  BASE_bin, HOP_list

    BASE_bin = args.get("BASE_bin")
    HOP_list = args.get("HOP_list")

    #Hamiltonian returns:
    #...... Sparse or Dense matrix. By default is SPARSE

    mat_type = args.get("mat_type")
    if mat_type == None:
        mat_type = 'Sparse'

    ham_ind1 = []
    ham_ind2 = []
    ham_val = []

    state = BASE_bin[i]

    ##----- INTERACTIONS

    int_val = action_interactions(state, **args)

    if int_val != 0.0:

        #---- INTERACTION = we store i,i,int_val !!!!
        ham_ind1.append(i)
        ham_ind2.append(i)
        ham_val.append(int_val)

##----- Barrier

    int_bar = action_potential(state, **args)

    if int_bar != 0.0:

        #---- INTERACTION = we store i,i,int_val !!!!
        ham_ind1.append(i)
        ham_ind2.append(i)
        ham_val.append(int_bar)


##----- KINETIC_first
    for hop in HOP_list:
        hop_state_bin = ff.TO_bin(state) ^ ff.TO_bin(hop)

        # we cut states with not N particles
        if ff.one_count(hop_state_bin) == nn:

            hop_state = ff.TO_con(hop_state_bin, ll + nn - 1)

            j = ff.get_index(hop_state, **args)
            kin_val = action_hopping(i, j, **args)

            if kin_val != 0.0:

                #---- KINETIC = we store i,j,kin_val !!!!
                ham_ind1.append(i)
                ham_ind2.append(j)
                ham_val.append(kin_val)

    # here we put the PERIODIC
    #...................BC=0 periodic, BC=1 open

    if BC == 0:
        if state[0] == '1':

            PBC_newstate1 = state[1:] + state[0]
            j = ff.get_index(PBC_newstate1, **args)
            kin_val = action_hopping(i, j, **args)

            if kin_val != 0.0:

                #---- KINETIC = we store i,j,kin_val !!!!
                ham_ind1.append(i)
                ham_ind2.append(j)
                ham_val.append(kin_val)

        if state[-1] == '1':

            PBC_newstate2 = state[-1] + state[:-1]
            j = ff.get_index(PBC_newstate2, **args)
            kin_val = action_hopping(i, j, **args)

            if kin_val != 0.0:

                #---- KINETIC = we store i,j,kin_val !!!!
                ham_ind1.append(i)
                ham_ind2.append(j)
                ham_val.append(kin_val)

    return [ham_ind1, ham_ind2, ham_val]
def bose_Hamiltonian_parity_fast(**args):

    DIM_H = np.int(args.get("DIM_H"))
    BASE_bin = args.get("BASE_bin")
    BASE_bose = args.get("BASE_bose")
    mat_type = args.get("mat_type")
    b_p_inp = args.get("parity_index")
    b_p = np.asarray(b_p_inp)

    len_sym = args.get("sim_sec_len")
    len_b_p = len(b_p)

    len_asym = DIM_H - len_sym

    X0_s = []
    Y0_s = []
    A0_s = []

    X0_a = []
    Y0_a = []
    A0_a = []

    for i in range(len_b_p):

        if b_p[i, 0] < 0:
            continue

        X_1, Y_1, A_1 = ham.evaluate_ham(b_p[i, 1], **args)
        X_2, Y_2, A_2 = ham.evaluate_ham(b_p[i, 2], **args)

        X = [item for sublist in [X_1, X_2] for item in sublist]
        Y = [item for sublist in [Y_1, Y_2] for item in sublist]
        A = [item for sublist in [A_1, A_2] for item in sublist]

        for j in range(len(A)):

            state_X_0 = BASE_bin[X[j]]
            state_Y_0 = BASE_bin[Y[j]]

            state_X_rev = state_X_0[::-1]
            state_Y_rev = state_Y_0[::-1]

            ind_X = X[j]
            ind_X_rev = ff.get_index(state_X_rev, **args)

            ind_Y = Y[j]
            ind_Y_rev = ff.get_index(state_Y_rev, **args)

            ind_col_X = b_p[min(ind_X, ind_X_rev), 0]
            ind_col_Y = b_p[min(ind_Y, ind_Y_rev), 0]

            coef_s = 2

            ##.... SYM SEC

            if ind_X == ind_X_rev:

                ind_col_X = b_p[ind_X, 0]
                coef_s = 2 * np.sqrt(2)

            X0_s.append(ind_col_X)

            if ind_Y == ind_Y_rev:

                ind_col_Y = b_p[ind_Y, 0]
                coef_s = 2 / np.sqrt(2)

                if ind_X == ind_X_rev:

                    coef_s = 2

            Y0_s.append(ind_col_Y)
            A0_s.append(A[j] / coef_s)

        ##.... A_SYM SEC

        for j in range(len(A_1)):

            state_X_0 = BASE_bin[X[j]]
            state_Y_0 = BASE_bin[Y[j]]

            state_X_rev = state_X_0[::-1]
            state_Y_rev = state_Y_0[::-1]

            ind_X = X[j]
            ind_X_rev = ff.get_index(state_X_rev, **args)

            ind_Y = Y[j]
            ind_Y_rev = ff.get_index(state_Y_rev, **args)

            ind_col_X = b_p[min(ind_X, ind_X_rev), 3]
            ind_col_Y = b_p[min(ind_Y, ind_Y_rev), 3]

            if Y[j] > ind_Y_rev:
                coef_a = -1

            elif Y[j] < ind_Y_rev:
                coef_a = 1

            else:
                continue

            X0_a.append(ind_col_X + len_sym)
            Y0_a.append(ind_col_Y + len_sym)
            A0_a.append(A[j] * coef_a)

    X = [item for sublist in [X0_a, X0_s] for item in sublist]
    Y = [item for sublist in [Y0_a, Y0_s] for item in sublist]
    A = [item for sublist in [A0_a, A0_s] for item in sublist]

    #Hamiltonian = csc_matrix((A, (X,Y)), shape=(DIM_H,DIM_H), dtype=np.double)
    Hamiltonian = csc_matrix((A, (X, Y)),
                             shape=(DIM_H, DIM_H),
                             dtype=np.double)

    #Hamiltonian_sym  = csc_matrix((A0_s, (X0_s,Y0_s)), shape=(len_sym,len_sym), dtype=np.double)
    #Hamiltonian_asym = csc_matrix((A0_a, (X0_a,Y0_a)), shape=(len_asym,len_asym), dtype=np.double)

    if mat_type == 'Dense':

        Hamiltonian = csc_matrix.todense(Hamiltonian)

        #Hamiltonian_sym  = csc_matrix.todense(Hamiltonian_sym)
        #Hamiltonian_asym = csc_matrix.todense(Hamiltonian_asym)

    #ff.print_matrix(Hamiltonian)

    #ff.print_matrix(Hamiltonian_sym)
    #ff.print_matrix(Hamiltonian_asym)

    return Hamiltonian  #_sym, Hamiltonian_asym