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

post-scf-methods.mddocs/

0

# Post-SCF Methods

1

2

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.

3

4

## Capabilities

5

6

### Møller-Plesset Perturbation Theory

7

8

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

9

10

```python { .api }

11

class MP2:

12

"""

13

Generic MP2 method selector.

14

15

Automatically selects restricted, unrestricted, or generalized

16

MP2 based on the reference SCF calculation.

17

"""

18

19

def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):

20

"""

21

Initialize MP2 calculation.

22

23

Parameters:

24

- mf: SCF object as reference

25

- frozen: int or list, frozen core orbitals

26

- mo_coeff: ndarray, molecular orbital coefficients

27

- mo_occ: ndarray, orbital occupations

28

"""

29

30

def run(self):

31

"""Run MP2 calculation and return self."""

32

33

def kernel(self):

34

"""MP2 kernel returning correlation energy."""

35

36

class RMP2:

37

"""

38

Restricted MP2 for closed-shell systems.

39

40

Most efficient MP2 implementation for closed-shell references

41

with spatial orbital symmetry constraints.

42

"""

43

44

class UMP2:

45

"""

46

Unrestricted MP2 for open-shell systems.

47

48

Handles systems with unpaired electrons using separate

49

alpha and beta orbital spaces.

50

"""

51

52

class GMP2:

53

"""

54

Generalized MP2 with complex orbitals.

55

56

Most general MP2 implementation supporting complex

57

molecular orbitals and arbitrary spin configurations.

58

"""

59

```

60

61

### Coupled Cluster Methods

62

63

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

64

65

```python { .api }

66

class CCSD:

67

"""

68

Coupled Cluster Singles and Doubles.

69

70

Includes single and double excitations in the cluster operator

71

for systematic treatment of dynamic correlation.

72

73

Attributes:

74

- conv_tol: float, convergence tolerance (default: 1e-7)

75

- max_cycle: int, maximum CC iterations (default: 50)

76

- frozen: int or list, frozen core orbitals

77

"""

78

79

def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):

80

"""Initialize CCSD calculation."""

81

82

def run(self, t1=None, t2=None):

83

"""Run CCSD calculation."""

84

85

def ccsd_t(self):

86

"""Calculate (T) triples correction."""

87

88

class RCCSD:

89

"""Restricted CCSD for closed-shell systems."""

90

91

class UCCSD:

92

"""Unrestricted CCSD for open-shell systems."""

93

94

class GCCSD:

95

"""Generalized CCSD with complex orbitals."""

96

97

class CCSD_T:

98

"""

99

CCSD with perturbative triples correction (CCSD(T)).

100

101

Adds perturbative treatment of triple excitations to CCSD

102

for highly accurate correlation energies.

103

"""

104

```

105

106

### Configuration Interaction

107

108

Variational treatment of electron correlation through explicit configuration expansion.

109

110

```python { .api }

111

class CISD:

112

"""

113

Configuration Interaction Singles and Doubles.

114

115

Variational treatment including single and double excitations

116

from the reference determinant.

117

"""

118

119

def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):

120

"""Initialize CISD calculation."""

121

122

def run(self, ci0=None):

123

"""Run CISD calculation."""

124

125

class RCISD:

126

"""Restricted CISD for closed-shell systems."""

127

128

class UCISD:

129

"""Unrestricted CISD for open-shell systems."""

130

```

131

132

### Multi-Configurational Methods

133

134

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

135

136

```python { .api }

137

class CASSCF:

138

"""

139

Complete Active Space SCF.

140

141

Simultaneously optimizes orbitals and CI coefficients within

142

a chosen active space for systems with significant static correlation.

143

144

Attributes:

145

- ncas: int, number of active space orbitals

146

- nelecas: int or tuple, number of active space electrons

147

- frozen: int or list, frozen core orbitals

148

"""

149

150

def __init__(self, mf, ncas, nelecas, ncore=None, frozen=None):

151

"""

152

Initialize CASSCF calculation.

153

154

Parameters:

155

- mf: SCF reference object

156

- ncas: number of active orbitals

157

- nelecas: number of active electrons (or (alpha, beta) tuple)

158

- ncore: number of core orbitals (auto-determined if None)

159

- frozen: frozen orbitals

160

"""

161

162

def run(self, mo_coeff=None, ci0=None):

163

"""Run CASSCF calculation."""

164

165

class CASCI:

166

"""

167

Complete Active Space CI.

168

169

CI calculation within active space without orbital optimization.

170

Useful for analyzing excited states and multi-reference character.

171

"""

172

```

173

174

### Full Configuration Interaction

175

176

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

177

178

