CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pyscf

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

Pending
Overview
Eval results
Files

post-scf-methods.mddocs/

Post-SCF Methods

Advanced methods for capturing electron correlation beyond mean-field theory, including perturbation theory, coupled-cluster, configuration interaction, and multi-configurational approaches for accurate electronic structure calculations.

Capabilities

Møller-Plesset Perturbation Theory

Second-order perturbation theory for including dynamic correlation effects beyond the Hartree-Fock approximation.

class MP2:
    """
    Generic MP2 method selector.
    
    Automatically selects restricted, unrestricted, or generalized
    MP2 based on the reference SCF calculation.
    """
    
    def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
        """
        Initialize MP2 calculation.
        
        Parameters:
        - mf: SCF object as reference
        - frozen: int or list, frozen core orbitals
        - mo_coeff: ndarray, molecular orbital coefficients
        - mo_occ: ndarray, orbital occupations
        """
    
    def run(self):
        """Run MP2 calculation and return self."""
    
    def kernel(self):
        """MP2 kernel returning correlation energy."""

class RMP2:
    """
    Restricted MP2 for closed-shell systems.
    
    Most efficient MP2 implementation for closed-shell references
    with spatial orbital symmetry constraints.
    """

class UMP2:
    """
    Unrestricted MP2 for open-shell systems.
    
    Handles systems with unpaired electrons using separate
    alpha and beta orbital spaces.
    """

class GMP2:
    """
    Generalized MP2 with complex orbitals.
    
    Most general MP2 implementation supporting complex
    molecular orbitals and arbitrary spin configurations.
    """

Coupled Cluster Methods

Systematic hierarchy of coupled cluster methods providing highly accurate treatment of electron correlation.

class CCSD:
    """
    Coupled Cluster Singles and Doubles.
    
    Includes single and double excitations in the cluster operator
    for systematic treatment of dynamic correlation.
    
    Attributes:
    - conv_tol: float, convergence tolerance (default: 1e-7)
    - max_cycle: int, maximum CC iterations (default: 50)
    - frozen: int or list, frozen core orbitals
    """
    
    def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
        """Initialize CCSD calculation."""
    
    def run(self, t1=None, t2=None):
        """Run CCSD calculation."""
    
    def ccsd_t(self):
        """Calculate (T) triples correction."""

class RCCSD:
    """Restricted CCSD for closed-shell systems."""

class UCCSD:
    """Unrestricted CCSD for open-shell systems."""

class GCCSD:
    """Generalized CCSD with complex orbitals."""

class CCSD_T:
    """
    CCSD with perturbative triples correction (CCSD(T)).
    
    Adds perturbative treatment of triple excitations to CCSD
    for highly accurate correlation energies.
    """

Configuration Interaction

Variational treatment of electron correlation through explicit configuration expansion.

class CISD:
    """
    Configuration Interaction Singles and Doubles.
    
    Variational treatment including single and double excitations
    from the reference determinant.
    """
    
    def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
        """Initialize CISD calculation."""
    
    def run(self, ci0=None):
        """Run CISD calculation."""

class RCISD:
    """Restricted CISD for closed-shell systems."""

class UCISD:
    """Unrestricted CISD for open-shell systems."""

Multi-Configurational Methods

Methods handling static correlation through multi-reference wavefunctions and active space treatments.

class CASSCF:
    """
    Complete Active Space SCF.
    
    Simultaneously optimizes orbitals and CI coefficients within
    a chosen active space for systems with significant static correlation.
    
    Attributes:
    - ncas: int, number of active space orbitals
    - nelecas: int or tuple, number of active space electrons
    - frozen: int or list, frozen core orbitals
    """
    
    def __init__(self, mf, ncas, nelecas, ncore=None, frozen=None):
        """
        Initialize CASSCF calculation.
        
        Parameters:
        - mf: SCF reference object
        - ncas: number of active orbitals
        - nelecas: number of active electrons (or (alpha, beta) tuple)
        - ncore: number of core orbitals (auto-determined if None)
        - frozen: frozen orbitals
        """
    
    def run(self, mo_coeff=None, ci0=None):
        """Run CASSCF calculation."""

class CASCI:
    """
    Complete Active Space CI.
    
    CI calculation within active space without orbital optimization.
    Useful for analyzing excited states and multi-reference character.
    """

Full Configuration Interaction

Exact solution within a given basis set providing benchmark accuracy for small systems.

