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 (