inquanto-pyscf

InQuanto PySCF extension.

class AVAS(aolabels, aolabels_vir=None, threshold=0.2, threshold_vir=0.2, n_occ=None, n_vir=None, n_occ_active=None, n_vir_active=None, minao='minao', with_iao=False, force_halves_active=False, freeze_half_filled=False, canonicalize=True, frozen=None, spin_as=None, verbose=None)

AVAS (Atomic Valence Active Space) / RE (Regional Embedding class) to construct MCSCF active space.

Parameters:
  • aolabels (List[str]) – AO labels for AO active space, for example [‘Cr 3d’, ‘Cr 4s’] or [“1 C 2p”, “2 C 2p”].

  • aolabels_vir (List[str], default: None) – If given, separate AO labels for the virtual orbitals. If not given, aolabels is used.

  • threshold (float, default: 0.2) – Truncating threshold of the AO-projector above which AOs are kept in the active space (occupied orbitals).

  • threshold_vir (float, default: 0.2) – Truncating threshold of the AO-projector above which AOs are kept in the active space (virtual orbitals).

  • n_occ (Optional[int], default: None) – None or number of localised occupied orbitals to create. If specified, the value of threshold is ignored.

  • n_vir (Optional[int], default: None) – None or number of localised virtual orbitals to create. If specified, the value of threshold_vir is ignored.

  • n_occ_active (Optional[int], default: None) – Optional. If specified, number of returned occupied orbitals in the active space (out of the total number of localised occupied orbitals defined by n_occ).

  • n_vir_active (Optional[int], default: None) – Optional. If specified, number of returned virtual orbitals in the active space (out of the total number of localised virtual orbitals defined by n_virt).

  • minao (str, default: "minao") – A reference AO basis for the occupied orbitals in AVAS.

  • with_iao (bool, default: False) – Whether to use Intrinsic Atomic Orbitals (IAO) localization to construct the reference active AOs.

  • force_halves_active (bool, default: False) – How to handle singly-occupied orbitals in the active space. The singly-occupied orbitals are projected as part of alpha orbitals if False (default), or completely kept in active space if True. See Section 2.5 option 2 or 3 of the AVAS paper for more details.

  • freeze_half_filled (bool, default: False) – If True, all half-filled orbitals (if present) are frozen, i.e. excluded from the AVAS transformation and from the active space.

  • canonicalize (bool, default: True) – Block-diagonalize and symmetrize the core, active and virtual orbitals.

  • frozen (Union[List[int], List[List[int]]], default: None) – List of orbitals to be excluded from the AVAS method.

  • spin_as (int, default: None) – Number of unpaired electrons in the active space.

  • verbose (int, default: None) – Control PySCF verbosity.

Note

  • The reference AO basis for the virtual orbitals is always the computational basis, in contrast to original AVAS but as in the RE method.

  • Selecting force_halves_active=False for an open-shell system will force double occupations on all orbitals outside of the AVAS active space.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF, AVAS
>>> avas= AVAS(aolabels=['Li 2s', 'H 1s'], threshold=0.8, threshold_vir=0.8, verbose=5)
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='Li 0 0 0; H 0 0 1.75', basis='631g',
...     transf=avas, frozen=avas.frozenf)
>>> hamiltonian, space, state = driver.get_system() 
compute_unitary(mf)

Calculate the unitary matrix to transform the MO coefficients.

Parameters:

mf (HF) – PySCF mean-field object.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Unitary matrix to transform the original MO coeffs.

dump_flags()

Print all modifiable options and their current values.

Return type:

None

frozenf(mf)

Return a list of frozen orbitals.

Parameters:

mf (HF) – PySCF mean-field object.

Returns:

List[int] – Frozen orbital indices.

property is_transf: bool

Return true if MO transformation is applied.

Returns:

bool – True if the orbitals is transformed from HF MOs.

property original: ndarray[Any, dtype[_ScalarType_co]]

Returns the original MO coefficient matrix.

Returns:

Original MO coefficients of HF.

run(mf)

Generate the active space.

Parameters:

mf (HF) – PySCF restricted mean-field object.

Raises:

NotImplementedError – If the PySCF mean field object is of type UHF.

Returns:

Tuple[int, int, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Number of active orbitals, number of active electrons, orbital coefficients.

transf(mf)

Execute the MO transformation to CASSCF natural orbitals.

Parameters:

mf (HF) – PySCF mean-field object that can be passed to mcscf.CASSCF.

Return type:

None

class CASSCF(ncas, nelecas, ncore=None, max_cycle=50, conv_tol=1e-7, conv_tol_grad=None, fix_spin_squared=None, spin_squared_tolerance=0.01, transf=None, init_orbitals=None, print_ci_coeff=False, ci_print_cutoff=0.1)

Postprocess orbitals with Complete Active Space Self-Consistent Field (CASSCF) method for building molecular integrals.

Parameters:
  • ncas (int) – number of active spatial orbitals passed to pyscf.mcscf.CASSCF.

  • nelecas (int) – number of active electrons passed to pyscf.mcscf.CASSCF.

  • ncore (Optional[int], default: None) – (optional) number of core orbitals passed to pyscf.mcscf.CASSCF. In most cases, it is unnecessary as PySCF computes ncore correctly. Can be necessary when the active space contains some “chemical core” orbitals.

  • max_cycle (int, default: 50) – maximum number of CASSCF macroiterations.

  • conv_tol (float, default: 1e-7) – energy convergence threshold.

  • conv_tol_grad (Optional[float], default: None) – orbital gradient convergence threshold.

  • fix_spin_squared (Optional[float], default: None) – desired value of \(S^2\). If not None, a penalty term is added to the energy to drive optimisation to the desired state.

  • spin_squared_tolerance (float, default: 0.01) – tolerance of \(S^2\).

  • transf (Union[Transf, Callable, None], default: None) – orbital transformation (e.g. AVAS) to be performed before CASSCF.

  • init_orbitals (Optional[ndarray], default: None) – initial orbital coefficients, can be from a different geometry.

  • print_ci_coeff (bool, default: False) – If True, the determinants which have coefficients > ci_print_cutoff will be printed out.

  • ci_print_cutoff (float, default: 0.1) – Tolerance for printing CI coefficients.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF, CASSCF
>>> # Optimize HOMO-LUMO with CASSCF.
>>> driver = ChemistryDriverPySCFMolecularRHF(geometry='Li 0 0 0; H 0 0 1.75',
...     basis='631g',
...     transf=CASSCF(ncas=2, nelecas=2)
... )
>>> hamiltonian, space, state = driver.get_system()
compute_unitary(mf)

Calculate the unitary matrix to transform the MO coefficients.

Parameters:

mf (HF) – PySCF mean-field object.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Unitary matrix to transform the original MO coeffs.

property is_transf: bool

Return true if MO transformation is applied.

Returns:

bool – True if the orbitals is transformed from HF MOs.

property original: ndarray[Any, dtype[_ScalarType_co]]

Returns the original MO coefficient matrix.

Returns:

Original MO coefficients of HF.

transf(mf)

Execute the MO transformation to CASSCF natural orbitals.

Parameters:

mf (HF) – PySCF mean-field object that can be passed to mcscf.CASSCF.

Return type:

None

class ChemistryDriverPySCFEmbeddingGammaRHF(geometry=None, zmatrix=None, cell=None, basis=None, ecp=None, charge=0, exp_to_discard=None, df='GDF', dimension=3, frozen=None, transf=None, verbose=0, output=None, functional='b3lyp', transf_inner=None, frozen_inner=None, level_shift=1.0e6, precision=1e-9)

Projection-based embedding. Partially based on PsiEmbed.

Implements the Projection-based embedding method. Runs a RHF (if functional is None) or RKS calculation on the whole system and then creates an embedding, the subsystem is defined by the orbitals selected with frozen.

Parameters:
  • geometry (Union[List, str, GeometryPeriodic], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • cell (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], default: None) – unit cell vectors (if not specified in the geometry object).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • exp_to_discard (float, default: None) – Exponent to discard a primitive Gaussian.

  • df (str, default: "GDF") – Type of density fitting ("GDF", "FFTDF", "AFTDF" or "MDF").

  • dimension (int, default: 3) – Number of spatial dimensions.

  • frozen (Union[List[int], Callable[[RHF], int]], default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • functional (str, default: "b3lyp") – KS functional to use for the system calculation, or None if RHF is desired.

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformer to be used on the sub-system Hamiltonian.

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – List of frozen orbitals in the sub-system Hamiltonian.

  • level_shift (float, default: 1.0e6) – Controls the projection-based embedding.

  • precision (float, default: 1e-9) – Ewald sum precision.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, df='GDF', transf=None, transf_inner=None, frozen_inner=None, level_shift=1.0e6)

Initialize Projection-embedding driver from a PySCF mean-field object.

Use transf to localise orbitals and frozen to select active orbitals.

Parameters:
  • mf (RHF) – PySCF mean-field object, must be RKS or RHF.

  • frozen (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – Frozen core specified as either list or callable.

  • df (str, default: "GDF") – Type of density fitting ("GDF", "FFTDF", "AFTDF" or "MDF").

  • transf (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function.

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function to be applied to the embedded Hamiltonian.

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – Frozen orbitals in the embedded Hamiltonian.

  • level_shift (float, default: 1.0e6) – Projection-based embedding level shift.

Returns:

ChemistryDriverPySCFEmbeddingGammaRHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Not implemented. To obtain AC0 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]])

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_madelung_constant()

Return Madelung constant for Gamma-point calculations.

Returns:

float – Madelung constant contribution to the energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Not implemented. To obtain NEVPT2 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple)

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:
  • symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals.

  • as (Uses the same convention) – PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[PySCFChemistryRestrictedIntegralOperator, Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFEmbeddingGammaROHF_UHF(geometry=None, zmatrix=None, cell=None, basis=None, ecp=None, charge=0, multiplicity=1, exp_to_discard=None, df='GDF', dimension=3, frozen=None, transf=None, verbose=0, output=None, embedded_spin=None, functional='b3lyp', transf_inner=None, frozen_inner=None, level_shift=1.0e6, precision=1e-9)

Projection-based embedding. Partially based on PsiEmbed.

Implements Projection-based embedding method. Runs a ROHF (if functional is None) or ROKS calculation on the whole system and then creates an embedding, the subsystem is defined by the orbitals selected with frozen. The embedded calculation uses the same type of density fitting as the system calculation, is run as ROHF and subsequently converted to UHF. The Hamiltonian operator returned is unrestricted.

Parameters:
  • geometry (Union[List, str, GeometryPeriodic], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • cell (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], default: None) – unit cell vectors (if not specified in the geometry object).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity of the total system.

  • exp_to_discard (float, default: None) – Exponent to discard a primitive Gaussian.

  • df (str, default: "GDF") – Type of density fitting ("GDF", "FFTDF", "AFTDF" or "MDF").

  • dimension (int, default: 3) – Number of spatial dimensions.

  • frozen (Union[List[int], Callable[[RHF], int]], default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • embedded_spin (int, default: None) – number of unpaired electrons in the sub-system. None means the same as in the total system.

  • functional (str, default: "b3lyp") – KS functional to use for the system calculation, or None if RHF is desired.

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformer to be used on the sub-system Hamiltonian.

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – List of frozen orbitals in the sub-system Hamiltonian.

  • level_shift (float, default: 1.0e6) – Controls the projection-based embedding.

  • precision (float, default: 1e-9) – Ewald sum precision.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, df='GDF', transf=None, transf_inner=None, frozen_inner=None, embedded_spin=None, level_shift=1.0e6)

Initialize Projection-embedding driver from a PySCF mean-field object.

Use transf to localise orbitals and frozen to select active orbitals.

Parameters:
  • mf (ROHF) – PySCF mean-field object, must be ROKS or ROHF.

  • frozen (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – Frozen core specified as either list or callable.

  • transf (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function.

  • level_shift (float, default: 1.0e6) – Projection-based embedding level shift.

  • df (str, default: "GDF")

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None)

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None)

  • embedded_spin (int, default: None)

Returns:

ChemistryDriverPySCFEmbeddingGammaROHF_UHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Not implemented. To obtain AC0 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]])

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_madelung_constant()

