Source-linked AI summary

The Python-based Simulations of Chemistry Framework (PySCF)

Qiming Sun, Timothy C. Berkelbach, Nick S. Blunt, George H. Booth, Sheng Guo, Zhendong Li, Junzi Liu, James McClain, Elvira R. Sayfutyarova, Sandeep Sharma, Sebastian Wouters, Garnet Kin-Lic Chan

arXiv:1701.08223v2physics.chem-ph

TL;DR

Quantum-chemistry software often balances implementation accessibility against functionality and performance. This paper presents PySCF, a primarily Python-based platform with optimized numerical components and broad molecular and periodic-system capabilities, reporting performance at least as fast as leading existing implementations.

  • Problem

    PySCF addresses the limited use of Python as a primary implementation language in quantum-chemistry and electronic-structure software.

  • Method

    The paper documents PySCF, a general-purpose platform whose features are implemented primarily in Python with optimized compiled routines for critical computational paths.

  • Results

    PySCF performs at least as fast as the best existing quantum-chemistry implementations while supporting molecular and periodic electronic-structure calculations.

  • Takeaways & Limitations

    PySCF combines simplicity, flexibility, broad electronic-structure capabilities, and efficient execution in a single computational chemistry package.

  • Takeaways & Limitations

    The package does not adopt an optimization strategy to increase I/O throughput.

Abstract

from arXiv · show

PySCF is a general-purpose electronic structure platform designed from the ground up to emphasize code simplicity, both to aid new method development, as well as for flexibility in computational workflow. The package provides a wide range of tools to support simulations of finite size systems, extended systems with periodic boundary conditions, low dimensional periodic systems, and custom Hamiltonians, using mean-field and post-mean-field methods with standard Gaussian basis functions. To ensure easy of extensibility, PySCF uses the Python language to implement almost all its features, while computationally critical paths are implemented with heavily optimized C routines. Using this combined Python/C implementation, the package is as efficient as the best existing C or Fortran based quantum chemistry programs. In this paper we document the capabilities and design philosophy of the current version of the PySCF package.

1 INTRODUCTION

PySCF was created as an open-source quantum-chemistry toolbox implemented primarily in Python, prioritizing simplicity, generality, and efficiency. Its Python/C design supports extensibility while reaching performance comparable to leading quantum-chemistry implementations.

  • Python is used as an implementation language rather than merely a supporting language, although this remains uncommon in quantum-chemistry software.
  • PySCF was started in 2014 to develop a highly functional, high-performance quantum-chemistry toolbox for molecules and materials, implemented primarily in Python.
  • The project emphasizes simplicity, generality, and efficiency in that order as its primary development goals.
  • Most PySCF functions are written in Python, with limited C code reserved for the most time-critical parts.
  • The paper documents PySCF’s current capabilities and design philosophy, including user-modifiable APIs intended to support scientific workflows.
  • PySCF uses numerical Python libraries to perform at least as fast as the best existing quantum-chemistry implementations.

2 CAPABILITIES

PySCF provides a broad suite of molecular electronic-structure methods, spanning mean-field, correlated, configuration-interaction, and coupled-cluster calculations. Implementations combine readable, modifiable code with optimized routines supporting sizable calculations.

  • PySCF supports molecular Hartree–Fock and DFT calculations for restricted, unrestricted, closed-shell, and open-shell references.
  • The SCF implementation can handle over 5000 basis functions on a single symmetric multiprocessing node.
  • PySCF includes MP2, configuration interaction, CCSD, CCSD(T), and equation-of-motion coupled-cluster methods with associated properties and derivatives.
  • A CCSD implementation for H50 with 25 occupied and 1500 virtual orbitals completes one iteration in less than 3 hours on 28 CPU cores.
  • The FCI solver supports fermion, boson, and coupled fermion-boson Hamiltonians and performs a matrix-vector operation for 16 electrons and 16 orbitals in 30 seconds using 16 CPU cores.

2.3 Multireference methods

PySCF’s multireference functionality addresses large active spaces and external-solver integration through an AO-driven CASSCF optimizer. The implementation supports several external solvers while limiting memory and communication demands.

  • PySCF provides CASSCF and NEVPT2 methods for multireference electronic-structure calculations.
  • Large active spaces create communication and memory challenges because active-space integrals can exceed available memory.
  • The AO-driven CASSCF optimizer provides second-order convergence and interfaces with external DMRG, FCIQMC, and state-averaged solvers.
  • Only the two-particle density matrix and Hamiltonian integrals are communicated between the CASSCF driver and external CI solver.
  • The current implementation supports 3000 basis functions and 30–50 active orbitals on a single SMP node with 128 GB memory without approximating AO integrals.
  • PySCF also supplies analytic gradients, Hessians, NMR shielding parameters, density matrices, and excited-state methods for supported calculations.

