Commit d533eaf2 authored by Alberto Ramos's avatar Alberto Ramos

Main program to test LatticeGPU.jl

parents
This diff is collapsed.
[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
BDIO = "375f315e-f2c4-11e9-2ef9-134f02f79e27"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LatticeGPU = "958c3683-801a-4582-9cfa-2d6e2ae1763b"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
# Simulations of YM with LatticeGPU.jl
This is a main program to simulate YM `SU(2)` and `SU(3)`
theories. The main porpose is to compare with the existing literature
and validate the code.
[Run]
user = "alberto"
host = "artemisa"
name = "SU2_PBC_bt2.4_L12"
seed = 1234
[Simulation]
group = "SU3" # Choose SU2, SU3
dimensions = 4
size = [12,12,12,12]
blocks = [4,4,4,4]
bcs = "SF" # Choose PERIODIC, SF
beta = 2.4
c0 = 1.0 # 1.0 is Wilson action, 1.66... is LW, 3.648 is Iwasaki
cG = 0.0 # Only used with SF bcs
[HMC]
integrator = "OMF4" # "LEAPFROPG", "OMF2", "OMF4"
ns = 10
eps = 0.1
nthm = 1000
ntraj = 10000
###
### "THE BEER-WARE LICENSE":
### Alberto Ramos wrote this file. As long as you retain this
### notice you can do whatever you want with this stuff. If we meet some
### day, and you think this stuff is worth it, you can buy me a beer in
### return. <alberto.ramos@cern.ch>
###
### file: ym.jl
### created: Wed Oct 27 11:33:34 2021
###
using LatticeGPU, TOML, BDIO, ArgParse, Random, CUDA, Pkg, InteractiveUtils, TimerOutputs, Printf
function parse_commandline()
s = ArgParseSettings()
@add_arg_table s begin
"-i"
help = "input file"
required = true
arg_type = String
end
return parse_args(s)
end
function read_options(fname)
s = TOML.parsefile(fname)
BDIO_set_user(s["Run"]["user"])
BDIO_set_host(s["Run"]["host"])
# Lattice Parameters
if s["Simulation"]["bcs"] == "PERIODIC"
BCS = BC_PERIODIC
elseif s["Simulation"]["bcs"] == "SF"
BCS = BC_SF_AFWB
end
dim = s["Simulation"]["dimensions"]
lp = SpaceParm{dim}(Tuple(x for x in s["Simulation"]["size"]),
Tuple(x for x in s["Simulation"]["blocks"]),
BCS)
# Gauge Parameters
if s["Simulation"]["group"] == "SU2"
GRP = SU2
elseif s["Simulation"]["group"] == "SU3"
GRP = SU3
end
T = Float64
gp = GaugeParm{T}(GRP{T},
s["Simulation"]["beta"],
s["Simulation"]["c0"],
(s["Simulation"]["cG"],s["Simulation"]["cG"]))
# HMC parameters
if s["HMC"]["integrator"] == "OMF4"
int = omf4(T, s["HMC"]["eps"], s["HMC"]["ns"])
elseif s["HMC"]["integrator"] == "OMF2"
int = omf2(T, s["HMC"]["eps"], s["HMC"]["ns"])
elseif s["HMC"]["integrator"] == "LEAPFROG"
int = leapfrog(T, s["HMC"]["eps"], s["HMC"]["ns"])
else
error("Unknown integrator")
end
# Write basic info to log file
flog = open(s["Run"]["name"]*".log", "w+")
println(flog, "\n## HMC LatticeGPU simulation")
println(flog, lp)
println(flog, gp)
println(flog, int)
println(flog, " # [Enviroment Info]")
println(flog, "User: ", s["Run"]["user"])
println(flog, "Host: ", s["Run"]["host"])
println(flog, " ")
versioninfo(flog)
println(flog, " ")
Pkg.status(io=flog)
# Pkg.status(mode=Pkg.PKGMODE_MANIFEST, io=flog)
println(flog, " # END [Enviroment Info]")
fb = BDIO_open(s["Run"]["name"]*".bdio", "w",
"HMC simulation with LatticeGPU")
BDIO_start_record!(fb, BDIO_ASC_GENERIC, 1, true)
BDIO_write!(fb, read(fname))
BDIO_write_hash!(fb)
# Random.seed!(CURAND.default_rng(), s["Run"]["seed"])
Random.seed!(s["Run"]["seed"])
nthm = s["HMC"]["nthm"]
nt = s["HMC"]["ntraj"]
return gp, lp, int, nthm, nt, fb, flog, GRP, T, BCS
end
parsed_args = parse_commandline()
infile = parsed_args["i"]
gp, lp, int, nthm, nt, fb, flog, GRP, T, BCS = read_options(infile)
U = vector_field(GRP{T}, lp)
fill!(U, one(GRP{T}))
ymws = YMworkspace(GRP, T, lp)
dh = Vector{T}(undef, nthm+nt)
pl = Vector{T}(undef, nthm+nt)
acc = Vector{Bool}(undef, nthm+nt)
if BCS == BC_SF_AFWB
sfc = Array{T}(undef, nthm+nt, 2)
end
println(flog, " # Thermalization")
for i in 1:nthm
dh[i], acc[i] = HMC!(U,int,lp, gp, ymws, noacc=true)
pl[i] = plaquette(U,lp, gp, ymws)
if BCS == BC_PERIODIC
@printf(flog, " THM %d/%d: %s %6.2e %20.12e \n",
i, nthm, acc[i] ? "true " : "false", dh[i], pl[i])
else
sfc[i,1], sfc[i,2] = sfcoupling(U, lp, gp, ymws)
@printf(flog, " THM %d/%d: %s %6.2e %20.12e %20.12e %20.12e \n",
i, nthm, acc[i] ? "true " : "false", dh[i], pl[i],
sfc[i,1], sfc[i,2])
end
end
println(flog, "\n # Measurements")
for i in 1:nt
k = i + nthm
dh[k], acc[k] = HMC!(U,int,lp, gp, ymws, noacc=true)
pl[k] = plaquette(U,lp, gp, ymws)
if BCS == BC_PERIODIC
@printf(flog, " MSM %d/%d: %s %6.2e %20.12e \n",
i, nt, acc[k] ? "true " : "false", dh[k], pl[k])
else
sfc[k,1], sfc[k,2] = sfcoupling(U, lp, gp, ymws)
@printf(flog, " MSM %d/%d: %s %6.2e %20.12e %20.12e %20.12e \n",
i, nt, acc[k] ? "true " : "false", dh[k], pl[k],
sfc[k,1], sfc[k,2])
end
end
print_timer(flog)
println(flog, "\n## END HMC LatticeGPU simulation")
# Measurements
#
# uid 2: dh thermalization
# uid 3: dh measurements
# uid 4: pl thermalization
# uid 5: pl measurements
# uid 8: dsdeta thermalization
# uid 9: dsdeta measurements
# uid 10: ddsdnu measurements
# uid 11: ddsdnu measurements
function write_record(fb, uid, dt)
BDIO_start_record!(fb, BDIO_BIN_F64LE, uid, true)
BDIO_write!(fb, dt[1:nthm])
BDIO_write_hash!(fb)
BDIO_start_record!(fb, BDIO_BIN_F64LE, uid+1, true)
BDIO_write!(fb, dt[1+nthm:end])
BDIO_write_hash!(fb)
return nothing
end
write_record(fb, 2, dh)
write_record(fb, 4, pl)
write_record(fb, 8, sfc[:,1])
write_record(fb, 10, sfc[:,2])
BDIO_close!(fb)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment