or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ao2mo.mdindex.mdmolecular-structure.mdperiodic.mdpost-scf-methods.mdproperties.mdscf-methods.mdspecialized.mdutilities.md
tile.json

tessl/pypi-pyscf

Python-based quantum chemistry framework providing electronic structure methods for molecular simulations

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyscf@2.10.x

To install, run

npx @tessl/cli install tessl/pypi-pyscf@2.10.0

index.mddocs/

PySCF

A comprehensive Python-based quantum chemistry framework providing electronic structure methods for molecular simulations. PySCF offers implementations of density functional theory (DFT), Hartree-Fock, coupled cluster, configuration interaction, and many other quantum chemical methods with support for various basis sets and molecular properties calculations.

Package Information

  • Package Name: pyscf
  • Language: Python
  • Installation: pip install pyscf
  • Documentation: http://www.pyscf.org
  • License: Apache-2.0

Core Imports

import pyscf

Common patterns for quantum chemistry calculations:

from pyscf import gto, scf, dft
from pyscf import mp, cc, ci, mcscf, fci
from pyscf import grad, hessian
from pyscf.pbc import gto as pbcgto, scf as pbcscf

Basic Usage

import pyscf

# Create a molecule
mol = pyscf.M(atom='H 0 0 0; H 0 0 1.2', basis='cc-pvdz')

# Run Hartree-Fock calculation
mf = mol.RHF().run()
print(f"RHF energy: {mf.e_tot}")

# Run DFT calculation
mf_dft = mol.RKS(xc='b3lyp').run()
print(f"DFT energy: {mf_dft.e_tot}")

# Post-SCF methods
mp2 = pyscf.mp.MP2(mf).run()
print(f"MP2 energy: {mp2.e_tot}")

# Calculate gradients
grad = pyscf.grad.RHF(mf).run()
print("Forces:", grad)

Architecture

PySCF follows a modular architecture organized around quantum chemistry method families:

  • Core Foundation: lib (utilities), gto (molecular structure), scf (self-consistent field)
  • Electronic Structure Methods: Hartree-Fock, DFT, post-SCF methods (MP, CC, CI, MCSCF)
  • Properties: Analytical gradients, Hessians, excited states
  • Specialized Methods: Relativistic methods (X2C), solvation models, QM/MM
  • Periodic Systems: Complete support for crystalline systems with k-point sampling
  • Computational Acceleration: Density fitting, parallelization, semi-numerical methods

This design enables systematic method development while maintaining computational efficiency for both small molecules and large chemical systems.

Capabilities

Molecular Structure and Basis Sets

Core functionality for defining molecular systems, atomic coordinates, basis sets, and Gaussian type orbitals that form the foundation for all quantum chemistry calculations.

def M(**kwargs): # Main driver to create molecules or crystals
class Mole: # Molecule class for quantum chemistry calculations
    def RHF(self): # Create RHF object
    def UHF(self): # Create UHF object  
    def ROHF(self): # Create ROHF object
    def GHF(self): # Create GHF object
    def RKS(self, xc='lda'): # Create RKS object
    def UKS(self, xc='lda'): # Create UKS object
    def ROKS(self, xc='lda'): # Create ROKS object
    def GKS(self, xc='lda'): # Create GKS object
def gto_norm(l, expnt): # GTO normalization factors
def format_atom(atoms, origin=0, axes=None): # Format atomic coordinates
def getints(intor, atm, bas, env): # General integral evaluation
def eval_gto(mol, eval_name, coords): # Evaluate GTOs at coordinates

Molecular Structure

Self-Consistent Field Methods

Hartree-Fock and density functional theory methods forming the foundation for quantum chemistry calculations, including restricted, unrestricted, and relativistic variants.

class RHF: # Restricted Hartree-Fock
    def run(self, dm0=None): # Run SCF calculation
    def kernel(self, dm0=None): # SCF kernel
    def get_hcore(self): # Core Hamiltonian matrix
    def get_veff(self, dm): # Effective potential
    def get_fock(self, h1e, s1e, vhf): # Fock matrix
    def make_rdm1(self): # 1-particle density matrix
class UHF: # Unrestricted Hartree-Fock  
class ROHF: # Restricted open-shell Hartree-Fock
class GHF: # Generalized Hartree-Fock
class DHF: # Dirac Hartree-Fock (relativistic)
class RKS: # Restricted Kohn-Sham DFT
class UKS: # Unrestricted Kohn-Sham DFT
class ROKS: # Restricted open-shell Kohn-Sham
class GKS: # Generalized Kohn-Sham
def density_fit(mf, auxbasis=None): # Density fitting acceleration
def newton(mf): # Second-order SCF acceleration