2.5 Relativistic effects

PySCF extends electronic-structure capabilities to relativistic treatments, orbital localization, analysis tools, and periodic systems. Its periodic implementation reuses molecular interfaces while supporting multiple boundary conditions, pseudopotentials, k-point methods, and large calculations.

  • Relativistic effects: PySCF offers scalar-relativistic ECP and spin-free X2C corrections, plus four-component relativistic Hartree–Fock and no-pair MP2 methods.
  • Orbital localizer and result analysis: Orbital-localization routines include Boys, Boys–Foster, Edmiston–Ruedenberg, and Pipek–Mezey methods, along with IAO, NAO, and meta-Löwdin orbitals.
  • Orbital localizer and result analysis: Using 16 CPU cores, Boys localization processes 1620 unoccupied HF orbitals for C60 in 3 minutes.
  • Extended systems with periodic boundary conditions: The PBC module supports zero-, one-, two-, and three-dimensional periodic systems, including all-electron and pseudopotential calculations.
  • Extended systems with periodic boundary conditions: PBC interfaces correspond directly to molecular interfaces, allowing molecular methods to be reused for Γ-point calculations and specialized for k-point sampling.
  • Extended systems with periodic boundary conditions: Explicit k-point methods are available for HF, DFT, MP2, CCSD, CCSD(T), and EOM-CCSD calculations.
  • Extended systems with periodic boundary conditions: On 100 computational cores, PySCF can execute mean-field simulations with unit cells over 100 atoms and k-point CCSD calculations with over 3000 orbitals.

2.8 General AO integral evaluator and J/K builds

PySCF provides general AO integral evaluation and J/K contraction through simple Python-accessible APIs. Its contraction routines handle large integral tensors with small memory footprints and support subsystem partitioning for fragment and parallel calculations.

  • AO integral access: PySCF exposes Libcint AO integrals through a one-line Python API, either as a giant array or individual shells.Supported integrals include multiple Gaussian-orbital representations, polynomial expressions, and several two-electron operators.
  • J/K construction: The general AO-driven J/K contraction combines high-order integral tensors with lower-order density tensors.When both tensors fit in memory, NumPy einsum provides a convenient implementation.
  • J/K construction: AO-driven contraction can process integral tensors or their high-order derivatives with multiple density matrices using a small memory footprint.This approach is intended for cases where the high-order tensor does not fit in available memory.
  • Subsystem contraction: Subsystem contraction distributes four-index integral segments across system fragments or computational partitions.The feature supports fragment-based Coulomb or exchange energies and parallel algorithms that divide J/K construction into smaller segments.

2.9 General integral transformations

PySCF implements general integral transformations for arbitrary Libcint AO integrals and orbital choices, while storing transformed data in accessible HDF5 chunks. Density fitting extends integral handling across finite and periodic systems, with representations selected according to system requirements and accuracy needs.

  • Integral transformations: PySCF transforms four-index two-electron integrals using four different orbital sets and supports arbitrary AO integrals and orbital types.Permutation symmetry over i and j, k and l reduces disk usage when real integrals permit it.
  • Integral transformations: PySCF does not adopt precomputation or data compression to reduce integral-transformation costs and increase I/O throughput.The passage identifies integral transformations as having high computational and I/O costs.
  • Integral transformations: Integral transformations require no initialization and can be launched with one line of Python code.Transformed integrals are stored in uncompressed HDF5 chunks for fast subblock indexing and access by other packages.
  • Density fitting: Density fitting is implemented for finite systems and crystals with periodic boundary conditions, using multiple fitting representations.Periodic calculations may use plane waves, while high-accuracy all-electron calculations can use mixed Gaussian-plus-plane-wave fitting functions and different metrics.
  • Density fitting: The three-index density-fitting tensor is stored as an uncompressed HDF5 giant array, enabling straightforward two-electron-integral access and DF-object substitution.In finite systems, density fitting supports J/K and molecular-orbital integrals for HF, DFT, and MP2, while periodic systems represent integrals as products of three-index tensors.

2.11 Custom Hamiltonians

