示例#1
0
    1.3814802514389157e-05,
    8.530755621904973e-06,
    7.805140739947092e-06,
    5.135065748618217e-06,
    5.082366897113388e-06,
    4.842216185352299e-06,
    7.341488071688218e-06,
    7.706037649768405e-06,
]

eps = np.linalg.norm(np.array(J5q) - np.array(J5q_ref))
g.message(f"J5q test: {eps}")
assert eps < 1e-5

# compute conserved current divergence
div = g.mspin(grid)
div[:] = 0

for mu in range(4):
    tmp = qm.conserved_vector_current(dst_qm_bulk, src, dst_qm_bulk, src, mu)
    tmp -= g.cshift(tmp, mu, -1)
    div += g.color_trace(tmp)

div = g(g.trace(g.adj(div) * div))

g.message("div(conserved_current) contact term", div[0, 1, 0, 0].real)

div[0, 1, 0, 0] = 0

eps = g.sum(div).real
g.message(f"div(conserved_current) = {eps} without contact term")
示例#2
0
文件: tensors.py 项目: mbruno46/gpt
# now test outer products
cm @= cv * g.adj(cv)
assert g.norm2(cm[0, 0, 0, 0] -
               g.mcolor([[1, 2, 0], [2, 4, 0], [0, 0, 0]])) < 1e-13

# test inner and outer products
res = g.eval(cv * g.adj(cv) * cm * cv)
eps2 = g.norm2(res - g.norm2(cv)**2.0 * cv)
assert eps2 < 1e-13

# create spin color matrix and peek spin index
msc = g.mspincolor(grid)
rng.cnormal(msc)

ms = g.mspin(grid)
mc = g.mcolor(grid)

# peek spin index 1,2
mc[:] = msc[:, :, :, :, 1, 2, :, :]

A = mc[0, 1, 0, 1]
B = msc[0, 1, 0, 1]
for i in range(3):
    for j in range(3):
        eps = abs(A[i, j] - B[1, 2, i, j])
        assert eps < 1e-13

mc[0, 1, 0, 1, 2, 2] = 5

# poke spin index 1,2
示例#3
0
ref = np.exp(1j * np.dot(p_arbitrary, x)) * l_dp[xc]
val = g.eval(exp_ixp_rel * l_dp)[xc]
eps = g.norm2(ref - val)
g.message("Reference value test (arbitrary momentum with origin): ", eps)
assert eps < 1e-25

################################################################################
# Test slice sums
################################################################################
for lattice_object in [
        g.complex(grid_dp),
        g.vcomplex(grid_dp, 10),
        g.vspin(grid_dp),
        g.vcolor(grid_dp),
        g.vspincolor(grid_dp),
        g.mspin(grid_dp),
        g.mcolor(grid_dp),
        g.mspincolor(grid_dp),
]:
    g.message(f"Testing slice with random {lattice_object.describe()}")
    obj_list = [g.copy(lattice_object) for _ in range(3)]
    rng.cnormal(obj_list)

    for dimension in range(4):
        tmp = g.slice(obj_list, dimension)
        full_sliced = np.array([[g.util.tensor_to_value(v) for v in obj]
                                for obj in tmp])

        for n, obj in enumerate(obj_list):
            tmp = g.slice(obj, dimension)
            sliced = np.array([g.util.tensor_to_value(v) for v in tmp])