```python { .api }

179

class FCI:

180

"""

181

Full Configuration Interaction.

182

183

Exact diagonalization of the electronic Hamiltonian within

184

the given basis set. Scales exponentially with system size.

185

186

Attributes:

187

- nroots: int, number of roots to solve (default: 1)

188

- max_cycle: int, maximum Davidson iterations

189

- conv_tol: float, convergence tolerance

190

"""

191

192

def __init__(self, mf, mo_coeff=None, mo_occ=None):

193

"""Initialize FCI calculation."""

194

195

def run(self, h1e=None, eri=None, norb=None, nelec=None):

196

"""Run FCI calculation."""

197

```

198

199

### Time-Dependent Methods

200

201

Linear response methods for excited states and dynamic properties.

202

203

```python { .api }

204

class TDHF:

205

"""

206

Time-dependent Hartree-Fock (Random Phase Approximation).

207

208

Linear response theory for excited states using HF reference.

209

Provides excitation energies and transition properties.

210

"""

211

212

def __init__(self, mf):

213

"""Initialize TDHF calculation."""

214

215

def run(self, nstates=None):

216

"""Run TDHF calculation for excited states."""

217

218

class TDDFT:

219

"""

220

Time-dependent Density Functional Theory.

221

222

Linear response DFT for excited states including

223

exchange-correlation kernel effects.

224

"""

225

226

class TDA:

227

"""

228

Tamm-Dancoff Approximation.

229

230

Simplified TDDFT treating only single excitations

231

without de-excitation contributions.

232

"""

233

```

234

235

## Usage Examples

236

237

### MP2 Calculations

238

239

```python

240

import pyscf

241

242

# Basic MP2 calculation

243

mol = pyscf.M(atom='H2O', basis='cc-pvdz')

244

mf = mol.RHF().run()

245

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

246

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

247

print(f"Correlation energy: {mp2.e_corr}")

248

249

# MP2 with frozen core

250

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

251

252

# Density-fitted MP2 for larger systems

253

mp2_df = pyscf.mp.DFMP2(mf).run()

254

```

255

256

### Coupled Cluster Calculations

257

258

```python

259

# CCSD calculation

260

mol = pyscf.M(atom='N2', basis='cc-pvdz')

261

mf = mol.RHF().run()

262

cc = pyscf.cc.CCSD(mf).run()

263

print(f"CCSD energy: {cc.e_tot}")

264

265

# CCSD(T) for high accuracy

266

et = cc.ccsd_t()

267

print(f"CCSD(T) energy: {cc.e_tot + et}")

268

269

# With frozen core

270

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

271

```

272

273

### CASSCF Calculations

274

275

```python

276

# CASSCF for N2 dissociation

277

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

278

mf = mol.RHF().run()

279

280

# CAS(10,8): 10 electrons in 8 orbitals

281

cas = pyscf.mcscf.CASSCF(mf, ncas=8, nelecas=10)

282

cas.run()

283

print(f"CASSCF energy: {cas.e_tot}")

284

285

# State-averaged CASSCF for excited states

286

cas_sa = pyscf.mcscf.CASSCF(mf, ncas=8, nelecas=10)

287

cas_sa = cas_sa.state_average([0.5, 0.3, 0.2]) # weights for 3 states

288

cas_sa.run()

289

```

290

291

### Excited States

292

293

```python

294

# TDDFT for excited states

295

mol = pyscf.M(atom='H2CO', basis='6-31g')

296

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

297

td = pyscf.tdscf.TDDFT(mf)

298

td.nstates = 5 # calculate 5 excited states

299

td.run()

300

301

for i, energy in enumerate(td.e):

302

print(f"Excited state {i+1}: {energy*27.2114:.2f} eV")

303

```

304

305

### FCI for Small Systems

306

307

```python

308

# FCI benchmark calculation

309

mol_small = pyscf.M(atom='H2', basis='6-31g')

310

mf = mol_small.RHF().run()

311

fci = pyscf.fci.FCI(mf)

312

fci.run()

313

print(f"FCI energy: {fci.e_tot}")

314

315

# Multiple roots for excited states

316

fci.nroots = 3

317

fci.run()

318

for i, energy in enumerate(fci.e_states):

319

print(f"State {i}: {energy:.8f} Hartree")

320

```

321

322

## Types

323

324

```python { .api }

325

from typing import Union, List, Tuple, TypedDict

326

import numpy as np

327

ndarray = np.ndarray

328

329

# Correlation method base classes

330

class PostSCF:

331

"""Base class for post-SCF correlation methods."""

332

333

# Active space specification

334

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

335

336

# CI vector types

337

CIVector = Union[ndarray, List[ndarray]]

338

339

# Excitation energies and properties

340

ExcitedState = TypedDict('ExcitedState', {

341

'energy': float,

342

'oscillator_strength': float,

343

'transition_dipole': ndarray

344

})

345

```