PySCF allows users to replace standard ab initio Hamiltonians with arbitrary model Hamiltonians through mean-field integral attributes. These custom Hamiltonians can then be used by mean-field and post-Hartree–Fock calculations, while the package also supports external solvers and interoperable workflow components.

  • Custom Hamiltonians: PySCF supports arbitrary model Hamiltonians for semi-empirical quantum chemistry and condensed-matter model studies.The Hamiltonian can be overwritten directly because it is an attribute of the mean-field calculation object.
  • Custom Hamiltonians: Defining the one-particle and two-particle integral attributes makes them available to mean-field and subsequent post-Hartree–Fock correlation treatments.Correlated calculations with model Hamiltonians can be carried out in the same way as calculations with standard ab initio Hamiltonians.
  • Workflow integration: PySCF can act as an independent solver or as a driver within workflows involving other software.External DMRG and FCIQMC programs can replace the FCI routine for large active spaces in CASCI/CASSCF calculations.
  • Workflow integration: The QM/MM interface supports HF, DFT, MP2, CC, CI, and MCSCF energies and analytic derivatives from supplied MM charges and positions.Utility functions also support Hamiltonian and orbital exchange through FCIDUMP, Molden, GAMESS WFN, and Molpro XML formats.
  • Numerical components: PySCF provides common numerical components such as DIIS optimization and Davidson or Arnoldi/Krylov solvers for quantum-chemistry algorithms.The DIIS handler supports arbitrary-size, arbitrary-type object arrays with or without supplied error vectors.

3 Design and implementation of PySCF

PySCF is designed for extensibility and workflow flexibility through a mostly Python implementation, functional programming patterns, and direct use of the host Python language. These choices aim to let users customize and combine functionality without learning a complex object hierarchy or package-specific input language.

  • Design rationale: The authors describe these design choices as responses to the difficulty of customizing typical object-oriented programs and the limitations of built-in functionality.The package combines extensibility with accessible workflow construction rather than requiring users to master an object hierarchy.
  • Design goals: A major PySCF design goal is making the package sufficiently flexible for users to extend its functionality.The design choices target robust components for complex problems and non-trivial workflows.
  • Language: PySCF uses mostly Python with limited C for computational hot spots, supporting development and testing of new functionality in Python.Most functions are written in pure Python, while selected performance-critical paths are rewritten in C.
  • Programming style: The package favors a mostly functional style because independently callable functions let users mix functionality with minimal knowledge of PySCF.Most functions are pure and can be invoked independently of one another.
  • Input language: PySCF avoids a package-specific input language and instead calls functionality from scripts written in host Python.This design addresses the burden of learning a new domain-specific language for each quantum-chemistry package.

1. There is no need to learn a domain-specific language. Python, as a general program-

PySCF uses Python as its implementation and input language, leveraging its accessibility for electronic structure work. The language is widely used, taught in modern computer science courses, and supported by a large community.

  • Python is widely used for numerical computing and taught in modern computer science courses.
  • For novices, Python is easy to learn and supported by readily available help from its large community.

2. One can use all Python language features in the input script. This allows the input

PySCF lets users combine Python language features, interactive execution, modular components, and parallel computation in a single workflow. Its design emphasizes ease of use while balancing simplicity with versatility through plugins and lightweight parallel interfaces.

  • Input scripts can combine complex logic, computational workflows, data processing, and plotting with electronic structure simulations.
  • PySCF can be mixed with other Python modules to build a personalized computing environment.
  • Interactive computation allows simulations to be tested, debugged, and executed step by step within the Python interpreter shell.
  • Interactive usability is supported by accessible functions and data, execution-order insensitivity, and computations that avoid significant shell halts.
  • PySCF uses plugins to place advanced features outside basic methods, preserving clear core-method structure while increasing plugin implementation complexity.The main mean-field module implements the basic self-consistent loop, while corrections such as relativistic effects are independent plugins activated at runtime.
  • Parallel execution uses a daemon-based MPI mechanism so code can be developed mainly in serial mode and enabled for high performance when needed.For periodic calculations, changing only the density fitting object provides parallel functionality compared with serial invocation.

4 CONCLUSIONS

The paper presents PySCF as a Python-based approach to quantum chemistry that prioritizes productivity, simplicity, extensibility, and performance. It supports molecular and extended-system simulations through a lightweight, extensible electronic structure toolbox.

  • The Python ecosystem can make numerical simulations more productive by letting researchers work at a high abstraction level.This avoids requiring attention to complex software implementation details.
  • PySCF brings Python ecosystem benefits to quantum chemistry and electronic structure simulations as an open-source project.
  • PySCF is a simple, lightweight, and efficient package supporting ab initio calculations for molecular and extended systems.
  • The package provides an extensible electronic structure toolbox with many fundamental operations exposed through simple APIs for methods, integrals, and wave functions.
  • The authors emphasize simplicity of use and implementation while preserving competitive functionality and performance.
  • The authors propose PySCF as a new style of program and library design representative of future field developments.
Loading 1701.08223v2…