Return Madelung constant for Gamma-point calculations.

Returns:

float – Madelung constant contribution to the energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Not implemented. To obtain NEVPT2 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple)

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryUnrestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[PySCFChemistryUnrestrictedIntegralOperator, Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFEmbeddingRHF(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, frozen=None, transf=None, verbose=0, output=None, point_group_symmetry=False, functional='b3lyp', transf_inner=None, frozen_inner=None, level_shift=1.0e6, df=False)

Projection-based embedding. Partially based on PsiEmbed.

Implements Projection-based embedding method. Runs a RHF (if functional is None) or RKS calculation on the whole system and then creates an embedding, the subsystem is defined by the orbitals selected with frozen. The embedded calculation is run as RHF.

Parameters:
  • geometry (Union[List, str, Geometry], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • frozen (Union[List[int], Callable[[RHF], int]], default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • functional (str, default: "b3lyp") – KS functional to use for the system calculation, or None if RHF is desired.

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformer to be used on the sub-system Hamiltonian.

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – List of frozen orbitals in the sub-system Hamiltonian.

  • level_shift (float, default: 1.0e6) – Controls the projection-based embedding.

  • df (bool, default: False) – Use density fitting.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None, transf_inner=None, frozen_inner=None, level_shift=1.0e6)

Initialize Projection-embedding driver from a PySCF mean-field object.

Use transf to localise orbitals and frozen to select active orbitals.

Parameters:
Returns:

ChemistryDriverPySCFEmbeddingRHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Not implemented. To obtain AC0 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]])

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Not implemented. To obtain NEVPT2 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple)

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFEmbeddingROHF(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, multiplicity=1, frozen=None, transf=None, verbose=0, output=None, point_group_symmetry=False, embedded_spin=None, functional='b3lyp5', transf_inner=None, frozen_inner=None, level_shift=1.0e6, df=False)

Projection-based embedding. Partially based on PsiEmbed.

Implements Projection-based embedding method. Runs a ROHF (if functional is None) or ROKS calculation on the whole system and then creates an embedding, the subsystem is defined by the orbitals selected with frozen. The embedded calculation is run as ROHF. The Hamiltonian operator returned is restricted (the embedding potential is averaged over spin channels).

Parameters:
  • geometry (Union[List, str, Geometry], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity of the total system

  • frozen (Any, default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • embedded_spin (int, default: None) – number of unpaired electrons in the sub-system. None means the same as in the total system.

  • functional (str, default: "b3lyp5") – KS functional to use for the system calculation, or None if RHF is desired.

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformer to be used on the sub-system Hamiltonian.

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – List of frozen orbitals in the sub-system Hamiltonian.

  • level_shift (float, default: 1.0e6) – Controls the projection-based embedding.

  • df (bool, default: False) – Use density fitting.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None, transf_inner=None, frozen_inner=None, embedded_spin=None, level_shift=1.0e6)

Initialize Projection-embedding driver from a PySCF mean-field object.

Use transf to localise orbitals and frozen to select active orbitals. Note: when creating the IntegralOperator, the 1-electron embedding potential is averaged over spin channels (would have to use UHF to avoid this).

Parameters:
  • mf (ROKS) – PySCF mean-field object, must be ROKS or ROHF.

  • frozen (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – Embedding (bath) orbitals

  • transf (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function (to be used on the ROKS input).

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function (to be used on the embedded system)

  • embedded_spin (int, default: None) – Number of unpaired electrons in the embedded system (if different than total)

  • level_shift (float, default: 1.0e6) – Projection-based embedding level shift

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None)

Returns:

ChemistryDriverPySCFEmbeddingROHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Not implemented. To obtain AC0 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]])

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Not implemented. To obtain NEVPT2 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple)

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFEmbeddingROHF_UHF(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, multiplicity=1, frozen=None, transf=None, verbose=0, output=None, point_group_symmetry=False, embedded_spin=None, functional='b3lyp5', transf_inner=None, frozen_inner=None, level_shift=1.0e6, df=False)

Projective embedding. Partially based on PsiEmbed.

Implements Projection-based embedding method. Runs a ROHF (if functional is None) or ROKS calculation on the whole system and then creates an embedding, the subsystem is defined by the orbitals selected with frozen. The embedded calculation is run as ROHF and subsequently converted to UHF. The Hamiltonian operator returned is unrestricted.

Parameters:
  • geometry (Union[List, str, Geometry], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity of the total system

  • frozen (Any, default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • embedded_spin (int, default: None) – number of unpaired electrons in the sub-system. None means the same as in the total system.

  • functional (str, default: "b3lyp5") – KS functional to use for the system calculation, or None if RHF is desired.

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformer to be used on the sub-system Hamiltonian.

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – List of frozen orbitals in the sub-system Hamiltonian.

  • level_shift (float, default: 1.0e6) – Controls the projection-based embedding.

  • df (bool, default: False) – Use density fitting.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None, transf_inner=None, frozen_inner=None, embedded_spin=None, level_shift=1.0e6)

Initialize Projection-embedding driver from a PySCF mean-field object.

Use transf to localise orbitals and frozen to select active orbitals. Note: when creating the IntegralOperator, the 1-electron embedding potential is averaged over spin channels (would have to use UHF to avoid this).

Parameters:
  • mf (ROKS) – PySCF mean-field object, must be ROKS or ROHF.

  • frozen (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None) – Embedding (bath) orbitals

  • transf (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function (to be used on the ROKS input).

  • transf_inner (Union[Callable[[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]], Transf], default: None) – Orbital transformation function (to be used on the embedded system)

  • embedded_spin (int, default: None) – Number of unpaired electrons in the embedded system (if different than total)

  • level_shift (float, default: 1.0e6) – Projection-based embedding level shift

  • frozen_inner (Union[List[int], List[List[int]], Callable[[SCF], Union[List[int], List[List[int]]]]], default: None)

Returns:

ChemistryDriverPySCFEmbeddingROHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Not implemented. To obtain AC0 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]])

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Not implemented. To obtain NEVPT2 correction to WFT-in-DFT, use get_subsystem_driver().

Parameters:

rdms (Tuple)

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1)

Return type:

Tuple[Union[ChemistryUnrestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState]

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFGammaRHF(geometry=None, cell=None, basis=None, ecp=None, pseudo=None, charge=0, exp_to_discard=None, frozen=None, transf=None, dimension=3, output=None, space_group_symmetry=False, precision=1e-9, verbose=0, soscf=False, df='GDF')

PySCF driver for Gamma-point RHF calculations.

Parameters:
  • geometry (Union[List, str, GeometryPeriodic], default: None) – Molecular geometry.

  • cell (ndarray, default: None) – Unit cell parameter. If provided, overrides geometry.unit_cell.

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • pseudo (Any, default: None) – Pseudo potentials.

  • charge (int, default: 0) – Total charge.

  • exp_to_discard (Optional[float], default: None) – Exponent to discard a primitive Gaussian.

  • frozen (Union[List[int], Callable[[RHF], List[int]]], default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • dimension (int, default: 3) – Number of spatial dimensions.

  • output (Optional[str], default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • space_group_symmetry (bool, default: False) – Whether to use space group symmetry.

  • precision (float, default: 1e-9) – Ewald sum precision.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (str, default: "GDF") – Density fitting function name.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFGammaRHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_madelung_constant()

Return Madelung constant for Gamma-point calculations.

Returns:

float – Madelung constant contribution to the energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFGammaROHF(geometry=None, cell=None, basis=None, ecp=None, pseudo=None, charge=0, multiplicity=1, exp_to_discard=None, frozen=None, transf=None, dimension=3, output=None, space_group_symmetry=False, precision=1e-9, verbose=0, soscf=False, df='GDF')

PySCF driver for Gamma-point ROHF calculations.

Parameters:
  • geometry (Union[List, str, GeometryPeriodic], default: None) – Molecular geometry.

  • cell (ndarray, default: None) – Unit cell parameter. If provided, overrides geometry.unit_cell.

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • pseudo (Any, default: None) – Pseudo potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multicplicity, 2S+1.

  • exp_to_discard (Optional[float], default: None) – Exponent to discard a primitive Gaussian.

  • frozen (Union[List[int], Callable[[RHF], List[int]]], default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • dimension (int, default: 3) – Number of spatial dimensions.

  • output (Optional[str], default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • space_group_symmetry (bool, default: False) – Whether to use space group symmetry.

  • precision (float, default: 1e-9) – Ewald sum precision.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (str, default: "GDF") – Density fitting function name.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFGammaROHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_madelung_constant()

Return Madelung constant for Gamma-point calculations.

Returns:

float – Madelung constant contribution to the energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFIntegrals(constant, h1, h2, n_electron, multiplicity=1, initial_dm=None, frozen=None, transf=None)

PySCF chemistry driver with electronic integrals as input.

Compatible with restricted spin calculations only.

Parameters:
  • constant (float) – Constant contribution to the Hamiltonian.

  • h1 (ndarray) – One-body integrals.

  • h2 (ndarray) – Two-body integrals.

  • n_electron (int) – Number of electrons.

  • multiplicity (int, default: 1) – Spin multiplicity.

  • initial_dm (ndarray, default: None) – Initial density matrix.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – List of frozen orbitals.

  • transf (Union[Callable[[array], array], Transf], default: None) – Orbital transformer.

classmethod from_integral_operator(hamiltonian_operator, n_electron, *args, **kwargs)

Generate PySCF driver from a ChemistryRestrictedIntegralOperator.

Parameters:
Returns:

BasePySCFDriverIntegrals – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_one_body_rdm()

Compute one-body restricted densoty matrix.

Returns:

RestrictedOneBodyRDM – One-body RDM object from the mean-field calculation.

Raises:

RunTimeError – If the SCF object is not of type RHF or ROHF.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property mo_coeff: ndarray[Any, dtype[_ScalarType_co]]

Return the molecular orbital coefficient matrix.

Returns:

MO coefficients.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMolecularRHF(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, frozen=None, transf=None, verbose=0, output=None, point_group_symmetry=False, point_group_symmetry_subgroup=None, soscf=False, df=False)

RHF calculations.

Parameters:
  • geometry (Union[List, str, Geometry], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • frozen (Union[List[int], Callable[[RHF], int]], default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • point_group_symmetry_subgroup (str, default: None) – Use this point group symmetry instead of full point group symmetry.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (bool, default: False) – Use density fitting.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMolecularRHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMolecularRHFQMMMCOSMO(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, frozen=None, transf=None, do_qmmm=None, mm_charges=None, mm_geometry=None, do_mm_coulomb=None, do_cosmo=None, solvent_epsilon=COSMO_SOLVENT['water'], verbose=0, output=None, point_group_symmetry=False, point_group_symmetry_subgroup=None, soscf=False, df=False)

PySCF driver for molecular RHF, with Quantum Mechanics - Molecular Mechanics (QMMM) and COnductor-like Screening MOdel (COSMO) calculations.

Parameters:
  • geometry (Union[List, str], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • frozen (Any, default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • do_qmmm (bool, default: None) – If True, do QMMM embedding. MM geometry and charges are required.

  • mm_charges (Any, default: None) – Point charge values for MM region.

  • mm_geometry (Any, default: None) – Geometry of MM region.

  • do_mm_coulomb (bool, default: None) – If True, calculate MM-MM Coulomb interaction energy. Needs to be added as a constant to the final energy: <\| H \|> + self.e_mm_coulomb

  • do_cosmo (bool, default: None) – If True, adds implicit water (COSMO) to the mean-field calculation. get_system_legacy() returns H + v_solvent as fermion operator. The resulting final energy needs to be corrected as <\|H + v_solvet\|> + self.cosmo_correction. Where self.cosmo_correction = E_cosmo - Tr[v_solvent * rdm1]. If do_cosmo=True, self.cosmo_correction is defined after self._run_hf().

  • solvent_epsilon (float, default: COSMO_SOLVENT["water"]) – Dielectric constant of the solvent in the COSMO model.

  • verbose (int, default: 0) – Control SCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • point_group_symmetry_subgroup (str, default: None) – Use this point group symmetry instead of full point group symmetry.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (bool, default: False) – Use density fitting.

static build_mm_charges(mm_charges, mm_geometry)

Puts InQuanto MM charge dict into PySCF-friendly format.

Orders MM charges according to mm_geometry.

Parameters:
  • mm_geometry (List) – Geometry of MM region in format ['Atom1', [x, y, z]], 'Atom2', [x, y, z]], ...].

  • mm_charges (Union[Dict, List, float]) – Dict of charges, or float if all charges are the same. If float, all output charges will all have this value. If it is already a list, do nothing.

Returns:

List – List of MM charges ordered the same as mm_geometry.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMolecularRHFQMMMCOSMO – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

static get_mm_coulomb(mm_charges_pyscf, mm_geometry, unit='Ha')

Get the Coulomb interaction energy between MM particles.

Parameters:
  • mm_charges_pyscf (Any) – Charges of MM region, in same order as mm_geometry.

  • mm_geometry (Any) – Geometry of MM region in format ['Atom1', [x, y, z]], 'Atom2', [x, y, z]], ...].

  • unit (str, default: "Ha") – Energy units of Coulomb interaction energy. Default is Hartree.

Returns:

Electrostatic Coulomb energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMolecularROHF(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, multiplicity=1, frozen=None, transf=None, verbose=0, output=None, point_group_symmetry=False, point_group_symmetry_subgroup=None, soscf=False, df=False)

PySCF driver for molecular ROHF calculations.

Parameters:
  • geometry (Union[List, str, Geometry], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity, 2S+1.

  • frozen (Any, default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • point_group_symmetry_subgroup (str, default: None) – Use this point group symmetry instead of full point group symmetry.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (bool, default: False) – Use density fitting.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMolecularROHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMolecularROHFQMMMCOSMO(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, multiplicity=1, frozen=None, transf=None, do_qmmm=None, mm_charges=None, mm_geometry=None, do_mm_coulomb=None, do_cosmo=None, solvent_epsilon=COSMO_SOLVENT['water'], verbose=0, output=None, point_group_symmetry=False, point_group_symmetry_subgroup=None, soscf=False, df=False)

PySCF driver for molecular ROHF, with Quantum Mechanics - Molecular Mechanics (QMMM) and COnductor-like Screening MOdel (COSMO) calculations.

Parameters:
  • geometry (Union[List, str], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity, 2S+1.

  • frozen (Any, default: None) – Frozen orbital information.

  • transf (Transf, default: None) – Orbital transformer.

  • do_qmmm (bool, default: None) – If True, do QMMM embedding. MM geometry and charges are required.

  • mm_charges (Any, default: None) – Point charge values for MM region.

  • mm_geometry (Any, default: None) – Geometry of MM region.

  • do_mm_coulomb (bool, default: None) – If True, calculate MM-MM Coulomb interaction energy. Needs to be added as a constant to the final energy: \(\lVert H \rVert\) + self.e_mm_coulomb.

  • do_cosmo (bool, default: None) – If True, adds implicit water (COSMO) to the mean-field calculation. get_system_legacy() returns H + v_solvent as fermion operator. The resulting final energy needs to be corrected as \(\lVert H + v_{solve} \rVert\) + self.cosmo_correction. Where self.cosmo_correction = \(E_{\text{cosmo}} - \text{Tr}[v_{\text{solvent}} \cdot \text{rdm1}]\). If do_cosmo=True, self.cosmo_correction is defined after self._run_hf().

  • solvent_epsilon (float, default: COSMO_SOLVENT["water"]) – Dielectric constant of the solvent in the COSMO model.

  • verbose (int, default: 0) – Control SCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • point_group_symmetry_subgroup (str, default: None) – Use this point group symmetry instead of full point group symmetry.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (bool, default: False) – Use density fitting.

static build_mm_charges(mm_charges, mm_geometry)

Puts InQuanto MM charge dict into PySCF-friendly format.

Orders MM charges according to mm_geometry.

Parameters:
  • mm_geometry (List) – Geometry of MM region in format ['Atom1', [x, y, z]], 'Atom2', [x, y, z]], ...].

  • mm_charges (Union[Dict, List, float]) – Dict of charges, or float if all charges are the same. If float, all output charges will all have this value. If it is already a list, do nothing.

Returns:

List – List of MM charges ordered the same as mm_geometry.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None, transf=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMolecularROHFQMMMCOSMO – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

static get_mm_coulomb(mm_charges_pyscf, mm_geometry, unit='Ha')

Get the Coulomb interaction energy between MM particles.

Parameters:
  • mm_charges_pyscf (Any) – Charges of MM region, in same order as mm_geometry.

  • mm_geometry (Any) – Geometry of MM region in format ['Atom1', [x, y, z]], 'Atom2', [x, y, z]], ...].

  • unit (str, default: "Ha") – Energy units of Coulomb interaction energy. Default is Hartree.

Returns:

Electrostatic Coulomb energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMolecularUHF(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, multiplicity=1, frozen=None, verbose=0, output=None, point_group_symmetry=False, point_group_symmetry_subgroup=None, soscf=False, df=False)

PySCF driver for molecular UHF calculations.

Parameters:
  • geometry (Union[List, str, Geometry], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity, 2S+1.

  • frozen (Any, default: None) – Frozen orbital information.

  • verbose (int, default: 0) – Control PySCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • point_group_symmetry_subgroup (str, default: None) – Use this point group symmetry instead of full point group symmetry.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (bool, default: False) – Use density fitting.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMolecularUHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMolecularUHFQMMMCOSMO(geometry=None, zmatrix=None, basis=None, ecp=None, charge=0, multiplicity=1, frozen=None, do_qmmm=None, mm_charges=None, mm_geometry=None, do_mm_coulomb=None, do_cosmo=None, solvent_epsilon=COSMO_SOLVENT['water'], verbose=0, output=None, point_group_symmetry=False, point_group_symmetry_subgroup=None, soscf=False, df=False)

PySCF driver for molecular UHF, with Quantum Mechanics - Molecular Mechanics (QMMM) and COnductor-like Screening MOdel (COSMO) calculations.

Parameters:
  • geometry (Union[List, str], default: None) – Molecular geometry.

  • zmatrix (str, default: None) – Z matrix representation of molecular geometry (Used only if geometry is not specified).

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • charge (int, default: 0) – Total charge.

  • multiplicity (int, default: 1) – Spin multiplicity, 2S+1.

  • frozen (Any, default: None) – Frozen orbital information.

  • do_qmmm (bool, default: None) – If True, do QMMM embedding. MM geometry and charges are required.

  • mm_charges (Any, default: None) – Point charge values for MM region.

  • mm_geometry (Any, default: None) – Geometry of MM region.

  • do_mm_coulomb (bool, default: None) – If True, calculate MM-MM Coulomb interaction energy. Needs to be added as a constant to the final energy: <\| H \|> + self.e_mm_coulomb

  • do_cosmo (bool, default: None) – If True, adds implicit water (COSMO) to the mean-field calculation. get_system_legacy() returns H + v_solvent as fermion operator. The resulting final energy needs to be corrected as <\|H + v_solvet\|> + self.cosmo_correction. Where self.cosmo_correction = E_cosmo - Tr[v_solvent * rdm1]. If do_cosmo=True, self.cosmo_correction is defined after self._run_hf().

  • solvent_epsilon (float, default: COSMO_SOLVENT["water"]) – Dielectric constant of the solvent in the COSMO model.

  • verbose (int, default: 0) – Control SCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • point_group_symmetry (bool, default: False) – Enable point group symmetry.

  • point_group_symmetry_subgroup (str, default: None) – Use this point group symmetry instead of full point group symmetry.

  • soscf (bool, default: False) – Use Second-Order SCF solver (Newton’s method).

  • df (bool, default: False) – Use density fitting.

static build_mm_charges(mm_charges, mm_geometry)

Puts InQuanto MM charge dict into PySCF-friendly format.

Orders MM charges according to mm_geometry.

Parameters:
  • mm_geometry (List) – Geometry of MM region in format ['Atom1', [x, y, z]], 'Atom2', [x, y, z]], ...].

  • mm_charges (Union[Dict, List, float]) – Dict of charges, or float if all charges are the same. If float, all output charges will all have this value. If it is already a list, do nothing.

Returns:

List – List of MM charges ordered the same as mm_geometry.

compute_nuclear_dipole()

Compute the nuclear electric dipole.

Returns:

Tuple[float, float, float] – x, y, and z components of nuclear electric dipole.

compute_one_electron_operator(oper, origin=(0, 0, 0))

Compute a one-electron fermionic operator in atomic units.

For operators with origin-dependent expectation values, origin can be specified. oper values:
  • ‘kin’ - kinetic energy.

  • ‘nuc’ - nucleus-electron attraction energy.

  • ‘hcore’ - one-electron hamiltonian.

  • ‘ovlp’ - one-electron overlap.

  • ‘r’ - electronic first moment (x, y, z).

  • ‘rr’ - electronic second moment (xx, xy, xz, yx, yy, yz, zx, zy, zz).

  • ‘dm’ - electronic dipole moment (x, y, z).

Parameters:
  • oper (str) – Key to specify the operator.

  • origin (tuple, default: (0, 0, 0)) – Coordinate position of the origin.

Returns:

Union[FermionOperator, List[FermionOperator]] – One electron operators.

extract_point_group_information(reduce_infinite_point_groups=True)

Returns point group information.

Parameters:

reduce_infinite_point_groups (default: True) – Reduce infinite point groups, e.g., Coov -> C2v.

Returns:

Tuple[str, List[str]] – Point group symmetry, list of orbital irreps.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='H 0 0 0; H 0 0 0.75',
...     basis='sto3g',
...     point_group_symmetry=True,
... )
>>> ham, space, state = driver.get_system()
>>> driver.extract_point_group_information()
('D2h', ['Ag', 'Ag', 'B1u', 'B1u'])
classmethod from_mf(mf, frozen=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMolecularUHFQMMMCOSMO – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_ac0_correction(rdms)

Compute the AC0 correction to the energy from the provided density matrices.

Requires installation of pyscf-ac0 extension, which is partially based on GAMMCOR and is distributed separately.

Parameters:

rdms (Tuple[ndarray[Any, dtype[float]], ndarray[Any, dtype[float]]]) – A tuple of one- and two-particle reduced density matrices as RDMs as (rdm1, rdm2).

Returns:

The AC0 correction to the energy.

See also

For more information on AC0 correction, refer to: - DOI: 10.1021/acs.jctc.8b00213

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_cube_density(density_matrix, cube_resolution=0.25)

Output Gaussian Cube contents for density.

Parameters:
  • density_matrix (ndarray) – One-body reduced density matrix. 2D array for RHF/ROHF, 3D array for UHF.

  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

Returns:

str – Cube file formatted string.

get_cube_orbitals(cube_resolution=0.25, mo_coeff=None, orbital_indices=None)

Output Gaussian Cube file contents for orbitals.

Parameters:
  • cube_resolution (float, default: 0.25) – Resolution to be passed to cubegen.orbital.

  • mo_coeff (Optional[array], default: None) – Molecular orbital coefficients for the orbitals to be visualised.

  • orbital_indices (Optional[List], default: None) – Indices of the molecular orbitals of interest. If None, all orbitals are returned.

Returns:

List[str] – List of cube file formatted strings. For UHF, the spinorbitals are returned as [mo1_alpha, mo1_beta, mo2_alpha, mo2_beta...].

get_double_factorized_system(tol1=-1, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Calculate double-factorized Hamiltonian operator, Fock space, and Hartree-Fock state.

Writes the hamiltonian as \(H = H_0 + H_1 + S + V\) where \(S+V\) is the coulomb interaction. \(V = (1/2)\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator which is to be double-factorized, and \(S\) is a one-body energy offset given by \(S = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -(1/2)\sum_k (ik|kj)\). \(H_0\) and \(H_1\) are the constant and one-electron terms respectively.

First level of factorization decomposes the electron repulsion integral (ERI) tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or pivoted, incomplete Cholesky decomposition (method='cho'). For details about Cholesky decomposition, refer to References [1] and [2]. The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. For ‘eig’, we discard eigenvalues, starting from the smallest, until the sum of those discarded exceeds tol1. For ‘cho’, the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

Not intended for reduction of classical memory usage, only for truncating the two-body terms of the hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1) – Truncation threshold for first decomposition of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second decomposition. If None, same as tol1.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. ‘eig’ for an eigenvalue decomposition, ‘cho’ for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_pq\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\).

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

Tuple[DoubleFactorizedHamiltonian, FermionSpace, FermionState] – Hamiltonian operator storing two-body integrals in double factorized form, Fock space, Fock state.

References

  1. Henrik Koch, Alfredo Sánchez de Merás, and Thomas Bondo Pedersen. Reduced scaling in electronic structure calculations using Cholesky decompositions. J. Chem. Phys., 118(21): 9481-9484, 2003. URL: https://doi.org/10.1063/1.1578621, doi:10.1063/1.1578621

  2. Evgeny Epifanovsky, Dmitry Zuev, Xintian Feng, Kirill Khistyaev, Yang Shao, and Anna I. Krylov. General implementation of the resolution-of-the-identity and Cholesky representations of electron repulsion integrals within coupled-cluster and equation-of-motion methods: Theory and benchmarks. J. Chem. Phys., 139(13): 134105, 2013. URL: https://doi.org/10.1063/1.4820484, doi:10.1063/1.4820484

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

Returns:

SymbolDict – Excitation parameters.

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators and (guess) parameters.

Parameters:
  • fock_space (FermionSpace) – Fermionic Fock space information.

  • threshold (float, default: 0.0) – Threshold of the amplitude to include the excitation operator.

  • t1 (Optional[ndarray], default: None) – Guess single-electron excitation amplitudes.

  • t2 (Optional[ndarray], default: None) – Guess two-electron excitation amplitudes.

  • compact (bool, default: False) – Enable compact form of excitation for the restricted wavefunctions.

  • antihermitian (bool, default: True) – Returns anti-Hermitian operators \(T - T^\dagger\) if specified.

Returns:

FermionOperatorList – Excitation operator list.

get_lowdin_system(method='lowdin', store_ao=False)

Calculate Hamiltonian operator (fermion) in orthogonalized AO, Fock space.

Parameters:
Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], FermionSpace, Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM]] – Fermion Hamiltonian, Fock space, Fock state.

