add an implementation to read the first ~200 bytes of the par file of openQCD's qcd2
This commit is contained in:
parent
f98521b5a1
commit
5c37c06b13
1 changed files with 56 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import os
|
||||||
import fnmatch
|
import fnmatch
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import struct
|
||||||
|
|
||||||
|
|
||||||
def read_ms1_param(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
def read_ms1_param(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
||||||
|
|
@ -304,3 +305,58 @@ def extract_t1(path: Path, project: str, dir_in_project: str, param: dict[str, A
|
||||||
t1_dict[param["type"]] = {}
|
t1_dict[param["type"]] = {}
|
||||||
t1_dict[param["type"]][pars] = t0
|
t1_dict[param["type"]][pars] = t0
|
||||||
return t1_dict
|
return t1_dict
|
||||||
|
|
||||||
|
|
||||||
|
def read_par_file(fname: str) -> dict[str, dict[str, Any]]:
|
||||||
|
|
||||||
|
def _qcd2_write_lat_parms() -> dict[str, Any]:
|
||||||
|
lat_pars = {}
|
||||||
|
|
||||||
|
t = fp.read(16)
|
||||||
|
lat_pars["N"] = list(struct.unpack('iiii', t)) # lattice extends
|
||||||
|
t = fp.read(8)
|
||||||
|
nk, isw = struct.unpack('ii', t)
|
||||||
|
lat_pars["nk"] = nk
|
||||||
|
lat_pars["isw"] = isw
|
||||||
|
t = fp.read(8)
|
||||||
|
lat_pars["beta"] = struct.unpack('d', t)[0]
|
||||||
|
t = fp.read(8)
|
||||||
|
lat_pars["c0"] = struct.unpack('d', t)[0]
|
||||||
|
t = fp.read(8)
|
||||||
|
lat_pars["c1"] = struct.unpack('d', t)[0]
|
||||||
|
t = fp.read(8)
|
||||||
|
lat_pars["csw"] = struct.unpack('d', t)[0]
|
||||||
|
kappas = []
|
||||||
|
m0s = []
|
||||||
|
for ik in range(nk):
|
||||||
|
t = fp.read(8)
|
||||||
|
kappas.append(struct.unpack('d', t)[0])
|
||||||
|
t = fp.read(8)
|
||||||
|
m0s.append(struct.unpack('d', t)[0])
|
||||||
|
lat_pars["kappas"] = kappas
|
||||||
|
lat_pars["m0s"] = m0s
|
||||||
|
return lat_pars
|
||||||
|
|
||||||
|
def _qcd2_write_bc_parms() -> dict[str, Any]:
|
||||||
|
bc_pars = {}
|
||||||
|
t = fp.read(4)
|
||||||
|
bc_pars["type"] = struct.unpack('i', t)[0]
|
||||||
|
t = fp.read(104)
|
||||||
|
bc_parms = struct.unpack('d'*13, t)
|
||||||
|
bc_pars["cG"] = list(bc_parms[:2])
|
||||||
|
bc_pars["cF"] = list(bc_parms[2:4])
|
||||||
|
phi = [[], []]
|
||||||
|
phi[0] = list(bc_parms[4:7])
|
||||||
|
phi[1] = list(bc_parms[7:10])
|
||||||
|
bc_pars["phi"] = phi
|
||||||
|
bc_pars["theta"] = list(bc_parms[10:])
|
||||||
|
return bc_pars
|
||||||
|
|
||||||
|
with open(fname, "rb") as fp:
|
||||||
|
lat_par_dict = _qcd2_write_lat_parms()
|
||||||
|
bc_par_dict = _qcd2_write_bc_parms()
|
||||||
|
fp.close()
|
||||||
|
par_dict = {}
|
||||||
|
par_dict["lat"] = lat_par_dict
|
||||||
|
par_dict["bc"] = bc_par_dict
|
||||||
|
return par_dict
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue