Serial Module Reference¶
This guide summarises the serial implementation that lives under src/QAssemble/. Use it as a map when extending the solver, plumbing new data into the HDF5 workflow, or coordinating work between modules.
Top-Level Driver (src/QAssemble/run.py)¶
- Entry points
The
Runclass is the main driver. It can be invoked via the CLI commandqassemble(defined insrc/QAssemble/cli.py) or viapython -m QAssemble(defined insrc/QAssemble/__main__.py). The legacy scriptsrc/QAssemble.pyis retained for backward compatibility. - Run lifecycle
Instantiating
Run(test=False)callsReadInput, stores the parsed control dictionary, and dispatches toRunDiagEfor methodstb,hf, orgw. Passingtest=Truebuilds a lightweightCorrelationFunctioninstance without launching a full run. - Input discovery
ReadInputexecutesinput.ini, expectingCrystal,Hamiltonian, andControlsections. It writes a canonicalised copy to<prefix>.h5under/input(creating the file on first run) and compares subsequent executions to guard against stale prefixes. - Derived dictionaries
The routine populates nested dictionaries for
crystal,ft,ham, andrun, filling defaults such asMode=FromScratch. HelperCheckKeyinStringraises early errors if required configuration keys are missing. - HDF5 bookkeeping
When an existing
<prefix>.h5is present,ReadInputmirrors the new settings against the stored/inputgroup. It aborts if values diverge, forcing the user to pick a new prefix. Fresh runs dump the executed Python objects into the HDF5 tree throughDict2Hdf5. Additional helpersHdf52Dict,CheckInput,ChangeInput, andCompareDictmanage round-trip serialisation and input validation. - Environment expectations
Ensure dependencies such as
h5py,numpy, andmpi4pyare available; MPI-specific packages are no-ops in serial mode but must still import cleanly.
Core Entry Points¶
src/QAssemble/CorrelationFunction.pyCorrelationFunctionorchestrates the full workflow. It parses the control dictionary produced by theRunclass and exposesTightBinding,HartreeFock, andGWApproximation. Each solver builds crystal data (Crystal), frequency grids (DLR), then calls into the fermionic/bosonic lattice helpers to compute self-energies, mix them, and persist results to<prefix>.h5. The helperSCFCheckevaluates self-consistency convergence between iterations.src/QAssemble/Crystal.pyHolds lattice metadata: lattice vectors, basis positions, spin count, and index maps between composite, fermionic, and bosonic spaces. Key helpers such asFAtomOrb,BAtomOrb,OrbSpin2Composite,Composite2OrbSpin, andQuad2Doubleconvert between different orbital labellings. Methods likeKpath,KPoint, andMappingRVecgenerate momentum grids that downstream modules reuse. Additional methods includeBoson2Fermion,Boson2Full,SetFullBasis,Projectorfor projection setup, and symmetry helpersR2mRMapping,R2mR,RT2mRmT,T2mT.
Fermionic Lattice Modules¶
src/QAssemble/FLatDyn.pyFLatDynhandles momentum-frequency (k, omega) Green's functions for fermions using a discrete Lehmann representation (DLR). Core methods includeF2T/T2Ftransforms,Momentfor high-frequency tails, andK2R/R2Kfor Fourier hopping between reciprocal and real space. Additional methods provideInverse,Mixing,Dyson,ChemEmbedding,StcEmbedding,Spectral,R2KArb,KArb,Diagonalize, and symmetry operationsR2mR/T2mT/TauB2TauF. Helper classes manage common workflows:GreenBarebuilds non-interacting propagators (Cal) and writes them to disk (Save).GreenIntiteratively adjusts the chemical potential withCalMu0,Occ(property),SearchMu,UpdateMu, andNumOfE.SigmaGWCevaluates GW self-energies (Cal), computes the static part (SigmaStc), and renormalisation factors viaZfactor.GreenABconverts interpolated data between k-indexed layouts (KI2KF).src/QAssemble/FLatStc.pyProvides band-structure and static self-energy routines.FLatStcexposesInverse,K2R/R2K,Band,DOS,Visualization,Mixing,Dyson,ChemEmbedding,R2KArb,Diagonalize,HermitianCheck,SortKpoint, andKValley. Subcomponents:NIHamiltonianconstructs k-space Hamiltonians (Cal,Save) and optional valley-resolved blocks (Valley,AntiValley).SigmaHartreeandSigmaFockcreate mean-field corrections (Cal,Save).Hamiltoniancontrols charge self-consistency:CalMu0,NumOfE,SearchMu,Occ(property),UpdateMu,OccMixing,Save.HamiltonianABoffers k-path interpolation helpers for A/B sublattice presentations (KI2KF).ZFactorcomputes quasiparticle renormalisation from the frequency-dependent self-energy (Cal,Save).SigmaStcextracts the static component of the GW self-energy (Cal,Save).src/QAssemble/FPathDyn.pyEvaluates dynamic quantities along high-symmetry paths. The constructor can rebuildCrystalandDLRfrom an HDF5 checkpoint when invoked with only a file name.Inverse,R2K, andKArbprovide on-the-fly interpolation.MQEMWrapperandMQEMPreparebridge to the Julia-basedMQEMexperiments.Spectralcomputes spectral functions along paths.src/QAssemble/FPathStc.pyStatic analogue ofFPathDyn. It supports custom path transforms (R2K,K2R), slab projections (Slab,SlabZmat,SlabKpoint), and diagnostics likeGaussian,Dos,Band,FermiSurface,Occ, andMoments.Reshaperearranges k-point data layouts.
Bosonic Lattice Modules¶
src/QAssemble/BLatDyn.pyControls bosonic lattice dynamics.Inversebuilds composite orbital-spin blocks,Moment/F2T/T2Fshare the DLR pipeline with fermions, andK2R/R2Kadapt the phase factors to bosonic indexing. Additional methods includeMixing,Dyson,StcEmbedding,RT2mRmT,TauF2TauB,R2KArb,Save, and index-space conversions (Quad2Double,Double2Quad,Double2Full,Full2Double,Quad2Full,Full2Quad). High-level classes:PolLatcomputes polarisation tensors (Cal,Save).WLatcomputes screened-interaction tensors (Cal,Save).src/QAssemble/BLatStc.pyProvides static (omega=0) bosonic response support. Core methods:Inverse,K2R/R2K,Mixing,Dyson,Save,R2KArb,HermitianCheck, plus the same index-space conversions asBLatDyn. Subcomponent:VBareevaluates bare Coulomb kernels (Cal,LocPlusNonLoc,OhnoYukawa,OhnoParameter,JTHPotential) and writes parameter tables withSave.src/QAssemble/BPathDyn.py/BPathStc.pyMinimal wrappers that exposeR2Ktransforms for k-path extraction from real-space datasets.
Local Bosonic Module¶
src/QAssemble/BLocStc.pyBLocStcmanages static local (impurity-level) bosonic quantities. Methods includeInverse,Mixing,Dyson,Save,Imp2Loc/Loc2Impfor mapping between impurity and local representations,Arr2Dict/Dict2Arrfor converting between array and dictionary formats, and index-space conversions. Subcomponent:VLochandles local interaction vertices:SetLocalInteracting,GenOnsite,SlaterKanamori,SlaterParameter,KanamoriParameter,AngularIntegral,RotationMatrix,Spherical2Cubic, andGetUijklComCTQMC.
Utility Layer¶
src/QAssemble/utility/DLR.pyWraps the discrete Lehmann representation grids. Constructor parameters set temperature, beta, and frequency cutoffs;FT2F,FF2T,BT2F, andBF2Tperform high-accuracy imaginary-time/Matsubara conversions. TheTauDLR2Uniformfamily (includingTauDLR2Points,TauDLR2Uniform_v2) exports non-uniform sampling onto uniform meshes when plotting. Additional methods:TauUniform,MatsubaraFermionUniform,MatsubaraBosonUniform,TauUniform2DLR,MatsubaraDLR2Uniform,T2mT,TauF2TauB,TauB2TauF.src/QAssemble/utility/Fourier.pyStatic methods for Fourier transforms across all lattice types. Moment extraction:FLocDynM,FLatDynM,BLocDynM,BLatDynM. Real/reciprocal conversions:FLatStcK2R/R2K,FLatDynK2R/R2K,BLatStcK2R/R2K,BLatDynK2R/R2K,FPathStcR2K,FPathDynR2K.src/QAssemble/utility/Dyson.pyStatic Dyson-equation solvers for every lattice/local combination:FLocStc,FLatStc,FLocDyn,FLatDyn,BLocStc,BLocDyn,BLatStc,BLatDyn.src/QAssemble/utility/Bare.pyStatic methods for bare propagator construction. Scalar versions:FFreq,FTau,BFreq,BTau. Matrix versions for local and lattice:FLocFreq,FLatFreq,FLocTau,FLatTau,BLocFreq,BLatFreq,BLocTau,BLatTau.src/QAssemble/utility/Common.pyGeneral numerical helpers:MatInv(matrix inversion),HermitianEigenCmplx(Hermitian diagonalisation),SplineCmplx/FderivCmplx(complex spline interpolation and derivatives),BernoulliPolynomial,EulerPolynomial,FactorialInt,Ttind(Chebyshev-node index mapping for tau grids),Gcoeff(high-frequency expansion coefficients), andMinDistance.src/QAssemble/utility/Mixing.pyMixingclass supporting linear and Pulay (DIIS) mixing for self-consistent field iterations. Callable interface with automatic history management. Maintains input and residual vectors for DIIS extrapolation with configurable history depth (npulay). Methods:reset,_linear,_pulay.
Stub / Placeholder Modules¶
The following modules exist but contain only placeholder or fully commented-out code:
- src/QAssemble/utility/Embedding.py — empty Embedding class for future bath-embedding support.
- src/QAssemble/utility/Projection.py — empty Projection class for future basis-projection support.
- src/QAssemble/Projector.py — fully commented-out MPI projector code.
- src/QAssemble/FLocStc.py, FLocDyn.py, BLocDyn.py — entirely commented out.
Working Tips¶
- Dynamic classes (
FLatDyn,BLatDyn) expect aDLRinstance seeded with the same beta/cutoff as the solver. When adding new routines, pass theDLRobject rather than re-instantiating it. - Real/reciprocal conversions apply phase factors derived from
Crystal.basisf. Preserve these factors if you alter the basis ordering, otherwise the transforms will silently break hermiticity. - Many methods previously called into the Fortran extension
QAFort. The Python fallbacks inutility/Fourier.pyandutility/Dyson.pyare feature-complete but slower; profile large runs if you disable the compiled modules.