or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

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

index.mddocs/

0

# PySCF

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: pyscf

7

- **Language**: Python

8

- **Installation**: `pip install pyscf`

9

- **Documentation**: http://www.pyscf.org

10

- **License**: Apache-2.0

11

12

## Core Imports

13

14

```python

15

import pyscf

16

```

17

18

Common patterns for quantum chemistry calculations:

19

20

```python

21

from pyscf import gto, scf, dft

22

from pyscf import mp, cc, ci, mcscf, fci

23

from pyscf import grad, hessian

24

from pyscf.pbc import gto as pbcgto, scf as pbcscf

25

```

26

27

## Basic Usage

28

29

```python

30

import pyscf

31

32

# Create a molecule

33

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

34

35

# Run Hartree-Fock calculation

36

mf = mol.RHF().run()

37

print(f"RHF energy: {mf.e_tot}")

38

39

# Run DFT calculation

40

mf_dft = mol.RKS(xc='b3lyp').run()

41

print(f"DFT energy: {mf_dft.e_tot}")

42

43

# Post-SCF methods

44

mp2 = pyscf.mp.MP2(mf).run()

45

print(f"MP2 energy: {mp2.e_tot}")

46

47

# Calculate gradients

48

grad = pyscf.grad.RHF(mf).run()

49

print("Forces:", grad)

50

```

51

52

## Architecture

53

54

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

55

56

- **Core Foundation**: `lib` (utilities), `gto` (molecular structure), `scf` (self-consistent field)

57

- **Electronic Structure Methods**: Hartree-Fock, DFT, post-SCF methods (MP, CC, CI, MCSCF)

58

- **Properties**: Analytical gradients, Hessians, excited states

59

- **Specialized Methods**: Relativistic methods (X2C), solvation models, QM/MM

60

- **Periodic Systems**: Complete support for crystalline systems with k-point sampling

61

- **Computational Acceleration**: Density fitting, parallelization, semi-numerical methods

62

63

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

64

65

## Capabilities

66

67

### Molecular Structure and Basis Sets

68

69

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

70

71

```python { .api }

72

def M(**kwargs): # Main driver to create molecules or crystals

73

class Mole: # Molecule class for quantum chemistry calculations

74

def RHF(self): # Create RHF object

75

def UHF(self): # Create UHF object

76

def ROHF(self): # Create ROHF object

77

def GHF(self): # Create GHF object

78

def RKS(self, xc='lda'): # Create RKS object

79

def UKS(self, xc='lda'): # Create UKS object

80

def ROKS(self, xc='lda'): # Create ROKS object

81

def GKS(self, xc='lda'): # Create GKS object

82

def gto_norm(l, expnt): # GTO normalization factors

83

def format_atom(atoms, origin=0, axes=None): # Format atomic coordinates

84

def getints(intor, atm, bas, env): # General integral evaluation

85

def eval_gto(mol, eval_name, coords): # Evaluate GTOs at coordinates

86

```

87

88

[Molecular Structure](./molecular-structure.md)

89

90

### Self-Consistent Field Methods

91

92

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

93

94

```python { .api }

95

class RHF: # Restricted Hartree-Fock

96

def run(self, dm0=None): # Run SCF calculation

97

def kernel(self, dm0=None): # SCF kernel

98

def get_hcore(self): # Core Hamiltonian matrix

99

def get_veff(self, dm): # Effective potential

100

def get_fock(self, h1e, s1e, vhf): # Fock matrix

101

def make_rdm1(self): # 1-particle density matrix

102

class UHF: # Unrestricted Hartree-Fock

103

class ROHF: # Restricted open-shell Hartree-Fock

104

class GHF: # Generalized Hartree-Fock

105

class DHF: # Dirac Hartree-Fock (relativistic)

106

class RKS: # Restricted Kohn-Sham DFT

107

class UKS: # Unrestricted Kohn-Sham DFT

108

class ROKS: # Restricted open-shell Kohn-Sham

109

class GKS: # Generalized Kohn-Sham

110

def density_fit(mf, auxbasis=None): # Density fitting acceleration

111

def newton(mf): # Second-order SCF acceleration

112

```

113

114

[SCF Methods](./scf-methods.md)

115

116

### Post-SCF Electron Correlation

117

118

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

119

120

