httk.atomistic.wavefunction¶
Provide NumPy-native plane-wave wavefunctions and VASP WAVECAR adapters.
Attributes¶
Classes¶
Provide a zero-based, NumPy-native collection of plane-wave coefficients. |
Functions¶
|
Return the complex overlap of two wavefunctions. |
|
Save real and imaginary wave components as VASP volumetric files. |
Module Contents¶
- class httk.atomistic.wavefunction.PlaneWaveFunctions(source=None, *, cell=None, encut=None, kpoints=None, eigenvalues=None, occupations=None, coefficients=None, nplanewaves=None, double_precision=None, gamma_half=None)[source]¶
Provide a zero-based, NumPy-native collection of plane-wave coefficients.
This is an eager NumPy representation, not a backend or view family. NumPy is required at construction time; install the
httk-atomistic[numpy]extra when it is absent.A WAVECAR does not store whether gamma compression used the
xorzhalf-space. The default interpretation isx; passgamma_half="z"toload()when loading a z-half gamma WAVECAR. Gamma compression is detected from the k-point and plane-wave count during construction.- Parameters:
source (Any) – A WAVECAR source or neutral WAVECAR payload, or
Nonefor in-memory data.cell (Any) – The real-space cell used by the in-memory coefficients.
encut (Any) – The plane-wave energy cutoff used to generate reciprocal vectors.
kpoints (Any) – The k-points used by the in-memory coefficients.
eigenvalues (Any) – The band eigenvalues.
occupations (Any) – The band occupations.
coefficients (Any) – The coefficient vectors keyed by zero-based spin, k-point, and band.
nplanewaves (Any) – The number of plane waves for each k-point, or
Noneto infer it.double_precision (Any) – Whether to retain double-precision complex coefficients.
gamma_half (Any) – The gamma-compression half-space,
"x"or"z", if applicable.
- Raises:
ImportError – If NumPy is unavailable.
- property cell: httk.atomistic.models.cell.cell.Cell[source]¶
Return the real-space cell.
- property gamma_half: str | None[source]¶
Return the detected gamma-compression half-space, if applicable.
- coefficients(spin, kpt, band, *, cache=True)[source]¶
Return one coefficient vector, using an existing cache even when
cache=False.An uncached source read occurs once and is not stored; cached coefficients remain available after a file-backed source is closed.
- Parameters:
- Returns:
The selected coefficient vector.
- Raises:
ValueError – If an index is out of range or source coefficients have the wrong length.
- Return type:
Any
- gvectors(kpt=0, *, gamma=None, gamma_half=None)[source]¶
Return the reciprocal grid vectors for a k-point.
- Parameters:
- Returns:
The reciprocal grid vectors selected by the cutoff.
- Raises:
ValueError – If the k-point, gamma flag, or half-space is invalid.
- Return type:
Any
- realspace_wave(spin, kpt, band, *, norm=True)[source]¶
Transform coefficients to a real-space wave using NumPy FFTs.
The transform uses
numpy.fftwithnorm="ortho". Gamma-compressed coefficients are expanded according to the detected half-space before the transform.- Parameters:
- Returns:
The real-space wave on the reciprocal grid.
- Raises:
ValueError – If an index is out of range or the stored gamma metadata is invalid.
- Return type:
Any
- select(spins=None, kpts=None, bands=None, *, format=None, gamma_half='x')[source]¶
Select spins, k-points, and bands, optionally converting coefficient format.
Indices are zero-based and must be unique. Converting standard coefficients to gamma format derives a signed real wave from the standard complex wave and therefore destroys phase information; converting gamma coefficients to standard format expands the stored half-space. A gamma selection must contain exactly one gamma-point k-point.
- Parameters:
spins (collections.abc.Sequence[int] | None) – The zero-based spin indices to retain, or all spins when
None.kpts (collections.abc.Sequence[int] | None) – The zero-based k-point indices to retain, or all k-points when
None.bands (collections.abc.Sequence[int] | None) – The zero-based band indices to retain, or all bands when
None.format (str | None) – The requested coefficient format,
"std","gamma", orNone.gamma_half (str) – The target gamma-compression half-space.
- Returns:
A new in-memory collection containing the selected data.
- Raises:
ValueError – If indices, format, gamma selection, or half-space conversion is invalid.
- Return type:
- httk.atomistic.wavefunction.wavefunction_overlap(phi1, phi2)[source]¶
Return the complex overlap of two wavefunctions.
- Parameters:
phi1 (Any) – The first wavefunction.
phi2 (Any) – The second wavefunction.
- Returns:
The conjugate-inner-product overlap.
- Raises:
ValueError – If the wavefunctions do not have matching shapes.
- Return type:
- httk.atomistic.wavefunction.save_vesta(basename, structure, wave, *, cols=10)[source]¶
Save real and imaginary wave components as VASP volumetric files.
The files are written as
<basename>_r.vaspand<basename>_i.vasp.- Parameters:
- Raises:
ImportError – If NumPy is not installed.
ValueError – If
waveis not a three-dimensional complex array.