Exemplo n.º 1
0
def fft_baryon(baryon_list, contracted_baryon, integer_momenta,
               source_position):
    lattice_momenta = np.zeros((integer_momenta.shape[0], 4), dtype=np.float64)
    lattice_momenta[:, :3] = integer_momenta * 2 * np.pi / L
    for ii, momentum in enumerate(lattice_momenta):
        phase = g.exp_ixp(-1 * momentum)
        source_phase = np.exp(1.0j * np.dot(momentum[:3], source_position[:3]))
        baryon_list.append(
            np.array(g.slice(phase * contracted_baryon, 3)[:]) * source_phase)
Exemplo n.º 2
0
    def perform(self, root):
        global basis_size, T

        output_correlator = g.corr_io.writer(f"{root}/{self.name}/head.dat")

        vcj = g.load(f"{root}/{self.conf}/pm_basis/basis")

        for m in self.mom:
            mom_str = "_".join([str(x) for x in m])
            p = np.array([
                2.0 * np.pi / vcj[0].grid.gdimensions[i] * m[i]
                for i in range(3)
            ] + [0])

            phase = g.complex(vcj[0].grid)
            phase[:] = 1
            phase @= g.exp_ixp(p) * phase

            g.message("L = ", vcj[0].grid.gdimensions)
            g.message("Momentum", p, m)

            for n in range(basis_size):
                t0 = g.time()
                vc_n = g(phase * vcj[n])
                t1 = g.time()
                slc_nprime = [
                    g(g.adj(vcj[nprime]) * vc_n)
                    for nprime in range(basis_size)
                ]
                t2 = g.time()
                slc = g.slice(slc_nprime, 3)
                t3 = g.time()

                for nprime in range(basis_size):
                    output_correlator.write(
                        f"output/mom/{mom_str}_n_{nprime}_{n}", slc[nprime])

                t4 = g.time()

                if n % 10 == 0:
                    g.message(n, "Timing", t1 - t0, t2 - t1, t3 - t2, t4 - t3)

        output_correlator.close()
Exemplo n.º 3
0
theta = 0.91231
quark0 = g.qcd.fermion.mobius(
    U_unit,
    Ls=8,
    mass=0.1,
    b=1,
    c=0,
    M5=1.8,
    boundary_phases=[np.exp(1j * theta), 1, 1, 1],
)
q0prop = quark0.propagator(
    inv.preconditioned(pc.eo2_ne(), inv.cg(eps=1e-7, maxiter=1000)))
src = g.vspincolor(U_unit[0].grid)
src[:] = 0
src[:, :, :, 0, 0, 0] = 1
prop = g(q0prop * g.exp_ixp(np.array([theta / L[0], 0, 0, 0])) * src)
prop_1000_over_0000 = complex(prop[1, 0, 0, 2, 0, 0]) / complex(prop[0, 0, 0,
                                                                     2, 0, 0])
eps = abs(prop_1000_over_0000) - 1
g.message(f"Twisted boundary covariance is a phase: {eps}")
assert eps < 1e-6
eps = abs(prop_1000_over_0000 - np.exp(1j * theta / L[0]))
g.message(f"Twisted boundary covariance as expected momentum: {eps}")
assert eps < 1e-6

# test instantiation of other actions
rhq = g.qcd.fermion.rhq_columbia(U,
                                 mass=4.0,
                                 cp=3.0,
                                 zeta=2.5,
                                 boundary_phases=[1, 1, 1, -1])
Exemplo n.º 4
0
src = g.mspincolor(grid)
rng.cnormal(src)
dst1 = g(V * smear * src)
dst2 = g(smear_transformed * V * src)
eps2 = g.norm2(dst1 - dst2) / g.norm2(dst1)
g.message(f"Covariance test: {eps2}")
assert eps2 < 1e-29

# Test smearing operator on point source over unit gauge field
for dimensions in [[0, 1, 2], [0, 1, 2, 3]]:
    for sigma, steps in [(0.5, 3), (0.16, 2)]:
        smear_unit = g.create.smear.gauss(U_unit,
                                          sigma=sigma,
                                          steps=steps,
                                          dimensions=dimensions)
        src = g.vcolor(grid)
        src[:] = g.vcolor([1, 0, 0])

        # anti-periodic boundary conditions in time mean space and time are
        # differently quantized
        p = 2.0 * np.pi * np.array([1, 2, 3, 4.5]) / L
        src_mom = g(g.exp_ixp(p) * src)

        laplace = sum([2.0 * (np.cos(p[i]) - 1.0) for i in dimensions])
        factor = (1.0 + laplace * sigma**2.0 / steps / 4.0)**steps
        dst = g(smear_unit * src_mom)
        eps2 = g.norm2(dst - factor * src_mom) / g.norm2(dst)
        g.message(f"Gaussian test using eigen representation: {eps2}")
        assert eps2 < 1e-29
