tangelo.algorithms.classical package

Subpackages

Submodules

tangelo.algorithms.classical.ccsd_solver module

Class performing electronic structure calculation employing the CCSD method.

class tangelo.algorithms.classical.ccsd_solver.CCSDSolver(molecule: SecondQuantizedMolecule, solver: None | str | Type[ElectronicStructureSolver] = 'pyscf', **solver_kwargs)

Bases: ElectronicStructureSolver

Uses the Full CI method to solve the electronic structure problem.

Parameters:
  • molecule (SecondQuantizedMolecule) – Molecule

  • solver (string or Type[ElectronicStructureSolver] or None) – Supported string identifiers can be found in available_ccsd_solvers (from tangelo.algorithms.classical.ccsd_solver). Can also provide a user-defined CCSD implementation (child to ElectronicStructureSolver class)

  • solver_kwargs – Other arguments that could be passed to a target. Examples are solver type (e.g. lambdacc, fnocc), Convergence options etc.

solver

The backend specific CCSD solver

Type:

Type[ElectronicStructureSolver]

get_rdm()

Compute the Full CI 1- and 2-particle reduced density matrices.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

Raises:

RuntimeError – If method “simulate” hasn’t been run.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total CCSD energy.

class tangelo.algorithms.classical.ccsd_solver.CCSDSolverPsi4(molecule: SecondQuantizedMolecule)

Bases: ElectronicStructureSolver

Uses the CCSD method to solve the electronic structure problem, through Psi4.

Parameters:

molecule (SecondQuantizedMolecule) – The molecule to simulate.

ccwfn

The CCSD wavefunction (float64).

Type:

psi4.core.CCWavefunction

backend

The psi4 module

Type:

psi4

molecule

The molecule with symmetry=False

Type:

SecondQuantizedMolecule

get_rdm()

Compute the Full CI 1- and 2-particle reduced density matrices.

Returning RDMS from a CCSD calculation in Psi4 is not implemented at this time.

It may be possible to obtain the one-rdm by running a psi4 CCSD gradient calculation (https://forum.psicode.org/t/saving-ccsd-density-for-read-in/2416/2) Another option to obtain the one-rdm is to use pycc (https://github.com/CrawfordGroup/pycc)

Raises:

NotImplementedError – Returning RDMs from Psi4 in Tangelo is not supported at this time.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total CCSD energy.

class tangelo.algorithms.classical.ccsd_solver.CCSDSolverPySCF(molecule)

Bases: ElectronicStructureSolver

Uses the CCSD method to solve the electronic structure problem, through pyscf.

Parameters:

molecule (SecondQuantizedMolecule) – The molecule to simulate.

cc_fragment

The coupled-cluster object.

Type:

pyscf.cc.CCSD

mean_field

The mean field of the molecule.

Type:

pyscf.scf.RHF

frozen

Frozen molecular orbitals.

Type:

list or int

get_rdm()

Calculate the 1- and 2-particle reduced density matrices. The CCSD lambda equation will be solved for calculating the RDMs.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

Raises:

RuntimeError – If no simulation has been run.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – CCSD energy.

tangelo.algorithms.classical.ccsd_solver.get_ccsd_solver(molecule: SecondQuantizedMolecule, solver: None | str | Type[ElectronicStructureSolver] = 'pyscf', **solver_kwargs)

Return requested target CCSDSolverName object.

Parameters:
  • molecule (SecondQuantizedMolecule) – Molecule

  • solver (string or Type[ElectronicStructureSolver] or None) – Supported string identifiers can be found in ccsd_solver_dict (from tangelo.algorithms.classical.ccsd_solver). Can also provide a user-defined backend (child to ElectronicStructureSolver class)

  • solver_kwargs – Other arguments that could be passed to a target. Examples are solver type (e.g. lambdacc, fnocc), Convergence options etc.

tangelo.algorithms.classical.fci_solver module

Define electronic structure solver employing the full configuration interaction (CI) method.

class tangelo.algorithms.classical.fci_solver.FCISolver(molecule: SecondQuantizedMolecule, solver: None | str | Type[ElectronicStructureSolver] = 'pyscf', **solver_kwargs)

Bases: ElectronicStructureSolver

Uses the Full CI method to solve the electronic structure problem.

Parameters:
  • molecule (SecondQuantizedMolecule) – Molecule

  • solver (string or Type[ElectronicStructureSolver] or None) – Supported string identifiers can be found in available_fci_solvers (from tangelo.algorithms.classical.fci_solver). Can also provide a user-defined FCI implementation (child to ElectronicStructureSolver class)

  • solver_kwargs – Other arguments that could be passed to a target. Examples are solver type (e.g. mcscf, fci), Convergence options etc.

solver

The solver that is used for obtaining the FCI solution.

Type:

Type[ElectronicStructureSolver]

get_rdm()

Compute the Full CI 1- and 2-particle reduced density matrices.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

Raises:

RuntimeError – If method “simulate” hasn’t been run.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total FCI energy.

class tangelo.algorithms.classical.fci_solver.FCISolverPsi4(molecule: SecondQuantizedMolecule)

Bases: ElectronicStructureSolver

Uses the Full CI method to solve the electronic structure problem, through Psi4.

Parameters:

molecule (SecondQuantizedMolecule) – The molecule to simulate.

ciwfn

The CI wavefunction (float64).

Type:

psi4.core.CIWavefunction

backend

The psi4 module

Type:

psi4

molecule

The molecule with symmetry=False

Type:

SecondQuantizedMolecule

get_rdm()

Compute the Full CI 1- and 2-particle reduced density matrices.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

Raises:

RuntimeError – If method “simulate” hasn’t been run.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total FCI energy.

class tangelo.algorithms.classical.fci_solver.FCISolverPySCF(molecule)

Bases: ElectronicStructureSolver

Uses the Full CI method to solve the electronic structure problem, through pyscf.

Parameters:

molecule (SecondQuantizedMolecule) – The molecule to simulate.

ci

The CI wavefunction (float64).

Type:

numpy.array

norb

The number of molecular orbitals.

Type:

int

nelec

The number of electrons.

Type:

int

cisolver

The Full CI object.

Type:

pyscf.fci.direct_spin0.FCI

mean_field

Mean field object.

Type:

pyscf.scf

get_rdm()

Compute the Full CI 1- and 2-particle reduced density matrices.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

Raises:

RuntimeError – If method “simulate” hasn’t been run.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total FCI energy.

tangelo.algorithms.classical.fci_solver.get_fci_solver(molecule: SecondQuantizedMolecule, solver: None | str | Type[ElectronicStructureSolver] = 'pyscf', **solver_kwargs)

Return requested target FCISolverName object.

Parameters:
  • molecule (SecondQuantizedMolecule) – Molecule

  • solver (string or Type[ElectronicStructureSolver] or None) – Supported string identifiers can be found in available_fci_solvers (from tangelo.algorithms.classical.fci_solver). Can also provide a user-defined FCI implementation (child to ElectronicStructureSolver class)

  • solver_kwargs – Other arguments that could be passed to a target. Examples are solver type (e.g. mcscf, fci), Convergence options etc.

tangelo.algorithms.classical.mp2_solver module

Define electronic structure solver employing the Moller-Plesset perturbation theory to second order (MP2) method.

class tangelo.algorithms.classical.mp2_solver.MP2Solver(molecule: SecondQuantizedMolecule, solver: None | str | Type[ElectronicStructureSolver] = 'pyscf', **solver_kwargs)

Bases: ElectronicStructureSolver

Uses the MP2 method to solve the electronic structure problem.

Parameters:
  • molecule (SecondQuantizedMolecule) – Molecule

  • solver (string or Type[ElectronicStructureSolver] or None) – Supported string identifiers can be found in available_mp2_solvers (see mp2_solver.py). Can also provide a user-defined MP2 implementation (child to ElectronicStructureSolver class)

  • solver_kwargs – Other arguments that could be passed to a target. Examples are solver type (e.g. dfmp2, mp2), Convergence options etc.

solver

The solver that is used for obtaining the MP2 solution.

Type:

Type[ElectronicStructureSolver]

get_mp2_amplitudes()

Compute the double amplitudes from the MP2 perturbative method, and then reorder the elements into a dense list. The single (T1) amplitudes are set to a small non-zero value. The ordering is single, double (diagonal), double (non-diagonal).

Returns:

list of float – The electronic excitation amplitudes.

get_rdm()

Compute the Full CI 1- and 2-particle reduced density matrices.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total MP2 energy.

class tangelo.algorithms.classical.mp2_solver.MP2SolverPsi4(molecule: SecondQuantizedMolecule)

Bases: ElectronicStructureSolver

Uses the MP2 method to solve the electronic structure problem, through Psi4.

Only supports frozen core (active) orbitals sequentially from bottom (top) of energy ordering.

Parameters:

molecule (SecondQuantizedMolecule) – The molecule to simulate.

mp2wfn

The Psi4 Wavefunction returned from an mp2 calculation.

Type:

psi4.core.Wavefunction

backend

The psi4 module

Type:

psi4

molecule

The molecule with symmetry=False

Type:

SecondQuantizedMolecule

get_mp2_amplitudes()

Compute the double amplitudes from the MP2 perturbative method, and then reorder the elements into a dense list. The single (T1) amplitudes are set to a small non-zero value. The ordering is single, double (diagonal), double (non-diagonal).

Returning MP2 amplitudes from Psi4 is not currently supported in Tangelo

Using https://github.com/psi4/psi4numpy/blob/master/Tutorials/10_Orbital_Optimized_Methods/10a_orbital-optimized-mp2.ipynb should return appropriate amplitudes for a closed shell RHF reference.

Raises:

NotImplementedError – Not implemented at this time

get_rdm()

Calculate the 1- and 2-particle reduced density matrices.

Obtaining MP2 rdms from Psi4 is not currently supported in Tangelo.

Using https://github.com/psi4/psi4numpy/blob/master/Tutorials/10_Orbital_Optimized_Methods/10a_orbital-optimized-mp2.ipynb should return appropriate RDMs for a closed shell RHF reference.

Raises:

NotImplementedError – Not implemented at this time

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – Total MP2 energy.

class tangelo.algorithms.classical.mp2_solver.MP2SolverPySCF(molecule)

Bases: ElectronicStructureSolver

Uses the Second-order Moller-Plesset perturbation theory (MP2) method to solve the electronic structure problem, through pyscf.

Parameters:

molecule (SecondQuantizedMolecule) – The molecule to simulate.

mp2_fragment

The coupled-cluster object.

Type:

pyscf.mp.MP2

mean_field

The mean field of the molecule.

Type:

pyscf.scf.RHF

frozen

Frozen molecular orbitals.

Type:

list or int

get_mp2_amplitudes()

Compute the double amplitudes from the MP2 perturbative method, and then reorder the elements into a dense list. The single (T1) amplitudes are set to a small non-zero value. The ordering is single, double (diagonal), double (non-diagonal).

Returns:

list of float – The electronic excitation amplitudes.

get_rdm()

Calculate the 1- and 2-particle reduced density matrices.

Returns:
  • numpy.array – One-particle RDM.

  • numpy.array – Two-particle RDM.

Raises:

RuntimeError – If no simulation has been run.

simulate()

Perform the simulation (energy calculation) for the molecule.

Returns:

float – MP2 energy.

tangelo.algorithms.classical.mp2_solver.get_mp2_solver(molecule: SecondQuantizedMolecule, solver: None | str | Type[ElectronicStructureSolver] = 'pyscf', **solver_kwargs)

Return requested target MP2SolverName object.

Parameters:
  • molecule (SecondQuantizedMolecule) – Molecule

  • solver (string or Type[ElectronicStructureSolver] or None) – Supported string identifiers can be found in available_mp2_solvers (see mp2_solver.py). Can also provide a user-defined MP2 implementation (child to ElectronicStructureSolver class)

  • solver_kwargs – Other arguments that could be passed to a target. Examples are solver type (e.g. mcscf, mp2), Convergence options etc.

Raises:
  • ModuleNoyFoundError – No solver is specified and a user defined IntegralSolver was used in molecule.

  • ValueError – The specified solver str is not one of the available_mp2_solvers (see mp2_solver.py)

  • TypeError – The specified solver was not a string or sub class of ElectronicStructureSolver.

Module contents