class FCI:
    """
    Full Configuration Interaction.
    
    Exact diagonalization of the electronic Hamiltonian within
    the given basis set. Scales exponentially with system size.
    
    Attributes:
    - nroots: int, number of roots to solve (default: 1)
    - max_cycle: int, maximum Davidson iterations
    - conv_tol: float, convergence tolerance
    """
    
    def __init__(self, mf, mo_coeff=None, mo_occ=None):
        """Initialize FCI calculation."""
    
    def run(self, h1e=None, eri=None, norb=None, nelec=None):
        """Run FCI calculation."""

Time-Dependent Methods

Linear response methods for excited states and dynamic properties.

class TDHF:
    """
    Time-dependent Hartree-Fock (Random Phase Approximation).
    
    Linear response theory for excited states using HF reference.
    Provides excitation energies and transition properties.
    """
    
    def __init__(self, mf):
        """Initialize TDHF calculation."""
    
    def run(self, nstates=None):
        """Run TDHF calculation for excited states."""

class TDDFT:
    """
    Time-dependent Density Functional Theory.
    
    Linear response DFT for excited states including
    exchange-correlation kernel effects.
    """

class TDA:
    """
    Tamm-Dancoff Approximation.
    
    Simplified TDDFT treating only single excitations
    without de-excitation contributions.
    """

Usage Examples

MP2 Calculations

import pyscf

# Basic MP2 calculation
mol = pyscf.M(atom='H2O', basis='cc-pvdz')
mf = mol.RHF().run()
mp2 = pyscf.mp.MP2(mf).run()
print(f"MP2 energy: {mp2.e_tot}")
print(f"Correlation energy: {mp2.e_corr}")

# MP2 with frozen core
mp2_fc = pyscf.mp.MP2(mf, frozen=1).run()  # freeze 1 core orbital

# Density-fitted MP2 for larger systems
mp2_df = pyscf.mp.DFMP2(mf).run()

Coupled Cluster Calculations

# CCSD calculation
mol = pyscf.M(atom='N2', basis='cc-pvdz')
mf = mol.RHF().run()
cc = pyscf.cc.CCSD(mf).run()
print(f"CCSD energy: {cc.e_tot}")

# CCSD(T) for high accuracy
et = cc.ccsd_t()
print(f"CCSD(T) energy: {cc.e_tot + et}")

# With frozen core
cc_fc = pyscf.cc.CCSD(mf, frozen=2).run()

CASSCF Calculations

# CASSCF for N2 dissociation
mol = pyscf.M(atom='N 0 0 0; N 0 0 2.5', basis='cc-pvdz')
mf = mol.RHF().run()

# CAS(10,8): 10 electrons in 8 orbitals
cas = pyscf.mcscf.CASSCF(mf, ncas=8, nelecas=10)
cas.run()
print(f"CASSCF energy: {cas.e_tot}")

# State-averaged CASSCF for excited states
cas_sa = pyscf.mcscf.CASSCF(mf, ncas=8, nelecas=10)
cas_sa = cas_sa.state_average([0.5, 0.3, 0.2])  # weights for 3 states
cas_sa.run()

Excited States

# TDDFT for excited states
mol = pyscf.M(atom='H2CO', basis='6-31g')
mf = mol.RKS(xc='b3lyp').run()
td = pyscf.tdscf.TDDFT(mf)
td.nstates = 5  # calculate 5 excited states
td.run()

for i, energy in enumerate(td.e):
    print(f"Excited state {i+1}: {energy*27.2114:.2f} eV")

FCI for Small Systems

# FCI benchmark calculation
mol_small = pyscf.M(atom='H2', basis='6-31g')
mf = mol_small.RHF().run()
fci = pyscf.fci.FCI(mf)
fci.run()
print(f"FCI energy: {fci.e_tot}")

# Multiple roots for excited states
fci.nroots = 3
fci.run()
for i, energy in enumerate(fci.e_states):
    print(f"State {i}: {energy:.8f} Hartree")

Types

from typing import Union, List, Tuple, TypedDict
import numpy as np
ndarray = np.ndarray

# Correlation method base classes
class PostSCF:
    """Base class for post-SCF correlation methods."""

# Active space specification
ActiveSpace = Tuple[int, int]  # (ncas, nelecas)

# CI vector types
CIVector = Union[ndarray, List[ndarray]]

# Excitation energies and properties
ExcitedState = TypedDict('ExcitedState', {
    'energy': float,
    'oscillator_strength': float,
    'transition_dipole': ndarray
})

Install with Tessl CLI

npx tessl i tessl/pypi-pyscf

docs

ao2mo.md

index.md

molecular-structure.md

periodic.md

post-scf-methods.md

properties.md

scf-methods.md

specialized.md

utilities.md

tile.json