bcal.calculations package¶
Submodules¶
bcal.calculations.bcal module¶
Band structure and effective mass from a generated structure directory.
This module consumes the per-crystal layout produced by
bcal.utils.input_maker.InputMaker (structure.json + inputs/)
and runs the calculation pipeline:
inputs/ –(DFT)–> logs/ –(extract)–> matrices/ –(TB)–> results/
The crystal-symmetry transfer-integral construction (one DFT per unique dimer
type, reused for symmetry-equivalent pairs) is the core of bcal and is ported
from the reference implementation. The external library yu-tcal is reused
for SCF orchestration (TcalPySCF/TcalORCA driven with
skip_monomer_num), Gaussian log/matrix parsing (Tcal.read_matrix etc.),
and the transfer-integral formula/unit (Tcal.EV).
- class bcal.calculations.bcal.Bcal(struct_dir, num_mo=15, engine='g16', cpu=4, mem=16, method='B3LYP/6-31G(d,p)', bse=False)[source]¶
Bases:
objectRun the band-structure / effective-mass pipeline for one structure.
- Parameters:
struct_dir (str or pathlib.Path) – Directory containing
structure.jsonandinputs/(as written bybcal.utils.input_maker.InputMaker).logs/,matrices/andresults/are created beneath it.num_mo (int, optional) – Number of MOs per molecule on each side of the frontier; the total window is
n = 2 * num_moorbitals (num_moHOMO-side andnum_moLUMO-side). By default 15.engine (str, optional) – Calculation engine and the single source of engine selection:
"g16"/"g09"(Gaussian),"pyscf"/"gpu4pyscf"(PySCF),"orca"(ORCA). By default"g16".cpu (int, optional) – Number of CPU cores / threads for the engine, by default 4.
mem (int, optional) – Memory in GB for the engine, by default 16.
method (str, optional) – DFT method/basis string, by default
"B3LYP/6-31G(d,p)".bse (bool, optional) – Use Basis Set Exchange to resolve the basis set (PySCF/gpu4pyscf only; ignored for other engines), by default
False.
- run_dft(read=False, resume=False)[source]¶
Execute (or read) DFT, extract matrices, and build transfer integrals.
- Parameters:
- Return type:
None
- cal_transfer_integrals_all()[source]¶
Build the transfer-integral tensor for all pairs using symmetry.
- Returns:
Transfer integrals in eV for the
n-orbital window of each pair.- Return type:
numpy.ndarray, shape (n_pairs, n, n)
- cal_reciprocal_lattice()[source]¶
Calculate reciprocal lattice vectors from the direct lattice.
- Return type:
- energies_at_ks(k)[source]¶
Calculate band energies at given k-points.
- Parameters:
k (numpy.ndarray, shape (N, 3) or (3,)) – k-point vectors in reciprocal space.
- Returns:
Band energies (eV) at each k-point.
- Return type:
numpy.ndarray, shape (N, m*n)
- cal_effective_mass(draw_band=True, band_path='XGYGZ')[source]¶
Calculate effective masses at the HOMO maximum and LUMO minimum.
- Parameters:
draw_band (bool, optional) – If True, draw and save a band diagram, by default True.
band_path (str, optional) – High-symmetry k-path passed to
draw_band_diagram()whendraw_bandis True, by default"XGYGZ".
- Returns:
Principal effective masses (in units of electron mass): the first three at the HOMO maximum, the last three at the LUMO minimum.
- Return type:
numpy.ndarray, shape (6,)
Notes
The band-edge k-points are also stored on the instance as
homo_edge_frac/lumo_edge_frac(fractional reciprocal-lattice coordinates) andhomo_edge_label/lumo_edge_label(the matching high-symmetry label fromHIGH_SYMMETRY_POINTS, orNone).The principal effective masses (sorted by
|m|ascending) and their unit principal-axis vectors (rows, Cartesian reciprocal-space) are stored ashomo_em/lumo_emandhomo_em_vectors/lumo_em_vectors; the returned(6,)array keeps the original unsorted layout for backward compatibility. Directions with nearly zero inverse mass are reported asinf.
- refine_around_min_or_max(k_points, mo_index, window_size=0.01, max_or_min='max')[source]¶
Refine a band extremum k-point with Nelder-Mead optimization.
- draw_band_diagram(path='XGYGZ')[source]¶
Draw and save a band diagram along a high-symmetry k-path.
The
pathstring is read one character at a time; each character is a high-symmetry point label fromHIGH_SYMMETRY_POINTS("G"denotes Gamma). For"XGYGZ"the path is X -> Gamma -> Y -> Gamma -> Z. The horizontal axis is the cumulative k-distance along the path and the ticks are placed at the requested points. The figure is written toresults/band.pngand the raw data toresults/band.npz.- Parameters:
path (str, optional) – Sequence of single-character high-symmetry point labels, by default
"XGYGZ".- Raises:
ValueError – If
pathcontains a label absent fromHIGH_SYMMETRY_POINTS, or has fewer than two points.- Return type:
None
- band_edges_on_path(path)[source]¶
Report whether the HOMO/LUMO band edges lie on the band-diagram path.
A band edge is “on the path” when its k-point lies on one of the straight segments connecting the high-symmetry nodes of
path(the same geometry drawn bydraw_band_diagram()), and is therefore visible inresults/band.png. When an edge is off the path, the plotted HOMO/LUMO curve does not reach the true band extremum.- Parameters:
path (str) – High-symmetry k-path string, identical to the one passed to
draw_band_diagram()/cal_effective_mass().- Returns:
Maps
"HOMO"and"LUMO"toTrueif that band edge lies on the drawn path.- Return type:
- Raises:
RuntimeError – If the band edges have not been computed yet; call
cal_effective_mass()first.
Module contents¶
- class bcal.calculations.Bcal(struct_dir, num_mo=15, engine='g16', cpu=4, mem=16, method='B3LYP/6-31G(d,p)', bse=False)[source]¶
Bases:
objectRun the band-structure / effective-mass pipeline for one structure.
- Parameters:
struct_dir (str or pathlib.Path) – Directory containing
structure.jsonandinputs/(as written bybcal.utils.input_maker.InputMaker).logs/,matrices/andresults/are created beneath it.num_mo (int, optional) – Number of MOs per molecule on each side of the frontier; the total window is
n = 2 * num_moorbitals (num_moHOMO-side andnum_moLUMO-side). By default 15.engine (str, optional) – Calculation engine and the single source of engine selection:
"g16"/"g09"(Gaussian),"pyscf"/"gpu4pyscf"(PySCF),"orca"(ORCA). By default"g16".cpu (int, optional) – Number of CPU cores / threads for the engine, by default 4.
mem (int, optional) – Memory in GB for the engine, by default 16.
method (str, optional) – DFT method/basis string, by default
"B3LYP/6-31G(d,p)".bse (bool, optional) – Use Basis Set Exchange to resolve the basis set (PySCF/gpu4pyscf only; ignored for other engines), by default
False.
- run_dft(read=False, resume=False)[source]¶
Execute (or read) DFT, extract matrices, and build transfer integrals.
- Parameters:
- Return type:
None
- cal_transfer_integrals_all()[source]¶
Build the transfer-integral tensor for all pairs using symmetry.
- Returns:
Transfer integrals in eV for the
n-orbital window of each pair.- Return type:
numpy.ndarray, shape (n_pairs, n, n)
- cal_reciprocal_lattice()[source]¶
Calculate reciprocal lattice vectors from the direct lattice.
- Return type:
- energies_at_ks(k)[source]¶
Calculate band energies at given k-points.
- Parameters:
k (numpy.ndarray, shape (N, 3) or (3,)) – k-point vectors in reciprocal space.
- Returns:
Band energies (eV) at each k-point.
- Return type:
numpy.ndarray, shape (N, m*n)
- cal_effective_mass(draw_band=True, band_path='XGYGZ')[source]¶
Calculate effective masses at the HOMO maximum and LUMO minimum.
- Parameters:
draw_band (bool, optional) – If True, draw and save a band diagram, by default True.
band_path (str, optional) – High-symmetry k-path passed to
draw_band_diagram()whendraw_bandis True, by default"XGYGZ".
- Returns:
Principal effective masses (in units of electron mass): the first three at the HOMO maximum, the last three at the LUMO minimum.
- Return type:
numpy.ndarray, shape (6,)
Notes
The band-edge k-points are also stored on the instance as
homo_edge_frac/lumo_edge_frac(fractional reciprocal-lattice coordinates) andhomo_edge_label/lumo_edge_label(the matching high-symmetry label fromHIGH_SYMMETRY_POINTS, orNone).The principal effective masses (sorted by
|m|ascending) and their unit principal-axis vectors (rows, Cartesian reciprocal-space) are stored ashomo_em/lumo_emandhomo_em_vectors/lumo_em_vectors; the returned(6,)array keeps the original unsorted layout for backward compatibility. Directions with nearly zero inverse mass are reported asinf.
- refine_around_min_or_max(k_points, mo_index, window_size=0.01, max_or_min='max')[source]¶
Refine a band extremum k-point with Nelder-Mead optimization.
- draw_band_diagram(path='XGYGZ')[source]¶
Draw and save a band diagram along a high-symmetry k-path.
The
pathstring is read one character at a time; each character is a high-symmetry point label fromHIGH_SYMMETRY_POINTS("G"denotes Gamma). For"XGYGZ"the path is X -> Gamma -> Y -> Gamma -> Z. The horizontal axis is the cumulative k-distance along the path and the ticks are placed at the requested points. The figure is written toresults/band.pngand the raw data toresults/band.npz.- Parameters:
path (str, optional) – Sequence of single-character high-symmetry point labels, by default
"XGYGZ".- Raises:
ValueError – If
pathcontains a label absent fromHIGH_SYMMETRY_POINTS, or has fewer than two points.- Return type:
None
- band_edges_on_path(path)[source]¶
Report whether the HOMO/LUMO band edges lie on the band-diagram path.
A band edge is “on the path” when its k-point lies on one of the straight segments connecting the high-symmetry nodes of
path(the same geometry drawn bydraw_band_diagram()), and is therefore visible inresults/band.png. When an edge is off the path, the plotted HOMO/LUMO curve does not reach the true band extremum.- Parameters:
path (str) – High-symmetry k-path string, identical to the one passed to
draw_band_diagram()/cal_effective_mass().- Returns:
Maps
"HOMO"and"LUMO"toTrueif that band edge lies on the drawn path.- Return type:
- Raises:
RuntimeError – If the band edges have not been computed yet; call
cal_effective_mass()first.