```python { .api }

121

class MP2: # Møller-Plesset second-order perturbation theory

122

def run(self): # Run MP2 calculation

123

def kernel(self): # MP2 kernel

124

class RMP2, UMP2, GMP2: # Restricted, unrestricted, generalized MP2

125

class DFMP2, DFUMP2: # Density-fitted MP2 variants

126

class CCSD: # Coupled cluster singles and doubles

127

def run(self): # Run CCSD calculation

128

def ccsd_t(self): # CCSD(T) triples correction

129

class RCCSD, UCCSD, GCCSD: # Restricted, unrestricted, generalized CCSD

130

class QCISD: # Quadratic configuration interaction

131

class CISD: # Configuration interaction singles and doubles

132

class RCISD, UCISD, GCISD: # Restricted, unrestricted, generalized CISD

133

class CASCI: # Complete active space CI

134

class CASSCF: # Complete active space SCF

135

class UCASSCF: # Unrestricted CASSCF

136

class FCI: # Full configuration interaction

137

def direct_spin0, direct_spin1: # FCI solvers for different spin cases

138

```

139

140

[Post-SCF Methods](./post-scf-methods.md)

141

142

### Molecular Properties

143

144

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

145

146

```python { .api }

147

class Gradients: # Base analytical gradient class

148

def run(self): # Calculate gradients

149

class RHF_Gradients, UHF_Gradients: # HF gradient implementations

150

class RKS_Gradients, UKS_Gradients: # DFT gradient implementations

151

class Hessian: # Base analytical Hessian class

152

def run(self): # Calculate Hessian matrix

153

class TDHF: # Time-dependent Hartree-Fock

154

def run(self): # Run TDHF calculation

155

def nuc_grad_method(self): # Excited state gradients

156

class TDDFT: # Time-dependent DFT

157

def run(self): # Run TDDFT calculation

158

class TDA: # Tamm-Dancoff approximation

159

class RTDHF, UTDHF: # Restricted/unrestricted TDHF

160

class RTDDFT, UTDDFT: # Restricted/unrestricted TDDFT

161

```

162

163

[Properties](./properties.md)

164

165

### Integral Transformations

166

167

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.

168

169

```python { .api }

170

def kernel(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo'): # General AO→MO transformation

171

def full(eri_or_mol, mo_coeff, erifile=None): # Full 4-index transformation

172

def general(eri_or_mol, mo_coeffs, erifile=None): # General transformation with different orbital sets

173

def semi_incore(mol, mo_coeffs, max_memory=2000): # Semi-incore transformation

174

def outcore(mol, mo_coeffs, erifile, max_memory=2000): # Out-of-core transformation

175

```

176

177

[AO2MO Transformations](./ao2mo.md)

178

179

### Periodic Boundary Conditions

180

181

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

182

183

```python { .api }

184

class Cell: # Periodic system (crystal) class

185

def build(self): # Build periodic system

186

def RHF(self): # Create k-point RHF

187

def UHF(self): # Create k-point UHF

188

def RKS(self, xc='lda'): # Create k-point RKS

189

def UKS(self, xc='lda'): # Create k-point UKS

190

class KRHF: # k-point sampling RHF

191

class KUHF: # k-point sampling UHF

192

class KRKS: # k-point sampling RKS

193

class KUKS: # k-point sampling UKS

194

class KMP2: # k-point MP2

195

class KCCSD: # k-point CCSD

196

```

197

198

[Periodic Systems](./periodic.md)

199

200

### Specialized Methods

201

202

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

203

204

```python { .api }

205

class X2C: # Exact two-component relativistic method

206

def sfx2c1e(mf): # Spin-free X2C with 1-electron approximation

207

class DHF: # Dirac Hartree-Fock (4-component relativistic)

208

class PCM: # Polarizable continuum model

209

def run(self): # Run solvation calculation

210

class QMMM: # QM/MM interface

211

def run(self): # Run QM/MM calculation

212

def density_fit(mf, auxbasis=None): # Density fitting acceleration

213

def smearing(mf, sigma=None, method='fermi'): # Electron smearing for metals

214

```

215

216

[Specialized Methods](./specialized.md)

217

218

### Utilities and Tools

219

220

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

221

222

```python { .api }

223

def einsum(subscripts, *tensors, **kwargs): # Enhanced Einstein summation

224

def davidson(aop, x0, precond, max_cycle=50): # Davidson diagonalization

225

def krylov(aop, b, x0=None, tol=1e-9): # Krylov subspace methods

226

def load_library(libname): # Load C extension libraries

227

def finger(a): # Generate fingerprint for arrays

228

def logger(mol, output=None): # Logging utilities

229

def param(method): # Parameter handling for methods

230

```

231

232

[Utilities](./utilities.md)