示例#1
0
def test_hmc(total_site, ga):
    #
    q.qmkdir_info("results")
    q.qmkdir_info("results/gf_info")
    q.qmkdir_info("results/wilson_flow_energy_info")
    q.qmkdir_info("results/gm_force_info")
    #
    geo = q.Geometry(total_site, 1)
    rs = q.RngState("test_hmc-{}x{}x{}x{}".format(total_site[0], total_site[1],
                                                  total_site[2],
                                                  total_site[3]))
    gf = q.GaugeField(geo)
    q.set_unit(gf)
    traj = 0
    for i in range(4):
        traj += 1
        run_hmc(gf, ga, traj, rs.split("hmc-{}".format(traj)))
        plaq_avg = q.gf_avg_plaq(gf)
        plaq_sum = np.prod(total_site) * 6.0 * (1.0 - plaq_avg)
        q.displayln_info("test_hmc: traj={} ; plaq_avg={}".format(
            traj, plaq_avg))
        if traj % 2 == 0:
            q.display_gauge_field_info_table_with_wilson_flow(
                "results/gf_info/traj={}.lat".format(traj),
                "results/wilson_flow_energy_info/traj={}.lat".format(traj), gf,
                0.1, 5, 2)
            q.save_gm_force_magnitudes_list(
                "results/gm_force_info/traj={}.lat".format(traj))
示例#2
0
文件: run.py 项目: rqzhang0/Qlattice
def run(job_tag, traj):
    q.qmkdir_info(f"locks")
    q.qmkdir_info(get_save_path(f""))
    q.qmkdir_info(get_save_path(f"eig"))
    q.qmkdir_info(get_save_path(f"eig/{job_tag}"))
    q.qmkdir_info(get_save_path(f"configs"))
    q.qmkdir_info(get_save_path(f"configs/{job_tag}"))
    #
    total_site = ru.get_total_site(job_tag)
    geo = q.Geometry(total_site, 1)
    q.displayln_info("geo.show() =", geo.show())
    #
    path_gf = get_load_path(f"configs/{job_tag}/ckpoint_lat.{traj}")
    if path_gf is None:
        gf = mk_sample_gauge_field(job_tag, traj)
        gf.show_info()
        gf.save(get_save_path(f"configs/{job_tag}/ckpoint_lat.{traj}"))
    else:
        gf = q.GaugeField()
        gf.load(path_gf)
    #
    if q.obtain_lock(f"locks/{job_tag}-{traj}-compute-eig"):
        get_eig = compute_eig(gf,
                              job_tag,
                              inv_type=0,
                              path=f"eig/{job_tag}/traj={traj}")
        test_eig(gf, get_eig(), job_tag, inv_type=0)
        q.release_lock()
示例#3
0
def get_fgrid(total_site, fermion_params):
    geo = q.Geometry(total_site, 1)
    gf = q.GaugeField(geo)
    gf.set_unit()
    gpt_gf = g.convert(gpt_from_qlat(gf), g.single)
    if "omega" in fermion_params:
        qm = g.qcd.fermion.zmobius(gpt_gf, fermion_params)
    else:
        qm = g.qcd.fermion.mobius(gpt_gf, fermion_params)
    return qm.F_grid_eo
示例#4
0
def qlat_from_gpt_ff4d(gpt_ff):
    ctype = "WilsonVector"
    total_site = gpt_ff.grid.fdimensions
    multiplicity = 1
    tag = "qlat_from_gpt"
    plan = get_qlat_gpt_copy_plan(ctype, total_site, multiplicity, tag)
    geo = q.Geometry(total_site, 1)
    ff = q.FermionField4d(geo)
    plan(ff.mview(), gpt_ff)
    return ff
示例#5
0
文件: run.py 项目: rqzhang0/Qlattice
def mk_sample_gauge_field(job_tag, traj):
    rs = q.RngState(f"seed {job_tag} {traj}").split("mk_sample_gauge_field")
    total_site = ru.get_total_site(job_tag)
    geo = q.Geometry(total_site, 1)
    gf = q.GaugeField(geo)
    gf.set_rand(rs, sigma=0.25, n_step=4)
    for i in range(4):
        q.gf_wilson_flow_step(gf, 0.05)
    gf.unitarize()
    return gf