See also

orth.orth_ao documentation.

static get_mm_coulomb(mm_charges_pyscf, mm_geometry, unit='Ha')

Get the Coulomb interaction energy between MM particles.

Parameters:
  • mm_charges_pyscf (Any) – Charges of MM region, in same order as mm_geometry.

  • mm_geometry (Any) – Geometry of MM region in format ['Atom1', [x, y, z]], 'Atom2', [x, y, z]], ...].

  • unit (str, default: "Ha") – Energy units of Coulomb interaction energy. Default is Hartree.

Returns:

Electrostatic Coulomb energy.

get_mulliken_pop()

Interface for Mulliken population analysis of PySCF.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Mulliken population, Mulliken atomic charges.

get_nevpt2_correction(rdms)

Compute the Strongly contracted NEVPT2 correction to the energy from the provided density matrices.

Parameters:

rdms (Tuple) – A tuple of reduced density matrices as PDMs in PySCF’s un-reordered format as (pdm1, …, pdm4).

Returns:

The NEVPT2 correction to the energy.

get_orbital_coefficients()

Returns orbital coefficients.

Returns:

ndarray – Orbital coefficients.

get_rdm1_ccsd()

Reduced one-body density matrix in the AO basis from CCSD.

Returns:

Union[RestrictedOneBodyRDM, UnrestrictedOneBodyRDM] – One-body reduced density matrix.

get_rdm2_ccsd()

Reduced two-body density matrix in the AO basis with CCSD.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Two-body reduced density matrix.

Note

This object will be replaced with an RestrictedTwoBodyRDM class to avoid returning a raw 4D tensor.

get_subsystem_driver(frozen=None, transf=None)

Generate a driver object wrapping the current active space Hamiltonian.

Parameters:
Returns:

BasePySCFDriver – PySCF driver object wrapping the current active space Hamiltonian.

get_system(symmetry=1)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Parameters:

symmetry (Union[str, int], default: 1) – Code to specify target symmetry for storage of two-body integrals. Uses the same convention as PySCF. Currently, supports s1, s4 and s8 index permutation symmetries.

Warning

For unrestricted integral operators, the aabb and bbaa two-body integrals cannot be compacted with s8 symmetry. If s8 symmetry is requested, the aaaa and bbbb will be stored with s8 symmetry, while the aabb and bbaa integrals will be stored with s4 symmetry.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator, ChemistryRestrictedIntegralOperatorCompact, ChemistryUnrestrictedIntegralOperatorCompact], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

get_system_ao(run_hf=True)

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Output hamiltonian operator will be of type PySCFChemistryRestrictedIntegralOperator or PySCFChemistryUnrestrictedIntegralOperator, which store the underlying atomic orbitals.

Parameters:

run_hf (bool, default: True) – If True, a Hartree-Fock calculation for the system will be executed, and the Fock space and HF state are returned with the hamiltonian operator. If False, no calculation is performed and the Fock space and HF state are returned as None. If the PySCF mean-field object has already been converged prior to calling get_system_ao(), behaviour will follow run_hf=True.

Returns:

Tuple[Union[PySCFChemistryRestrictedIntegralOperator, PySCFChemistryUnrestrictedIntegralOperator], Optional[FermionSpace], Optional[FermionState]] – Fermion Hamiltonian, Fock space, Fock state.

make_actives_contiguous()

Reorder orbitals so that active orbitals form a contiguous block.

Reorders orbital coefficients, orbital energies, occupations and the list of frozen (active) orbitals. Implemented for RHF, ROHF and UHF.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string, with options including "RHF", "ROHF", and "UHF".

Returns:

Mean-field type name.

property n_electron: int

Return the total number of electrons in the active space.

Returns:

Total number of electrons.

property n_orb: int

Return the number of spatial orbitals.

Returns:

Number of spatial orbitals.

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_checkfile(chkfile, init_guess=True)

Set checkpoint file name.

The PySCF calculation results will be saved to the checkpoint file.

Parameters:
  • chkfile (str) – name of checkpoint file.

  • init_guess (bool, default: True) – If True and the checkpoint file exists, the initial guess will be read from the checkpoint file.

set_diis_space_dimension(diis_space_dimension=8)

Set number of DIIS vectors.

Parameters:

diis_space_dimension (int, default: 8) – dimension of the DIIS space.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

set_level_shift(level_shift_value=0)

Set value of the artificial shift applied to virtual orbitals during SCF.

Note

Level shifting in PySCF changes the HF energy, even though the last SCF iteration is performed without it.

Parameters:

level_shift_value (float, default: 0) – value of the level shift parameter.

set_max_scf_cycles(max_cycles=50)

Set maximum number of SCF cycles.

Parameters:

max_cycles (int, default: 50) – maximum number of SCF cycles.

class ChemistryDriverPySCFMomentumRHF(geometry=None, cell=None, nks=None, basis=None, ecp=None, pseudo=None, charge=0, exp_to_discard=None, df='GDF', dimension=3, verbose=0, output=None, frozen=None, space_group_symmetry=False, precision=1e-9, soscf=False)

PySCF driver for momentum-space RHF calculations.

Parameters:
  • geometry (Union[List, str], default: None) – Molecular geometry.

  • cell (List[List], default: None) – Unit cell parameter. If provided, overrides geometry.unit_cell.

  • nks (List[int], default: None) – Number of k-points for each direction.

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • pseudo (Any, default: None) – Pseudo potentials.

  • charge (int, default: 0) – Total charge.

  • exp_to_discard (float, default: None) – Exponent to discard a primitive Gaussian.

  • df (str, default: "GDF") – Density fitting function name.

  • dimension (int, default: 3) – Number of spatial dimensions.

  • verbose (int, default: 0) – Control SCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • frozen (Any, default: None) – Frozen orbital information.

  • space_group_symmetry (bool, default: False) – Whether to use space group symmetry.

  • precision (float, default: 1e-9) – Ewald sum precision.

  • soscf (bool, default: False) – Use second-order SCF (Newton converger).

