Building a calculation¤
One builder captures every choice as a value: the system, the functional, and the grid/Coulomb/spin/mesh/dispersion specs. See All of dftax for the tour.
dftax.ks.energy.KS
¤
The Kohn-Sham total energy as a differentiable function of the density matrix.
P has shape (nspin, nao, nao): one channel holding the total
density for a closed shell, α and β channels for a spin-polarized system.
__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.
__init__(system: Molecule | System | object, xc: XCFunctional, *, grid: Becke | Points | tuple | None = None, coulomb: ExactSpec | DFSpec | None = None, spin: int | None = None, mesh: MeshSpec | None = None, dispersion: D3BJSpec | None = None)
¤
Build the energy functional.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
Molecule | System | object
|
a :class: |
required |
xc
|
XCFunctional
|
the exchange-correlation functional, e.g. |
required |
grid
|
Becke | Points | tuple | None
|
the quadrature: a :func: |
None
|
coulomb
|
ExactSpec | DFSpec | None
|
:func: |
None
|
spin
|
int | None
|
number of unpaired electrons, |
None
|
mesh
|
MeshSpec | None
|
a :func: |
None
|
dispersion
|
D3BJSpec | None
|
a :func: |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
NotImplementedError
|
|
Example
ks = KS(mol, PBE0(), grid=becke(75, 302), coulomb=df(chunk=None))
e_xc(P: Float[Array, 'nspin nao nao']) -> Scalar
¤
Exchange-correlation energy ∫ ε_xc ρ (DFT part only).
electronic(P: Float[Array, 'nspin nao nao']) -> Scalar
¤
Electronic energy Tr(P_tot·Hcore) + E_J + a_x·E_x^exact + E_xc.
total(P: Float[Array, 'nspin nao nao']) -> Scalar
¤
Total KS energy (electronic + nuclear repulsion + dispersion).
energy_and_fock(P: Float[Array, 'nspin nao nao'], idempotent: bool = True) -> tuple[Scalar, Float[Array, 'nspin nao nao']]
¤
Total energy and Fock matrix sym(∂E/∂P) for one density,
computed together at about the cost of one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
P
|
Float[Array, 'nspin nao nao']
|
density matrix, |
required |
idempotent
|
bool
|
whether |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Scalar, Float[Array, 'nspin nao nao']]
|
|
energy_and_grad_orbitals(Cs, idempotent: bool = True)
¤
Total energy and its gradient with respect to the occupied orbitals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Cs
|
tuple[Array, ...]
|
occupied orbital coefficients per spin channel, each
|
required |
idempotent
|
bool
|
as in :meth: |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
E |
Array
|
the total energy (Hartree). |
grads |
tuple[Array, ...]
|
|
occupations()
¤
Occupation numbers of the occupied orbitals per channel: 2 for a closed shell, 1 per spin channel.
density(P: Float[Array, 'nspin nao nao']) -> tuple[Float[Array, ng], Float[Array, 'ng 3']]
¤
Total electron density and its gradient on the grid from P.
dftax.energy.d3.d3bj(method: str | None = None, *, atm: bool = False) -> D3BJSpec
¤
Grimme's D3 dispersion correction with Becke-Johnson damping (S. Grimme, S. Ehrlich and L. Goerigk, J. Comput. Chem. 32, 1456 (2011)).
Pass the result as KS(..., dispersion=d3bj()).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str | None
|
name of the damping-parameter set, e.g. |
None
|
atm
|
bool
|
add the Axilrod-Teller-Muto three-body term ( |
False
|
dftax.energy.d4.d4(method: str | None = None, *, atm: bool = False) -> D4Spec
¤
Grimme's charge-dependent D4 dispersion correction (E. Caldeweyher et al., J. Chem. Phys. 150, 154122 (2019)).
Pass the result as KS(..., dispersion=d4()).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str | None
|
name of the damping-parameter set, e.g. |
None
|
atm
|
bool
|
add the Axilrod-Teller-Muto three-body term ( |
False
|
dftax.system.molecule.Molecule
¤
A molecular system: atoms, geometry, charge/spin, and a basis name.
__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
¤
Total electron count (sum of Z minus the total charge).
__init__(symbols: list[str], coords_bohr: np.ndarray, basis: str, charge: int = 0, spin: int = 0, spherical: bool = False)
¤
from_xyz(atom: str, basis: str, *, unit: str = 'angstrom', charge: int = 0, spin: int = 0, spherical: bool = False) -> Molecule
classmethod
¤
Build from a PySCF-style atom string (Angstrom by default).
atom_coords() -> np.ndarray
¤
Nuclear coordinates in Bohr, shape (n_atoms, 3).
atom_charges() -> np.ndarray
¤
Nuclear charges (atomic numbers), shape (n_atoms,).
dftax.ks.energy.System
¤
A system given by its built basis, for callers that construct the basis themselves.
Attributes:
| Name | Type | Description |
|---|---|---|
basis |
the orbital basis. |
|
coords |
nuclear coordinates (Bohr), |
|
charges |
nuclear charges, |
|
nelec |
number of electrons. |
|
spin |
number of unpaired electrons, |
__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
¤
__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
__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.
__weakref__
property
¤
list of weak references to the object
spin
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