Example #1
0
File: wick.py Project: spieseba/gpt
        def _eval(context, path):

            t = tensor(basis(indices), context["n"])
            for idx, sign in g.epsilon(len(indices)):
                t[tuple(idx)] = sign

            return t
Example #2
0
File: baryon.py Project: lehner/gpt
def diquark(Q1, Q2):
    eps = g.epsilon(Q1.otype.shape[2])
    R = g.lattice(Q1)

    # D_{a2,a1} = epsilon_{a1,b1,c1}*epsilon_{a2,b2,c2}*spin_transpose(Q1_{b1,b2})*Q2_{c1,c2}
    Q1 = g.separate_color(Q1)
    Q2 = g.separate_color(Q2)

    D = {x: g.lattice(Q1[x]) for x in Q1}
    for d in D:
        D[d][:] = 0

    for i1, sign1 in eps:
        for i2, sign2 in eps:
            D[i2[0], i1[0]] += (sign1 * sign2 * Q1[i1[1], i2[1]] *
                                g.transpose(Q2[i1[2], i2[2]]))

    g.merge_color(R, D)
    return R
Example #3
0
                eps2 = g.norm2(lat - np) / g.norm2(lat)
            g.message(
                f"Test {tr.__name__}({a_type.__name__} + {b_type.__name__}): {eps2}"
            )
            assert eps2 < 1e-11


for a_type in [
        g.ot_matrix_spin_color(4, 3),
        g.ot_vector_spin_color(4, 3),
        g.ot_matrix_spin(4),
        g.ot_vector_spin(4),
        g.ot_matrix_color(3),
        g.ot_vector_color(3),
        g.ot_matrix_singlet(8),
        g.ot_vector_singlet(8),
]:
    a = rng.cnormal(g.lattice(grid, a_type))
    b = rng.cnormal(g.lattice(grid, a_type))

    test_linear_combinations(a, b)

# test epsilon tensor
M = np.random.rand(5, 5)
d1 = np.linalg.det(M)
d2 = 0
for idx, sign in g.epsilon(5):
    d2 += (M[0, idx[0]] * M[1, idx[1]] * M[2, idx[2]] * M[3, idx[3]] *
           M[4, idx[4]] * sign)
assert abs(d1 - d2) < 1e-13