API
PeriodicSystem —
- class pypwdft.PeriodicSystem(sz: float, npts: int)
Class that encapsulates a cubic unitcell with periodic boundary conditions and which can host the nuclei and electrons
- __init__(sz: float, npts: int)
Build a periodic system
- Parameters:
sz (float) – edge size of the cubic unit cell
npts (int) – number of sampling points per Cartesian direction
- add_atom(x: float, y: float, z: float, charge: float, unit: str = 'bohr')
Add an atom to the unit cell
- Parameters:
x (float) – x-coordinate
y (float) – y-coordinate
z (float) – z-coordinate
charge (float) – charge of the atom
unit (str, optional) – Which length unit, ‘bohr’ or ‘angstrom’. Defaults to ‘bohr’.
- Raises:
Exception – Invalid unit received.
- calculate_ewald_sum(gcut: float = 2, gamma: float = 1e-08) float
Calculate Ewald sum
- Parameters:
gcut (float, optional) – Plane wave cut off energy in Ht. Defaults to 2.
gamma (float, optional) – Separation parameter. Defaults to 1e-8.
- Returns:
Ewald sum in Ht
- Return type:
float
- calculate_vpot() ndarray
Construct the nuclear attraction potential
- Returns:
nuclear attraction potential in real-space
- Return type:
np.ndarray
- get_atom_charges() ndarray
Get the atomic charges
- Returns:
atomic charges
- Return type:
np.ndarray
- get_atom_positions() ndarray
Get atomic positions in real-space
- Returns:
atomic positions
- Return type:
np.ndarray
- get_ct() float
- Get the FFT transformation constant from canonical FFT to an FFT using
a normalized plane wave basis set.
- Returns:
FFT transformation constant
- Return type:
float
- get_nelec() int
Get the number of electrons
- Returns:
number of electrons
- Return type:
int
- get_npts() int
Get the number of sampling points per Cartesian direction
- Returns:
number of sampling points per Cartesian direction
- Return type:
int
- get_omega() float
Get unitcell volume
- Returns:
volume of the unit cell
- Return type:
float
- get_pw_k() ndarray
Get the plane wave vectors
- Returns:
plane wave vectors
- Return type:
np.ndarray
- get_pw_k2() ndarray
Get the squared length of the plane wave vectors
- Returns:
squared length of plane wave vectors
- Return type:
np.ndarray
- get_r() ndarray
Get the sampling vectors in real-space
- Returns:
real-space sampling vectors
- Return type:
np.ndarray
- get_r_norms() ndarray
Get real-space sampling vector lengths
- Returns:
real-space sampling vector lengths
- Return type:
np.ndarray
- translate(dist: ndarray)
Translate all atoms in unit cell
- Parameters:
dist (np.ndarray) – displacement vector
PyPWDFT
- class pypwdft.PyPWDFT(sys: PeriodicSystem, fft: str = 'pyfftw')
Class that encapsulates the planewave DFT method
- __init__(sys: PeriodicSystem, fft: str = 'pyfftw')
Build PyPWDFT class
- Parameters:
sys (PeriodicSystem) – periodic system
fft (str, optional) – which FFT algorithm to use. Defaults to ‘pyfftw’.
- scf(tol: float = 1e-05, nsol: int = None, verbose: bool = False) dict
Perform self-consistent field procedure
- Parameters:
tol (float, optional) – electronic convergence criterion. Defaults to 1e-5.
nsol (int, optional) – number of solutions to find. Defaults to None.
verbose (bool, optional) – whether verbose output should be given. Defaults to False.
- Returns:
Dictionary containing system results
- Return type:
dict
SystemBuilder
- class pypwdft.SystemBuilder
Class that builds molecules from templates or from point group descriptions
- __init__()
Create the object
- from_file(path: str, sz: float = 10, npts: int = 32) PeriodicSystem
Construct a PeriodicSystem instance from a .xyz file
- Parameters:
path (str) – path to .xyz file
sz (float, optional) – edge size of the cubic unit cell in a.u. Defaults to 10 a.u.
npts (int, optional) – number of sampling points per Cartesian direction. Defaults to 32.
- Returns:
PeriodicSystem instance encapsulating the specified molecule
- Return type:
- from_name(molname: str, sz: float = 10, npts: int = 32) PeriodicSystem
Create a PeriodicSystem instance by specifying the name of the molecule
- Parameters:
molname (str) – name of the molecule
sz (float, optional) – edge size of the cubic unit cell in a.u. Defaults to 10 a.u.
npts (int, optional) – number of sampling points per Cartesian direction. Defaults to 32.
- Returns:
PeriodicSystem instance encapsulating the specified molecule
- Return type: