pyscf.mcscf package

Submodules

pyscf.mcscf.PiOS module

When using results of this code for publications, please cite the following paper: “Constructing molecular pi-orbital active spaces for multireference calculations of conjugated systems”

    1. Sayfutyarova and S. Hammes-Schiffer, J. Chem. Theory Comput., 15, 1679 (2019).

pyscf.mcscf.PiOS.Atoms_w_Coords(mol)

collect info about atoms’ positions

pyscf.mcscf.PiOS.FindValenceAoIndices(iAt, Shells, TargetL)
pyscf.mcscf.PiOS.GetCovalentRadius(At)
pyscf.mcscf.PiOS.GetNumPiElec(iAt, Elements, Coords)
pyscf.mcscf.PiOS.GetPzOrientation(iTargetAtoms, Coords_, Elements_)
pyscf.mcscf.PiOS.MakeIaosRaw(COcc, S1, S2, S12)
pyscf.mcscf.PiOS.MakeOverlappingOrbSubspace(Space, Name, COrb, nOrbExpected, CTargetIb, S1, Fock)
pyscf.mcscf.PiOS.MakePiOS(mol, mf, PiAtomsList, nPiOcc=None, nPiVirt=None)
pyscf.mcscf.PiOS.MakePiSystemOrbitals(TargetName, iTargetAtomsForPlane_, iTargetAtomsForBasis_, Elements, Coords, CIb, Shells, S1, S12, S2, Fock, COcc, CVir)
pyscf.mcscf.PiOS.MakePzMinaoVectors(iTargetAtoms, vPz, Shells)
pyscf.mcscf.PiOS.MakeShells(mol, Elements)

collect MINAO basis set data for all elements

pyscf.mcscf.PiOS.MakeShellsForElement(mol, Element)

make a list with MINAO basis set data for a given element in the mol object

pyscf.mcscf.PiOS.MakeSmh(S)
pyscf.mcscf.PiOS.SemiCanonicalize(COut, Fock, S1, Name, Print=True)
pyscf.mcscf.PiOS.mdot(*args)

chained matrix product: mdot(A,B,C,..) = A*B*C*… No attempt is made to optimize the contraction order.

pyscf.mcscf.PiOS.rmsd(a, b=None)

pyscf.mcscf.addons module

class pyscf.mcscf.addons.StateAverageFCISolver

Bases: object

class pyscf.mcscf.addons.StateAverageMCSCFSolver

Bases: object

class pyscf.mcscf.addons.StateSpecificFCISolver

Bases: object

pyscf.mcscf.addons.cas_natorb(casscf, mo_coeff=None, ci=None, sort=False)

Natrual orbitals in CAS space

pyscf.mcscf.addons.caslst_by_irrep(casscf, mo_coeff, cas_irrep_nocc, cas_irrep_ncore=None, s=None, base=1)

Given number of active orbitals for each irrep, return the orbital indices of active space

Args:

casscf : an CASSCF or CASCI object

cas_irrep_nocclist or dict

Number of active orbitals for each irrep. It can be a dict, eg {‘A1’: 2, ‘B2’: 4} to indicate the active space size based on irrep names, or {0: 2, 3: 4} for irrep Id, or a list [2, 0, 0, 4] (identical to {0: 2, 3: 4}) in which the list index is served as the irrep Id.

Kwargs:
cas_irrep_ncorelist or dict

Number of closed shells for each irrep. It can be a dict, eg {‘A1’: 6, ‘B2’: 4} to indicate the closed shells based on irrep names, or {0: 6, 3: 4} for irrep Id, or a list [6, 0, 0, 4] (identical to {0: 6, 3: 4}) in which the list index is served as the irrep Id. If cas_irrep_ncore is not given, the program will generate a guess based on the lowest CASCI.ncore orbitals.

sndarray

overlap matrix

baseint

0-based (C-like) or 1-based (Fortran-like) caslst

Returns:

A list of orbital indices

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvtz', symmetry=True, verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.kernel()
>>> mc = mcscf.CASSCF(mf, 12, 4)
>>> mcscf.caslst_by_irrep(mc, mf.mo_coeff, {'E1gx':4, 'E1gy':4, 'E1ux':2, 'E1uy':2})
[5, 7, 8, 10, 11, 14, 15, 20, 25, 26, 31, 32]
pyscf.mcscf.addons.get_fock(casscf, mo_coeff=None, ci=None)

Generalized Fock matrix in AO representation

pyscf.mcscf.addons.make_rdm1(casscf, mo_coeff=None, ci=None, **kwargs)

One-particle densit matrix in AO representation

Args:

casscf : an CASSCF or CASCI object

Kwargs:
cindarray

CAS space FCI coefficients. If not given, take casscf.ci.

mo_coeffndarray

Orbital coefficients. If not given, take casscf.mo_coeff.

Examples:

>>> import scipy.linalg
>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='sto-3g', verbose=0)
>>> mf = scf.RHF(mol)
>>> res = mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> res = mc.kernel()
>>> natocc = numpy.linalg.eigh(mcscf.make_rdm1(mc), mf.get_ovlp(), type=2)[0]
>>> print(natocc)
[ 0.0121563   0.0494735   0.0494735   1.95040395  1.95040395  1.98808879
  2.          2.          2.          2.        ]
pyscf.mcscf.addons.make_rdm12(casscf, mo_coeff=None, ci=None)
pyscf.mcscf.addons.make_rdm1s(casscf, mo_coeff=None, ci=None, **kwargs)

Alpha and beta one-particle densit matrices in AO representation

pyscf.mcscf.addons.map2hf(casscf, mf_mo=None, base=1, tol=0.4)

The overlap between the CASSCF optimized orbitals and the canonical HF orbitals.

pyscf.mcscf.addons.project_init_guess(casscf, init_mo, prev_mol=None)

Project the given initial guess to the current CASSCF problem. The projected initial guess has two parts. The core orbitals are directly taken from the Hartree-Fock orbitals, and the active orbitals are projected from the given initial guess.

Args:

casscf : an CASSCF or CASCI object

init_mondarray or list of ndarray

Initial guess orbitals which are not orth-normal for the current molecule. When the casscf is UHF-CASSCF, the init_mo needs to be a list of two ndarrays, for alpha and beta orbitals

Kwargs:
prev_molan instance of Mole

If given, the inital guess orbitals are associated to the geometry and basis of prev_mol. Otherwise, the orbitals are based of the geometry and basis of casscf.mol

Returns:

New orthogonal initial guess orbitals with the core taken from Hartree-Fock orbitals and projected active space from original initial guess orbitals

Examples:

import numpy
from pyscf import gto, scf, mcscf
mol = gto.Mole()
mol.build(atom='H 0 0 0; F 0 0 0.8', basis='ccpvdz', verbose=0)
mf = scf.RHF(mol)
mf.scf()
mc = mcscf.CASSCF(mf, 6, 6)
mo = mcscf.sort_mo(mc, mf.mo_coeff, [3,4,5,6,8,9])
print('E(0.8) = %.12f' % mc.kernel(mo)[0])
init_mo = mc.mo_coeff
for b in numpy.arange(1.0, 3., .2):
    mol.atom = [['H', (0, 0, 0)], ['F', (0, 0, b)]]
    mol.build(0, 0)
    mf = scf.RHF(mol)
    mf.scf()
    mc = mcscf.CASSCF(mf, 6, 6)
    mo = mcscf.project_init_guess(mc, init_mo)
    print('E(%2.1f) = %.12f' % (b, mc.kernel(mo)[0]))
    init_mo = mc.mo_coeff
pyscf.mcscf.addons.select_mo_by_irrep(casscf, cas_occ_num, mo=None, base=1)
pyscf.mcscf.addons.sort_mo(casscf, mo_coeff, caslst, base=1)

Pick orbitals for CAS space

Args:

casscf : an CASSCF or CASCI object

mo_coeffndarray or a list of ndarray

Orbitals for CASSCF initial guess. In the UHF-CASSCF, it’s a list of two orbitals, for alpha and beta spin.

caslstlist of int or nested list of int

A list of orbital indices to represent the CAS space. In the UHF-CASSCF, it’s consist of two lists, for alpha and beta spin.

Kwargs:
baseint

0-based (C-style) or 1-based (Fortran-style) caslst

Returns:

An reoreded mo_coeff, which put the orbitals given by caslst in the CAS space

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> cas_list = [5,6,8,9] # pi orbitals
>>> mo = mc.sort_mo(cas_list)
>>> mc.kernel(mo)[0]
-109.007378939813691
pyscf.mcscf.addons.sort_mo_by_irrep(casscf, mo_coeff, cas_irrep_nocc, cas_irrep_ncore=None, s=None)

Given number of active orbitals for each irrep, construct the mo initial guess for CASSCF

Args:

casscf : an CASSCF or CASCI object

cas_irrep_nocclist or dict

Number of active orbitals for each irrep. It can be a dict, eg {‘A1’: 2, ‘B2’: 4} to indicate the active space size based on irrep names, or {0: 2, 3: 4} for irrep Id, or a list [2, 0, 0, 4] (identical to {0: 2, 3: 4}) in which the list index is served as the irrep Id.

Kwargs:
cas_irrep_ncorelist or dict

Number of closed shells for each irrep. It can be a dict, eg {‘A1’: 6, ‘B2’: 4} to indicate the closed shells based on irrep names, or {0: 6, 3: 4} for irrep Id, or a list [6, 0, 0, 4] (identical to {0: 6, 3: 4}) in which the list index is served as the irrep Id. If cas_irrep_ncore is not given, the program will generate a guess based on the lowest CASCI.ncore orbitals.

sndarray

overlap matrix

Returns:

sorted orbitals, ordered as [c,..,c,a,..,a,v,..,v]

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvtz', symmetry=True, verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.kernel()
>>> mc = mcscf.CASSCF(mf, 12, 4)
>>> mo = mc.sort_mo_by_irrep({'E1gx':4, 'E1gy':4, 'E1ux':2, 'E1uy':2})
>>> # Same to mo = sort_mo_by_irrep(mc, mf.mo_coeff, {2: 4, 3: 4, 6: 2, 7: 2})
>>> # Same to mo = sort_mo_by_irrep(mc, mf.mo_coeff, [0, 0, 4, 4, 0, 0, 2, 2])
>>> mc.kernel(mo)[0]
-108.162863845084
pyscf.mcscf.addons.spin_square(casscf, mo_coeff=None, ci=None, ovlp=None)

Spin square of the UHF-CASSCF wavefunction

Returns:

