Python-based quantum chemistry framework providing electronic structure methods for molecular simulations
—
Complete support for crystalline systems with periodic boundary conditions, k-point sampling, and all electronic structure methods adapted for solid-state calculations using plane wave and Gaussian basis approaches.
Core functionality for defining periodic systems with lattice parameters, k-point meshes, and crystal symmetry.
class Cell:
"""
Periodic system (crystal) class with lattice parameters.
Extends Mole functionality to include periodicity, lattice vectors,
and k-point sampling for solid-state calculations.
Attributes:
- a: ndarray, lattice vectors (3, 3)
- atom: atomic coordinates and symbols
- basis: basis set specification
- pseudo: pseudopotential specification
- mesh: tuple, FFT mesh for plane wave calculations
- ke_cutoff: float, kinetic energy cutoff for plane waves
"""
def __init__(self, **kwargs):
"""Initialize periodic cell."""
def build(self):
"""Build cell and initialize periodic data structures."""
def make_kpts(self, nks, wrap_around=False):
"""
Generate k-point mesh.
Parameters:
- nks: tuple, k-point mesh dimensions (nkx, nky, nkz)
- wrap_around: bool, wrap k-points to first Brillouin zone
Returns:
ndarray, k-point coordinates
"""
def M(**kwargs):
"""
Create Cell object for periodic systems.
Automatically creates Cell when lattice parameter 'a' is provided,
otherwise creates molecular Mole object.
"""Self-consistent field methods adapted for periodic boundary conditions with k-point sampling.
class KRHF:
"""
k-point sampling restricted Hartree-Fock.
Handles Brillouin zone sampling for periodic Hartree-Fock
calculations in crystalline systems.
Attributes:
- kpts: ndarray, k-point coordinates
- exxdiv: str, treatment of Coulomb divergence ('ewald', 'vcut_sph')
"""
def __init__(self, cell, kpts=None):
"""Initialize k-point RHF calculation."""
class KUHF:
"""k-point sampling unrestricted Hartree-Fock."""
class KRKS:
"""
k-point sampling restricted Kohn-Sham DFT.
Periodic DFT with k-point sampling and plane wave
or Gaussian basis representations.
"""
class KUKS:
"""k-point sampling unrestricted Kohn-Sham DFT."""Advanced correlation methods adapted for periodic systems including MP2, coupled cluster, and CI.
class KMP2:
"""k-point sampling MP2 for periodic systems."""
class KCCSD:
"""k-point sampling coupled cluster for solids."""
class KRPA:
"""k-point random phase approximation."""Plane wave basis implementations for solid-state calculations with pseudopotentials.
def get_coulG(cell, k=None, exx=False, mf=None):
"""
Coulomb kernel in reciprocal space.
Parameters:
- cell: Cell object
- k: ndarray, k-point
- exx: bool, exact exchange treatment
- mf: SCF object for screening
Returns:
ndarray, Coulomb kernel
"""
def get_ao_pairs_G(cell, kpts=None):
"""
AO pair products in reciprocal space for plane wave calculations.
"""import pyscf.pbc as pbc
import numpy as np
# Create unit cell for diamond
cell = pbc.gto.M(
atom='C 0 0 0; C 0.25 0.25 0.25',
a=np.eye(3) * 3.5668, # lattice vectors in Bohr
basis='gth-szv',
pseudo='gth-pade'
)
# Gamma-point calculation
mf = cell.RHF()
mf.run()
print(f"Total energy: {mf.e_tot}")
# k-point sampling
kpts = cell.make_kpts([2, 2, 2]) # 2x2x2 k-mesh
mf_k = cell.KRHF(kpts=kpts)
mf_k.run()# Periodic DFT calculation
cell = pbc.gto.M(
atom='Si 0 0 0; Si 0.25 0.25 0.25',
a=np.array([[0.0, 2.715, 2.715],
[2.715, 0.0, 2.715],
[2.715, 2.715, 0.0]]),
basis='gth-szv',
pseudo='gth-pade'
)
# DFT with k-points
mf_dft = cell.KRKS(xc='pbe')
mf_dft.kpts = cell.make_kpts([4, 4, 4])
mf_dft.run()# Calculate band structure along high-symmetry path
kpath = cell.get_kpts_path('Gamma-X-W-K-Gamma', npoints=100)
mf_bands = cell.KRKS(kpts=kpath[0])
mf_bands.run()
# Extract eigenvalues for plotting
eigenvalues = mf_bands.mo_energyfrom typing import Union, Tuple
import numpy as np
ndarray = np.ndarray
# Lattice specification
LatticeVectors = ndarray # Shape (3, 3)
# k-point specifications
KPoints = Union[ndarray, int, Tuple[int, int, int]]
# Pseudopotential specification
PseudoPotential = Union[str, Dict[str, str]]Install with Tessl CLI
npx tessl i tessl/pypi-pyscf