Periodic systems¤
Kohn-Sham DFT of crystals with GTH pseudopotentials, in a Gaussian basis
(at the Gamma point or on a k-mesh) or in plane waves. All three engines
share the verbs: scf (or scf_pw), forces and stress. The guide is
Periodic systems.
Cells and grids¤
dftax.pbc.cell.Cell
¤
Atoms in a periodic cell with GTH pseudopotentials.
Coordinates and lattice vectors (the rows of a) are stored in Bohr.
spherical defaults to True: the GTH basis sets are defined, and used
by PySCF and CP2K, with spherical harmonics.
__dict__
class-attribute
¤
Read-only proxy of a mapping.
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__firstlineno__
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating-point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer iteral.
int('0b100', base=0) 4
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__static_attributes__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__weakref__
property
¤
list of weak references to the object
nelectron
property
¤
Valence electron count (ionic charges minus the total charge).
volume
property
¤
Cell volume in Bohr^3.
__init__(symbols: list[str], coords_bohr: np.ndarray, a_bohr: np.ndarray, basis: str, pseudo: str = 'gth-pade', charge: int = 0, spin: int = 0, spherical: bool = True)
¤
from_xyz(atom: str, a, basis: str, pseudo: str = 'gth-pade', *, unit: str = 'angstrom', charge: int = 0, spin: int = 0, spherical: bool = True) -> Cell
classmethod
¤
Build from a PySCF-style atom string and lattice rows a, both
in unit (Angstrom by default).
atom_coords() -> np.ndarray
¤
Nuclear coordinates in Bohr, shape (n_atoms, 3).
lattice_vectors() -> np.ndarray
¤
Lattice vectors in Bohr, one per row, shape (3, 3).
atom_charges() -> np.ndarray
¤
Ionic charges: the valence charge of each atom's pseudopotential.
atomic_numbers() -> np.ndarray
¤
Atomic numbers (the elements, not the ionic charges).
dftax.pbc.build.uniform(*, mesh: tuple[int, int, int] | None = None, cutoff: float | None = None, chunk: int | str | None = 'auto') -> Uniform
¤
The uniform real-space grid of a cell: the quadrature of the XC energy and the grid of the FFT Hartree term.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
tuple[int, int, int] | None
|
points along each lattice vector, |
None
|
cutoff
|
float | None
|
instead of a mesh, the kinetic-energy cutoff (Hartree) of the plane waves the grid must hold; the mesh is the smallest FFT-friendly one that does. |
None
|
chunk
|
int | str | None
|
|
'auto'
|
Example
KS(cell, PBE(), grid=uniform(mesh=(33, 33, 33)))
KS(cell, PBE(), grid=uniform(cutoff=60.0))
dftax.pbc.kpoints.kmesh(n1: int, n2: int, n3: int, shift=(0, 0, 0))
¤
A Gamma-centred Monkhorst-Pack mesh: fractional k-points (nk, 3)
and weights (nk,) (see :func:dftax.pbc.pw.monkhorst_pack).
Gaussian basis¤
KS(cell, xc, grid=uniform(...)) builds the Gamma-point functional, which
every molecular solver takes unchanged (scf, gdm, minimize).
dftax.pbc.kpoints.kpoint_ks(cell, xc, *, grid, kpts) -> KPointKS
¤
The k-point functional of a cell on the uniform(...) grid at
kpts = (kfrac, weights) (see :func:kmesh), solved by
:func:dftax.scf like the Gamma-point :class:~dftax.KS.
dftax.pbc.kpoints.KPointKS
¤
The Kohn-Sham functional of a cell at a k-mesh (closed shell).
__abstractclassvars__
class-attribute
¤
Build an immutable unordered collection of unique elements.
__abstractmethods__
class-attribute
¤
Build an immutable unordered collection of unique elements.
__abstractvars__
class-attribute
¤
Build an immutable unordered collection of unique elements.
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_fields__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_params__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__firstlineno__
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating-point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer iteral.
int('0b100', base=0) 4
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__static_attributes__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
total(P)
¤
energy_and_fock(P)
¤
(E, F): F^k = (1/w_k) ∂E/∂P^k (real and imaginary parts
differentiated separately), Hermitian.
__init__(S: Complex[Array, 'nk nao nao'], hcore: Complex[Array, 'nk nao nao'], grid: KGrid, e_nn: Float[Array, ''], kfrac: Float[Array, 'nk 3'], kweights: Float[Array, nk], nelec: int, nocc: int) -> None
¤
Initialize self. See help(type(self)) for accurate signature.
dftax.pbc.kpoints.scf_k(ks: KPointKS, *, smearing=None, e_tol=1e-10, d_tol=1e-07, max_iter=100, diis_space=8, verbose=False, lindep: float = 1e-08) -> KResult
¤
SCF of a k-point cell: an insulator (the lowest nocc bands of every
k doubly occupied) or, with smearing (a :func:~dftax.ks.scf.fermi
spec or its width in Hartree), Fermi-Dirac occupations with one Fermi
level; e_tot is then the free energy. lindep: the
canonical-orthogonalization threshold (as PySCF's
remove_linear_dep_). :func:dftax.scf calls this for a
:class:KPointKS.
dftax.pbc.kpoints.KResult
¤
A k-point calculation: energies, the density matrices P^k, bands
eps, occupations occ and orbitals C of every k, the Fermi
level mu under smearing, and the k-points it was solved at.
C
class-attribute
¤
Alias for field number 6
P
class-attribute
¤
Alias for field number 3
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__firstlineno__
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating-point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer iteral.
int('0b100', base=0) 4
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__orig_bases__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__slots__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__static_attributes__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
converged
class-attribute
¤
Alias for field number 8
e_tot
class-attribute
¤
Alias for field number 0
energy
class-attribute
¤
Alias for field number 1
eps
class-attribute
¤
Alias for field number 4
kpts
class-attribute
¤
Alias for field number 10
mu
class-attribute
¤
Alias for field number 7
n_iter
class-attribute
¤
Alias for field number 9
occ
class-attribute
¤
Alias for field number 5
ts
class-attribute
¤
Alias for field number 2
Plane waves¤
dftax.pbc.pw.basis.planewaves(ecut: float, *, mesh: tuple[int, int, int] | None = None) -> PlaneWaves
¤
Plane waves up to the kinetic energy ecut (Hartree).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ecut
|
float
|
the wavefunction cutoff, |
required |
mesh
|
tuple[int, int, int] | None
|
the density mesh; default, the smallest FFT-friendly one
holding |
None
|
Example
res = scf_pw(cell, LDA(), planewaves(40.0))
dftax.pbc.pw.solve.scf_pw(cell: Cell, xc: XCFunctional, pw: PlaneWaves, *, kpts: tuple | None = None, nbands: int | None = None, e_tol: float = 1e-09, smearing: FermiSpec | float | None = None, d_tol: float = 1e-06, max_iter: int = 100, mixing: float = 0.5, kerker: float | None = 1.5, n_iter: int = 4, seed: int = 0, model: PWModel | None = None, verbose: bool = False) -> PWResult
¤
Self-consistent field of a cell in plane waves (closed shell, an
insulator: the lowest nocc bands of every k doubly occupied; with
smearing, Fermi-Dirac occupations with one Fermi level, and
e_tot the free energy E - TS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
Cell
|
the :class: |
required |
xc
|
XCFunctional
|
the functional (LDA or GGA). |
required |
pw
|
PlaneWaves
|
the basis, :func: |
required |
kpts
|
tuple | None
|
|
None
|
smearing
|
FermiSpec | float | None
|
a :func: |
None
|
nbands
|
int | None
|
bands per |
None
|
e_tol
|
float
|
convergence of the energy (Ha). |
1e-09
|
d_tol
|
float
|
convergence of the density residual (electrons,
|
1e-06
|
mixing
|
float
|
the Pulay step. |
0.5
|
kerker
|
float | None
|
the Kerker wave vector (None: plain Pulay). |
1.5
|
n_iter
|
int
|
eigensolver steps per SCF iteration. |
4
|
model
|
PWModel | None
|
the plane-wave set of an earlier result ( |
None
|
dftax.pbc.pw.solve.PWResult
¤
A converged (or not) plane-wave calculation.
C
class-attribute
¤
Alias for field number 2
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__firstlineno__
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating-point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer iteral.
int('0b100', base=0) 4
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.
__orig_bases__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__slots__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__static_attributes__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
converged
class-attribute
¤
Alias for field number 6
e_tot
class-attribute
¤
Alias for field number 0
eps
class-attribute
¤
Alias for field number 4
model
class-attribute
¤
Alias for field number 8
mu
class-attribute
¤
Alias for field number 10
n_iter
class-attribute
¤
Alias for field number 7
occ
class-attribute
¤
Alias for field number 3
rho
class-attribute
¤
Alias for field number 5
terms
class-attribute
¤
Alias for field number 1
ts
class-attribute
¤
Alias for field number 9
Forces and stress¤
dftax.forces(cell, xc, result, grid=...) takes a cell and the result of
any engine; see cell_forces.
dftax.pbc.derivatives.cell_forces(cell: Cell, xc: XCFunctional, result: KSResult | KResult | PWResult | tuple, *, grid: Uniform | None = None, spin: int | None = None) -> Float[Array, 'n_atom 3']
¤
Forces on the atoms of a cell, -dE/dR (Ha/Bohr), (n_atom, 3).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
Cell
|
the :class: |
required |
xc
|
XCFunctional
|
its functional. |
required |
result
|
KSResult | KResult | PWResult | tuple
|
the converged result of any engine: a
:class: |
required |
grid
|
Uniform | None
|
the |
None
|
spin
|
int | None
|
|
None
|
dftax.pbc.derivatives.stress(cell: Cell, xc: XCFunctional, result: KSResult | KResult | PWResult | tuple, *, grid: Uniform | None = None, spin: int | None = None) -> Float[Array, '3 3']
¤
Stress tensor of a cell, (1/Ω) ∂E/∂ε (Ha/Bohr^3), (3, 3).
Arguments as :func:cell_forces. The strain moves the lattice vectors,
the atoms (fixed fractional coordinates) and the grid points together;
the plane-wave stress is that of a fixed plane-wave set.
Example
res = scf(KS(cell, LDA(), grid=uniform(mesh=(33, 33, 33))))
sigma = stress(cell, LDA(), res, grid=uniform(mesh=(33, 33, 33)))