Ejemplo n.º 1
0
bases = [(basis_1d_S, basis_1d_pauli_1, basis_1d_pauli_2),
         (spin_basis_general_S, spin_basis_general_pauli_1,
          spin_basis_general_pauli_2)]

no_checks = dict(check_herm=False,
                 check_pcon=False,
                 check_symm=False,
                 dtype=np.float64)

for basis_S, basis_pauli_1, basis_pauli_2 in bases:

    # check Op and Op_bra_ket functions
    for static in opstr_lists:

        static_list = _consolidate_static(static)

        compare_inplace_Op(static_list,
                           basis_S,
                           basis_pauli_1,
                           1 / 2**2,
                           test_ratio=False)
        compare_inplace_Op(static_list,
                           basis_S,
                           basis_pauli_2,
                           1 / 2**2,
                           test_ratio=True)

        compare_Op(static_list,
                   basis_S,
                   basis_pauli_1,
Ejemplo n.º 2
0
#####


# setting up site-coupling lists
J1_list=[[J1,i,T_x[i]] for i in range(N_2d)] + [[J1,i,T_y[i]] for i in range(N_2d)]
J2_list=[[J2,i,T_d[i]] for i in range(N_2d)] + [[J2,i,T_a[i]] for i in range(N_2d)]
#
static=[ ["++",J1_list],["--",J1_list],["zz",J1_list],  
		 ["++",J2_list],["--",J2_list],["zz",J2_list]
		]

static_spfs=[ ["++|",J1_list],["--|",J1_list], ["|++",J1_list],["|--",J1_list], ["z|z",J1_list],
			  ["++|",J2_list],["--|",J2_list], ["|++",J2_list],["|--",J2_list], ["z|z",J2_list],
		]

static_list = _consolidate_static(static)
static_list_spfs = _consolidate_static(static_spfs)



def compare(static_list,basis,basis_op):
	for opstr,indx,J in static_list:
		ME,bra,ket = basis.Op_bra_ket(opstr,indx,J,np.float64,basis_op.states)
		ME_op,row,col = basis_op.Op(opstr,indx,J,np.float64)
		np.testing.assert_allclose(bra - basis_op[row],0.0,atol=1E-5,err_msg='failed bra/row in Op_bra_cket test!')
		np.testing.assert_allclose(ket - basis_op[col],0.0,atol=1E-5,err_msg='failed ket/col in Op_bra_ket test!')
		np.testing.assert_allclose(ME - ME_op,0.0,atol=1E-5,err_msg='failed ME in Op_bra_ket test!')


for Np in [ None, 2, N_2d-1, [N_2d//4,N_2d//8] ]:
Ejemplo n.º 3
0
P_y = (Lx - x - 1) + Lx * y  # reflection about y-axis
P_d = y + Lx * x  # reflection about diagonal
#
Z = -(sites + 1)  # spin inversion
#
###### setting up operator string for Hamiltonian matrix elements H_{ss'} ######
# setting up site-coupling lists for the J1-J2 model on a 2d square lattice
J1_list = [[J1, i, T_x[i]] for i in range(N_2d)] + [[J1, i, T_y[i]]
                                                    for i in range(N_2d)]
J2_list = [[J2, i, T_d[i]] for i in range(N_2d)] + [[J2, i, T_a[i]]
                                                    for i in range(N_2d)]
# setting up opstr list
static = [["xx", J1_list], ["yy", J1_list], ["zz", J1_list], ["xx", J2_list],
          ["yy", J2_list], ["zz", J2_list]]
# convert static list to format which is easy to use with the basis_general.Op and basis_general.Op_bra_ket methods.
static_formatted = _consolidate_static(static)
#
###### setting up basis object without computing the basis (make=False) ######
basis = spin_basis_general(
    N_2d,
    pauli=0,
    make_basis=False,
    Nup=N_2d // 2,
    kxblock=(T_x, 0),
    kyblock=(T_y, 0),
    pxblock=(P_x, 0),
    pyblock=(P_y, 0),
    pdblock=(P_d, 0),
    zblock=(Z, 0),
    block_order=[
        'zblock', 'pdblock', 'pyblock', 'pxblock', 'kyblock', 'kxblock'