classmethod from_mf(mf, frozen=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMomentumRHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Return type:

SymbolDict

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators.

Return type:

FermionOperatorList

get_madelung_constant()

Return Madelung constant for momentum-space calculations.

Returns:

float – Madelung constant contribution to the energy.

get_system()

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Returns:

Tuple[Union[ChemistryRestrictedIntegralOperator, ChemistryUnrestrictedIntegralOperator], FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string (e.g. “RHF”).

Returns:

Mean-field type name.

property n_electron: int

Number of electrons in the active space.

Returns:

Number of electrons in the active space.

property n_kp: int

Number of k points.

Returns:

Number of k points.

property n_orb: int

Number of spatial orbitals in a unit cell.

Returns:

Number of spatial orbitals in a unit cell

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

class ChemistryDriverPySCFMomentumROHF(geometry=None, cell=None, nks=None, basis=None, ecp=None, pseudo=None, multiplicity=1, charge=0, exp_to_discard=None, df='GDF', dimension=3, verbose=0, output=None, frozen=None, space_group_symmetry=False, precision=1e-9, soscf=False)

PySCF driver for momentum-space ROHF calculations.

Parameters:
  • geometry (Union[List, str], default: None) – Molecular geometry.

  • cell (List[List], default: None) – Unit cell parameter. If provided, overrides geometry.unit_cell.

  • nks (List[int], default: None) – Number of k-points for each direction.

  • basis (Any, default: None) – Atomic basis set valid for Mole class.

  • ecp (Any, default: None) – Effective core potentials.

  • pseudo (Any, default: None) – Pseudo potentials.

  • multiplicity (int, default: 1) – Spin multiplicity, 2S+1.

  • charge (int, default: 0) – Total charge.

  • exp_to_discard (float, default: None) – Exponent to discard a primitive Gaussian.

  • df (str, default: "GDF") – Density fitting function name.

  • dimension (int, default: 3) – Number of spatial dimensions.

  • verbose (int, default: 0) – Control SCF verbosity.

  • output (str, default: None) – Specify log file name. If None, logs are printed to STDOUT.

  • frozen (Any, default: None) – Frozen orbital information.

  • space_group_symmetry (bool, default: False) – Whether to use space group symmetry.

  • precision (float, default: 1e-9) – Ewald sum precision.

  • soscf (bool, default: False) – Use second-order SCF (Newton converger.

classmethod from_mf(mf, frozen=None)

Initialize driver from a PySCF mean-field object.

Parameters:
Returns:

ChemistryDriverPySCFMomentumROHF – PySCF driver.

property frozen: List[int] | List[List[int]]

Return the frozen orbital information.

generate_report()

Generate report in a hierarchical dictionary format.

PySCF attributes such as mo_coeff are exported if the SCF is converged.

Returns:

Dict[str, Any] – Attributes of the internal PySCF mean-field object.

get_casci_1234pdms()

Calculate 1-, 2-, 3- and 4-PDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1-, 2-, 3- and 4-PDMs.

get_casci_12rdms()

Calculate 1-RDM and 2-RDM from a CASCI wavefunction.

Returns:

Tuple[ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – A tuple of 1- and 2-RDMs.

get_excitation_amplitudes(fock_space, threshold=0.0, t1=None, t2=None, compact=False)

Get the (guess) parameters as excitation amplitudes from a classical calculation.

Return type:

SymbolDict

get_excitation_operators(fock_space, threshold=0.0, t1=None, t2=None, compact=False, antihermitian=True)

Get the excitation operators.

Return type:

FermionOperatorList

get_madelung_constant()

Return Madelung constant for momentum-space calculations.

Returns:

float – Madelung constant contribution to the energy.

get_system()

Calculate fermionic Hamiltonian operator, Fock space, and Hartree Fock state.

Returns:

Tuple[ChemistryRestrictedIntegralOperator, FermionSpace, FermionState] – Fermion Hamiltonian, Fock space, Fock state.

property mf_energy: float

Return the total mean-field energy.

Returns:

Total mean-field energy.

property mf_type: str

Return the mean-field type as a string (e.g. “RHF”).

Returns:

Mean-field type name.

property n_electron: int

Number of electrons in the active space.

Returns:

Number of electrons in the active space.

property n_kp: int

Number of k points.

Returns:

Number of k points.

property n_orb: int

Number of spatial orbitals in a unit cell.

Returns:

Number of spatial orbitals in a unit cell

print_json_report(*args, **kwargs)

Prints report in json format.

run_casci(**kwargs)

Calculate the CASCI energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mcscf.CASCI object.

Returns:

float – CASCI energy.

run_ccsd(**kwargs)

Calculate the CCSD energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the cc.CCSD object.

Returns:

float – CCSD energy.

run_hf()

Calculate the HF energy.

Returns:

float – HF energy.

run_mp2(**kwargs)

Calculate the MP2 energy.

Parameters:

**kwargs – Keyword arguments to set attributes of the mp.MP2 object.

Returns:

float – MP2 energy.

set_init_orbitals(init_orbs)

Sets the initial guess orbitals for the SCF.

Parameters:

init_orbs (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Initial orbital coefficients.

Return type:

None

class DMETRHFFragmentPySCFActive(dmet, mask, name=None, frozen=None)

Custom active space fragment solver for DMETRHF method based on PySCF RHF method.

This class implements the solve() method, which uses PySCF to perform a RHF calculation to select an active space, then calls the solve_active() method to calculate the ground state quantities for the active space.

Note

The class does not implement a solve_active() method to solve the fragment problem within the chosen active space of orbitals, it is the user’s responsibility to create a subclass and provide an implementation.

Parameters:
  • dmet (DMETRHF) – DMETRHF instance that uses this fragment.

  • mask (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Array of booleans, indices correspond to the spatial orbitals of the total system. If the corresponding orbital is in the fragment, then the boolean should be True - else it should be False.

  • name (str, default: None) – Optional name of the fragment.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information.

static construct_fragment_energy_operator(one_body, two_body, veff, mask)

Computes the fragment energy with symmetrization.

Parameters:
  • mask (ndarray) – Fragment orbitals boolean mask.

  • one_body (ndarray) – One-body integrals in the fragment basis.

  • two_body (ndarray) – Two-body integrals in the fragment basis.

  • veff (ndarray) – Fock matrix in the fragment basis.

Returns:

ChemistryRestrictedIntegralOperator – Fragment energy operator based on democratic mixing defined by DMET.

solve(hamiltonian_operator, fragment_energy_operator, n_electron)

Solves the fragment system using PySCF’s RHF and a user-implemented solve_active() method.

First it performs an RHF calculation and the active space problem will be passed on to the solve_active() method.

It returns the ground state energy, the fragment energy and the one-body RDM for the whole fragment+bath system.

Parameters:
Returns:

Tuple[float, float, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Energy, fragment energy, 1-RDM of the embedding system (fragment and bath).

solve_active(hamiltonian_operator, fragment_energy_operator, fermion_space, fermion_state)

This is an abstract method.

The subclass implementation must return the energy, fragment energy, and the one-particle reduced density matrix (1-RDM) for the active space problem.

Parameters:
Returns:

Tuple[float, float, RestrictedOneBodyRDM] – Energy, fragment energy, 1-RDM of the active space of the embedding system (fragment and bath).

class DMETRHFFragmentPySCFCCSD(dmet, mask, name=None, frozen=None)

PySCF CCSD fragment solver for the DMETRHF method.

This class implements the solve() method, which uses PySCF to calculate CCSD ground state quantities of a fragment.

Parameters:
  • dmet (DMETRHF) – DMETRHF instance that uses this fragment.

  • mask (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Array of booleans, indices correspond to the spatial orbitals of the total system. If the corresponding orbital is in the fragment, then the boolean should be True - else it should be False.

  • name (str, default: None) – Optional name of the fragment.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information.

static compute_fragment_energy(rdm1, rdm2, one_body, two_body, veff, mask)

Computes the fragment energy with symmetrization.

Parameters:
  • mask (ndarray) – Fragment orbitals boolean mask.

  • rdm1 (ndarray) – One-body density matrix in the fragment basis.

  • rdm2 (ndarray) – Two-body density matrix in the fragment basis.

  • one_body (ndarray) – One-body integrals in the fragment basis.

  • two_body (ndarray) – Two-body integrals in the fragment basis.

  • veff (ndarray) – Fock matrix in the fragment basis.

Returns:

float – Fragment energy.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s CCSD method.

It returns the CCSD ground state energy, and one- and two-body RDM-s.

Parameters:
Returns:

Tuple[float, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Energy, 1-RDM, 2-RDM of the embedding system (fragment and bath).

class DMETRHFFragmentPySCFFCI(dmet, mask, name=None)

PySCF FCI fragment solver for the DMETRHF method.

This class implements the solve() method, which uses PySCF to calculate FCI ground state quantities of a fragment.

Parameters:
  • dmet (DMETRHF) – DMETRHF instance that uses this fragment.

  • mask (ndarray) – Array of booleans, indices correspond to the spatial orbitals of the total system. If the corresponding orbital is in the fragment, then the boolean should be True - else it should be False.

  • name (Optional[str], default: None) – Optional name of the fragment.

static compute_fragment_energy(rdm1, rdm2, one_body, two_body, veff, mask)

Computes the fragment energy with symmetrization.

Parameters:
  • mask (ndarray) – Fragment orbitals boolean mask.

  • rdm1 (ndarray) – One-body density matrix in the fragment basis.

  • rdm2 (ndarray) – Two-body density matrix in the fragment basis.

  • one_body (ndarray) – One-body integrals in the fragment basis.

  • two_body (ndarray) – Two-body integrals in the fragment basis.

  • veff (ndarray) – Fock matrix in the fragment basis.

Returns:

float – Fragment energy.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s FCI method.

It returns the FCI ground state energy, and one- and two-body RDM-s.

Parameters:
Returns:

Tuple[float, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Energy, 1-RDM, 2-RDM of the embedding system (fragment and bath).

class DMETRHFFragmentPySCFMP2(dmet, mask, name=None, frozen=None)

PySCF MP2 fragment solver for the DMETRHF method.

This class implements the solve() method, which uses PySCF to calculate MP2 ground state quantities of a fragment.

Parameters:
  • dmet (DMETRHF) – DMETRHF instance that uses this fragment.

  • mask (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Array of booleans, indices correspond to the spatial orbitals of the total system. If the corresponding orbital is in the fragment, then the boolean should be True - else it should be False.

  • name (str, default: None) – Optional name of the fragment.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information.

static compute_fragment_energy(rdm1, rdm2, one_body, two_body, veff, mask)

Computes the fragment energy with symmetrization.

Parameters:
  • mask (ndarray) – Fragment orbitals boolean mask.

  • rdm1 (ndarray) – One-body density matrix in the fragment basis.

  • rdm2 (ndarray) – Two-body density matrix in the fragment basis.

  • one_body (ndarray) – One-body integrals in the fragment basis.

  • two_body (ndarray) – Two-body integrals in the fragment basis.

  • veff (ndarray) – Fock matrix in the fragment basis.

Returns:

float – Fragment energy.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s MP2 method.

It returns the MP2 ground state energy, and one- and two-body RDM-s.

Parameters:
Returns:

Tuple[float, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Energy, 1-RDM, 2-RDM of the embedding system (fragment and bath).

class DMETRHFFragmentPySCFRHF(dmet, mask, name=None)

PySCF RHF fragment solver for DMETRHF method.

This class implements the solve() method, which uses PySCF to calculate RHF ground state quantities of a fragment.

Parameters:
  • dmet (DMETRHF) – DMETRHF instance that uses this fragment.

  • mask (ndarray) – Array of booleans, indices correspond to the spatial orbitals of the total system. If the corresponding orbital is in the fragment, then the boolean should be True - else it should be False.

  • name (Optional[str], default: None) – Optional name of the fragment.

static compute_fragment_energy(rdm1, rdm2, one_body, two_body, veff, mask)

Computes the fragment energy with symmetrization.

Parameters:
  • mask (ndarray) – Fragment orbitals boolean mask.

  • rdm1 (ndarray) – One-body density matrix in the fragment basis.

  • rdm2 (ndarray) – Two-body density matrix in the fragment basis.

  • one_body (ndarray) – One-body integrals in the fragment basis.

  • two_body (ndarray) – Two-body integrals in the fragment basis.

  • veff (ndarray) – Fock matrix in the fragment basis.

Returns:

float – Fragment energy.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s RHF method.

It returns the RHF ground state energy, and one- and two-body RDM-s.

Parameters:
Returns:

Tuple[float, ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]], ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]] – Energy, 1-RDM, 2-RDM of the embedding system (fragment and bath).

class FromActiveOrbitals(active_orbitals)

Selection of active orbitals.

This class helps specify the list of active orbitals based on user-provided information. See below for a HOMO-LUMO CI calculation for minimal basis LiH, where the use of this class with FromActiveOrbitals(active_orbitals = [1,2]) is equivalent to the explicit list [0, 3, 4, 5, 6].

Parameters:

active_orbitals (List[int]) – List of indices of active orbitals.

Note

Invalid (i.e., non-existent) orbital indices are ignored.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF, FromActiveOrbitals
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='Li 0 0 0; H 0 0 1.75',
...     basis='sto3g',
...     frozen=FromActiveOrbitals(active_orbitals = [1,2]),
... )
class FromActiveSpace(ncas, nelecas)

Complete Active Space for molecular RHF/ROHF.

This class helps to specify the list of frozen orbitals from information about the active space. See below for a HOMO-LUMO CI calculation for minimal basis LiH, where the use of this class with FromActiveSpace(nelecas=2, ncas=2) is equivalent to the explicit list [0, 3, 4, 5, 6].

Parameters:
  • ncas (int) – Number of active spatial orbitals.

  • nelecas (int) – Number of active electrons.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF, FromActiveSpace
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='Li 0 0 0; H 0 0 1.75',
...     basis='sto3g',
...     frozen=FromActiveSpace(ncas=5, nelecas=2),
... )
class FrozenCore(n_core)

Frozen core orbitals for molecular RHF/ROHF/UHF.

An alternative way of specifying the frozen spatial orbitals.

Parameters:

n_core (int) – Number of frozen core spatial orbitals.

Examples

>>> from inquanto.extensions.pyscf import ChemistryDriverPySCFMolecularRHF, FrozenCore
>>> driver = ChemistryDriverPySCFMolecularRHF(
...     geometry='Li 0 0 0; H 0 0 1.75', basis='sto3g',
...     frozen=FrozenCore(n_core=1),
... )
class ImpurityDMETROHFFragmentPySCFActive(dmet, mask, name=None, multiplicity=1, frozen=None)

Custome active space fragment solver for ImpurityDMETROHF method based on PySCF ROHF method.

This class implements the solve() method, which uses PySCF to perform a ROHF calculation to select an active space, then calls the solve_active() method to calculate the ground state quantities for the active space.

Note

The class does not implement the active_space() method, it is the user’s responsibility to create a subclass and provide an implementation.

Parameters:
  • dmet (ImpurityDMETROHF) – DMETRHF instance that uses this fragment.

  • mask (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Array of booleans, indices correspond to the spatial orbitals of the total system. If the corresponding orbital is in the fragment, then the boolean should be True - else it should be False.

  • name (str, default: None) – Optional name of the fragment.

  • multiplicity (int, default: 1) – Multiplicity for the fragment ROHF.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s ROHF and solve_active() method.

This method first runs an PySCF ROHF for the fragment system, then for the active space it calls the solve_active() method.

Parameters:
Returns:

float – Energy of the embedding system (fragment and bath).

solve_active(hamiltonian_operator, fermion_space, fermion_state)

This is an abstract method.

The subclass implementation must return an accurate ground state energy of the active space of the embedding system (fragment+bath).

Parameters:
  • hamiltonian_operator (ChemistryRestrictedIntegralOperator) – Hamiltonian operator for the active space of the fragment system.

  • fermion_space (FermionSpace) – Fermion space object for the active space of the fragment system.

  • fermion_state (FermionState) – Fock state for the active space of the fragment system.

Returns:

float – Energy of the embedding system (fragment and bath).

class ImpurityDMETROHFFragmentPySCFCCSD(dmet, mask, name=None, multiplicity=1, frozen=None)

PySCF CCSD fragment solver for Impurity DMETROHF.

This class implements the solve() method, which uses PySCF to calculate the CCSD ground state energy of a fragment.

Parameters:
  • dmet (ImpurityDMETROHF) – ImpurityDMET ROHF that uses this fragment.

  • mask (ndarray) – Array of booleans, indices correspond to the spatial orbitals of the total system, the fragment is masked with True.

  • name (str, default: None) – Name of the fragment.

  • multiplicity (int, default: 1) – Multiplicity for the fragment ROHF.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s CCSD method.

It returns the CCSD ground state energy.

Parameters:
Returns:

float – Energy of the embedding system (fragment and bath).

class ImpurityDMETROHFFragmentPySCFFCI(dmet, mask, name=None, multiplicity=1)

PySCF FCI fragment solver for Impurity DMETROHF.

This class implements the solve() method, which uses PySCF to calculate the FCI ground state energy of a fragment.

Parameters:
  • dmet (ImpurityDMETROHF) – ImpurityDMET ROHF that uses this fragment.

  • mask (ndarray) – Array of booleans, indices correspond to the spatial orbitals of the total system, the fragment is masked with True.

  • name (Optional[str], default: None) – Name of the fragment.

  • multiplicity (int, default: 1) – Multiplicity for the fragment ROHF.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s FCI method.

It returns the FCI ground state energy.

Parameters:
Returns:

float – Energy of the embedding system (fragment and bath).

class ImpurityDMETROHFFragmentPySCFMP2(dmet, mask, name=None, multiplicity=1, frozen=None)

PySCF MP2 fragment solver for Impurity DMETROHF.

This class implements the solve() method, which uses PySCF to calculate the MP2 ground state energy of a fragment.

Parameters:
  • dmet (ImpurityDMETROHF) – ImpurityDMET ROHF that uses this fragment.

  • mask (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Array of booleans, indices correspond to the spatial orbitals of the total system, the fragment is masked with True.

  • name (str, default: None) – Name of the fragment.

  • multiplicity (int, default: 1) – Multiplicity for the fragment ROHF.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s MP2 method.

It returns the MP2 ground state energy.

Parameters:
Returns:

float – Energy of the embedding system (fragment and bath).

class ImpurityDMETROHFFragmentPySCFROHF(dmet, mask, name=None, multiplicity=1)

PySCF ROHF fragment solver for Impurity DMETROHF.

This class implements the solve() method, which uses PySCF to calculate the ROHF ground state energy of a fragment.

Parameters:
  • dmet (ImpurityDMETROHF) – ImpurityDMETROHF instance that uses this fragment.

  • mask (ndarray) – Array of booleans, indices correspond to the spatial orbitals of the total system, the fragment is masked with True.

  • name (Optional[str], default: None) – Name of the fragment.

  • multiplicity (int, default: 1) – Multiplicity for the fragment ROHF.

solve(hamiltonian_operator, n_electron)

Solves the fragment system using PySCF’s ROHF method.

It returns the ROHF ground state energy.

Parameters:
Returns:

float – Energy of the embedding system (fragment and bath).

class PySCFChemistryRestrictedIntegralOperator(mol_or_mf, run_hf=True)

Handles a (restricted-orbital) chemistry integral operator.

Stores a PySCF pyscf.scf.hf.RHF object, and uses it to generate the constant, one- and two-body spatial integrals. All indices are in chemistry notation, two_body[p, q, r, s] = (pq|rs).

Raises:
  • ValueError – If the input mol_or_mf is not of type pyscf.gto.Mole or pyscf.scf.hf.RHF.

  • RuntimeError – If the PySCF self-consistent Hartree-Fock calculation does not converge.

Parameters:
  • mol_or_mf (Union[Mole, RHF]) – Input PySCF object from which the molecular orbital integrals are computed.

  • run_hf (bool, default: True) – Whether to run a restricted Hartree-Fock calculation on the input system.

TOLERANCE = 1e-08

Internal tolerance used when iterating over terms. Terms with magnitude smaller than this are not returned by items().

approx_equal(other, rtol=1.0e-5, atol=1.0e-8, equal_nan=False)

Checks if the two objects are numerically equal.

Input parameters propagated to numpy.allclose().

Parameters:
  • other (PySCFChemistryRestrictedIntegralOperator) – Integrals for comparison to (must be of the same type).

  • rtol (float, default: 1.0e-5) – Relative tolerance.

  • atol (float, default: 1.0e-8) – Absolute tolerance.

  • equal_nan (bool, default: False) – Whether to compare NaN values as equal.

Returns:

boolTrue if operators are numerically equal within tolerances, False otherwise.

copy()

Performs a deep copy of object.

Return type:

BaseChemistryIntegralOperator

df()

Returns a pandas.DataFrame object showing all terms in the operator.

Return type:

DataFrame

double_factorize(tol1=-1.0, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Double factorizes the two-electron integrals and returns the Hamiltonian in diagonal form.

The Hamiltonian can be written as \(\hat{H} = H_0 + \hat{H}_1 + \hat{S} + \hat{V}\) where \(\hat{S}+\hat{V}\) is the Coulomb interaction. \(V = \frac{1}{2}\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator and \(\hat{S}\) is a one-body offset term given by \(\hat{S} = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -\frac{1}{2}\sum_k (ik|kj)\). \(H_0\) and \(\hat{H}_1\) are the constant and one-electron terms respectively.

The first level of factorization decomposes the electron repulsion integrals tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or a pivoted, incomplete Cholesky decomposition (method="cho") (see J. Chem. Phys. 118, 9481–9484 (2003) and J. Chem. Phys. 139, 134105 (2013)). The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. With "eig", truncation is performed by discarding eigenvalues, starting from the smallest in magnitude, until the sum of those discarded magnitudes exceeds the threshold tol1. With "cho", the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding low-magnitude eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

This is not intended for reduction of classical memory usage, only for truncating the two-body terms of the Hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1.0) – Truncation threshold for first diagonalization of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second diagonalization of ERI matrix. If None, same as tol1. If negative, no truncation is performed.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. "eig" for an eigenvalue decomposition, "cho" for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_{pq}\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\)

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

DoubleFactorizedHamiltonian – Hamiltonian operator storing two-body integrals in double factorized form and, optionally, diagonalized one-body integrals.

effective_potential(rdm1)

Calculates the effective Coulombic potential for a given 1-RDM.

Calculates only the potential due to the total density, RDM1a + RDM1b.

Parameters:

rdm1 (RestrictedOneBodyRDM) – Restricted, one-body reduced density matrix object.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Effective potential matrix.

effective_potential_spin(rdm1)

Calculates the contribution to the effective Coulomb potential due to a spin imbalance.

Parameters:

rdm1 (RestrictedOneBodyRDM) – Restricted, one-body reduced density matrix object.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Effective potential matrix.

energy(rdm1, rdm2=None)

Calculates the total energy based on the one- and two-body reduced density matrices.

If rdm2 is not given, this method returns the mean-field energy.

Warning

This method computes the full, rank-4 two-body integrals tensor and stores in memory to calculate the electron interaction energy.

Parameters:
Returns:

float – Total energy.

energy_electron_mean_field(rdm1)

Calculates the electronic energy in the mean-field approximation.

Parameters:

rdm1 (RestrictedOneBodyRDM) – Restricted, one-body reduced density matrix object.

Returns:

Tuple[float, float] – Mean-field electronic energy (1e + 2e), and Mean-field Coulomb contribution (2e).

is_openshell()

Returns True if the PySCF mean-field object is of type ROHF, False otherwise.

Return type:

bool

items(yield_constant=True, yield_one_body=True, yield_two_body=True)

Generates the constant, one- and two-body operator terms contained in the operator object.

Parameters:
  • yield_constant (bool, default: True) – Whether to generate a constant term.

  • yield_one_body (bool, default: True) – Whether to generate one-body terms.

  • yield_two_body (bool, default: True) – Whether to generate two-body terms.

Yields:

Next requested FermionOperatorString and constant/integral value.

Return type:

Generator[Tuple[FermionOperatorString, float], None, None]

classmethod load_h5(name)

Loads operator object from .h5 file.

Parameters:

name (Union[str, Group]) – Name of .h5 file to be loaded.

Returns:

BaseChemistryIntegralOperator – Loaded integral operator object.

print_table()

Prints operator terms in a table format.

Return type:

None

qubit_encode(mapping=None, qubits=None)

Performs qubit encoding (mapping), using provided mapping class, of this instance.

This proceeds by creation of a FermionOperator class, via the to_FermionOperator() method, before mapping to a QubitOperator using the provided mapping scheme. Please see the documentation for to_FermionOperator() for finer grained control over operator generation.

Parameters:
Returns:

QubitOperator – Mapped QubitOperator object.

rotate(rotation, check_unitary=True, check_unitary_atol=1e-15)

Performs an in-place unitary rotation of the chemistry integrals.

Rotation must be real-valued (orthogonal). In practice, this rotates the MO coefficient matrix.

Raises:

ValueError – If dimensions of rotation matrix are not compatible with integrals.

Parameters:
  • rotation (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Orthogonal rotation matrix.

  • check_unitary (bool, default: True) – If True, performs a unitarity check on the rotation matrix.

  • check_unitary_atol (float, default: 1e-15) – Absolute tolerance for the unitarity check.

Returns:

PySCFChemistryRestrictedIntegralOperator – self after molecular orbital rotation.

run_rhf()

Run a restricted Hartree-Fock calculation.

Sets MO coefficients internally.

Raises:

RuntimeError – If the RHF calculation does not converge.

Returns:

ndarray[Any, dtype[float]] – MO coefficient matrix.

save_h5(name)

Dumps operator object to .h5 file.

Parameters:

name (Union[str, Group]) – Destination filename of .h5 file.

Return type:

None

to_ChemistryRestrictedIntegralOperator()

Convert to a core InQuanto ChemistryRestrictedIntegralOperator object.

Output object stores integrals in the MO basis explicitly.

Returns:

ChemistryRestrictedIntegralOperator – Core InQuanto integral operator.

to_FermionOperator(yield_constant=True, yield_one_body=True, yield_two_body=True)

Converts chemistry integral operator to FermionOperator.

Parameters:
  • yield_constant (bool, default: True) – Whether to include a constant term.

  • yield_one_body (bool, default: True) – Whether to include one-body terms.

  • yield_two_body (bool, default: True) – Whether to include two-body terms.

Returns:

FermionOperator – Integral operator in general fermionic operator form.

class PySCFChemistryUnrestrictedIntegralOperator(mol_or_mf, run_hf=True)

Handles a (unrestricted-orbital) chemistry integral operator.

Stores a PySCF pyscf.scf.uhf.UHF object, and uses it to generate the constant, one- and two-body spatial integrals. All indices are in chemistry notation, two_body[p, q, r, s] = (pq|rs).

Raises:
  • ValueError – If the input mol_or_mf is not of type pyscf.gto.Mole or pyscf.scf.uhf.UHF.

  • RuntimeError – If the PySCF self-consistent Hartree-Fock calculation does not converge.

Parameters:
  • mol_or_mf (Union[Mole, UHF]) – Input PySCF object from which the molecular orbital integrals are computed.

  • run_hf (bool, default: True)

TOLERANCE = 1e-08

Internal tolerance used when iterating over terms. Terms with magnitude smaller than this are not returned by items().

approx_equal(other, rtol=1.0e-5, atol=1.0e-8, equal_nan=False)

Checks if the two objects are numerically equal.

Input parameters propagated to numpy.allclose().

Parameters:
  • other (PySCFChemistryUnrestrictedIntegralOperator) – Integrals for comparison to (must be of the same type).

  • rtol (float, default: 1.0e-5) – Relative tolerance.

  • atol (float, default: 1.0e-8) – Absolute tolerance.

  • equal_nan (bool, default: False) – Whether to compare NaN values as equal.

Returns:

boolTrue if operators are numerically equal within tolerances, False otherwise.

copy()

Performs a deep copy of object.

Return type:

BaseChemistryIntegralOperator

df()

Returns a pandas.DataFrame object showing all terms in the operator.

Return type:

DataFrame

double_factorize(tol1=-1.0, tol2=None, method=DecompositionMethod.EIG, diagonalize_one_body=True, diagonalize_one_body_offset=True, combine_one_body_terms=True)

Double factorizes the two-electron integrals and returns the Hamiltonian in diagonal form.

The Hamiltonian can be written as \(\hat{H} = H_0 + \hat{H}_1 + \hat{S} + \hat{V}\) where \(\hat{S}+\hat{V}\) is the Coulomb interaction. \(V = \frac{1}{2}\sum_{ijkl} (ij|kl) a_i^\dagger a_j a_k^\dagger a_l\) is a reordered two-body operator and \(\hat{S}\) is a one-body offset term given by \(\hat{S} = \sum_{ij} s_{ij} a_i^\dagger a_j\) where \(s_{ij} = -\frac{1}{2}\sum_k (ik|kj)\). \(H_0\) and \(\hat{H}_1\) are the constant and one-electron terms respectively.

The first level of factorization decomposes the electron repulsion integrals tensor into the form: \((pq|rs)=\sum_t^{N_\gamma} V_{pq}^t \gamma^t V_{rs}^t\). This may be performed using an eigenvalue decomposition (method='eig'), or a pivoted, incomplete Cholesky decomposition (method="cho") (see J. Chem. Phys. 118, 9481–9484 (2003) and J. Chem. Phys. 139, 134105 (2013)). The second factorization is diagonalization of the \(V_{pq}^t\) matrix for each t: \(V_{pq}^t = \sum_u^{N_\lambda^t} U_{pu}^t \lambda_u^t U_{qu}^t\).

At the first factorization stage, truncation depends on the decomposition method. With "eig", truncation is performed by discarding eigenvalues, starting from the smallest in magnitude, until the sum of those discarded magnitudes exceeds the threshold tol1. With "cho", the decomposition is constructed iteratively until the error is less than tol1. At the second factorization level, truncation is always performed by discarding low-magnitude eigenvalues.

One-body-like terms are consolidated and diagonalized by default: \(\tilde{h}_{pq} = h_{pq} + s_{pq} = \sum_r W_{pr} \omega_r W_{qr}\). One-body diagonalization is not truncated.

Warning

This is not intended for reduction of classical memory usage, only for truncating the two-body terms of the Hamiltonian for quantum simulation.

Parameters:
  • tol1 (float, default: -1.0) – Truncation threshold for first diagonalization of ERI matrix. If negative, no truncation is performed.

  • tol2 (Optional[float], default: None) – Truncation threshold for second diagonalization of ERI matrix. If None, same as tol1. If negative, no truncation is performed.

  • method (Union[DecompositionMethod, str], default: DecompositionMethod.EIG) – Decomposition method used for the first level of factorization. "eig" for an eigenvalue decomposition, "cho" for a pivoted, incomplete Cholesky decomposition.

  • diagonalize_one_body (bool, default: True) – Whether to diagonalize the physical one-body integrals \(h_{pq}\).

  • diagonalize_one_body_offset (bool, default: True) – Whether to diagonalize the one-body offset integrals \(s_{pq}\)

  • combine_one_body_terms (bool, default: True) – Whether to consolidate the one-body and one-body offset integrals into effective one-body integrals. Requires diagonalize_one_body == diagonalize_one_body_offset.

Returns:

DoubleFactorizedHamiltonian – Hamiltonian operator storing two-body integrals in double factorized form and, optionally, diagonalized one-body integrals.

effective_potential(rdm1)

Calculates the effective Coulombic potential for a given 1-RDM.

Parameters:

rdm1 (UnrestrictedOneBodyRDM) – Unrestricted, one-body reduced density matrix.

Returns:

List[ndarray] – Effective potentials for the alpha and beta spin channels.

energy(rdm1, rdm2=None)

Calculates the total energy based on the one- and two-body reduced density matrices.

If rdm2 is not given, this method returns the mean-field energy.

Warning

This method computes the full, rank-4 two-body integrals tensor and stores in memory to calculate the electron interaction energy.

Parameters:
Returns:

float – Total energy.

energy_electron_mean_field(rdm1)

Calculates the electronic energy in the mean-field approximation.

Parameters:

rdm1 (UnrestrictedOneBodyRDM) – Unrestricted, one-body reduced density matrix object.

Returns:

Tuple[float, float] – Mean-field electronic energy (1e + 2e), and Mean-field Coulomb contribution (2e).

items(yield_constant=True, yield_one_body=True, yield_two_body=True)

Generates the constant, one- and two-body operator terms contained in the operator object.

Parameters:
  • yield_constant (bool, default: True) – Whether to generate a constant term.

  • yield_one_body (bool, default: True) – Whether to generate one-body terms.

  • yield_two_body (bool, default: True) – Whether to generate two-body terms.

Yields:

Next requested FermionOperatorString and constant/integral value.

Return type:

Generator[Tuple[FermionOperatorString, float], None, None]

classmethod load_h5(name)

Loads operator object from .h5 file.

Parameters:

name (Union[str, Group]) – Name of .h5 file to be loaded.

Returns:

BaseChemistryIntegralOperator – Loaded integral operator object.

print_table()

Prints operator terms in a table format.

Return type:

None

qubit_encode(mapping=None, qubits=None)

Performs qubit encoding (mapping), using provided mapping class, of this instance.

This proceeds by creation of a FermionOperator class, via the to_FermionOperator() method, before mapping to a QubitOperator using the provided mapping scheme. Please see the documentation for to_FermionOperator() for finer grained control over operator generation.

Parameters:
Returns:

QubitOperator – Mapped QubitOperator object.

rotate(rotation_aa, rotation_bb, check_unitary=True, check_unitary_atol=1e-15)

Performs an in-place rotation of the chemistry integrals.

Each spin block is rotated separately. Rotation matrices must be real-valued (orthogonal). In practice, this rotates the MO coefficient matrices.

Raises:

ValueError – If dimensions of rotation matrices are not compatible with integrals.

Parameters:
  • rotation_aa (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Orthogonal rotation matrix for the alpha spin block.

  • rotation_bb (ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Orthogonal rotation matrix for the beta spin block.

  • check_unitary (bool, default: True) – If True, performs a unitarity check on the rotation matrix.

  • check_unitary_atol (float, default: 1e-15) – Absolute tolerance for the unitarity check.

Returns:

PySCFChemistryUnrestrictedIntegralOperator – self after molecular orbital rotation.

run_uhf()

Run an unrestricted Hartree-Fock calculation.

Sets MO coefficients internally.

Raises:

RuntimeError – If the UHF calculation does not converge.

Returns:

ndarray[Any, dtype[float]] – MO coefficient matrices.

save_h5(name)

Dumps operator object to .h5 file.

Parameters:

name (Union[str, Group]) – Destination filename of .h5 file.

Return type:

None

to_ChemistryUnrestrictedIntegralOperator()

Convert to a core InQuanto ChemistryUnrestrictedIntegralOperator object.

Output object stores integrals in the MO basis explicitly.

Returns:

ChemistryUnrestrictedIntegralOperator – Core InQuanto integral operator.

to_FermionOperator(yield_constant=True, yield_one_body=True, yield_two_body=True)

Converts chemistry integral operator to FermionOperator.

Parameters:
  • yield_constant (bool, default: True) – Whether to include a constant term.

  • yield_one_body (bool, default: True) – Whether to include one-body terms.

  • yield_two_body (bool, default: True) – Whether to include two-body terms.

Returns:

FermionOperator – Integral operator in general fermionic operator form.

get_correlation_potential_pattern(driver, *atoms_list)

Get correlation potential pattern.

Parameters:
  • driver (BasePySCFDriverMolecular) – Molecular PySCF driver.

  • *atoms_list (List[int]) – List of atom indices.

Returns:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] – Pattern matrix.

get_fragment_orbital_masks(driver, *atoms_list)

Get fragment orbital masks.

Parameters:
  • driver (BasePySCFDriverMolecular) – Molecular PySCF driver.

  • *atoms_list (List[int]) – List of atom indices.

Returns:

Tuple[ndarray[Any, dtype[bool]], ...] – Fragment orbital mask.

get_fragment_orbitals(driver, *atoms_list)

Get fragment orbitals.

Parameters:
  • driver (BasePySCFDriverMolecular) – Molecular PySCF driver

  • *atoms_list (List[int]) – List of atom indices.

Returns:

DataFrame – Orbitals table in a DataFrame.

inquanto.extensions.pyscf.fmo

Module for Fragment Molecular Orbital (FMO) calculations of orthogonalized second quantized systems.

class FMO(hamiltonian_operator, scf_max_iteration=20, scf_tolerance=1e-5)

Bases: object

Basic FMO driver class.

This class serves as a basic driver for the Fragment Molecular Orbital (FMO) method.

Parameters:

References

  1. Kazuo Kitaura, Eiji Ikeo, Toshio Asada, Tatsuya Nakano, and Masami Uebayasi. Fragment molecular orbital method: an approximate computational method for large molecules. Chem. Phys. Lett., 313(3-4): 701-706, 1999. URL: https://doi.org/10.1016/S0009-2614(99)00874-X, doi:10.1016/S0009-2614(99)00874-X

  2. Takeshi Yamazaki, Shunji Matsuura, Ali Narimani, Anushervon Saidmuradov, and Arman Zaribafiyan. Towards the practical application of near-term quantum computers in quantum chemistry simulations: A problem decomposition approach. arXiv:1806.01305, 2018. arXiv:1806.01305

static ao_mask_2_atom_mask(mol, ao_mask)

Convert a mask covering the list of atomic orbitals (AOs) to a mask covering all atoms in the system.

Parameters:
  • mol (Mole) – PySCF gto.Mole object describing the molecular system.

  • ao_mask (List[bool]) – List of bool indicating if each AO is included or not.

Raises:

ValueError – If the ao_mask fragments a single atom.

Returns:

List[bool] – Atomic mask corresponding to input AO mask.

static atom_mask_2_ao_mask(mol, atom_mask)

Convert a mask covering the list of atoms to a mask covering all atomic orbitals (AOs) in the system.

Parameters:
  • mol (Mole) – PySCF gto.Mole object describing the molecular system.

  • atom_mask (List[bool]) – List of bool indicating if each atom is included or not.

Returns:

List[bool] – AO mask corresponding to input atomic mask.

energy(fragments, dimer_fragments)

Computes the total FMO energies.

Parameters:
Returns:

Energy.

run(fragments)

Running the FMO self-consistent cycles.

Parameters:

fragments (List[FMOFragment]) – List of FMO fragment solvers.

Returns:

float – Total energy.

class FMOFragment(fmo, mask, n_electron, name=None)

Bases: object

Base solver for an FMO fragment.

Default solver is Restricted Hartree-Fock.

Parameters:
  • fmo (FMO) – Fragment Molecular Orbital calculator.

  • mask (Union[List[bool], ndarray[Any, dtype[bool]]]) – Orbital fragment mask.

  • n_electron (int) – Number of electrons in fragment.

  • name (str, default: None) – Reference name for fragment.

classmethod compose_fragments(fragment, *fragments)

Combines two or more fragments into a single fragment.

Parameters:
Returns:

FMOFragment – A new fragment solver.

solve(hamiltonian_operator)

Compute the energy and 1-RDM of the fragment.

Used in the self-consistent FMO cycle.

Note

Default solver is RHF (does not use PySCF).

Parameters:

hamiltonian_operator (ChemistryRestrictedIntegralOperator) – Integral operator for the fragment.

Returns:

Tuple[float, RestrictedOneBodyRDM] – Electronic energy and 1-RDM of the fragment.

solve_final(hamiltonian_operator)

Compute the final energy of the fragment.

Used after FMO self-consistency is reached, to compute final energies.

Note

Unless overwritten it does the same as solve().

Parameters:

hamiltonian_operator (ChemistryRestrictedIntegralOperator) – Integral operator for the fragment.

Returns:

float – Electronic energy.

class FMOFragmentPySCFActive(fmo, mask, n_electron, name=None, frozen=None)

Bases: FMOFragmentPySCFRHF

PySCF custom active space solver for FMO fragments.

Uses RHF as the solver in the FMO self-consistent cycle, and a user defined solver for the final energy calculation.

Parameters:
  • fmo (FMO) – Fragment Molecular Orbital calculator.

  • mask (Union[List[bool], ndarray[Any, dtype[bool]]]) – Orbital fragment mask.

  • n_electron (int) – Number of electrons in fragment.

  • name (str, default: None) – Reference name for fragment.

  • frozen (Union[List[int], Callable[[SCF], List[int]]], default: None) – Frozen orbital information passed to PySCf driver.

classmethod compose_fragments(fragment, *fragments)

Combines two or more fragments into a single fragment.

Parameters:
Returns:

FMOFragment – A new fragment solver.

solve(hamiltonian_operator)

Compute the energy and 1-RDM of the fragment using the PySCF RHF solver.

Used in the self-consistent FMO cycle.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

Tuple[float, RestrictedOneBodyRDM] – Electronic energy and 1-RDM of the fragment.

solve_final(hamiltonian_operator)

Compute the final energy of the fragment using the custom active space solver.

Used after FMO self-consistency is reached, to compute final energies.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

Electronic energy of the fragment.

solve_final_active(hamiltonian_operator, fermion_space, fermion_state)

Compute the final energy of an active space in the fragment.

Used by FMOFragmentPySCFActive.solve_final().

Note

Must be implemented by user.

Parameters:
Returns:

Tuple[float, RestrictedOneBodyRDM] – Electronic energy.

class FMOFragmentPySCFCCSD(fmo, mask, n_electron, name=None, frozen=None)

Bases: FMOFragmentPySCFRHF

PySCF RHF-CCSD solver for FMO fragments.

Uses RHF as the solver in the FMO self-consistent cycle, and CCSD for the final energy calculation.

Parameters:
  • fmo (FMO) – Fragment Molecular Orbital calculator.

  • mask (Union[List[bool], ndarray[Any, dtype[bool]]]) – Orbital fragment mask.

  • n_electron (int) – Number of electrons in fragment.

  • name (str, default: None) – Reference name for fragment.

classmethod compose_fragments(fragment, *fragments)

Combines two or more fragments into a single fragment.

Parameters:
Returns:

FMOFragment – A new fragment solver.

solve(hamiltonian_operator)

Compute the energy and 1-RDM of the fragment using the PySCF RHF solver.

Used in the self-consistent FMO cycle.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

Tuple[float, RestrictedOneBodyRDM] – Electronic energy and 1-RDM of the fragment.

solve_final(hamiltonian_operator)

Compute the final energy of the fragment using the PySCF CCSD solver.

Used after FMO self-consistency is reached, to compute final energies.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

float – Electronic energy of the fragment.

class FMOFragmentPySCFMP2(fmo, mask, n_electron, name=None, frozen=None)

Bases: FMOFragmentPySCFRHF

PySCF RHF-MP2 solver for FMO fragments.

Uses RHF as the solver in the FMO self-consistent cycle, and MP2 for the final energy calculation.

Parameters:
  • fmo (FMO) – Fragment Molecular Orbital calculator.

  • mask (Union[List[bool], ndarray[Any, dtype[bool]]]) – Orbital fragment mask.

  • n_electron (int) – Number of electrons in fragment.

  • name (str, default: None) – Reference name for fragment.

classmethod compose_fragments(fragment, *fragments)

Combines two or more fragments into a single fragment.

Parameters:
Returns:

FMOFragment – A new fragment solver.

solve(hamiltonian_operator)

Compute the energy and 1-RDM of the fragment using the PySCF RHF solver.

Used in the self-consistent FMO cycle.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

Tuple[float, RestrictedOneBodyRDM] – Electronic energy and 1-RDM of the fragment.

solve_final(hamiltonian_operator)

Compute the final energy of the fragment using the PySCF MP2 solver.

Used after FMO self-consistency is reached, to compute final energies.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

Electronic energy of the fragment.

class FMOFragmentPySCFRHF(fmo, mask, n_electron, name=None)

Bases: FMOFragment

PySCF RHF solver for FMO fragments.

Parameters:
  • fmo (FMO) – Fragment Molecular Orbital calculator.

  • mask (Union[List[bool], ndarray[Any, dtype[bool]]]) – Orbital fragment mask.

  • n_electron (int) – Number of electrons in fragment.

  • name (str, default: None) – Reference name for fragment.

classmethod compose_fragments(fragment, *fragments)

Combines two or more fragments into a single fragment.

Parameters:
Returns:

FMOFragment – A new fragment solver.

solve(hamiltonian_operator)

Compute the energy and 1-RDM of the fragment using the PySCF RHF solver.

Used in the self-consistent FMO cycle.

Parameters:

hamiltonian_operator (Union[ChemistryRestrictedIntegralOperator, PySCFChemistryRestrictedIntegralOperator]) – Integral operator for the fragment.

Returns:

Tuple[float, RestrictedOneBodyRDM] – Electronic energy and 1-RDM of the fragment.

solve_final(hamiltonian_operator)

Compute the final energy of the fragment.

Used after FMO self-consistency is reached, to compute final energies.

Note

Unless overwritten it does the same as solve().

Parameters:

hamiltonian_operator (ChemistryRestrictedIntegralOperator) – Integral operator for the fragment.

Returns:

float – Electronic energy.