Esempio n. 1
0
def make_para_consistent_qes(para):
    para = make_para_consistent_idmrg(para)
    para['phys_sites'] = list(range(1, para['l_phys'] + 1))
    para['bath_sites'] = [0, para['l_phys'] + 1]
    para['positions_h2'] = hm.positions_nearest_neighbor_1d(
        para['l_phys'] + 2, 'open')
    para['num_h2'] = para['positions_h2'].shape[0]
    tmp = np.zeros((para['num_h2'], 1), dtype=int)
    tmp[0] = 1
    tmp[-1] = 2
    para['couplings'] = np.hstack((para['positions_h2'], tmp))
    para['d'] = physical_dim_from_spin(para['spin'])
    para['pos4corr'] = np.hstack(
        (np.ones((para['l_phys'] - 1, 1),
                 dtype=int), np.arange(2, para['l_phys'] + 1,
                                       dtype=int).reshape(-1, 1)))
    op = hm.spin_operators(para['spin'])
    para['op'] = [op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']]
    para['op'].append(-para['hx'] * para['op'][1] - para['hz'] * para['op'][3])
    para['data_path'] = '../data_qes/results/'
    para['data_exp'] = 'QES_ED_chainL(%d,2)_j(%g,%g)_h(%g,%g)_chi%d' % \
                       (para['l_phys'], para['jxy'], para['jz'], para['hx'],
                        para['hz'], para['chi'])
    para['bath_path'] = '../data_qes/bath/'
    para['bath_exp'] = 'bath_chain_j(%g,%g)_h(%g,%g)_chi%d' % \
                       (para['jxy'], para['jz'], para['hx'],
                        para['hz'], para['chi'])
    if para['dmrg_type'] is 'white':
        para['data_exp'] += '_white'
        para['bath_exp'] += '_white'
    para['data_exp'] += '.pr'
    para['bath_exp'] += '.pr'
    return para
Esempio n. 2
0
def make_para_consistent_tebd(para):
    para['positions_h2'] = hm.positions_nearest_neighbor_1d(
        para['l'], para['bound_cond'])
    para['num_h2'] = para['positions_h2'].shape[0]
    para['d'] = physical_dim_from_spin(para['spin'])
    op = hm.spin_operators(para['spin'])
    para['op'] = [op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']]
    para['op'].append(-para['hx'] * para['op'][1] - para['hz'] * para['op'][3])
    para['ob_time'] = int(para['iterate_time'] / para['dt_ob'])
    return para
Esempio n. 3
0
def make_para_consistent_ed(para):
    para['positions_h2'] = hm.positions_nearest_neighbor_1d(
        para['l'], para['bound_cond'])
    para['num_h2'] = para['positions_h2'].shape[0]
    tmp = np.zeros((para['num_h2'], 1), dtype=int)
    para['couplings'] = np.hstack((para['positions_h2'], tmp))
    para['d'] = physical_dim_from_spin(para['spin'])
    para['pos4corr'] = np.hstack((np.zeros(
        (para['l'] - 1, 1), dtype=int), np.arange(1, para['l'],
                                                  dtype=int).reshape(-1, 1)))
    op = hm.spin_operators(para['spin'])
    para['op'] = [op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']]
    para['op'].append(-para['hx'] * para['op'][1] - para['hz'] * para['op'][3])
    if para['task'] is not 'GS':
        para['iterate_time'] = int(para['time'] / para['tau'])
    return para
Esempio n. 4
0
 para['if_print_detail'] = False
 para['tau'] = 1e-3  # shift to ensure the GS energy has the largest magnitude
 para['eigs_tol'] = 1e-10
 para['break_tol'] = 1e-8  # tolerance for breaking the loop
 para['is_real'] = True
 para['dt_ob'] = 5  # in how many sweeps, observe to check the convergence
 para['ob_position'] = (para['l']/2).__int__()  # to check the convergence, chose a position to observe
 para['data_path'] = '.\\data_dmrg\\'
 if para['lattice'] is 'square':
     para['positions_h2'] = hm.positions_nearest_neighbor_square(
         para['square_width'], para['square_height'], para['bound_cond'])
     para['data_exp'] = 'square' + '(%d,%d)' % (para['square_width'], para['square_height']) + \
                        'N%d_j(%g,%g)_h(%g,%g)_chi%d' % (para['l'], para['jxy'], para['jz'], para['hx'],
                                                         para['hz'], para['chi']) + para['bound_cond']
 elif para['lattice'] is 'chain':
     para['positions_h2'] = hm.positions_nearest_neighbor_1d(para['l'], para['bound_cond'])
     para['data_exp'] = 'chainN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                        (para['l'], para['jxy'], para['jz'], para['hx'],
                         para['hz'], para['chi']) + para['bound_cond']
 elif para['lattice'] is 'arbitrary':
     para['data_exp'] = 'arbitraryN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                        (para['l'], para['jxy'], para['jz'], para['hx'],
                         para['hz'], para['chi']) + para['bound_cond']
 para['index1'] = np.mat(np.arange(0, para['l']))
 para['index1'] = np.vstack((para['index1'], 6 * np.ones((1, para['l'])))).T.astype(int)
 para['index2'] = hm.interactions_position2full_index_heisenberg_two_body(para['positions_h2'])
 para['coeff1'] = np.ones((para['l'], 1))
 para['coeff2'] = np.ones((para['positions_h2'].shape[0]*3, 1))
 for n in range(0, para['positions_h2'].shape[0]):
     para['coeff2'][n * 3, 0] = para['jxy']
     para['coeff2'][n * 3 + 1, 0] = para['jxy']
Esempio n. 5
0
def make_consistent_parameter_dmrg(para):
    if para['lattice'] is 'chain':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_nearest_neighbor_1d(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'chainN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
    elif para['lattice'] is 'chain_Ising_stagger_hz':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz_up'] * para['op'][3])
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz_down'] * para['op'][3])

        para['index1'] = np.zeros((para['l'], 2), dtype=int)
        for it in range(0, para['l']):
            para['index1'][it, 0] = np.int(it)
            if np.mod(it, 2) == 0:
                para['index1'][it, 1] = np.int(7)
            elif np.mod(it, 2) == 1:
                para['index1'][it, 1] = np.int(8)

        para['positions_h2'] = hm.positions_nearest_neighbor_1d(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'chainN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']

    elif para['lattice'] is 'square':
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_nearest_neighbor_square(
            para['square_width'], para['square_height'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'square' + '(%d,%d)' % (para['square_width'], para['square_height']) + \
                           'N%d_j(%g,%g)_h(%g,%g)_chi%d' % (para['l'], para['jxy'], para['jz'], para['hx'],
                                                            para['hz'], para['chi']) + para['bound_cond']
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
    elif para['lattice'] is 'arbitrary':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        # para['coeff1'] = np.array(para['coeff1']).reshape(-1, 1)
        # para['coeff2'] = np.array(para['coeff2']).reshape(-1, 1)
        # para['index1'] = np.array(para['index1'], dtype=int)
        # para['index2'] = np.array(para['index2'], dtype=int)
        para['l'] = max(max(para['index1'][:, 0]), max(para['index2'][:, 0]),
                        max(para['index2'][:, 1])) + 1
        para['positions_h2'] = from_index2_to_positions_h2(para['index2'])
        check_continuity_pos_h2(pos_h2=para['positions_h2'])
    elif para['lattice'] is 'jigsaw':
        op = hm.spin_operators(para['spin'])
        if para['bound_cond'] is 'open':
            if para['l'] % 2 == 0:
                print(
                    'Note: for OBC jigsaw, l has to be odd. Auto-change l = %g to %g'
                    % (para['l'], para['l'] + 1))
                para['l'] += 1
        else:
            if para['l'] % 2 == 1:
                print(
                    'Note: for PBC jigsaw, l has to be even. Auto-change l = %g to %g'
                    % (para['l'], para['l'] + 1))
                para['l'] += 1
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_jigsaw_1d(para['l'],
                                                      para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['l'] - (para['bound_cond'] is 'open')):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
        for n in range(para['l'] - (para['bound_cond'] is 'open'),
                       para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy1'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy1'] / 2
            para['coeff2'][n * 3 + 2] = para['jz1']
        para['data_exp'] = 'JigsawN%d_j(%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['jxy1'], para['jz1'], para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']
    elif para['lattice'] is 'zigzag':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_zigzag(para['l'],
                                                   para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['l']):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
        for n in range(para['l'], para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy1'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy1'] / 2
            para['coeff2'][n * 3 + 2] = para['jz1']
        para['data_exp'] = 'ZigzagN%d_j(%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['jxy1'], para['jz1'], para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']

    elif para['lattice'] is 'ladderJ1J2J3J4':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)  #### 指向要加的磁场的位置
        para['positions_h2'] = hm.positions_ladderJ1J2J3J4(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones(
            (para['l'], 1))  ###磁场项前面的系数,若要给系统只加部分磁场的话 要看para['coeff1']是否进了哈密顿
        nh1 = round(para['l'] / 2)
        nh2 = round((para['l'] - 2) / 2)
        nh3 = round(para['l'] - 2)
        nh4 = round((para['l'] - 2) / 2)
        coeff2_1 = np.zeros((nh1 * 3, 1))
        coeff2_2 = np.zeros((nh2 * 3, 1))
        coeff2_3 = np.zeros((nh3 * 3, 1))
        coeff2_4 = np.zeros((nh4 * 3, 1))
        for n in range(0, nh1):
            coeff2_1[n * 3] = para['jxy1'] / 2
            coeff2_1[n * 3 + 1] = para['jxy1'] / 2
            coeff2_1[n * 3 + 2] = para['jz1']
        for n in range(0, nh2):
            coeff2_2[n * 3] = para['jxy2'] / 2
            coeff2_2[n * 3 + 1] = para['jxy2'] / 2
            coeff2_2[n * 3 + 2] = para['jz2']
        for n in range(0, nh3):
            coeff2_3[n * 3] = para['jxy3'] / 2
            coeff2_3[n * 3 + 1] = para['jxy3'] / 2
            coeff2_3[n * 3 + 2] = para['jz3']
        for n in range(0, nh4):
            coeff2_4[n * 3] = para['jxy4'] / 2
            coeff2_4[n * 3 + 1] = para['jxy4'] / 2
            coeff2_4[n * 3 + 2] = para['jz4']
        para['coeff2'] = np.vstack((coeff2_1, coeff2_2, coeff2_3, coeff2_4))
        para['data_exp'] = 'ladderJ1J2J3J4N%d_j(%g,%g,%g,%g,%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
            (para['l'], para['jxy1'], para['jz1'], para['jxy2'], para['jz2'],para['jxy3'], para['jz3'],
             para['jxy4'], para['jz4'],para['hx'],
             para['hz'], para['chi']) + para['bound_cond']
    elif para['lattice'] is 'sawtooth_ladder':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)  #### 指向要加的磁场的位置
        para['positions_h2'] = hm.positions_sawtooth_ladder(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones(
            (para['l'], 1))  ###磁场项前面的系数,若要给系统只加部分磁场的话 要看para['coeff1']是否进了哈密顿
        if para['bound_cond'] is 'periodic':
            nh1 = round(para['l'])
            nh2 = round(para['l'] / 2)
            nh3 = round(para['positions_h2'].shape[0] - nh1 - nh2)
        elif para['bound_cond'] is 'open':
            nh1 = round(para['l'] - 2)
            nh2 = round(para['l'] / 2 - 1)
            nh3 = round(para['positions_h2'].shape[0] - nh1 - nh2)
        coeff2_1 = np.zeros((nh1 * 3, 1))
        coeff2_2 = np.zeros((nh2 * 3, 1))
        coeff2_3 = np.zeros((nh3 * 3, 1))
        for n in range(0, nh1):
            coeff2_1[n * 3] = para['jxy_nn'] / 2
            coeff2_1[n * 3 + 1] = para['jxy_nn'] / 2
            coeff2_1[n * 3 + 2] = para['jz_nn']
        for n in range(0, nh2):
            coeff2_2[n * 3] = para['jxy_nnn'] / 2
            coeff2_2[n * 3 + 1] = para['jxy_nnn'] / 2
            coeff2_2[n * 3 + 2] = para['jz_nnn']
        for n in range(0, nh3):
            coeff2_3[n * 3] = para['jxy_rung'] / 2
            coeff2_3[n * 3 + 1] = para['jxy_rung'] / 2
            coeff2_3[n * 3 + 2] = para['jz_rung']
        para['coeff2'] = np.vstack((coeff2_1, coeff2_2, coeff2_3))
        para['data_exp'] = 'sawtooth_ladderN%d_J_(%g,%g,%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
                   (para['l'], para['jxy_nn'], para['jz_nn'], para['jxy_nnn'], para['jz_nnn'],
                    para['jxy_rung'], para['jz_rung'], para['hx'], para['hz'], para['chi']) + para['bound_cond']

    elif para['lattice'] is 'sawtooth_ladder_v2':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)  #### 指向要加的磁场的位置
        para['positions_h2'] = hm.positions_sawtooth_ladder_v2(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones(
            (para['l'], 1))  ###磁场项前面的系数,若要给系统只加部分磁场的话 要看para['coeff1']是否进了哈密顿
        if para['bound_cond'] is 'periodic':
            nh1 = round(para['l'])
            nh2 = round(para['l'] / 2)
            nh3 = round(para['positions_h2'].shape[0] - nh1 - nh2)
        elif para['bound_cond'] is 'open':
            nh1 = round(para['l'] - 2)
            nh2 = round(para['l'] / 2 - 1)
            nh3 = round(para['positions_h2'].shape[0] - nh1 - nh2)
        coeff2_1 = np.zeros((nh1 * 3, 1))
        coeff2_2 = np.zeros((nh2 * 3, 1))
        coeff2_3 = np.zeros((nh3 * 3, 1))
        for n in range(0, nh1):
            coeff2_1[n * 3] = para['jxy_nn'] / 2
            coeff2_1[n * 3 + 1] = para['jxy_nn'] / 2
            coeff2_1[n * 3 + 2] = para['jz_nn']
        for n in range(0, nh2):
            coeff2_2[n * 3] = para['jxy_nnn'] / 2
            coeff2_2[n * 3 + 1] = para['jxy_nnn'] / 2
            coeff2_2[n * 3 + 2] = para['jz_nnn']
        for n in range(0, nh3):
            coeff2_3[n * 3] = para['jxy_rung'] / 2
            coeff2_3[n * 3 + 1] = para['jxy_rung'] / 2
            coeff2_3[n * 3 + 2] = para['jz_rung']
        para['coeff2'] = np.vstack((coeff2_1, coeff2_2, coeff2_3))
        para['data_exp'] = 'sawladderv2_N%d_J_(%g,%g,%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy_nn'], para['jz_nn'], para['jxy_nnn'], para['jz_nnn'],
                            para['jxy_rung'], para['jz_rung'], para['hx'], para['hz'], para['chi']) + para['bound_cond']

    elif para['lattice'] is 'square_yy':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)  #### 指向要加的磁场的位置

        para['positions_h2'] = hm.positions_square_yy(para['Lx'], para['Ly'],
                                                      para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones(
            (para['l'], 1))  ###磁场项前面的系数,若要给系统只加部分磁场的话 要看para['coeff1']是否进了哈密顿

        coeff2 = np.zeros((3 * para['positions_h2'].shape[0], 1))
        for n in range(para['positions_h2'].shape[0]):
            coeff2[n * 3] = para['jxy'] / 2
            coeff2[n * 3 + 1] = para['jxy'] / 2
            coeff2[n * 3 + 2] = para['jz']
        para['coeff2'] = coeff2
        para['data_exp'] = 'square_yyN(%d,%d)_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['Lx'],para['Ly'],para['jxy'], para['jz'],para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']

    elif para['lattice'] is 'ladder_simple':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)  #### 指向要加的磁场的位置

        para['positions_h2'] = hm.positions_ladder_simple(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones(
            (para['l'], 1))  ###磁场项前面的系数,若要给系统只加部分磁场的话 要看para['coeff1']是否进了哈密顿

        coeff2 = np.zeros((3 * para['positions_h2'].shape[0], 1))
        for n in range(para['l'] - 2):
            coeff2[n * 3] = para['jxy'] / 2
            coeff2[n * 3 + 1] = para['jxy'] / 2
            coeff2[n * 3 + 2] = para['jz']
        for n in range(para['l'] - 2, para['l'] - 2 + np.int(para['l'] / 2)):
            coeff2[n * 3] = para['jxy_rung'] / 2
            coeff2[n * 3 + 1] = para['jxy_rung'] / 2
            coeff2[n * 3 + 2] = para['jz_rung']
        para['coeff2'] = coeff2
        para['data_exp'] = 'ladder_simpleN%d_j(%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'],para['jxy'], para['jz'],para['jxy_rung'],para['jz_rung'],para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']

    elif para['lattice'] is 'full':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_fully_connected(para['l'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'fullConnectedN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi'])
        if para['is_pauli']:
            para['coeff1'] = np.ones((para['l'], 1)) * 2
        else:
            para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            if para['is_pauli']:
                para['coeff2'][n * 3] = para['jxy'] * 2
                para['coeff2'][n * 3 + 1] = para['jxy'] * 2
                para['coeff2'][n * 3 + 2] = para['jz'] * 4
            else:
                para['coeff2'][n * 3] = para['jxy'] / 2
                para['coeff2'][n * 3 + 1] = para['jxy'] / 2
                para['coeff2'][n * 3 + 2] = para['jz']
    elif para['lattice'] is 'longRange':
        op = hm.spin_operators(para['spin'])
        para['op'] = [
            op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']
        ]
        para['op'].append(-para['hx'] * para['op'][1] -
                          para['hz'] * para['op'][3])
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_fully_connected(para['l'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'longRange' + para['bound_cond'] + 'N%d_j(%g,%g)_h(%g,%g)_chi%d_alpha%g' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi'], para['alpha'])
        if para['is_pauli']:
            para['coeff1'] = np.ones((para['l'], 1)) * 2
        else:
            para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            if para['bound_cond'] is 'open':
                dist = abs(para['positions_h2'][n, 0] -
                           para['positions_h2'][n, 1])
            else:  # periodic
                dist = min(
                    abs(para['positions_h2'][n, 0] -
                        para['positions_h2'][n, 1]),
                    para['l'] - abs(para['positions_h2'][n, 0] -
                                    para['positions_h2'][n, 1]))
            const = dist**(para['alpha'])
            if para['is_pauli']:
                para['coeff2'][n * 3] = para['jxy'] * 2 / const
                para['coeff2'][n * 3 + 1] = para['jxy'] * 2 / const
                para['coeff2'][n * 3 + 2] = para['jz'] * 4 / const
            else:
                para['coeff2'][n * 3] = para['jxy'] / 2 / const
                para['coeff2'][n * 3 + 1] = para['jxy'] / 2 / const
                para['coeff2'][n * 3 + 2] = para['jz'] / const
    para['d'] = physical_dim_from_spin(para['spin'])
    para['nh'] = para['index2'].shape[0]  # number of two-body interactions
    return para
Esempio n. 6
0
def make_consistent_parameter_dmrg(para):
    if para['lattice'] is 'chain':
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_nearest_neighbor_1d(
            para['l'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'chainN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
    elif para['lattice'] is 'square':
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_nearest_neighbor_square(
            para['square_width'], para['square_height'], para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'square' + '(%d,%d)' % (para['square_width'], para['square_height']) + \
                           'N%d_j(%g,%g)_h(%g,%g)_chi%d' % (para['l'], para['jxy'], para['jz'], para['hx'],
                                                            para['hz'], para['chi']) + para['bound_cond']
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
    elif para['lattice'] is 'arbitrary':
        para['l'] = max(max(para['index1'][:, 0]), max(para['index2'][:, 0]),
                        max(para['index2'][:, 1])) + 1
        para['positions_h2'] = from_index2_to_positions_h2(para['index2'])
        check_continuity_pos_h2(pos_h2=para['positions_h2'])
    elif para['lattice'] is 'jigsaw':
        if para['bound_cond'] is 'open':
            if para['l'] % 2 == 0:
                print(
                    'Note: for OBC jigsaw, l has to be odd. Auto-change l = %g to %g'
                    % (para['l'], para['l'] + 1))
                para['l'] += 1
        else:
            if para['l'] % 2 == 1:
                print(
                    'Note: for PBC jigsaw, l has to be even. Auto-change l = %g to %g'
                    % (para['l'], para['l'] + 1))
                para['l'] += 1
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_jigsaw_1d(para['l'],
                                                      para['bound_cond'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['l'] - (para['bound_cond'] is 'open')):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
        for n in range(para['l'] - (para['bound_cond'] is 'open'),
                       para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy1'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy1'] / 2
            para['coeff2'][n * 3 + 2] = para['jz1']
        para['data_exp'] = 'JigsawN%d_j(%g,%g,%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['jxy1'], para['jz1'], para['hx'],
                            para['hz'], para['chi']) + para['bound_cond']
    elif para['lattice'] is 'full':
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_fully_connected(para['l'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'fullConnectedN%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi'])
        if para['is_pauli']:
            para['coeff1'] = np.ones((para['l'], 1)) * 2
        else:
            para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            if para['is_pauli']:
                para['coeff2'][n * 3] = para['jxy'] * 2
                para['coeff2'][n * 3 + 1] = para['jxy'] * 2
                para['coeff2'][n * 3 + 2] = para['jz'] * 4
            else:
                para['coeff2'][n * 3] = para['jxy'] / 2
                para['coeff2'][n * 3 + 1] = para['jxy'] / 2
                para['coeff2'][n * 3 + 2] = para['jz']
    elif para['lattice'] is 'longRange':
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para['positions_h2'] = hm.positions_fully_connected(para['l'])
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'longRange' + para['bound_cond'] + 'N%d_j(%g,%g)_h(%g,%g)_chi%d_alpha%g' % \
                           (para['l'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi'], para['alpha'])
        if para['is_pauli']:
            para['coeff1'] = np.ones((para['l'], 1)) * 2
        else:
            para['coeff1'] = np.ones((para['l'], 1))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, 1))
        for n in range(0, para['positions_h2'].shape[0]):
            if para['bound_cond'] is 'open':
                dist = abs(para['positions_h2'][n, 0] -
                           para['positions_h2'][n, 1])
            else:  # periodic
                dist = min(
                    abs(para['positions_h2'][n, 0] -
                        para['positions_h2'][n, 1]),
                    para['l'] - abs(para['positions_h2'][n, 0] -
                                    para['positions_h2'][n, 1]))
            const = dist**(para['alpha'])
            if para['is_pauli']:
                para['coeff2'][n * 3] = para['jxy'] * 2 / const
                para['coeff2'][n * 3 + 1] = para['jxy'] * 2 / const
                para['coeff2'][n * 3 + 2] = para['jz'] * 4 / const
            else:
                para['coeff2'][n * 3] = para['jxy'] / 2 / const
                para['coeff2'][n * 3 + 1] = para['jxy'] / 2 / const
                para['coeff2'][n * 3 + 2] = para['jz'] / const
    elif para['lattice'] is 'husimi':
        para['positions_h2'] = hm.positions_husimi(para['depth'])
        para['l'] = para['positions_h2'].max() + 1
        para['index1'] = np.mat(np.arange(0, para['l']))
        para['index1'] = np.vstack((para['index1'], 6 * np.ones(
            (1, para['l'])))).T.astype(int)
        para[
            'index2'] = hm.interactions_position2full_index_heisenberg_two_body(
                para['positions_h2'])
        para['data_exp'] = 'HusimiDepth%d_j(%g,%g)_h(%g,%g)_chi%d' % \
                           (para['depth'], para['jxy'], para['jz'], para['hx'],
                            para['hz'], para['chi'])
        para['coeff1'] = np.ones((para['l'], ))
        para['coeff2'] = np.zeros((para['positions_h2'].shape[0] * 3, ))
        for n in range(0, para['positions_h2'].shape[0]):
            para['coeff2'][n * 3] = para['jxy'] / 2
            para['coeff2'][n * 3 + 1] = para['jxy'] / 2
            para['coeff2'][n * 3 + 2] = para['jz']
    para['d'] = physical_dim_from_spin(para['spin'])
    para['nh'] = para['index2'].shape[0]  # number of two-body interactions
    op = hm.spin_operators(para['spin'])
    para['op'] = [op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd']]
    para['op'].append(-para['hx'] * op['sx'] - para['hz'] * op['sz'])
    return para