qlat.c — Central C Extension Loader and API Aggregator¶
Source: qlat/qlat/c.py.in
Note: Update this document when updating the source file.
Outline¶
Overview¶
qlat.c is the single entry point that loads the compiled C++ shared
library (libqlat.so / libqlat.dylib) into the Python process and then
re-exports every public symbol from the internal Cython and Python
submodules. Importing this module is equivalent to importing the entire
low-level C-backed API of qlat.
The module is generated from a Mako template (.py.in) that expands
type-specific Field{Type}, SelectedField{Type}, and SelectedPoints{Type}
class names for every lattice data type.
Before loading the library the module temporarily enables RTLD_GLOBAL so
that dependent Cython extensions can resolve symbols from the same shared
object.
Exported API Categories¶
The module’s __all__ list groups symbols by functional area:
Category |
Key Symbols |
|---|---|
MPI / Node |
|
Geometry |
|
Fields |
|
Field Selection |
|
Shuffle |
|
Lock / Quit |
|
Field Operations |
|
Gauge Field |
|
Propagators |
|
Smearing |
|
Topology |
|
Wilson Flow |
|
Gauge Action |
|
HMC |
|
Muon Line |
|
HLBL Contract |
|
Fields I/O |
|
Re-exported Submodules¶
After loading the shared library, the module imports and re-exports symbols from these internal submodules:
Submodule |
Domain |
|---|---|
|
All qlat-utils low-level symbols |
|
Cython bindings for qlat C++ core |
|
File I/O utilities |
|
MPI communication |
|
Lattice geometry |
|
Field base classes |
|
Typed field classes |
|
Field/point selection |
|
Selected field classes |
|
Selected points classes |
|
Field utility operations |
|
QCD-specific operations |
|
Propagator types and operations |
|
Smearing operations |
|
Hybrid Monte Carlo |
|
Gauge action |
|
Topological charge |
|
Wilson flow |
|
Muon line integrals |
|
HLBL contractions |
|
Shuffled fields I/O |
Examples¶
Load the library and inspect available symbols¶
import qlat as q
q.begin_with_mpi([])
print("Number of MPI nodes:", q.get_num_node())
print("Node ID:", q.get_id_node())
q.end_with_mpi()
Create a geometry and field¶
import qlat as q
q.begin_with_mpi([])
geo = q.Geometry(q.Coordinate([4, 4, 4, 8]))
gf = q.GaugeField(geo)
gf.set_unit()
print("Average plaq:", q.gf_avg_plaq(gf))
q.end_with_mpi()
Matrix operations¶
import qlat_utils as q
gamma = q.get_gamma_matrix(0)
wm = q.WilsonMatrix()
tr = q.mat_tr_wm(wm)
wm2 = q.mat_mul_wm_wm(wm, wm)