コード例 #1
0
def gap_gap_correlator(state, pairing, adj):
    '''
        ⟨\\Delta^{\\dag} \\Delta⟩ = \\sum\\limits_{ijkl} \\Delta_{ij}^* \\Delta_{kl} c^{\\dag}_{j, down} c^{\\dag}_{i, up} c_{k, up} c_{l, down} = 
                                  = \\sum\\limits_{ijkl} \\Delta_{ij}^* \\Delta_{kl} d_{j + L} d^{\\dag}_{i} d_k d^{\\dag}_{l + L} = 
                                  = \\sum\\limits_{ijkl} \\Delta_{ij}^* \\Delta_{kl} d^{\\dag}_{i} d_{j + L} d^{\\dag}_{l + L} d_k = 
                                  = \\sum\\limits_{ijkl} \\Delta_{ij}^* \\Delta_{kl} [F(i, j + L, k, l + L) - D(i, j + L) D(k, l + L)}]
    '''

    L = len(state[3]) // 2
    correlator = 0.0
    for i in range(
            pairing.shape[0]
    ):  # over the whole lattice (exploit translational invariance)
        for j in np.where(pairing[i, :] != 0.0)[0]:
            for k in np.where(
                    adj[i, :] != 0.0
            )[0]:  # only the sites located at certain distance from i
                for l in np.where(pairing[k, :] != 0.0)[0]:
                    correlator += np.real((wf_vmc.get_wf_ratio_double_exchange(*state, i, j + L, l + L, k) - \
                                           wf_vmc.get_wf_ratio(*state, i, j + L) * wf_vmc.get_wf_ratio(*state, l + L, k)) * \
                                           np.conj(pairing[i, j]) * pairing[k, l])

    # normalize pairing for the number of bonds coming from every site
    correlator /= np.sum(np.abs(pairing[0, :])) / np.sum(adj)
    return correlator
コード例 #2
0
ファイル: tests.py プロジェクト: nikita-astronaut/XQMC
def test_double_move_check(config):
    success = True
    print('Testing double moves ⟨x|d^{\\dag}_i d_j d^{\\dag}_k d_l|Ф⟩ / ⟨x|Ф⟩', flush=True)
    n_agreed = 0
    n_failed = 0
    # wf = wavefunction_singlet(config, config.pairings_list, config.initial_parameters, False, None)
    while n_agreed < 20:
        print('try', n_agreed)
        wf = wavefunction_singlet(config, config.pairings_list, config.initial_parameters, False, None)
        L = len(wf.state) // 2
        i, j, k, l = np.random.randint(0, 2 * L, size = 4)
        print(i, j, k, l)
        #if i == j or i == l or k == l or k == j:
        #    continue  # the degenerate cases are considered separately (directly by density operator)

        initial_ampl = wf.current_ampl
        state = deepcopy((wf.Jastrow, wf.W_GF, wf.place_in_string, wf.state, wf.occupancy))
        ratio_fast = get_wf_ratio_double_exchange(*state, wf.var_f, i, j, k, l)
        
        W_ij_0 = get_wf_ratio(*state, wf.var_f, i, j)
        acc = wf.perform_MC_step(proposed_move = (i, j))[0]

        if not acc:
            print('failed first acc')
            continue
        wf.perform_explicit_GF_update()
        state = (wf.Jastrow, wf.W_GF, wf.place_in_string, wf.state, wf.occupancy)

        middle_ampl = wf.current_ampl

        W_kl_upd = get_wf_ratio(*state, wf.var_f, k, l)
        ratio_check = W_kl_upd * W_ij_0

        acc = wf.perform_MC_step(proposed_move = (k, l))[0]
        if not acc:
            print('failed 2nd acc')
            continue
        wf.perform_explicit_GF_update()
        final_ampl = wf.current_ampl

        ratio_straight = final_ampl / initial_ampl

        if np.allclose([ratio_fast, ratio_fast], [ratio_straight, ratio_check], atol = 1e-11, rtol = 1e-11):
            n_agreed += 1
            print('success', i, j, k, l)
        else:
            print('double move check ⟨x|d^{\\dag}_i d_j d^{\\dag}_k d_l|Ф⟩ / ⟨x|Ф⟩ failed:', ratio_fast / ratio_straight, ratio_straight, ratio_check, i, j, k, l)
            n_failed += 1
            success = False
            exit(-1)
    if n_failed == 0:
        print('Passed')
    else:
        print('Failed on samples:', n_failed)

    return success
コード例 #3
0
ファイル: tests.py プロジェクト: nikita-astronaut/XQMC
def test_onsite_gf_is_density_check(config):
    success = True
    print('Testing ⟨x|d^{\\dag}_i d_i|Ф⟩ / ⟨x|Ф⟩ = n_i', flush=True)
    n_agreed = 0
    n_failed = 0
    wf = wavefunction_singlet(config, config.pairings_list, config.initial_parameters, False, None)

    while n_agreed < 50:
        L = len(wf.state) // 2
        i = np.random.randint(0, 2 * L)

        state = (wf.Jastrow, wf.W_GF, wf.place_in_string, wf.state, wf.occupancy)
        gf = get_wf_ratio(*state, wf.var_f, i, i)

        density = float(wf.place_in_string[i] > -1)
        
        if np.isclose(density, gf, atol = 1e-11, rtol = 1e-11):
            n_agreed += 1
        else:
            print('Testing ⟨x|d^{\\dag}_i d_i|Ф⟩ / ⟨x|Ф⟩ = n_i failed:', density, gf, i)
            n_failed += 1
            success = False
    if n_failed == 0:
        print('Passed')
    else:
        print('Failed on samples:', n_failed)

    return success
