def D_DWF(dst, src, b, c, mass_plus, mass_minus): D_W = g.qcd.fermion.wilson_clover( U, mass=-1.8, csw_r=0.0, csw_t=0.0, nu=1.0, xi_0=1.0, isAnisotropic=False, boundary_phases=[1, 1, 1, -1], ) src_s = g.separate(src, 0) dst_s = [g.lattice(s) for s in src_s] Ls = len(src_s) src_plus_s = [] src_minus_s = [] for s in range(Ls): src_plus_s.append(g(0.5 * src_s[s] + 0.5 * g.gamma[5] * src_s[s])) src_minus_s.append(g(0.5 * src_s[s] - 0.5 * g.gamma[5] * src_s[s])) for d in dst_s: d[:] = 0 for s in range(Ls): dst_s[s] += b * D_W * src_s[s] + src_s[s] for s in range(1, Ls): dst_s[s] += c * D_W * src_plus_s[s - 1] - src_plus_s[s - 1] for s in range(0, Ls - 1): dst_s[s] += c * D_W * src_minus_s[s + 1] - src_minus_s[s + 1] dst_s[0] -= mass_plus * (c * D_W * src_plus_s[Ls - 1] - src_plus_s[Ls - 1]) dst_s[Ls - 1] -= mass_minus * (c * D_W * src_minus_s[0] - src_minus_s[0]) dst @= g.merge(dst_s, 0)
def lattice_reverse_check(lat): grid = lat.grid l_rev_ref = g.lattice(lat) l_rev_ref.checkerboard(lat.checkerboard().inv()) T = grid.fdimensions[3] for t in range(T): # 31 <- 0 => interchange even and odd sites l_rev_ref[:, :, :, T - t - 1] = lat[:, :, :, t] l_rev = g.merge(list(reversed(g.separate(lat, 3))), 3) eps = g.norm2(l_rev - l_rev_ref) g.message("Temporal inverse lattice test: ", eps) assert eps == 0.0
l_rev = g.merge(list(reversed(g.separate(lat, 3))), 3) eps = g.norm2(l_rev - l_rev_ref) g.message("Temporal inverse lattice test: ", eps) assert eps == 0.0 lattice_reverse_check(l[0]) lattice_reverse_check(l_rb[0]) ################################################################################ # Test merge/separate here ################################################################################ assert all([g.norm2(x) > 0 for x in l]) # Test merging slices along a new last dimension 4 at a time m = g.merge(l, N=4) assert len(m) == Nlat // 4 for i in range(len(m)): for j in range(4): k = i * 4 + j assert g.norm2(l[k][1, 2, 0, 0] - m[i][1, 2, 0, 0, j]) == 0.0 # Test merging slices along a new 2nd dimension 4 at a time m = g.merge(l, 1, N=4) assert len(m) == Nlat // 4 for i in range(len(m)): for j in range(4): k = i * 4 + j assert g.norm2(l[k][1, 2, 0, 0] - m[i][1, j, 2, 0, 0]) == 0.0
def mrg(x): return g.merge(x, dimension=0)
def mrg(x, N=-1): return g.merge(g(x), dimension=0, N=N)
g.unsplit(Vt, Vt_split, cache) g.message("Project to group (should only remove rounding errors)") Vt = [g.project(vt, "defect") for vt in Vt] g.message("Test") # test results for t in range(Nt): f = g.qcd.gauge.fix.landau([Usep[mu][t] for mu in range(3)]) dfv = f.gradient(Vt[t], Vt[t]) theta = g.norm2(dfv).real / Vt[t].grid.gsites / dfv.otype.Nc g.message(f"theta[{t}] = {theta}") g.message(f"V[{t}][0,0,0] = ", Vt[t][0, 0, 0]) if theta > p_theta_eps or np.isnan(theta): g.message(f"Time slice{t} did not converge: {theta} >= {p_theta_eps}") sys.exit(1) # merge time slices V = g.merge(Vt, 3) U_transformed = g.qcd.gauge.transformed(U, V) # remove rounding errors on U_transformed U_transformed = [g.project(u, "defect") for u in U_transformed] # save results g.save(f"{p_source}.Coulomb", U_transformed, g.format.nersc()) g.save(f"{p_source}.CoulombV", V)