A list of two floats. The first is the expectation value of S^2. The second is the corresponding 2S+1

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='O 0 0 0; O 0 0 1', basis='sto-3g', spin=2, verbose=0)
>>> mf = scf.UHF(mol)
>>> res = mf.scf()
>>> mc = mcscf.CASSCF(mf, 4, 6)
>>> res = mc.kernel()
>>> print('S^2 = %.7f, 2S+1 = %.7f' % mcscf.spin_square(mc))
S^2 = 3.9831589, 2S+1 = 4.1149284
pyscf.mcscf.addons.state_average(casscf, weights=(0.5, 0.5), wfnsym=None)

State average over the energy. The energy funcitonal is E = w1<psi1|H|psi1> + w2<psi2|H|psi2> + …

Note we may need change the FCI solver to

mc.fcisolver = fci.solver(mol, False)

before calling state_average_(mc), to mix the singlet and triplet states

MRH, 04/08/2019: Instead of turning casscf._finalize into an instance attribute that points to the previous casscf object, I’m going to make a whole new child class. This will have the added benefit of making state_average and state_average_ actually behave differently for the first time (until now they both modified the casscf object inplace). I’m also going to assign the weights argument as a member of the mc child class because an accurate second-order CASSCF algorithm for state-averaged calculations requires that the gradient and Hessian be computed for CI vectors of each root individually and then multiplied by that root’s weight. The second derivatives computed by newton_casscf.py need to be extended to state-averaged calculations in order to be used as intermediates for calculations of the gradient of a single root in the context of the SA-CASSCF method; see: Mol. Phys. 99, 103 (2001).

pyscf.mcscf.addons.state_average_(casscf, weights=(0.5, 0.5))

Inplace version of state_average

pyscf.mcscf.addons.state_average_mix(casscf, fcisolvers, weights=(0.5, 0.5))

State-average CASSCF over multiple FCI solvers.

pyscf.mcscf.addons.state_average_mix_(casscf, fcisolvers, weights=(0.5, 0.5))

Inplace version of state_average

pyscf.mcscf.addons.state_specific(casscf, state=1, wfnsym=None)

For excited state

Kwargs:

state : int 0 for ground state; 1 for first excited state.

pyscf.mcscf.addons.state_specific_(casscf, state=1, wfnsym=None)

For excited state

Kwargs:

state : int 0 for ground state; 1 for first excited state.

pyscf.mcscf.avas module

Automated construction of molecular active spaces from atomic valence orbitals. Ref. arXiv:1701.07862 [physics.chem-ph]

pyscf.mcscf.avas.avas(mf, aolabels, threshold=0.2, minao='minao', with_iao=False, openshell_option=2, canonicalize=True, ncore=0, verbose=None)

AVAS method to construct mcscf active space. Ref. arXiv:1701.07862 [physics.chem-ph]

Args:

mf : an SCF object

aolabelsstring or a list of strings

AO labels for AO active space

Kwargs:
thresholdfloat

Tructing threshold of the AO-projector above which AOs are kept in the active space.

minaostr

A reference AOs for AVAS.

with_iaobool

Whether to use IAO localization to construct the reference active AOs.

openshell_optionint

How to handle singly-occupied orbitals in the active space. The singly-occupied orbitals are projected as part of alpha orbitals if openshell_option=2, or completely kept in active space if openshell_option=3. See Section III.E option 2 or 3 of the reference paper for more details.

canonicalizebool

Orbitals defined in AVAS method are local orbitals. Symmetrizing the core, active and virtual space.

ncoreinteger

Number of core orbitals to exclude from the AVAS method.

Returns:

active-space-size, #-active-electrons, orbital-initial-guess-for-CASCI/CASSCF

Examples:

>>> from pyscf import gto, scf, mcscf
>>> from pyscf.mcscf import avas
>>> mol = gto.M(atom='Cr 0 0 0; Cr 0 0 1.6', basis='ccpvtz')
>>> mf = scf.RHF(mol).run()
>>> ncas, nelecas, mo = avas.avas(mf, ['Cr 3d', 'Cr 4s'])
>>> mc = mcscf.CASSCF(mf, ncas, nelecas).run(mo)
pyscf.mcscf.avas.kernel(mf, aolabels, threshold=0.2, minao='minao', with_iao=False, openshell_option=2, canonicalize=True, ncore=0, verbose=None)

AVAS method to construct mcscf active space. Ref. arXiv:1701.07862 [physics.chem-ph]

Args:

mf : an SCF object

aolabelsstring or a list of strings

AO labels for AO active space

Kwargs:
thresholdfloat

Tructing threshold of the AO-projector above which AOs are kept in the active space.

minaostr

A reference AOs for AVAS.

with_iaobool

Whether to use IAO localization to construct the reference active AOs.

openshell_optionint

How to handle singly-occupied orbitals in the active space. The singly-occupied orbitals are projected as part of alpha orbitals if openshell_option=2, or completely kept in active space if openshell_option=3. See Section III.E option 2 or 3 of the reference paper for more details.

canonicalizebool

Orbitals defined in AVAS method are local orbitals. Symmetrizing the core, active and virtual space.

ncoreinteger

Number of core orbitals to exclude from the AVAS method.

Returns:

active-space-size, #-active-electrons, orbital-initial-guess-for-CASCI/CASSCF

Examples:

>>> from pyscf import gto, scf, mcscf
>>> from pyscf.mcscf import avas
>>> mol = gto.M(atom='Cr 0 0 0; Cr 0 0 1.6', basis='ccpvtz')
>>> mf = scf.RHF(mol).run()
>>> ncas, nelecas, mo = avas.avas(mf, ['Cr 3d', 'Cr 4s'])
>>> mc = mcscf.CASSCF(mf, ncas, nelecas).run(mo)

pyscf.mcscf.casci module

class pyscf.mcscf.casci.CASCI(mf_or_mol, ncas, nelecas, ncore=None)

Bases: pyscf.lib.misc.StreamObject

Args:
mf_or_molSCF object or Mole object

SCF or Mole to define the problem size.

ncasint

Number of active orbitals.

nelecasint or a pair of int

Number of electrons in active space.

Kwargs:
ncoreint

Number of doubly occupied core orbitals. If not presented, this parameter can be automatically determined.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose.

max_memoryfloat or int

Allowed memory in MB. Default value equals to Mole.max_memory.

ncasint

Active space size.

nelecastuple of int

Active (nelec_alpha, nelec_beta)

ncoreint or tuple of int

Core electron number. In UHF-CASSCF, it’s a tuple to indicate the different core eletron numbers.

natorbbool

Whether to transform natural orbitals in active space. Note: when CASCI/CASSCF are combined with DMRG solver or selected CI solver, enabling this parameter may slightly change the total energy. False by default.

canonicalizationbool

Whether to canonicalize orbitals in core and external space against the general Fock matrix. The orbitals in active space are NOT transformed by default. To get the natural orbitals in active space, the attribute .natorb needs to be enabled. True by default.

sorting_mo_energybool

Whether to sort the orbitals based on the diagonal elements of the general Fock matrix. Default is False.

fcisolveran instance of FCISolver

The pyscf.fci module provides several FCISolver for different scenario. Generally, fci.direct_spin1.FCISolver can be used for all RHF-CASSCF. However, a proper FCISolver can provide better performance and better numerical stability. One can either use fci.solver() function to pick the FCISolver by the program or manually assigen the FCISolver to this attribute, e.g.

>>> from pyscf import fci
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> mc.fcisolver = fci.solver(mol, singlet=True)
>>> mc.fcisolver = fci.direct_spin1.FCISolver(mol)

You can control FCISolver by setting e.g.:

>>> mc.fcisolver.max_cycle = 30
>>> mc.fcisolver.conv_tol = 1e-7

For more details of the parameter for FCISolver, See fci.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

When canonicalization is specified, the orbitals are canonical orbitals which make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is specified, the active segment of the mo_coeff is natural orbitls.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

mo_occndarray

Occupation numbers of natural orbitals if natorb is specified.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASCI(mf, 6, 6)
>>> mc.kernel()[0]
-108.980200816243354
Gradients(*args, **kwargs)

Non-relativistic restricted Hartree-Fock gradients

