PAOFLOW.DataController#
Classes#
Central data store and I/O manager for a PAOFLOW run. |
Module Contents#
- class PAOFLOW.DataController.DataController(workpath, outputdir, inputfile, model, savedir, npool, smearing, save_overlaps, acbn0, sparse, sparse_threshold, verbose, restart, dft)[source]#
Central data store and I/O manager for a PAOFLOW run.
DataControllerowns every piece of data that flows through a PAOFLOW calculation. It is created once byPAOFLOW.PAOFLOWduring initialisation and is passed by reference to every physics kernel. The class is responsible for four distinct concerns:Data storage — two flat dictionaries,
data_arraysanddata_attributes, hold all intermediate results and configuration scalars respectively. Physics modules read and write these dicts directly viadata_dicts().Initialisation and DFT ingestion — reads the DFT output (QE
data-file-schema.xml/data-file.xmlor VASPvasprun.xml), optionally reads a PAOFLOW XML input file, or constructs a Hamiltonian from a tight-binding model. All data is populated on rank 0 and then broadcast to every MPI rank.MPI communication — thin wrappers around
mpi4pyprimitives for broadcasting arrays, lists, and scalar attributes from one rank to all others, and for scattering / gathering distributed arrays across the k-point pool decomposition.File I/O — writes band structures, Hamiltonians, Fermi-surface files, k-point paths, and two-column data files to the output directory.
Data dictionaries#
data_arraysdictNumPy array payloads. Common keys (populated progressively as the calculation advances):
Key
Content
kpntsk-points from the DFT calculation
kpnts_wghtBZ integration weights
a_vectorsLattice vectors (rows, in units of
alat)tauAtomic positions (crystal coordinates)
atomsAtom species labels
species(label, pseudopotential)pairsshellsAngular-momentum shell list per species
UPAO projection matrix
⟨φ|ψ_nk⟩SksOverlap matrix S(k) (if
save_overlaps=True)Hksk-space PAO Hamiltonian H(k)
HRsReal-space PAO Hamiltonian H(R)
HkspFourier-interpolated H(k) on the dense grid
E_kBand eigenvalues (scattered across k-pool)
v_kBand eigenvectors (scattered across k-pool)
pkspMomentum matrix elements p(k)
dHkspGradient ∇_k H(k)
SjSpin operator matrix (3, nawf, nawf)
EfieldExternal electric field (3,) — default zeros
BfieldExternal magnetic field (3,) — default zeros
HubbardUOn-site Hubbard-U corrections — default zeros
d_tensorDielectric tensor component indices
t_tensorTransport tensor component indices
a_tensorAnomalous Hall tensor component indices
s_tensorSpin Hall tensor component indices
data_attributesdictScalar configuration values. Common keys:
Key
Content
nawfNumber of PAO basis functions
nbndsNumber of DFT bands
nspinNumber of spin channels (1 or 2)
nkpntsTotal number of k-points
nk1,nk2,nk3k-grid dimensions
nelecNumber of electrons
natomsNumber of atoms in the unit cell
alatLattice parameter (Bohr)
omegaUnit-cell volume
npoolNumber of k-point pools
smearingSmearing type (
None,'m-p','gauss')acbn0Whether ACBN0 orthogonalisation is active
verboseVerbosity flag
opathAbsolute path to the output directory
fpathAbsolute path to the DFT
.savedirectoryabort_on_exceptionRe-raise exceptions immediately if
True
Parameters (constructor)#
- workpathstr
Path to the working directory.
- outputdirstr
Name of the output sub-directory (created under
workpath).- inputfilestr or None
Optional PAOFLOW XML input file.
- modeldict or None
Tight-binding model specification; if provided, DFT input is ignored.
- savedirstr or None
Path to the QE
.savedirectory.- npoolint
Number of k-point pools for distributed memory execution.
- smearingstr or None
BZ integration smearing type.
- save_overlapsbool
Keep the overlap matrices
Sksafter Hamiltonian construction.- acbn0bool
Activate ACBN0 orthogonalisation.
- verbosebool
Enable debugging output.
- restartbool
Skip initialisation (data will be loaded from a dump file).
- dftstr
DFT back-end:
'QE'or'VASP'.
Methods — data access#
- data_dicts()
Return
(data_arrays, data_attributes)as a 2-tuple.- print_data()
Print all keys in both data dictionaries (rank 0 only).
Methods — initialisation helpers#
- add_default_arrays()
Pre-populate
data_arrayswith zero-valued field arrays and full-tensor component index arrays.- read_pao_inputfile()
Parse a PAOFLOW XML input file into
data_attributes.- read_qe_output()
Parse
data-file-schema.xmlordata-file.xmlfrom a QE.savedirectory.- read_vasp_output(symprec)
Parse
vasprun.xmlfrom a VASP calculation.- build_arrays_adhoc_soc()
Construct
naw(orbital counts per atom) andorb_pseudo(orbital character labels) required for the ad-hoc spin-orbit coupling routines.
Methods — MPI communication#
- broadcast_single_array(key, dtype, root)
Broadcast a NumPy array stored at
data_arrays[key]fromrootto all ranks usingMPI.Bcast.- broadcast_single_list(key, root)
Broadcast a Python list stored at
data_arrays[key].- broadcast_attribute(key, root)
Broadcast a scalar stored at
data_attributes[key].- scatter_data_array(key)
Scatter
data_arrays[key]across ranks along the first axis.- gather_data_array(key)
Gather a distributed array back to rank 0.
Methods — file output#
- write_bands(fname, bands)
Write per-spin band structure files
<fname>_<ispin>.dat.- write_bxsf(fname, bands, nbnd, indices)
Write Fermi-surface data in
.bxsfformat (for XCrysDen / SKEAF).- write_HRs(fname)
Write the real-space Hamiltonian in the Wannier90 / Z2Pack
_hr.datformat.- write_Hk_acbn0()
Write
H(k),S(k), k-points, and weights to files for ACBN0 post-processing (binary.npyor plain text).- write_file_row_col(fname, col1, col2)
Write a two-column plain-text data file.
- write_kpnts_path(fname, path, kpnts, b_vectors)
Write the k-point path in Cartesian reciprocal coordinates.
Notes
Only rank 0 reads and populates the dictionaries; all other ranks receive the data via
MPI.bcastat the end of__init__.The
error_handlerattribute holds anErrorHandlerinstance;report_exceptionis a convenience alias for itsreport_exceptionmethod, used throughout the PAOFLOW codebase to format and print stack traces without aborting unlessabort_on_exceptionis set.
- data_dicts()[source]#
Get the data dictionaries
- Arguments:
None
- Returns:
(arrays, attributes): Tuple of two dictionaries, data_arrays and data_attributes
- build_arrays_adhoc_soc()[source]#
Construc arrays needed for the adhoc_spin_orbit routine
- Arguments:
None
- Returns:
None
- write_file_row_col(fname, col1, col2)[source]#
Write a file with 2 columns
- Arguments:
fname (str): Name of the file (written to outputdir) col1 (ndarray): 1D array of values for the rightmost column col2 (ndarray): 1D array of values for the leftmost column
- Returns:
None
- write_bxsf(fname, bands, nbnd, indices=None)[source]#
Write a file in the bxsf format
- Arguments:
fname (str): Name of the file (written to outputdir) bands (ndarray): The data array of values to be written nbnd (int): Number of values from array to write
- Returns:
None
- write_bands(fname, bands)[source]#
Write electronic band structure file
- Arguments:
fname (str): Name of the file (written to outputdir) bands (ndarray): Band data array (shape: (nk,nbnd,nspin))
- Returns:
None
- write_kpnts_path(fname, path, kpnts, b_vectors)[source]#
Write the k-path through the BZ
- Arguments:
fname (str): Name of the file (written to outputdir) kpnts (ndarray): k-point path (shape: (3,nk))
- Returns:
None
- write_HRs(fname)[source]#
Write HRs in the Z2 Pack format
- Arguments:
fname (str): Name of the file (written to outputdir)
- Returns:
None
- broadcast_single_list(key, root=0)[source]#
Broadcast list from ‘data_array’ with ‘key’ from ‘root’ to all other ranks
- Arguments:
key (str): The key for the attribute to broadcast (key must exist in dictionary ‘data_attributes’) root (int): The rank which is the source of the broadcasted attribut
- Returns:
None
- broadcast_attribute(key, root=0)[source]#
Broadcast attribute from ‘data_attributes’ with ‘key’ from ‘root’ to all other ranks
- Arguments:
key (str): The key for the attribute to broadcast (key must exist in dictionary ‘data_attributes’) root (int): The rank which is the source of the broadcasted attribut
- Returns:
None
- broadcast_single_array(key, dtype=complex, root=0)[source]#
Broadcast array from ‘data_arrays’ with ‘key’ from ‘root’ to all other ranks
- Arguments:
key (str): The key for the array to broadcast (key must exist in dictionary ‘data_arrays’) dtype (dtype): The data type of the array to broadcast root (int): The rank which is the source of the broadcasted array
- Returns:
None