---
name: "sc_MBPT2"
section: "3"
platform: "linux"
package: "libsc-doc"
version: "2.3.1-22"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_MBPT2"
---

# sc\_MBPT2(3)

The MBPT2 class implements several second-order perturbation theory methods.

## NAME

sc::MBPT2 - The **MBPT2** class implements several second-order perturbation theory methods.

## SYNOPSIS

`#include <mbpt.h>`

Inherits **sc::Wavefunction**.

Inherited by **sc::MBPT2\_R12**.

### Public Member Functions

**MBPT2** (**StateIn** &)\
 **MBPT2** (const **Ref**\< **KeyVal** \> &)\
 The **KeyVal** constructor.  void **save\_data\_state** (**StateOut** &)\
 Save the base classes (with save\_data\_state) and the members in the same order that the **StateIn** CTOR initializes them.  **Ref**\< **SCF** \> **ref** ()\
 double **ref\_energy** ()\
 double **corr\_energy** ()\
 **RefSCVector** **ref\_energy\_gradient** ()\
 **RefSCVector** **corr\_energy\_gradient** ()\
 int **nelectron** ()\
 Returns the number of electrons.  int **nfzcore** () const\
 int **nfzvirt** () const\
 **RefSymmSCMatrix** **density** ()\
 Returns the **SO** density.  int **spin\_polarized** ()\
 Return 1 if the alpha density is not equal to the beta density.  int **gradient\_implemented** () const\
 int **value\_implemented** () const\
 Information about the availability of values, gradients, and hessians.  void **symmetry\_changed** ()\
 Call this if you have changed the molecular symmetry of the molecule contained by this **MolecularEnergy**.  void **obsolete** ()\
 Marks all results as being out of date.  void **print** (std::ostream &o=**ExEnv::out0**()) const\
 Print information about the object.

### Protected Member Functions

void **init\_variables** ()\
 void **compute** ()\
 Recompute at least the results that have compute true and are not already computed.  void **eigen** (**RefDiagSCMatrix** &vals, **RefSCMatrix** &vecs, **RefDiagSCMatrix** &occs)\
 void **compute\_hsos\_v1** ()\
 **distsize\_t** **compute\_v2\_memory** (int ni, int nfuncmax, int nbfme, int nshell, int ndocc, int nsocc, int nvir, int nproc)\
 void **compute\_hsos\_v2** ()\
 void **compute\_hsos\_v2\_lb** ()\
 int **compute\_cs\_batchsize** (size\_t mem\_static, int nocc\_act)\
 **distsize\_t** **compute\_cs\_dynamic\_memory** (int ni, int nocc\_act)\
 int **make\_cs\_gmat** (**RefSymmSCMatrix** &Gmat, double \*DPmat)\
 int **make\_cs\_gmat\_new** (**RefSymmSCMatrix** &Gmat, const **RefSymmSCMatrix** &DPmat)\
 void **form\_max\_dens** (double \*DPmat, signed char \*maxp)\
 int **init\_cs\_gmat** ()\
 void **done\_cs\_gmat** ()\
 int **make\_g\_d\_nor** (**RefSymmSCMatrix** &Gmat, double \*DPmat, const double \*mgdbuff)\
 void **cs\_cphf** (double \*\*scf\_vector, double \*Laj, double \*eigval, **RefSCMatrix** &P2aj)\
 void **s2pdm\_contrib** (const double \*intderbuf, double \*PHF, double \*P2AO, double \*\*hf\_ginter, double \*\*ginter)\
 void **hcore\_cs\_grad** (double \*PHF, double \*PMP2, double \*\*hf\_ginter, double \*\*ginter)\
 void **overlap\_cs\_grad** (double \*WHF, double \*WMP2, double \*\*hf\_ginter, double \*\*ginter)\
 void **compute\_cs\_grad** ()\

### Protected Attributes

**Ref**\< **SCF** \> **reference\_**\
 **Ref**\< **MemoryGrp** \> **mem**\
 int **nfzc**\
 int **nfzv**\
 size\_t **mem\_alloc**\
 double **cphf\_epsilon\_**\
 int **eliminate\_in\_gmat\_**\
 const double \* **intbuf\_**\
 **Ref**\< **TwoBodyInt** \> **tbint\_**\
 **Ref**\< **TwoBodyInt** \> \* **tbints\_**\
 **Ref**\< **TwoBodyDerivInt** \> \* **tbintder\_**\
 int **nbasis**\
 int **noso**\
 **Ref**\< **MessageGrp** \> **msg\_**\
 int **nvir**\
 int **nocc**\
 int **nsocc**\
 **Ref**\< **ThreadGrp** \> **thr\_**\
 int **dynamic\_**\
 double **print\_percent\_**\
 int **max\_norb\_**\
 int \* **symorb\_irrep\_**\
 int \* **symorb\_num\_**\
 char \* **method\_**\
 char \* **algorithm\_**\
 int **do\_d1\_**\
 int **do\_d2\_**\
 int **nfuncmax**\
 double **hf\_energy\_**\
 **RefSCVector** **hf\_gradient\_**\
 double **restart\_ecorr\_**\
 int **restart\_orbital\_v1\_**\
 int **restart\_orbital\_memgrp\_**\