Exemplo n.º 5
0
def assign_pos_view():
    lhs[pos] = l_dp.view[pos]


for method in [assign_copy, assign_pos, assign_pos_view]:
    lhs[:] = 0
    method()
    eps2 = g.norm2(lhs - l_dp) / g.norm2(l_dp)
    assert eps2 < 1e-25

################################################################################
# Test exp_ixp
################################################################################
# multiply momentum phase in l
p = 2.0 * np.pi * np.array([1, 2, 3, 4]) / L
exp_ixp = g.exp_ixp(p)

# Test one component
xc = (2, 3, 1, 5)
x = np.array(list(xc))
ref = np.exp(1j * np.dot(p, x)) * l_dp[xc]

val = g.eval(exp_ixp * l_dp)[xc]
eps = g.norm2(ref - val)
g.message("Reference value test: ", eps)
assert eps < 1e-25

# single/double
eps = g.norm2(exp_ixp * l_sp -
              g.convert(exp_ixp * l_dp, g.single)) / g.norm2(l_sp)
g.message("Momentum phase test single/double: ", eps)
Exemplo n.º 6
0
# even-odd preconditioned matrix
eo = g.qcd.fermion.preconditioner.eo2(w)

# build solver
s = g.qcd.fermion.solver
cg = g.algorithms.iterative.cg({"eps": 1e-6, "maxiter": 1000})
propagator = s.propagator(s.inv_eo_ne(eo, cg))

# propagator
dst = g.mspincolor(grid)
dst @= propagator * src

# momentum
p = 2.0 * np.pi * np.array([1, 0, 0, 0]) / L
P = g.exp_ixp(p)

# operators
G_src = g.gamma[5] * P
G_snk = g.gamma[5] * g.adj(P)
G_op = g.gamma["T"]

# 2pt
correlator_2pt = g.slice(
    g.trace(G_src * g.gamma[5] * g.adj(dst) * g.gamma[5] * G_snk * dst), 3)

# sequential solve through t=8
t_op = 8
src_seq = g.lattice(src)
src_seq[:] = 0
src_seq[:, :, :, t_op] = dst[:, :, :, t_op]
Exemplo n.º 7
0
            assert info_index["blocks"] == 1
    plan(lhs, l_dp)


for method in [assign_copy, assign_pos, assign_pos_view]:
    lhs[:] = 0
    method()
    eps2 = g.norm2(lhs - l_dp) / g.norm2(l_dp)
    assert eps2 < 1e-25

################################################################################
# Test exp_ixp
################################################################################
# multiply momentum phase in l
p = 2.0 * np.pi * np.array([1, 2, 3, 4]) / L
exp_ixp = g.exp_ixp(p)

# Test one component
xc = (2, 3, 1, 5)
x = np.array(list(xc))
ref = np.exp(1j * np.dot(p, x)) * l_dp[xc]

val = g.eval(exp_ixp * l_dp)[xc]
eps = g.norm2(ref - val)
g.message("Reference value test: ", eps)
assert eps < 1e-25

# single/double
eps = g.norm2(exp_ixp * l_sp -
              g.convert(exp_ixp * l_dp, g.single)) / g.norm2(l_sp)
g.message("Momentum phase test single/double: ", eps)
Exemplo n.º 8
0
sink_mom = 2.0 * np.pi * np.array(
    ([-1, 0, 0, 0], [0, 0, 0, 0]), dtype=float) / L
sink_moms_list = ["sink_mom_-100", "sink_mom_000"]

t_sink = 31

for pol in pols:
    g.message(pol)

    # sequential source
    tmp_seq_src = g.qcd.sequential_source.nucleon3pt_seq_src.p2p_ubaru(
        dst, pols[pol], Cg5, t_sink)

    for snk_mom_n, snk_mom in enumerate(sink_mom):
        g.message(sink_moms_list[snk_mom_n])
        P = g.exp_ixp(snk_mom)

        seq_src = g.lattice(src)
        seq_src[:] = tmp_seq_src[:]
        seq_src @= P * seq_src

        sanity_corr = g.slice(g.trace(g.adj(seq_src) * seq_src), 3)
        g.message("Sequential Source Correlator")
        for t, c in enumerate(sanity_corr):
            g.message(t, c)

        # Sequential propagator
        seq_prop = g.lattice(src)
        seq_prop @= slv_eo2 * seq_src

        sanity_corr = g.slice(g.trace(g.adj(seq_prop) * seq_prop), 3)