コード例 #4
0
def get_EJ(edges_J, wf_state, tf):
    L = len(wf_state[3]) // 2
    E_loc = 0.0 + 0.0j

    for i in range(edges_J.shape[0] // 2):
        for j in range(edges_J.shape[1] // 2):

            if edges_J[i * 2, j * 2] == 0:
                continue

            for s in range(2):
                for o in range(2):
                    for sp in range(2):
                        for op in range(2):

                            if s == 0 and sp == 0:
                                E_loc += -edges_J[
                                    2 * i,
                                    2 * j] * get_wf_ratio_double_exchange(
                                        *wf_state, tf, 2 * i + o, 2 * i + op,
                                        2 * j + op, 2 * j + o)
                            if s == 0 and sp == 1:
                                E_loc += -edges_J[2 * i, 2 * j] * (
                                    -get_wf_ratio_double_exchange(
                                        *wf_state, tf, 2 * i + o, 2 * j + op +
                                        L, 2 * i + op + L, 2 * j + o)
                                )  # no delta since i != j by definition of NN Hund
                            if s == 1 and sp == 0:
                                E_loc += -edges_J[2 * i, 2 * j] * (
                                    -get_wf_ratio_double_exchange(
                                        *wf_state, tf, 2 * j + op, 2 * i + o +
                                        L, 2 * j + o + L, 2 * i + op))

                            if s == 1 and sp == 1:
                                d_o_op = 1.0 if o == op else 0.0
                                E_loc += -edges_J[2 * i, 2 * j] * (
                                    get_wf_ratio_double_exchange(
                                        *wf_state, tf, 2 * i + op + L, 2 * i +
                                        o + L, 2 * j + o + L, 2 * j + op + L) +
                                    d_o_op**2 - d_o_op *
                                    (get_wf_ratio(*wf_state, tf, 2 * j + o + L,
                                                  2 * j + op + L) +
                                     get_wf_ratio(*wf_state, tf, 2 * i + o + L,
                                                  2 * i + op + L)))
    return E_loc
コード例 #5
0
ファイル: tests.py プロジェクト: nikita-astronaut/XQMC
def test_gf_means_correct(config):
    success = True
    print('Testing Greens function ⟨x|d^{\\dag}_i d_k|Ф⟩ / ⟨x|Ф⟩', flush=True)
    n_agreed = 0
    n_failed = 0

    for _ in range(200):
        wf = wavefunction_singlet(config, config.pairings_list, config.initial_parameters, False, None)
        L = len(wf.state) // 2
        i, j = np.random.randint(0, 2 * L, size = 2)

        initial_ampl = wf.current_ampl
        state = (wf.Jastrow, wf.W_GF, wf.place_in_string, wf.state, wf.occupancy)
        ratio_fast = get_wf_ratio(*state, wf.var_f, i, j)
        
        acc = wf.perform_MC_step((i, j), enforce = False)[0]
        if not acc:
            continue
コード例 #6
0
def get_E_quadratic(base_state, edges_quadratic, wf_state, total_fugacity):
    E_loc = 0.0 + 0.0j

    for i in range(len(base_state)):
        for j in range(len(base_state)):
            if edges_quadratic[i, j] == 0:
                continue

            if i == j:
                E_loc += edges_quadratic[i, i] * density(wf_state[2], i)
                #print(E_loc, edges_quadratic[i, i], density(wf_state[2], i), 'density')
                #exit(-1)
                continue
            if not (base_state[i] == 1 and base_state[j] == 0):
                continue
            E_loc += edges_quadratic[i, j] * get_wf_ratio(
                *wf_state, total_fugacity, i, j)
            #print(get_wf_ratio(*wf_state, total_fugacity, i, j), i, j, total_fugacity)
            #print(E_loc, edges_quadratic[i, j], get_wf_ratio(*wf_state, total_fugacity, i, j), 'kinetik')
    return E_loc
コード例 #7
0
ファイル: tests.py プロジェクト: nikita-astronaut/XQMC
def test_single_move_check(config):
    success = True
    print('Testing simple moves ⟨x|d^{\\dag}_i d_k|Ф⟩ / ⟨x|Ф⟩', flush=True)
    n_agreed = 0
    n_failed = 0
    wf = wavefunction_singlet(config, config.pairings_list, config.initial_parameters, False, None)
    #for MC_step in range(config.MC_thermalisation):
    #    wf.perform_MC_step()
    #wf.perform_explicit_GF_update()

    for _ in range(20):
        wf = wavefunction_singlet(config, config.pairings_list, config.initial_parameters, False, None)
        L = len(wf.state) // 2
        i, j = np.random.randint(0, 2 * L, size = 2)

        initial_ampl = wf.current_ampl
        state = (wf.Jastrow, wf.W_GF, wf.place_in_string, wf.state, wf.occupancy)
        ratio_fast = get_wf_ratio(*state, wf.var_f, i, j)
        acc = wf.perform_MC_step((i, j), enforce = True)[0]
        if not acc:
            continue
        wf.perform_explicit_GF_update()
        final_ampl = wf.current_ampl
        final_ampl_solid = wf.get_cur_Jastrow_factor() * wf.get_cur_det()

        if np.isclose(final_ampl / initial_ampl, ratio_fast) and np.isclose(final_ampl_solid, final_ampl):
            n_agreed += 1

        else:
            print('single move check ⟨x|d^{\\dag}_i d_k|Ф⟩ / ⟨x|Ф⟩ failed:', final_ampl / initial_ampl, ratio_fast)
            n_failed += 1
            success = False
    if n_failed == 0:
        print('Passed')
    else:
        print('Failed on samples:', n_failed)

    return success