SCF Methods

Post-SCF Electron Correlation

Advanced methods for capturing electron correlation beyond mean-field theory, including perturbation theory, coupled-cluster, and configuration interaction.

class MP2: # Møller-Plesset second-order perturbation theory
    def run(self): # Run MP2 calculation
    def kernel(self): # MP2 kernel
class RMP2, UMP2, GMP2: # Restricted, unrestricted, generalized MP2
class DFMP2, DFUMP2: # Density-fitted MP2 variants
class CCSD: # Coupled cluster singles and doubles
    def run(self): # Run CCSD calculation
    def ccsd_t(self): # CCSD(T) triples correction
class RCCSD, UCCSD, GCCSD: # Restricted, unrestricted, generalized CCSD
class QCISD: # Quadratic configuration interaction
class CISD: # Configuration interaction singles and doubles
class RCISD, UCISD, GCISD: # Restricted, unrestricted, generalized CISD
class CASCI: # Complete active space CI
class CASSCF: # Complete active space SCF
class UCASSCF: # Unrestricted CASSCF
class FCI: # Full configuration interaction
def direct_spin0, direct_spin1: # FCI solvers for different spin cases

Post-SCF Methods

Molecular Properties

Analytical derivatives and molecular properties including forces, vibrational frequencies, and response properties for structure optimization and spectroscopy.

class Gradients: # Base analytical gradient class
    def run(self): # Calculate gradients
class RHF_Gradients, UHF_Gradients: # HF gradient implementations
class RKS_Gradients, UKS_Gradients: # DFT gradient implementations
class Hessian: # Base analytical Hessian class
    def run(self): # Calculate Hessian matrix
class TDHF: # Time-dependent Hartree-Fock
    def run(self): # Run TDHF calculation
    def nuc_grad_method(self): # Excited state gradients
class TDDFT: # Time-dependent DFT
    def run(self): # Run TDDFT calculation
class TDA: # Tamm-Dancoff approximation
class RTDHF, UTDHF: # Restricted/unrestricted TDHF
class RTDDFT, UTDDFT: # Restricted/unrestricted TDDFT

Properties

Integral Transformations

Atomic orbital to molecular orbital integral transformations essential for post-SCF methods, with both in-core and out-of-core algorithms for different system sizes.

def kernel(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo'): # General AO→MO transformation
def full(eri_or_mol, mo_coeff, erifile=None): # Full 4-index transformation
def general(eri_or_mol, mo_coeffs, erifile=None): # General transformation with different orbital sets
def semi_incore(mol, mo_coeffs, max_memory=2000): # Semi-incore transformation
def outcore(mol, mo_coeffs, erifile, max_memory=2000): # Out-of-core transformation

AO2MO Transformations

Periodic Boundary Conditions

Complete support for crystalline systems with periodic boundary conditions, k-point sampling, and all electronic structure methods adapted for solid-state calculations.

class Cell: # Periodic system (crystal) class
    def build(self): # Build periodic system
    def RHF(self): # Create k-point RHF
    def UHF(self): # Create k-point UHF
    def RKS(self, xc='lda'): # Create k-point RKS
    def UKS(self, xc='lda'): # Create k-point UKS
class KRHF: # k-point sampling RHF
class KUHF: # k-point sampling UHF
class KRKS: # k-point sampling RKS
class KUKS: # k-point sampling UKS
class KMP2: # k-point MP2
class KCCSD: # k-point CCSD

Periodic Systems

Specialized Methods

Advanced techniques including relativistic methods, solvation models, QM/MM interfaces, and computational acceleration methods for specialized applications.

class X2C: # Exact two-component relativistic method
def sfx2c1e(mf): # Spin-free X2C with 1-electron approximation
class DHF: # Dirac Hartree-Fock (4-component relativistic)
class PCM: # Polarizable continuum model
    def run(self): # Run solvation calculation
class QMMM: # QM/MM interface
    def run(self): # Run QM/MM calculation
def density_fit(mf, auxbasis=None): # Density fitting acceleration
def smearing(mf, sigma=None, method='fermi'): # Electron smearing for metals

Specialized Methods

Utilities and Tools

Mathematical libraries, file I/O, analysis tools, and computational utilities that support quantum chemistry calculations and data processing.

def einsum(subscripts, *tensors, **kwargs): # Enhanced Einstein summation
def davidson(aop, x0, precond, max_cycle=50): # Davidson diagonalization
def krylov(aop, b, x0=None, tol=1e-9): # Krylov subspace methods
def load_library(libname): # Load C extension libraries
def finger(a): # Generate fingerprint for arrays
def logger(mol, output=None): # Logging utilities
def param(method): # Parameter handling for methods

Utilities