### Additional Inherited Members

## Detailed Description

The **MBPT2** class implements several second-order perturbation theory methods.

## Constructor & Destructor Documentation

### sc::MBPT2::MBPT2 (const Ref\< KeyVal \> &)

The **KeyVal** constructor.

- `reference`

  This gives the reference wavefunction. It must be an object of type **CLSCF** for closed-shell molecules and **HSOSSCF** for open-shell molecules. The is no default.

- `nfzc`

  The number of frozen core orbitals. The default is 0. If no atoms have an atomic number greater than 30, then the number of orbitals to be frozen can be automatically determined by specifying nfzc = auto.

- `nfzv`

  The number of frozen virtual orbitals. The default is 0.

- `memory`

  The amount of memory, in bytes, that each processor may use.

- `method`

  This gives a string that must take on one of the values below. The default is mp for closed-shell systems and zapt for open-shell systems.

- `mp`

  Use Mo/ller-Plesset perturbation theory. This is only valid for closed-shell systems. Energies and gradients can be computed with this method.

- `opt1`

  Use the OPT1 variant of open-shell perturbation theory. Only energies can be computed for open-shell systems.

- `opt2`

  Use the OPT2 variant of open-shell perturbation theory. Only energies can be computed for open-shell systems.

- `zapt`

  Use the ZAPT variant of open-shell perturbation theory. Only energies can be computed for open-shell systems.

- `algorithm`

  This gives a string that must take on one of the values given below. The default is memgrp for closed-shell systems. For open-shell systems v1 is used for a small number of processors and v2 is used otherwise.

- `memgrp`

  Use the distributed shared memory algorithm (which uses a **MemoryGrp** object). This is only valid for MP2 energies and gradients.

- `v1`

  Use algorithm V1. Only energies can be computed. The maximum number of processors that can be utilized is the number of virtual orbitals. This algorithm computes few integrals than the others, but has higher communication requirements.

- `v2`

  Use algorithm V2. Only energies can be computed. The maximum number of processors that can be utilized is the number of shells.

- `v2lb`

  Use a modified V2 algorithm that may compute more two electron integrals, but may get better load balance on the $O(n\_thrm{basis}^5)$ part of the calculation. Only energies can be computed. This is recommended only for computations involving large molecules (where the transformation is dominant) on very many processors (approaching the number of shells).

The v1 and v2 algorithms are discussed in Ida M. B. Nielsen and Edward T. Seidl, J. Comp. Chem. 16, 1301 (1995). The memgrp algorithm is discussed in Ida M. B. Nielsen, Chem. Phys. Lett. 255, 210 (1996).

- `memorygrp`

  A **MemoryGrp** object is used by the memgrp algorithm. If this is not given the program will try to find an appropriate default.

## Member Function Documentation

### void sc::MBPT2::compute ()` [protected]`, ` [virtual]`

Recompute at least the results that have compute true and are not already computed. This should only be called by **Result**'s members.

Implements **sc::Compute**.

Reimplemented in **sc::MBPT2\_R12**.

### RefSymmSCMatrix sc::MBPT2::density ()` [virtual]`

Returns the **SO** density.

Implements **sc::Wavefunction**.

Reimplemented in **sc::MBPT2\_R12**.

### int sc::MBPT2::gradient\_implemented () const` [virtual]`

Reimplemented from **sc::Function**.

### int sc::MBPT2::nelectron ()` [virtual]`

Returns the number of electrons.

Implements **sc::Wavefunction**.

### void sc::MBPT2::obsolete ()` [virtual]`

Marks all results as being out of date. Any subsequent access to results will cause **Compute::compute()** to be called.

Reimplemented from **sc::Compute**.

Reimplemented in **sc::MBPT2\_R12**.

### void sc::MBPT2::print (std::ostream & = ExEnv::out0`()`) const` [virtual]`

Print information about the object.

Reimplemented from **sc::MolecularEnergy**.

Reimplemented in **sc::MBPT2\_R12**.

### void sc::MBPT2::save\_data\_state (StateOut &)` [virtual]`

Save the base classes (with save\_data\_state) and the members in the same order that the **StateIn** CTOR initializes them. This must be implemented by the derived class if the class has data.

Reimplemented from **sc::MolecularEnergy**.

Reimplemented in **sc::MBPT2\_R12**.

### int sc::MBPT2::spin\_polarized ()` [virtual]`

Return 1 if the alpha density is not equal to the beta density.

Implements **sc::Wavefunction**.

### void sc::MBPT2::symmetry\_changed ()` [virtual]`

Call this if you have changed the molecular symmetry of the molecule contained by this **MolecularEnergy**.

Reimplemented from **sc::MolecularEnergy**.

### int sc::MBPT2::value\_implemented () const` [virtual]`

Information about the availability of values, gradients, and hessians.

Reimplemented from **sc::Function**.

Reimplemented in **sc::MBPT2\_R12**.

## Author

Generated automatically by Doxygen for MPQC from the source code.