analyze(mo_coeff=None, ci=None, verbose=None, large_ci_tol=0.1, with_meta_lowdin=True, **kwargs)
ao2mo(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

as_scanner()

Generating a scanner for CASCI PES.

The returned solver is a function. This function requires one argument “mol” as input and returns total CASCI energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters of MCSCF object are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mf = scf.RHF(gto.Mole().set(verbose=0))
>>> mc_scanner = mcscf.CASCI(mf, 4, 4).as_scanner()
>>> mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
canonicalization = True
canonicalize(mo_coeff=None, ci=None, eris=None, sort=False, cas_natorb=False, casdm1=None, verbose=3, with_meta_lowdin=True)

Canonicalized CASCI/CASSCF orbitals of effecitive Fock matrix and update CI coefficients accordingly.

Effective Fock matrix is built with one-particle density matrix (see also mcscf.casci.get_fock()). For state-average CASCI/CASSCF object, the canonicalized orbitals are based on the state-average density matrix. To obtain canonicalized orbitals for an individual state, you need to pass “casdm1” of the specific state to this function.

Args:

mc: a CASSCF/CASCI object or RHF object

Kwargs:
mo_coeff (ndarray): orbitals that span the core, active and external

space.

ci (ndarray): CI coefficients (or objects to represent the CI

wavefunctions in DMRG/QMC-MCSCF calculations).

eris: Integrals for the MCSCF object. Input this object to reduce the

overhead of computing integrals. It can be generated by mc.ao2mo() method.

sort (bool): Whether the canonicalized orbitals are sorted based on

the orbital energy (diagonal part of the effective Fock matrix) within each subspace (core, active, external). If point group symmetry is not available in the system, orbitals are always sorted. When point group symmetry is available, sort=False will preserve the symmetry label of input orbitals and only sort the orbitals in each symmetry sector. sort=True will reorder all orbitals over all symmetry sectors in each subspace and the symmetry labels may be changed.

cas_natorb (bool): Whether to transform active orbitals to natual

orbitals. If enabled, the output orbitals in active space are transformed to natural orbitals and CI coefficients are updated accordingly.

casdm1 (ndarray): 1-particle density matrix in active space. This

density matrix is used to build effective fock matrix. Without input casdm1, the density matrix is computed with the input ci coefficients/object. If neither ci nor casdm1 were given, density matrix is computed by mc.fcisolver.make_rdm1() method. For state-average CASCI/CASCF calculation, this results in a set of canonicalized orbitals of state-average effective Fock matrix. To canonicalize the orbitals for one particular state, you can assign the density matrix of that state to the kwarg casdm1.

Returns:

A tuple, (natural orbitals, CI coefficients, orbital energies) The orbital energies are the diagonal terms of effective Fock matrix.

canonicalize_(mo_coeff=None, ci=None, eris=None, sort=False, cas_natorb=False, casdm1=None, verbose=None, with_meta_lowdin=True)

Canonicalized CASCI/CASSCF orbitals of effecitive Fock matrix and update CI coefficients accordingly.

Effective Fock matrix is built with one-particle density matrix (see also mcscf.casci.get_fock()). For state-average CASCI/CASSCF object, the canonicalized orbitals are based on the state-average density matrix. To obtain canonicalized orbitals for an individual state, you need to pass “casdm1” of the specific state to this function.

Args:

mc: a CASSCF/CASCI object or RHF object

Kwargs:
mo_coeff (ndarray): orbitals that span the core, active and external

space.

ci (ndarray): CI coefficients (or objects to represent the CI

wavefunctions in DMRG/QMC-MCSCF calculations).

eris: Integrals for the MCSCF object. Input this object to reduce the

overhead of computing integrals. It can be generated by mc.ao2mo() method.

sort (bool): Whether the canonicalized orbitals are sorted based on

the orbital energy (diagonal part of the effective Fock matrix) within each subspace (core, active, external). If point group symmetry is not available in the system, orbitals are always sorted. When point group symmetry is available, sort=False will preserve the symmetry label of input orbitals and only sort the orbitals in each symmetry sector. sort=True will reorder all orbitals over all symmetry sectors in each subspace and the symmetry labels may be changed.

cas_natorb (bool): Whether to transform active orbitals to natual

orbitals. If enabled, the output orbitals in active space are transformed to natural orbitals and CI coefficients are updated accordingly.

casdm1 (ndarray): 1-particle density matrix in active space. This

density matrix is used to build effective fock matrix. Without input casdm1, the density matrix is computed with the input ci coefficients/object. If neither ci nor casdm1 were given, density matrix is computed by mc.fcisolver.make_rdm1() method. For state-average CASCI/CASCF calculation, this results in a set of canonicalized orbitals of state-average effective Fock matrix. To canonicalize the orbitals for one particular state, you can assign the density matrix of that state to the kwarg casdm1.

Returns:

A tuple, (natural orbitals, CI coefficients, orbital energies) The orbital energies are the diagonal terms of effective Fock matrix.

cas_natorb(mo_coeff=None, ci=None, eris=None, sort=False, casdm1=None, verbose=None, with_meta_lowdin=True)

Transform active orbitals to natrual orbitals, and update the CI wfn accordingly

Args:

mc : a CASSCF/CASCI object or RHF object

Kwargs:
sortbool

Sort natural orbitals wrt the occupancy.

Returns:

A tuple, the first item is natural orbitals, the second is updated CI coefficients, the third is the natural occupancy associated to the natural orbitals.

cas_natorb_(mo_coeff=None, ci=None, eris=None, sort=False, casdm1=None, verbose=None, with_meta_lowdin=True)

Transform active orbitals to natrual orbitals, and update the CI wfn accordingly

Args:

mc : a CASSCF/CASCI object or RHF object

Kwargs:
sortbool

Sort natural orbitals wrt the occupancy.

Returns:

A tuple, the first item is natural orbitals, the second is updated CI coefficients, the third is the natural occupancy associated to the natural orbitals.

casci(mo_coeff=None, ci0=None, verbose=None)
density_fit(auxbasis=None, with_df=None)
dump_flags(verbose=None)
energy_nuc()
fix_spin(shift=0.2, ss=None)

Use level shift to control FCI solver spin.

\[(H + shift*S^2) |\Psi\rangle = E |\Psi\rangle\]
Kwargs:
shiftfloat

Energy penalty for states which have wrong spin

ssnumber

S^2 expection value == s*(s+1)

fix_spin_(shift=0.2, ss=None)

Use level shift to control FCI solver spin.

\[(H + shift*S^2) |\Psi\rangle = E |\Psi\rangle\]
Kwargs:
shiftfloat

Energy penalty for states which have wrong spin

ssnumber

S^2 expection value == s*(s+1)

get_fock(mo_coeff=None, ci=None, eris=None, casdm1=None, verbose=None)
get_h1cas(mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian

Args:

casci : a CASSCF/CASCI object or RHF object

Returns:

A tuple, the first is the effective one-electron hamiltonian defined in CAS space, the second is the electronic energy from core.

get_h1eff(mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian

Args:

casci : a CASSCF/CASCI object or RHF object

Returns:

A tuple, the first is the effective one-electron hamiltonian defined in CAS space, the second is the electronic energy from core.

get_h2cas(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

Note It is different to get_h2eff when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_h2eff(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

Note It is different to get_h2cas when df.approx_hessian is applied. in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_hcore(mol=None)
get_jk(mol, dm, hermi=1, with_j=True, with_k=True, omega=None)

Compute J, K matrices for all input density matrices

Args:

mol : an instance of Mole

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Kwargs:
hermiint

Whether J, K matrix is hermitian

0 : not hermitian and not symmetric
1 : hermitian or symmetric
2 : anti-hermitian
vhfopt :

A class which holds precomputed quantities to optimize the computation of J, K matrices

with_jboolean

Whether to compute J matrices

with_kboolean

Whether to compute K matrices

omegafloat

Parameter of range-seperated Coulomb operator: erf( omega * r12 ) / r12. If specified, integration are evaluated based on the long-range part of the range-seperated Coulomb operator.

Returns:

Depending on the given dm, the function returns one J and one K matrix, or a list of J matrices and a list of K matrices, corresponding to the input density matrices.

Examples:

>>> from pyscf import gto, scf
>>> from pyscf.scf import _vhf
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> dms = numpy.random.random((3,mol.nao_nr(),mol.nao_nr()))
>>> j, k = scf.hf.get_jk(mol, dms, hermi=0)
>>> print(j.shape)
(3, 2, 2)
get_veff(mol=None, dm=None, hermi=1)

Hartree-Fock potential matrix for the given density matrix

Args:

mol : an instance of Mole

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference HF potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
vhfopt :

A class which holds precomputed quantities to optimize the computation of J, K matrices

Returns:

matrix Vhf = 2*J - K. Vhf can be a list matrices, corresponding to the input density matrices.

Examples:

>>> import numpy
>>> from pyscf import gto, scf
>>> from pyscf.scf import _vhf
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> dm0 = numpy.random.random((mol.nao_nr(),mol.nao_nr()))
>>> vhf0 = scf.hf.get_veff(mol, dm0, hermi=0)
>>> dm1 = numpy.random.random((mol.nao_nr(),mol.nao_nr()))
>>> vhf1 = scf.hf.get_veff(mol, dm1, hermi=0)
>>> vhf2 = scf.hf.get_veff(mol, dm1, dm_last=dm0, vhf_last=vhf0, hermi=0)
>>> numpy.allclose(vhf1, vhf2)
True
h1e_for_cas(mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian

Args:

casci : a CASSCF/CASCI object or RHF object

Returns:

A tuple, the first is the effective one-electron hamiltonian defined in CAS space, the second is the electronic energy from core.

kernel(mo_coeff=None, ci0=None, verbose=None)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

make_rdm1(mo_coeff=None, ci=None, ncas=None, nelecas=None, ncore=None, **kwargs)

One-particle density matrix in AO representation

make_rdm1s(mo_coeff=None, ci=None, ncas=None, nelecas=None, ncore=None, **kwargs)

One-particle density matrices for alpha and beta spin on AO basis

natorb = False
property ncore
nuc_grad_method()
reset(mol=None)
sfx2c1e()
sort_mo(caslst, mo_coeff=None, base=1)

Pick orbitals for CAS space

Args:

casscf : an CASSCF or CASCI object

mo_coeffndarray or a list of ndarray

Orbitals for CASSCF initial guess. In the UHF-CASSCF, it’s a list of two orbitals, for alpha and beta spin.

caslstlist of int or nested list of int

A list of orbital indices to represent the CAS space. In the UHF-CASSCF, it’s consist of two lists, for alpha and beta spin.

Kwargs:
baseint

0-based (C-style) or 1-based (Fortran-style) caslst

Returns:

An reoreded mo_coeff, which put the orbitals given by caslst in the CAS space

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> cas_list = [5,6,8,9] # pi orbitals
>>> mo = mc.sort_mo(cas_list)
>>> mc.kernel(mo)[0]
-109.007378939813691
sorting_mo_energy = False
state_average(weights=(0.5, 0.5))

State average over the energy. The energy funcitonal is E = w1<psi1|H|psi1> + w2<psi2|H|psi2> + …

Note we may need change the FCI solver to

mc.fcisolver = fci.solver(mol, False)

before calling state_average_(mc), to mix the singlet and triplet states

MRH, 04/08/2019: Instead of turning casscf._finalize into an instance attribute that points to the previous casscf object, I’m going to make a whole new child class. This will have the added benefit of making state_average and state_average_ actually behave differently for the first time (until now they both modified the casscf object inplace). I’m also going to assign the weights argument as a member of the mc child class because an accurate second-order CASSCF algorithm for state-averaged calculations requires that the gradient and Hessian be computed for CI vectors of each root individually and then multiplied by that root’s weight. The second derivatives computed by newton_casscf.py need to be extended to state-averaged calculations in order to be used as intermediates for calculations of the gradient of a single root in the context of the SA-CASSCF method; see: Mol. Phys. 99, 103 (2001).

state_average_(weights=(0.5, 0.5))

State average over the energy. The energy funcitonal is E = w1<psi1|H|psi1> + w2<psi2|H|psi2> + …

Note we may need change the FCI solver to

mc.fcisolver = fci.solver(mol, False)

before calling state_average_(mc), to mix the singlet and triplet states

MRH, 04/08/2019: Instead of turning casscf._finalize into an instance attribute that points to the previous casscf object, I’m going to make a whole new child class. This will have the added benefit of making state_average and state_average_ actually behave differently for the first time (until now they both modified the casscf object inplace). I’m also going to assign the weights argument as a member of the mc child class because an accurate second-order CASSCF algorithm for state-averaged calculations requires that the gradient and Hessian be computed for CI vectors of each root individually and then multiplied by that root’s weight. The second derivatives computed by newton_casscf.py need to be extended to state-averaged calculations in order to be used as intermediates for calculations of the gradient of a single root in the context of the SA-CASSCF method; see: Mol. Phys. 99, 103 (2001).

state_specific_(state=1)

For excited state

Kwargs:

state : int 0 for ground state; 1 for first excited state.

x2c()
x2c1e()
pyscf.mcscf.casci.analyze(casscf, mo_coeff=None, ci=None, verbose=None, large_ci_tol=0.1, with_meta_lowdin=True, **kwargs)
pyscf.mcscf.casci.as_scanner(mc)

Generating a scanner for CASCI PES.

The returned solver is a function. This function requires one argument “mol” as input and returns total CASCI energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters of MCSCF object are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mf = scf.RHF(gto.Mole().set(verbose=0))
>>> mc_scanner = mcscf.CASCI(mf, 4, 4).as_scanner()
>>> mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
pyscf.mcscf.casci.canonicalize(mc, mo_coeff=None, ci=None, eris=None, sort=False, cas_natorb=False, casdm1=None, verbose=3, with_meta_lowdin=True)

Canonicalized CASCI/CASSCF orbitals of effecitive Fock matrix and update CI coefficients accordingly.

Effective Fock matrix is built with one-particle density matrix (see also mcscf.casci.get_fock()). For state-average CASCI/CASSCF object, the canonicalized orbitals are based on the state-average density matrix. To obtain canonicalized orbitals for an individual state, you need to pass “casdm1” of the specific state to this function.

Args:

mc: a CASSCF/CASCI object or RHF object

Kwargs:
mo_coeff (ndarray): orbitals that span the core, active and external

space.

ci (ndarray): CI coefficients (or objects to represent the CI

wavefunctions in DMRG/QMC-MCSCF calculations).

eris: Integrals for the MCSCF object. Input this object to reduce the

overhead of computing integrals. It can be generated by mc.ao2mo() method.

sort (bool): Whether the canonicalized orbitals are sorted based on

the orbital energy (diagonal part of the effective Fock matrix) within each subspace (core, active, external). If point group symmetry is not available in the system, orbitals are always sorted. When point group symmetry is available, sort=False will preserve the symmetry label of input orbitals and only sort the orbitals in each symmetry sector. sort=True will reorder all orbitals over all symmetry sectors in each subspace and the symmetry labels may be changed.

cas_natorb (bool): Whether to transform active orbitals to natual

orbitals. If enabled, the output orbitals in active space are transformed to natural orbitals and CI coefficients are updated accordingly.

casdm1 (ndarray): 1-particle density matrix in active space. This

density matrix is used to build effective fock matrix. Without input casdm1, the density matrix is computed with the input ci coefficients/object. If neither ci nor casdm1 were given, density matrix is computed by mc.fcisolver.make_rdm1() method. For state-average CASCI/CASCF calculation, this results in a set of canonicalized orbitals of state-average effective Fock matrix. To canonicalize the orbitals for one particular state, you can assign the density matrix of that state to the kwarg casdm1.

Returns:

A tuple, (natural orbitals, CI coefficients, orbital energies) The orbital energies are the diagonal terms of effective Fock matrix.

pyscf.mcscf.casci.cas_natorb(mc, mo_coeff=None, ci=None, eris=None, sort=False, casdm1=None, verbose=None, with_meta_lowdin=True)

Transform active orbitals to natrual orbitals, and update the CI wfn accordingly

Args:

mc : a CASSCF/CASCI object or RHF object

Kwargs:
sortbool

Sort natural orbitals wrt the occupancy.

Returns:

A tuple, the first item is natural orbitals, the second is updated CI coefficients, the third is the natural occupancy associated to the natural orbitals.

pyscf.mcscf.casci.get_fock(mc, mo_coeff=None, ci=None, eris=None, casdm1=None, verbose=None)

Effective one-electron Fock matrix in AO representation f = sum_{pq} E_{pq} F_{pq} F_{pq} = h_{pq} + sum_{rs} [(pq|rs)-(ps|rq)] DM_{sr}

Ref. Theor. Chim. Acta., 91, 31 Chem. Phys. 48, 157

For state-average CASCI/CASSCF object, the effective fock matrix is based on the state-average density matrix. To obtain Fock matrix of a specific state in the state-average calculations, you can pass “casdm1” of the specific state to this function.

Args:

mc: a CASSCF/CASCI object or RHF object

Kwargs:
mo_coeff (ndarray): orbitals that span the core, active and external

space.

ci (ndarray): CI coefficients (or objects to represent the CI

wavefunctions in DMRG/QMC-MCSCF calculations).

eris: Integrals for the MCSCF object. Input this object to reduce the

overhead of computing integrals. It can be generated by mc.ao2mo() method.

casdm1 (ndarray): 1-particle density matrix in active space. Without

input casdm1, the density matrix is computed with the input ci coefficients/object. If neither ci nor casdm1 were given, density matrix is computed by mc.fcisolver.make_rdm1() method. For state-average CASCI/CASCF calculation, this results in the effective Fock matrix based on the state-average density matrix. To obtain the effective Fock matrix for one particular state, you can assign the density matrix of that state to the kwarg casdm1.

Returns:

Fock matrix

pyscf.mcscf.casci.h1e_for_cas(casci, mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian

Args:

casci : a CASSCF/CASCI object or RHF object

Returns:

A tuple, the first is the effective one-electron hamiltonian defined in CAS space, the second is the electronic energy from core.

pyscf.mcscf.casci.kernel(casci, mo_coeff=None, ci0=None, verbose=3)

CASCI solver

pyscf.mcscf.casci_symm module

pyscf.mcscf.casci_symm.CASCI

alias of pyscf.mcscf.casci_symm.SymAdaptedCASCI

class pyscf.mcscf.casci_symm.SymAdaptedCASCI(mf_or_mol, ncas, nelecas, ncore=None)

Bases: pyscf.mcscf.casci.CASCI

kernel(mo_coeff=None, ci0=None, verbose=None)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

sort_mo_by_irrep(cas_irrep_nocc, cas_irrep_ncore=None, mo_coeff=None, s=None)

Select active space based on symmetry information. See also pyscf.mcscf.addons.sort_mo_by_irrep()

property wfnsym
pyscf.mcscf.casci_symm.eig(mat, orbsym)
pyscf.mcscf.casci_symm.label_symmetry_(mc, mo_coeff, ci0=None)

pyscf.mcscf.chkfile module

pyscf.mcscf.chkfile.dump_mcscf(mc, chkfile=None, key='mcscf', e_tot=None, mo_coeff=None, ncore=None, ncas=None, mo_occ=None, mo_energy=None, e_cas=None, ci_vector=None, casdm1=None, overwrite_mol=True)

Save CASCI/CASSCF calculation results or intermediates in chkfile.

pyscf.mcscf.chkfile.load_mcscf(chkfile)

pyscf.mcscf.df module

pyscf.mcscf.df.approx_hessian(casscf, auxbasis=None, with_df=None)

Approximate the orbital hessian with density fitting integrals

Note this function has no effects if the input casscf object is DF-CASSCF. It only modifies the orbital hessian of normal CASSCF object.

Args:

casscf : an CASSCF object

Kwargs:
auxbasisstr or basis dict

Same format to the input attribute mol.basis. The default basis ‘weigend+etb’ means weigend-coulomb-fit basis for light elements and even-tempered basis for heavy elements.

Returns:

A CASSCF object with approximated JK contraction for orbital hessian

Examples:

>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.approx_hessian(mcscf.CASSCF(mf, 4, 4))
-100.06458716530391
pyscf.mcscf.df.density_fit(casscf, auxbasis=None, with_df=None)

Generate DF-CASSCF for given CASSCF object. It is done by overwriting three CASSCF member functions:

  • casscf.ao2mo which generates MO integrals

  • casscf.get_veff which generate JK from core density matrix

  • casscf.get_jk which

Args:

casscf : an CASSCF object

Kwargs:
auxbasisstr or basis dict

Same format to the input attribute mol.basis. If auxbasis is None, auxiliary basis based on AO basis (if possible) or even-tempered Gaussian basis will be used.

Returns:

An CASSCF object with a modified J, K matrix constructor which uses density fitting integrals to compute J and K

Examples:

>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = DFCASSCF(mf, 4, 4)
-100.05994191570504
pyscf.mcscf.df.prange(start, end, step)

pyscf.mcscf.dmet_cas module

pyscf.mcscf.dmet_cas.dmet_cas(mf, dm, aolabels_or_baslst, threshold=0.05, occ_cutoff=1e-06, base=0, orth_method='meta_lowdin', s=None, canonicalize=True, freeze_imp=False, verbose=None)

DMET method to generate CASSCF initial guess. Ref. arXiv:1701.07862 [physics.chem-ph]

Args:

mf : an SCF object

dm2D np.array or a list of 2D array

Density matrix

aolabels_or_baslststring or a list of strings or a list of index

AO labels or indices

Kwargs:
thresholdfloat

Entanglement threshold of DMET bath. If the occupancy of an orbital is less than threshold, the orbital is considered as bath orbtial. If occ is greater than (1-threshold), the orbitals are taken for core determinant.

baseint

0-based (C-style) or 1-based (Fortran-style) for baslst if baslst is index list

orth_methodstr

It can be one of ‘lowdin’ and ‘meta_lowdin’

s2D array

AO overlap matrix. This option is mainly used for custom Hamilatonian.

canonicalizebool

Orbitals defined in AVAS method are local orbitals. Symmetrizing the core, active and virtual space.

Returns:

active-space-size, #-active-electrons, orbital-initial-guess-for-CASCI/CASSCF

Examples:

>>> from pyscf import gto, scf, mcscf
>>> from pyscf.mcscf import dmet_cas
>>> mol = gto.M(atom='Cr 0 0 0; Cr 0 0 1.6', basis='ccpvtz')
>>> mf = scf.RHF(mol).run()
>>> ncas, nelecas, mo = dmet_cas.dmet_cas(mf, ['Cr 3d', 'Cr 4s'])
>>> mc = mcscf.CASSCF(mf, ncas, nelecas).run(mo)
pyscf.mcscf.dmet_cas.guess_cas(mf, dm, aolabels_or_baslst, threshold=0.05, occ_cutoff=1e-06, base=0, orth_method='meta_lowdin', s=None, canonicalize=True, freeze_imp=False, verbose=None)

DMET method to generate CASSCF initial guess. Ref. arXiv:1701.07862 [physics.chem-ph]

Args:

mf : an SCF object

dm2D np.array or a list of 2D array

Density matrix

aolabels_or_baslststring or a list of strings or a list of index

AO labels or indices

Kwargs:
thresholdfloat

Entanglement threshold of DMET bath. If the occupancy of an orbital is less than threshold, the orbital is considered as bath orbtial. If occ is greater than (1-threshold), the orbitals are taken for core determinant.

baseint

0-based (C-style) or 1-based (Fortran-style) for baslst if baslst is index list

orth_methodstr

It can be one of ‘lowdin’ and ‘meta_lowdin’

s2D array

AO overlap matrix. This option is mainly used for custom Hamilatonian.

canonicalizebool

Orbitals defined in AVAS method are local orbitals. Symmetrizing the core, active and virtual space.

Returns:

active-space-size, #-active-electrons, orbital-initial-guess-for-CASCI/CASSCF

Examples:

>>> from pyscf import gto, scf, mcscf
>>> from pyscf.mcscf import dmet_cas
>>> mol = gto.M(atom='Cr 0 0 0; Cr 0 0 1.6', basis='ccpvtz')
>>> mf = scf.RHF(mol).run()
>>> ncas, nelecas, mo = dmet_cas.dmet_cas(mf, ['Cr 3d', 'Cr 4s'])
>>> mc = mcscf.CASSCF(mf, ncas, nelecas).run(mo)
pyscf.mcscf.dmet_cas.kernel(mf, dm, aolabels_or_baslst, threshold=0.05, occ_cutoff=1e-06, base=0, orth_method='meta_lowdin', s=None, canonicalize=True, freeze_imp=False, verbose=None)

DMET method to generate CASSCF initial guess. Ref. arXiv:1701.07862 [physics.chem-ph]

Args:

mf : an SCF object

dm2D np.array or a list of 2D array

Density matrix

aolabels_or_baslststring or a list of strings or a list of index

AO labels or indices

Kwargs:
thresholdfloat

Entanglement threshold of DMET bath. If the occupancy of an orbital is less than threshold, the orbital is considered as bath orbtial. If occ is greater than (1-threshold), the orbitals are taken for core determinant.

baseint

0-based (C-style) or 1-based (Fortran-style) for baslst if baslst is index list

orth_methodstr

It can be one of ‘lowdin’ and ‘meta_lowdin’

s2D array

AO overlap matrix. This option is mainly used for custom Hamilatonian.

canonicalizebool

Orbitals defined in AVAS method are local orbitals. Symmetrizing the core, active and virtual space.

Returns:

active-space-size, #-active-electrons, orbital-initial-guess-for-CASCI/CASSCF

Examples:

>>> from pyscf import gto, scf, mcscf
>>> from pyscf.mcscf import dmet_cas
>>> mol = gto.M(atom='Cr 0 0 0; Cr 0 0 1.6', basis='ccpvtz')
>>> mf = scf.RHF(mol).run()
>>> ncas, nelecas, mo = dmet_cas.dmet_cas(mf, ['Cr 3d', 'Cr 4s'])
>>> mc = mcscf.CASSCF(mf, ncas, nelecas).run(mo)
pyscf.mcscf.dmet_cas.search_for_degeneracy(e)
pyscf.mcscf.dmet_cas.symmetrize(mol, e, c, s, log)

pyscf.mcscf.mc1step module

class pyscf.mcscf.mc1step.CASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)

Bases: pyscf.mcscf.casci.CASCI

Args:
mf_or_molSCF object or Mole object

SCF or Mole to define the problem size.

ncasint

Number of active orbitals.

nelecasint or a pair of int

Number of electrons in active space.

Kwargs:
ncoreint

Number of doubly occupied core orbitals. If not presented, this parameter can be automatically determined.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose.

max_memoryfloat or int

Allowed memory in MB. Default value equals to Mole.max_memory.

ncasint

Active space size.

nelecastuple of int

Active (nelec_alpha, nelec_beta)

ncoreint or tuple of int

Core electron number. In UHF-CASSCF, it’s a tuple to indicate the different core eletron numbers.

natorbbool

Whether to transform natural orbitals in active space. Note: when CASCI/CASSCF are combined with DMRG solver or selected CI solver, enabling this parameter may slightly change the total energy. False by default.

canonicalizationbool

Whether to canonicalize orbitals in core and external space against the general Fock matrix. The orbitals in active space are NOT transformed by default. To get the natural orbitals in active space, the attribute .natorb needs to be enabled. True by default.

sorting_mo_energybool

Whether to sort the orbitals based on the diagonal elements of the general Fock matrix. Default is False.

fcisolveran instance of FCISolver

The pyscf.fci module provides several FCISolver for different scenario. Generally, fci.direct_spin1.FCISolver can be used for all RHF-CASSCF. However, a proper FCISolver can provide better performance and better numerical stability. One can either use fci.solver() function to pick the FCISolver by the program or manually assigen the FCISolver to this attribute, e.g.

>>> from pyscf import fci
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> mc.fcisolver = fci.solver(mol, singlet=True)
>>> mc.fcisolver = fci.direct_spin1.FCISolver(mol)

You can control FCISolver by setting e.g.:

>>> mc.fcisolver.max_cycle = 30
>>> mc.fcisolver.conv_tol = 1e-7

For more details of the parameter for FCISolver, See fci.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

When canonicalization is specified, the orbitals are canonical orbitals which make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is specified, the active segment of the mo_coeff is natural orbitls.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

mo_occndarray

Occupation numbers of natural orbitals if natorb is specified.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASCI(mf, 6, 6)
>>> mc.kernel()[0]
-108.980200816243354
CASSCF

Extra attributes for CASSCF:

conv_tolfloat

Converge threshold. Default is 1e-7

conv_tol_gradfloat

Converge threshold for CI gradients and orbital rotation gradients. Default is 1e-4

max_stepsizefloat

The step size for orbital rotation. Small step (0.005 - 0.05) is prefered. Default is 0.03.

max_cycle_macroint

Max number of macro iterations. Default is 50.

max_cycle_microint

Max number of micro iterations in each macro iteration. Depending on systems, increasing this value might reduce the total macro iterations. Generally, 2 - 5 steps should be enough. Default is 3.

ah_level_shiftfloat, for AH solver.

Level shift for the Davidson diagonalization in AH solver. Default is 1e-8.

ah_conv_tolfloat, for AH solver.

converge threshold for AH solver. Default is 1e-12.

ah_max_cyclefloat, for AH solver.

Max number of iterations allowd in AH solver. Default is 30.

ah_lindepfloat, for AH solver.

Linear dependence threshold for AH solver. Default is 1e-14.

ah_start_tolflat, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 0.2.

ah_start_cycleint, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 2.

ah_conv_tol, ah_max_cycle, ah_lindep, ah_start_tol and ah_start_cycle can affect the accuracy and performance of CASSCF solver. Lower ah_conv_tol and ah_lindep might improve the accuracy of CASSCF optimization, but decrease the performance.

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.UHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.conv_tol = 1e-10
>>> mc.ah_conv_tol = 1e-5
>>> mc.kernel()[0]
-109.044401898486001
>>> mc.ah_conv_tol = 1e-10
>>> mc.kernel()[0]
-109.044401887945668
chkfilestr

Checkpoint file to save the intermediate orbitals during the CASSCF optimization. Default is the checkpoint file of mean field object.

ci_response_spaceint

subspace size to solve the CI vector response. Default is 3.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current envrionment.

scale_restorationfloat

When a step of orbital rotation moves out of trust region, the orbital optimization will be restored to previous state and the step size of the orbital rotation needs to be reduced. scale_restoration controls how much to scale down the step size.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

Optimized CASSCF orbitals coefficients. When canonicalization is specified, the returned orbitals make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is enabled, the active segment of mo_coeff is transformed to natural orbitals.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.kernel()[0]
-109.044401882238134
Gradients(*args, **kwargs)

Non-relativistic restricted Hartree-Fock gradients

ah_conv_tol = 1e-12
ah_grad_trust_region = 3.0
ah_level_shift = 1e-08
ah_lindep = 1e-14
ah_max_cycle = 30
ah_scheduler(envs)
ah_start_cycle = 3
ah_start_tol = 2.5
ao2mo(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

ao2mo_level = 2
approx_hessian(auxbasis=None, with_df=None)
as_scanner()

Generating a scanner for CASSCF PES.

The returned solver is a function. This function requires one argument “mol” as input and returns total CASSCF energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters of MCSCF object (conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1.2', verbose=0)
>>> mc_scanner = mcscf.CASSCF(scf.RHF(mol), 4, 4).as_scanner()
>>> e = mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> e = mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
canonicalization = True
casci(mo_coeff, ci0=None, eris=None, verbose=None, envs=None)
chk_ci = False
ci_grad_trust_region = 3.0
ci_response_space = 4
property ci_update_dep
conv_tol = 1e-07
conv_tol_grad = None
dump_chk(envs)
dump_flags(verbose=None)
gen_g_hop(mo, u, casdm1, casdm2, eris)
get_grad(mo_coeff=None, casdm1_casdm2=None, eris=None)

Orbital gradients

get_h2cas(mo_coeff=None)

Computing active space two-particle Hamiltonian.

Note It is different to get_h2eff when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_h2eff(mo_coeff=None)

Computing active space two-particle Hamiltonian.

Note It is different to get_h2cas when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

property grad_update_dep
internal_rotation = False
kernel(mo_coeff=None, ci0=None, callback=None, _kern=<function kernel>)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

kf_interval = 4
kf_trust_region = 3.0
property max_cycle
max_cycle_macro = 50
max_cycle_micro = 4
property max_orb_stepsize
max_stepsize = 0.02
max_stepsize_scheduler(envs)
mc1step(mo_coeff=None, ci0=None, callback=None)
mc2step(mo_coeff=None, ci0=None, callback=None)
micro_cycle_scheduler(envs)
natorb = False
newton()
nuc_grad_method()
pack_uniq_var(mat)
rotate_mo(mo, u, log=None)

Rotate orbitals with the given unitary matrix

rotate_orb_cc(mo, fcivec, fcasdm1, fcasdm2, eris, x0_guess=None, conv_tol_grad=0.0001, max_stepsize=None, verbose=None)
scale_restoration = 0.5
solve_approx_ci(h1, h2, ci0, ecore, e_cas, envs)

Solve CI eigenvalue/response problem approximately

sorting_mo_energy = False
uniq_var_indices(nmo, ncore, ncas, frozen)
unpack_uniq_var(v)
update(chkfile=None)
update_ao2mo(mo)
update_casdm(mo, u, fcivec, e_cas, eris, envs={})
update_from_chk(chkfile=None)
update_jk_in_ah(mo, r, casdm1, eris)
update_rotate_matrix(dx, u0=1)
with_dep4 = False
pyscf.mcscf.mc1step.as_scanner(mc)

Generating a scanner for CASSCF PES.

The returned solver is a function. This function requires one argument “mol” as input and returns total CASSCF energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters of MCSCF object (conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1.2', verbose=0)
>>> mc_scanner = mcscf.CASSCF(scf.RHF(mol), 4, 4).as_scanner()
>>> e = mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> e = mc_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
pyscf.mcscf.mc1step.expmat(a)
pyscf.mcscf.mc1step.gen_g_hop(casscf, mo, u, casdm1, casdm2, eris)
pyscf.mcscf.mc1step.kernel(casscf, mo_coeff, tol=1e-07, conv_tol_grad=None, ci0=None, callback=None, verbose=3, dump_chk=True)

quasi-newton CASSCF optimization driver

pyscf.mcscf.mc1step.rotate_orb_cc(casscf, mo, fcivec, fcasdm1, fcasdm2, eris, x0_guess=None, conv_tol_grad=0.0001, max_stepsize=None, verbose=None)

pyscf.mcscf.mc1step_symm module

pyscf.mcscf.mc1step_symm.CASSCF

alias of pyscf.mcscf.mc1step_symm.SymAdaptedCASSCF

class pyscf.mcscf.mc1step_symm.SymAdaptedCASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)

Bases: pyscf.mcscf.mc1step.CASSCF

Args:
mf_or_molSCF object or Mole object

SCF or Mole to define the problem size.

ncasint

Number of active orbitals.

nelecasint or a pair of int

Number of electrons in active space.

Kwargs:
ncoreint

Number of doubly occupied core orbitals. If not presented, this parameter can be automatically determined.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose.

max_memoryfloat or int

Allowed memory in MB. Default value equals to Mole.max_memory.

ncasint

Active space size.

nelecastuple of int

Active (nelec_alpha, nelec_beta)

ncoreint or tuple of int

Core electron number. In UHF-CASSCF, it’s a tuple to indicate the different core eletron numbers.

natorbbool

Whether to transform natural orbitals in active space. Note: when CASCI/CASSCF are combined with DMRG solver or selected CI solver, enabling this parameter may slightly change the total energy. False by default.

canonicalizationbool

Whether to canonicalize orbitals in core and external space against the general Fock matrix. The orbitals in active space are NOT transformed by default. To get the natural orbitals in active space, the attribute .natorb needs to be enabled. True by default.

sorting_mo_energybool

Whether to sort the orbitals based on the diagonal elements of the general Fock matrix. Default is False.

fcisolveran instance of FCISolver

The pyscf.fci module provides several FCISolver for different scenario. Generally, fci.direct_spin1.FCISolver can be used for all RHF-CASSCF. However, a proper FCISolver can provide better performance and better numerical stability. One can either use fci.solver() function to pick the FCISolver by the program or manually assigen the FCISolver to this attribute, e.g.

>>> from pyscf import fci
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> mc.fcisolver = fci.solver(mol, singlet=True)
>>> mc.fcisolver = fci.direct_spin1.FCISolver(mol)

You can control FCISolver by setting e.g.:

>>> mc.fcisolver.max_cycle = 30
>>> mc.fcisolver.conv_tol = 1e-7

For more details of the parameter for FCISolver, See fci.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

When canonicalization is specified, the orbitals are canonical orbitals which make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is specified, the active segment of the mo_coeff is natural orbitls.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

mo_occndarray

Occupation numbers of natural orbitals if natorb is specified.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASCI(mf, 6, 6)
>>> mc.kernel()[0]
-108.980200816243354
CASSCF

Extra attributes for CASSCF:

conv_tolfloat

Converge threshold. Default is 1e-7

conv_tol_gradfloat

Converge threshold for CI gradients and orbital rotation gradients. Default is 1e-4

max_stepsizefloat

The step size for orbital rotation. Small step (0.005 - 0.05) is prefered. Default is 0.03.

max_cycle_macroint

Max number of macro iterations. Default is 50.

max_cycle_microint

Max number of micro iterations in each macro iteration. Depending on systems, increasing this value might reduce the total macro iterations. Generally, 2 - 5 steps should be enough. Default is 3.

ah_level_shiftfloat, for AH solver.

Level shift for the Davidson diagonalization in AH solver. Default is 1e-8.

ah_conv_tolfloat, for AH solver.

converge threshold for AH solver. Default is 1e-12.

ah_max_cyclefloat, for AH solver.

Max number of iterations allowd in AH solver. Default is 30.

ah_lindepfloat, for AH solver.

Linear dependence threshold for AH solver. Default is 1e-14.

ah_start_tolflat, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 0.2.

ah_start_cycleint, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 2.

ah_conv_tol, ah_max_cycle, ah_lindep, ah_start_tol and ah_start_cycle can affect the accuracy and performance of CASSCF solver. Lower ah_conv_tol and ah_lindep might improve the accuracy of CASSCF optimization, but decrease the performance.

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.UHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.conv_tol = 1e-10
>>> mc.ah_conv_tol = 1e-5
>>> mc.kernel()[0]
-109.044401898486001
>>> mc.ah_conv_tol = 1e-10
>>> mc.kernel()[0]
-109.044401887945668
chkfilestr

Checkpoint file to save the intermediate orbitals during the CASSCF optimization. Default is the checkpoint file of mean field object.

ci_response_spaceint

subspace size to solve the CI vector response. Default is 3.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current envrionment.

scale_restorationfloat

When a step of orbital rotation moves out of trust region, the orbital optimization will be restored to previous state and the step size of the orbital rotation needs to be reduced. scale_restoration controls how much to scale down the step size.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

Optimized CASSCF orbitals coefficients. When canonicalization is specified, the returned orbitals make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is enabled, the active segment of mo_coeff is transformed to natural orbitals.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.kernel()[0]
-109.044401882238134
kernel(mo_coeff=None, ci0=None, callback=None, _kern=None)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

mc1step(mo_coeff=None, ci0=None, callback=None)
mc2step(mo_coeff=None, ci0=None, callback=None)
newton()
rotate_mo(mo, u, log=None)

Rotate orbitals with the given unitary matrix

sort_mo_by_irrep(cas_irrep_nocc, cas_irrep_ncore=None, mo_coeff=None, s=None)

Select active space based on symmetry information. See also pyscf.mcscf.addons.sort_mo_by_irrep()

uniq_var_indices(nmo, ncore, ncas, frozen)
property wfnsym

pyscf.mcscf.mc2step module

pyscf.mcscf.mc2step.kernel(casscf, mo_coeff, tol=1e-07, conv_tol_grad=None, ci0=None, callback=None, verbose=None, dump_chk=True)

pyscf.mcscf.mc_ao2mo module

pyscf.mcscf.mc_ao2mo.prange(start, end, step)
pyscf.mcscf.mc_ao2mo.trans_e1_incore(eri_ao, mo, ncore, ncas)
pyscf.mcscf.mc_ao2mo.trans_e1_outcore(mol, mo, ncore, ncas, erifile, max_memory=None, level=1, verbose=2)

pyscf.mcscf.newton_casscf module

Second order CASSCF

class pyscf.mcscf.newton_casscf.CASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)

Bases: pyscf.mcscf.mc1step.CASSCF

Args:
mf_or_molSCF object or Mole object

SCF or Mole to define the problem size.

ncasint

Number of active orbitals.

nelecasint or a pair of int

Number of electrons in active space.

Kwargs:
ncoreint

Number of doubly occupied core orbitals. If not presented, this parameter can be automatically determined.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose.

max_memoryfloat or int

Allowed memory in MB. Default value equals to Mole.max_memory.

ncasint

Active space size.

nelecastuple of int

Active (nelec_alpha, nelec_beta)

ncoreint or tuple of int

Core electron number. In UHF-CASSCF, it’s a tuple to indicate the different core eletron numbers.

natorbbool

Whether to transform natural orbitals in active space. Note: when CASCI/CASSCF are combined with DMRG solver or selected CI solver, enabling this parameter may slightly change the total energy. False by default.

canonicalizationbool

Whether to canonicalize orbitals in core and external space against the general Fock matrix. The orbitals in active space are NOT transformed by default. To get the natural orbitals in active space, the attribute .natorb needs to be enabled. True by default.

sorting_mo_energybool

Whether to sort the orbitals based on the diagonal elements of the general Fock matrix. Default is False.

fcisolveran instance of FCISolver

The pyscf.fci module provides several FCISolver for different scenario. Generally, fci.direct_spin1.FCISolver can be used for all RHF-CASSCF. However, a proper FCISolver can provide better performance and better numerical stability. One can either use fci.solver() function to pick the FCISolver by the program or manually assigen the FCISolver to this attribute, e.g.

>>> from pyscf import fci
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> mc.fcisolver = fci.solver(mol, singlet=True)
>>> mc.fcisolver = fci.direct_spin1.FCISolver(mol)

You can control FCISolver by setting e.g.:

>>> mc.fcisolver.max_cycle = 30
>>> mc.fcisolver.conv_tol = 1e-7

For more details of the parameter for FCISolver, See fci.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

When canonicalization is specified, the orbitals are canonical orbitals which make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is specified, the active segment of the mo_coeff is natural orbitls.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

mo_occndarray

Occupation numbers of natural orbitals if natorb is specified.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASCI(mf, 6, 6)
>>> mc.kernel()[0]
-108.980200816243354
CASSCF

Extra attributes for CASSCF:

conv_tolfloat

Converge threshold. Default is 1e-7

conv_tol_gradfloat

Converge threshold for CI gradients and orbital rotation gradients. Default is 1e-4

max_stepsizefloat

The step size for orbital rotation. Small step (0.005 - 0.05) is prefered. (see notes in max_cycle_micro_inner attribute) Default is 0.03.

max_cycle_macroint

Max number of macro iterations. Default is 50.

max_cycle_microint

Max number of micro (CIAH) iterations in each macro iteration.

ah_level_shiftfloat, for AH solver.

Level shift for the Davidson diagonalization in AH solver. Default is 1e-8.

ah_conv_tolfloat, for AH solver.

converge threshold for AH solver. Default is 1e-12.

ah_max_cyclefloat, for AH solver.

Max number of iterations allowd in AH solver. Default is 30.

ah_lindepfloat, for AH solver.

Linear dependence threshold for AH solver. Default is 1e-14.

ah_start_tolflat, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 0.2.

ah_start_cycleint, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 2.

ah_conv_tol, ah_max_cycle, ah_lindep, ah_start_tol and ah_start_cycle can affect the accuracy and performance of CASSCF solver. Lower ah_conv_tol and ah_lindep might improve the accuracy of CASSCF optimization, but decrease the performance.

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.UHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.conv_tol = 1e-10
>>> mc.ah_conv_tol = 1e-5
>>> mc.kernel()
-109.044401898486001
>>> mc.ah_conv_tol = 1e-10
>>> mc.kernel()
-109.044401887945668
chkfilestr

Checkpoint file to save the intermediate orbitals during the CASSCF optimization. Default is the checkpoint file of mean field object.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current envrionment.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

cindarray

CAS space FCI coefficients

convergedbool

It indicates CASSCF optimization converged or not.

mo_coeffndarray

Optimized CASSCF orbitals coefficients

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.kernel()[0]
-109.044401882238134
casci(mo_coeff, ci0=None, eris=None, verbose=None, envs=None)
dump_flags(verbose=None)
get_h2cas(mo_coeff=None)

Computing active space two-particle Hamiltonian.

Note It is different to get_h2eff when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_h2eff(mo_coeff=None)

Computing active space two-particle Hamiltonian.

Note It is different to get_h2cas when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

kernel(mo_coeff=None, ci0=None, callback=None)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

update_ao2mo(mo)
pyscf.mcscf.newton_casscf.extract_rotation(casscf, dr, u, ci0)
pyscf.mcscf.newton_casscf.gen_g_hop(casscf, mo, ci0, eris, verbose=None)
pyscf.mcscf.newton_casscf.kernel(casscf, mo_coeff, tol=1e-07, conv_tol_grad=None, ci0=None, callback=None, verbose=3, dump_chk=True)

Second order CASSCF driver

pyscf.mcscf.newton_casscf.update_orb_ci(casscf, mo, ci0, eris, x0_guess=None, conv_tol_grad=0.0001, max_stepsize=None, verbose=None)

pyscf.mcscf.newton_casscf_symm module

class pyscf.mcscf.newton_casscf_symm.CASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)

Bases: pyscf.mcscf.newton_casscf.CASSCF

Args:
mf_or_molSCF object or Mole object

SCF or Mole to define the problem size.

ncasint

Number of active orbitals.

nelecasint or a pair of int

Number of electrons in active space.

Kwargs:
ncoreint

Number of doubly occupied core orbitals. If not presented, this parameter can be automatically determined.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose.

max_memoryfloat or int

Allowed memory in MB. Default value equals to Mole.max_memory.

ncasint

Active space size.

nelecastuple of int

Active (nelec_alpha, nelec_beta)

ncoreint or tuple of int

Core electron number. In UHF-CASSCF, it’s a tuple to indicate the different core eletron numbers.

natorbbool

Whether to transform natural orbitals in active space. Note: when CASCI/CASSCF are combined with DMRG solver or selected CI solver, enabling this parameter may slightly change the total energy. False by default.

canonicalizationbool

Whether to canonicalize orbitals in core and external space against the general Fock matrix. The orbitals in active space are NOT transformed by default. To get the natural orbitals in active space, the attribute .natorb needs to be enabled. True by default.

sorting_mo_energybool

Whether to sort the orbitals based on the diagonal elements of the general Fock matrix. Default is False.

fcisolveran instance of FCISolver

The pyscf.fci module provides several FCISolver for different scenario. Generally, fci.direct_spin1.FCISolver can be used for all RHF-CASSCF. However, a proper FCISolver can provide better performance and better numerical stability. One can either use fci.solver() function to pick the FCISolver by the program or manually assigen the FCISolver to this attribute, e.g.

>>> from pyscf import fci
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> mc.fcisolver = fci.solver(mol, singlet=True)
>>> mc.fcisolver = fci.direct_spin1.FCISolver(mol)

You can control FCISolver by setting e.g.:

>>> mc.fcisolver.max_cycle = 30
>>> mc.fcisolver.conv_tol = 1e-7

For more details of the parameter for FCISolver, See fci.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

e_casfloat

CAS space FCI energy

cindarray

CAS space FCI coefficients

mo_coeffndarray

When canonicalization is specified, the orbitals are canonical orbitals which make the general Fock matrix (Fock operator on top of MCSCF 1-particle density matrix) diagonalized within each subspace (core, active, external). If natorb (natural orbitals in active space) is specified, the active segment of the mo_coeff is natural orbitls.

mo_energyndarray

Diagonal elements of general Fock matrix (in mo_coeff representation).

mo_occndarray

Occupation numbers of natural orbitals if natorb is specified.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASCI(mf, 6, 6)
>>> mc.kernel()[0]
-108.980200816243354
CASSCF

Extra attributes for CASSCF:

conv_tolfloat

Converge threshold. Default is 1e-7

conv_tol_gradfloat

Converge threshold for CI gradients and orbital rotation gradients. Default is 1e-4

max_stepsizefloat

The step size for orbital rotation. Small step (0.005 - 0.05) is prefered. (see notes in max_cycle_micro_inner attribute) Default is 0.03.

max_cycle_macroint

Max number of macro iterations. Default is 50.

max_cycle_microint

Max number of micro (CIAH) iterations in each macro iteration.

ah_level_shiftfloat, for AH solver.

Level shift for the Davidson diagonalization in AH solver. Default is 1e-8.

ah_conv_tolfloat, for AH solver.

converge threshold for AH solver. Default is 1e-12.

ah_max_cyclefloat, for AH solver.

Max number of iterations allowd in AH solver. Default is 30.

ah_lindepfloat, for AH solver.

Linear dependence threshold for AH solver. Default is 1e-14.

ah_start_tolflat, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 0.2.

ah_start_cycleint, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 2.

ah_conv_tol, ah_max_cycle, ah_lindep, ah_start_tol and ah_start_cycle can affect the accuracy and performance of CASSCF solver. Lower ah_conv_tol and ah_lindep might improve the accuracy of CASSCF optimization, but decrease the performance.

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.UHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.conv_tol = 1e-10
>>> mc.ah_conv_tol = 1e-5
>>> mc.kernel()
-109.044401898486001
>>> mc.ah_conv_tol = 1e-10
>>> mc.kernel()
-109.044401887945668
chkfilestr

Checkpoint file to save the intermediate orbitals during the CASSCF optimization. Default is the checkpoint file of mean field object.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current envrionment.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

cindarray

CAS space FCI coefficients

convergedbool

It indicates CASSCF optimization converged or not.

mo_coeffndarray

Optimized CASSCF orbitals coefficients

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.kernel()[0]
-109.044401882238134
kernel(mo_coeff=None, ci0=None, callback=None, _kern=None)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

rotate_mo(mo, u, log=None)

Rotate orbitals with the given unitary matrix

uniq_var_indices(nmo, ncore, ncas, frozen)

pyscf.mcscf.ucasci module

UCASCI (CASCI with non-degenerated alpha and beta orbitals, typically UHF orbitals)

pyscf.mcscf.ucasci.CASCI

alias of pyscf.mcscf.ucasci.UCASCI

class pyscf.mcscf.ucasci.UCASCI(mf_or_mol, ncas, nelecas, ncore=None)

Bases: pyscf.mcscf.casci.CASCI

analyze(mo_coeff=None, ci=None, verbose=None, large_ci_tol=0.1, with_meta_lowdin=True, **kwargs)
ao2mo(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

cas_natorb(mo_coeff=None, ci0=None)

Transform active orbitals to natrual orbitals, and update the CI wfn accordingly

Args:

mc : a CASSCF/CASCI object or RHF object

Kwargs:
sortbool

Sort natural orbitals wrt the occupancy.

Returns:

A tuple, the first item is natural orbitals, the second is updated CI coefficients, the third is the natural occupancy associated to the natural orbitals.

cas_natorb_(mo_coeff=None, ci0=None)

Transform active orbitals to natrual orbitals, and update the CI wfn accordingly

Args:

mc : a CASSCF/CASCI object or RHF object

Kwargs:
sortbool

Sort natural orbitals wrt the occupancy.

Returns:

A tuple, the first item is natural orbitals, the second is updated CI coefficients, the third is the natural occupancy associated to the natural orbitals.

casci(mo_coeff=None, ci0=None)
dump_flags(verbose=None)
fix_spin = None
fix_spin_ = None
get_h1cas(mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF

Args:

casci : a U-CASSCF/U-CASCI object or UHF object

get_h1eff(mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF

Args:

casci : a U-CASSCF/U-CASCI object or UHF object

get_h2cas(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

Note It is different to get_h2eff when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_h2eff(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

Note It is different to get_h2cas when df.approx_hessian is applied. in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_hcore(mol=None)
get_veff(mol=None, dm=None, hermi=1)

Hartree-Fock potential matrix for the given density matrix

Args:

mol : an instance of Mole

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference HF potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
vhfopt :

A class which holds precomputed quantities to optimize the computation of J, K matrices

Returns:

matrix Vhf = 2*J - K. Vhf can be a list matrices, corresponding to the input density matrices.

Examples:

>>> import numpy
>>> from pyscf import gto, scf
>>> from pyscf.scf import _vhf
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> dm0 = numpy.random.random((mol.nao_nr(),mol.nao_nr()))
>>> vhf0 = scf.hf.get_veff(mol, dm0, hermi=0)
>>> dm1 = numpy.random.random((mol.nao_nr(),mol.nao_nr()))
>>> vhf1 = scf.hf.get_veff(mol, dm1, hermi=0)
>>> vhf2 = scf.hf.get_veff(mol, dm1, dm_last=dm0, vhf_last=vhf0, hermi=0)
>>> numpy.allclose(vhf1, vhf2)
True
h1e_for_cas(mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF

Args:

casci : a U-CASSCF/U-CASCI object or UHF object

kernel(mo_coeff=None, ci0=None)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

make_rdm1(mo_coeff=None, ci=None, ncas=None, nelecas=None, ncore=None, **kwargs)

One-particle density matrix in AO representation

make_rdm1s(mo_coeff=None, ci=None, ncas=None, nelecas=None, ncore=None, **kwargs)

One-particle density matrices for alpha and beta spin on AO basis

property ncore
sort_mo(caslst, mo_coeff=None, base=1)

Pick orbitals for CAS space

Args:

casscf : an CASSCF or CASCI object

mo_coeffndarray or a list of ndarray

Orbitals for CASSCF initial guess. In the UHF-CASSCF, it’s a list of two orbitals, for alpha and beta spin.

caslstlist of int or nested list of int

A list of orbital indices to represent the CAS space. In the UHF-CASSCF, it’s consist of two lists, for alpha and beta spin.

Kwargs:
baseint

0-based (C-style) or 1-based (Fortran-style) caslst

Returns:

An reoreded mo_coeff, which put the orbitals given by caslst in the CAS space

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> cas_list = [5,6,8,9] # pi orbitals
>>> mo = mc.sort_mo(cas_list)
>>> mc.kernel(mo)[0]
-109.007378939813691
spin_square(fcivec=None, mo_coeff=None, ovlp=None)
pyscf.mcscf.ucasci.extract_orbs(mo_coeff, ncas, nelecas, ncore)
pyscf.mcscf.ucasci.h1e_for_cas(casci, mo_coeff=None, ncas=None, ncore=None)

CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF

Args:

casci : a U-CASSCF/U-CASCI object or UHF object

pyscf.mcscf.ucasci.kernel(casci, mo_coeff=None, ci0=None, verbose=3)

UHF-CASCI solver

pyscf.mcscf.umc1step module

UCASSCF (CASSCF without spin-degeneracy between alpha and beta orbitals) 1-step optimization algorithm

pyscf.mcscf.umc1step.CASSCF

alias of pyscf.mcscf.umc1step.UCASSCF

class pyscf.mcscf.umc1step.UCASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)

Bases: pyscf.mcscf.ucasci.UCASCI

ah_conv_tol = 1e-12
ah_grad_trust_region = 3.0
ah_level_shift = 1e-08
ah_lindep = 1e-14
ah_max_cycle = 30
ah_start_cycle = 3
ah_start_tol = 2.5
ao2mo(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

approx_cas_integral(mo, u, eris)
casci(mo_coeff, ci0=None, eris=None, verbose=None, envs=None)
chk_ci = False
ci_response_space = 4
conv_tol = 1e-07
conv_tol_grad = None
dump_chk(envs)
dump_flags(verbose=None)
gen_g_hop(*args)
get_h2cas(mo_coeff=None)

Compute the active space two-particle Hamiltonian.

Note It is different to get_h2eff when df.approx_hessian is applied, in which get_h2eff function returns the DF integrals while get_h2cas returns the regular 2-electron integrals.

get_h2eff(mo_coeff=None)

Computing active space two-particle Hamiltonian.

internal_rotation = False
kernel(mo_coeff=None, ci0=None, callback=None, _kern=<function kernel>)
Returns:

Five elements, they are total energy, active space CI energy, the active space FCI wavefunction coefficients or DMRG wavefunction ID, the MCSCF canonical orbital coefficients, the MCSCF canonical orbital coefficients.

They are attributes of mcscf object, which can be accessed by .e_tot, .e_cas, .ci, .mo_coeff, .mo_energy

kf_interval = 4
kf_trust_region = 3.0
max_cycle_macro = 50
max_cycle_micro = 4
property max_orb_stepsize
max_stepsize = 0.02
max_stepsize_scheduler(envs)
mc1step(mo_coeff=None, ci0=None, callback=None)
mc2step(mo_coeff=None, ci0=None, callback=None)
micro_cycle_scheduler(envs)
natorb = False
pack_uniq_var(mat)
rotate_mo(mo, u, log=None)

Rotate orbitals with the given unitary matrix

rotate_orb_cc(mo, fcivec, fcasdm1, fcasdm2, eris, x0_guess=None, conv_tol_grad=0.0001, max_stepsize=None, verbose=None)
solve_approx_ci(h1, h2, ci0, ecore, e_cas)

Solve CI eigenvalue/response problem approximately

uniq_var_indices(nmo, ncore, ncas, frozen)
unpack_uniq_var(v)
update_casdm(mo, u, fcivec, e_cas, eris)
update_jk_in_ah(mo, r, casdm1s, eris)
update_rotate_matrix(dx, u0=1)
with_dep4 = False
pyscf.mcscf.umc1step.gen_g_hop(casscf, mo, u, casdm1s, casdm2s, eris)
pyscf.mcscf.umc1step.kernel(casscf, mo_coeff, tol=1e-07, conv_tol_grad=None, ci0=None, callback=None, verbose=None, dump_chk=True)

pyscf.mcscf.umc2step module

UCASSCF (CASSCF without spin-degeneracy between alpha and beta orbitals) 2-step optimization algorithm

pyscf.mcscf.umc2step.kernel(casscf, mo_coeff, tol=1e-07, conv_tol_grad=None, ci0=None, callback=None, verbose=None, dump_chk=True)

pyscf.mcscf.umc_ao2mo module

MO integrals for UCASSCF methods

pyscf.mcscf.umc_ao2mo.trans_e1_incore(eri_ao, mo, ncore, ncas)
pyscf.mcscf.umc_ao2mo.trans_e1_outcore(mol, mo, ncore, ncas, max_memory=None, ioblk_size=512, verbose=2)

Module contents

CASCI and CASSCF

When using results of this code for publications, please cite the following paper: “A general second order complete active space self-consistent-field solver for large-scale systems”, Q. Sun, J. Yang, and G. K.-L. Chan, Chem. Phys. Lett. 683, 291 (2017).

Simple usage:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.RHF(mol).run()
>>> mc = mcscf.CASCI(mf, 6, 6)
>>> mc.kernel()[0]
-108.980200816243354
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.kernel()[0]
-109.044401882238134
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> cas_list = [5,6,8,9] # pick orbitals for CAS space, 1-based indices
>>> mo = mcscf.sort_mo(mc, mf.mo_coeff, cas_list)
>>> mc.kernel(mo)[0]
-109.007378939813691

mcscf.CASSCF() or mcscf.CASCI() returns a proper instance of CASSCF/CASCI class. There are some parameters to control the CASSCF/CASCI method.

verboseint

Print level. Default value equals to Mole.verbose.

max_memoryfloat or int

Allowed memory in MB. Default value equals to Mole.max_memory.

ncasint

Active space size.

nelecastuple of int

Active (nelec_alpha, nelec_beta)

ncoreint or tuple of int

Core electron number. In UHF-CASSCF, it’s a tuple to indicate the different core eletron numbers.

natorbbool

Whether to restore the natural orbital during CASSCF optimization. Default is not.

canonicalizationbool

Whether to canonicalize orbitals. Default is True.

fcisolveran instance of FCISolver

The pyscf.fci module provides several FCISolver for different scenario. Generally, fci.direct_spin1.FCISolver can be used for all RHF-CASSCF. However, a proper FCISolver can provide better performance and better numerical stability. One can either use fci.solver() function to pick the FCISolver by the program or manually assigen the FCISolver to this attribute, e.g.

>>> from pyscf import fci
>>> mc = mcscf.CASSCF(mf, 4, 4)
>>> mc.fcisolver = fci.solver(mol, singlet=True)
>>> mc.fcisolver = fci.direct_spin1.FCISolver(mol)

You can control FCISolver by setting e.g.:

>>> mc.fcisolver.max_cycle = 30
>>> mc.fcisolver.conv_tol = 1e-7

For more details of the parameter for FCISolver, See fci.

By replacing this fcisolver, you can easily use the CASCI/CASSCF solver with other FCI replacements, such as DMRG, QMC. See dmrgscf and fciqmcscf.

The Following attributes are used for CASSCF

conv_tolfloat

Converge threshold. Default is 1e-7

conv_tol_gradfloat

Converge threshold for CI gradients and orbital rotation gradients. Default is 1e-4

max_stepsizefloat

The step size for orbital rotation. Small step size is prefered. Default is 0.03. (NOTE although the default step size is small enough for many systems, it happens that the orbital optimizor crosses the barriar of local minimum and converge to the neighbour solution, e.g. the CAS(4,4) for C2H4 in the test files. In these systems, adjusting max_stepsize, max_ci_stepsize and max_cycle_micro, max_cycle_micro_inner and ah_start_tol may be helpful)

>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.max_stepsize = .01
>>> mc.max_cycle_micro = 1
>>> mc.max_cycle_macro = 100
>>> mc.max_cycle_micro_inner = 1
>>> mc.ah_start_tol = 1e-6
max_ci_stepsizefloat

The max size for approximate CI updates. The approximate updates are used in 1-step algorithm, to estimate the change of CI wavefunction wrt the orbital rotation. Small step size is prefered. Default is 0.01.

max_cycle_macroint

Max number of macro iterations. Default is 50.

max_cycle_microint

Max number of micro iterations in each macro iteration. Depending on systems, increasing this value might reduce the total macro iterations. Generally, 2 - 3 steps should be enough. Default is 2.

max_cycle_micro_innerint

Max number of steps for the orbital rotations allowed for the augmented hessian solver. It can affect the actual size of orbital rotation. Even with a small max_stepsize, a few max_cycle_micro_inner can accumulate the rotation and leads to a significant change of the CAS space. Depending on systems, increasing this value migh reduce the total number of macro iterations. The value between 2 - 8 is preferred. Default is 4.

frozenint or list

If integer is given, the inner-most orbitals are excluded from optimization. Given the orbital indices (0-based) in a list, any doubly occupied core orbitals, active orbitals and external orbitals can be frozen.

ah_level_shiftfloat, for AH solver.

Level shift for the Davidson diagonalization in AH solver. Default is 0.

ah_conv_tolfloat, for AH solver.

converge threshold for Davidson diagonalization in AH solver. Default is 1e-8.

ah_max_cyclefloat, for AH solver.

Max number of iterations allowd in AH solver. Default is 20.

ah_lindepfloat, for AH solver.

Linear dependence threshold for AH solver. Default is 1e-16.

ah_start_tolflat, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 1e-4.

ah_start_cycleint, for AH solver.

In AH solver, the orbital rotation is started without completely solving the AH problem. This value is to control the start point. Default is 3.

ah_conv_tol, ah_max_cycle, ah_lindep, ah_start_tol and ah_start_cycle can affect the accuracy and performance of CASSCF solver. Lower ah_conv_tol and ah_lindep can improve the accuracy of CASSCF optimization, but slow down the performance.

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = scf.UHF(mol)
>>> mf.scf()
>>> mc = mcscf.CASSCF(mf, 6, 6)
>>> mc.conv_tol = 1e-10
>>> mc.ah_conv_tol = 1e-5
>>> mc.kernel()
-109.044401898486001
>>> mc.ah_conv_tol = 1e-10
>>> mc.kernel()
-109.044401887945668
chkfilestr

Checkpoint file to save the intermediate orbitals during the CASSCF optimization. Default is the checkpoint file of mean field object.

Saved results

e_totfloat

Total MCSCF energy (electronic energy plus nuclear repulsion)

cindarray

CAS space FCI coefficients

convergedbool, for CASSCF only

It indicates CASSCF optimization converged or not.

mo_energy: ndarray,

Diagonal elements of general Fock matrix

mo_coeffndarray, for CASSCF only

Optimized CASSCF orbitals coefficients Note the orbitals are NOT natural orbitals by default. There are two inbuilt methods to convert the mo_coeff to natural orbitals. 1. Set .natorb attribute. It can be used before calculation. 2. call .cas_natorb_ method after the calculation to in-place convert the orbitals

pyscf.mcscf.CASCI(mf_or_mol, ncas, nelecas, ncore=None)
pyscf.mcscf.CASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)
pyscf.mcscf.DFCASCI(mf_or_mol, ncas, nelecas, auxbasis=None, ncore=None)
pyscf.mcscf.DFCASSCF(mf_or_mol, ncas, nelecas, auxbasis=None, ncore=None, frozen=None)
pyscf.mcscf.RCASCI(mf_or_mol, ncas, nelecas, ncore=None)
pyscf.mcscf.RCASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)
pyscf.mcscf.UCASCI(mf_or_mol, ncas, nelecas, ncore=None)
pyscf.mcscf.UCASSCF(mf_or_mol, ncas, nelecas, ncore=None, frozen=None)
pyscf.mcscf.density_fit(mc, auxbasis=None, with_df=None)
pyscf.mcscf.newton(mc)