示例#6
0
def qlat_from_gpt_prop(gpt_prop):
    ctype = "WilsonMatrix"
    total_site = gpt_prop.grid.fdimensions
    multiplicity = 1
    tag = "qlat_from_gpt"
    plan = get_qlat_gpt_copy_plan(ctype, total_site, multiplicity, tag)
    geo = q.Geometry(total_site, 1)
    prop_msc = q.Prop(geo)
    plan(prop_msc.mview(), gpt_prop)
    prop_wm = q.Prop(geo)
    q.convert_wm_from_mspincolor_prop(prop_wm, prop_msc)
    return prop_wm
示例#7
0
def qlat_from_gpt_gauge_field(gpt_gf):
    assert len(gpt_gf) == 4
    ctype = "ColorMatrix"
    total_site = gpt_gf[0].grid.fdimensions
    multiplicity = 1
    tag = "qlat_from_gpt"
    plan = get_qlat_gpt_copy_plan(ctype, total_site, multiplicity, tag)
    geo = q.Geometry(total_site, 1)
    fs = [q.Field(ctype, geo) for i in range(4)]
    assert len(fs) == 4
    for i in range(4):
        plan(fs[i].mview(), gpt_gf[i])
    gf = q.GaugeField()
    q.merge_fields(gf, fs)
    return gf
示例#8
0
def mk_qlat_gpt_copy_plan(ctype, total_site, multiplicity, tag):
    geo = q.Geometry(total_site, multiplicity)
    f_gpt = mk_gpt_field(ctype, geo)
    f_qlat = q.Field(ctype, geo)
    lexicographic_coordinates = g.coordinates(f_gpt)
    buf = f_qlat.mview()
    if tag == "qlat_from_gpt":
        qlat_from_gpt = g.copy_plan(buf, f_gpt)
        qlat_from_gpt.destination += g.global_memory_view(
            f_gpt.grid, [[f_gpt.grid.processor, buf, 0, buf.nbytes]])
        qlat_from_gpt.source += f_gpt.view[lexicographic_coordinates]
        qlat_from_gpt = qlat_from_gpt(local_only=True)
        return qlat_from_gpt
    elif tag == "gpt_from_qlat":
        gpt_from_qlat = g.copy_plan(f_gpt, buf)
        gpt_from_qlat.source += g.global_memory_view(
            f_gpt.grid, [[f_gpt.grid.processor, buf, 0, buf.nbytes]])
        gpt_from_qlat.destination += f_gpt.view[lexicographic_coordinates]
        gpt_from_qlat = gpt_from_qlat(local_only=True)
        return gpt_from_qlat
    else:
        q.displayln_info(tag)
        raise Exception("mk_qlat_gpt_copy_plan")
示例#9
0
    g_src_gpt = g.mspincolor(grid)
    g.create.point(g_src_gpt, xg)
    src_g = qg.qlat_from_gpt(g_src_gpt)
    #
    src_diff = src_q.copy()
    src_diff -= src_g
    #
    q.displayln_info(src_q.qnorm(), src_g.qnorm(), src_diff.qnorm())
    assert src_diff.qnorm() == 0


qg.begin_with_gpt()

rs = q.RngState("seed")
total_site = [4, 4, 4, 8]
geo = q.Geometry(total_site, 1)
q.displayln_info("geo.show() =", geo.show())

gf = q.GaugeField(geo)
gf.set_rand(rs, 0.2, 2)
gf.show_info()

test_gf(gf)

for i in range(16):
    xg = [
        rs.rand_gen() % total_site[0],
        rs.rand_gen() % total_site[1],
        rs.rand_gen() % total_site[2],
        rs.rand_gen() % total_site[3]
    ]
示例#10
0
#!/usr/bin/env python3

import qlat_gpt as qg
import qlat as q
import gpt as g

qg.begin_with_gpt()

q.qremove_all_info("results")
q.qmkdir_info("results")
rs = q.RngState("seed")
geo = q.Geometry([4, 4, 4, 8], 1)
q.displayln_info("geo.show() =", geo.show())

gf = q.GaugeField(geo)

gf.set_rand(rs.split("gf-init"), 0.05, 2)

gf.show_info()

mobius_params = {
    "mass": 0.1,
    "M5": 1.0,
    "b": 1.0,
    "c": 0.0,
    "Ls": 8,
    "boundary_phases": [1.0, 1.0, 1.0, 1.0],
}

gpt_gf = qg.gpt_from_qlat(gf)