tangelo.problem_decomposition.dmet package

Submodules

tangelo.problem_decomposition.dmet.dmet_problem_decomposition module

Employ DMET as a problem decomposition technique.

class tangelo.problem_decomposition.dmet.dmet_problem_decomposition.DMETProblemDecomposition(opt_dict)

Bases: ProblemDecomposition

DMET single-shot algorithm is used for problem decomposition technique. By default, CCSD is used as the electronic structure solver, and Meta-Lowdin is used for the localization scheme. Users can define other electronic structure solver such as FCI or VQE as an impurity solver. IAO scheme can be used instead of the Meta-Lowdin localization scheme, but it cannot be used for minimal basis set.

The underlying mean-field for the computation is automatically detected from the SecondQuantizedMolecule. RHF, ROHF and UHF mean-fields are supported.

molecule

The molecular system.

Type:

SecondQuantizedMolecule

electron_localization

A type of localization scheme. Default is Meta-Lowdin.

Type:

Localization

fragment_atoms

List of number of atoms in each fragment. Sum of this list should be the same as the number of atoms in the original system.

Type:

list

fragment_solvers

List of solvers for each fragment. If only a string is detected, this solver is used for all fragments.

Type:

list or str

fragment_frozen_orbitals

List of frozen orbitals. List of integers freezes the n first orbitals in the fragment. Nested list of integers freezes orbitals based on indices.

Type:

list

optimizer

A function defining the classical optimizer and its behavior.

Type:

function handle

initial_chemical_potential

Initial value for the chemical potential.

Type:

float

solvers_options

List of dictionaries for the solver options. If only a single dictionary is passed, the same options are applied for every solver. This will raise an error if different solvers are parsed.

Type:

list or dict

virtual_orbital_threshold

Occupation threshold for the virtual orbital space. Setting it to 0. is the equivalent of turning off the virtual orbital space truncation. Default=1e-13.

Type:

float

verbose

Flag for DMET verbosity.

Type:

bool

build()

Building the orbitals list for each fragment. It sets the values of self.orbitals, self.orb_list and self.orb_list2.

energy_error_bars(n_shots, n_resamples, purify=False, rdm_measurements=None)

Perform bootstrapping of measured qubit terms in RDMs to obtain error bars for the calculated energy. Can also perform McWeeny purification of the RDMs between resampling and calculating the energy.

Parameters:
  • n_shots (int) – The number of shots used to resample from qubit terms.

  • n_resamples (int) – The number of bootstrapping samples for the estimate of the energy and standard deviation.

  • purify (bool) – Use mc_weeny_rdm_purification technique on 2-RDMs. Will only apply to fragments with 2 electrons.

  • rdm_measurements (dict) –

    A dictionary with keys being the DMET fragment number and corresponding values of a dictionary with keys of qubit terms in the rdm and corresponding values of a frequencies dictionary of the measurements. Example: { 0: {((0, “X”), (1, “Y”)): {“10”: 0.5, “01”: 0.5},

    ((1, “Z”), (1, “X”)): {“00”: 0.25, “11”: 0.25, “01”: 0.5}}

    1: {((0, “Z”)): {“0000”: 1}

    ((0, “X”), (1, “Y”)): {“1111”: 0.5, “0101”: 0.5}}

    }. If run _oneshot_loop with save_results=True is called: self.rdm_measurements will have the proper dictionary format with all values populated.

Returns:

float – The bootstrapped DMET energy and standard deviation.

get_resources()

Estimate the resources required by DMET. Only supports fragments solved with VQESolver. Resources for each fragments are outputed as a list.

property quantum_fragments_data

This aims to return a dictionary with all necessary components to run a quantum experiment for a (or more) DMET fragment(s).

simulate()

Perform DMET loop to optimize the chemical potential. It converges when the electron summation across all fragments is the same as the number of electron in the molecule.

Returns:

float – The DMET energy (dmet_energy).

class tangelo.problem_decomposition.dmet.dmet_problem_decomposition.Localization(value)

Bases: Enum

Enumeration of the electron localization supported by DMET.

iao = 1
meta_lowdin = 0
nao = 2

tangelo.problem_decomposition.dmet.fragment module

Module for data structure for DMET fragments.

class tangelo.problem_decomposition.dmet.fragment.SecondQuantizedDMETFragment(molecule: <module 'pyscf.gto' from '/Users/valentinsenicourt/Desktop/virtualenvs/test_release_0.4.2/lib/python3.10/site-packages/pyscf/gto/__init__.py'>, mean_field: <module 'pyscf.scf' from '/Users/valentinsenicourt/Desktop/virtualenvs/test_release_0.4.2/lib/python3.10/site-packages/pyscf/scf/__init__.py'>, fock: ~numpy.array, fock_frag_copy: ~numpy.array, t_list: list, one_ele: ~numpy.array, two_ele: ~numpy.array, uhf: bool, frozen_orbitals: list)

Bases: object

Mimicking SecondQuantizedMolecule for DMET fragments. It has the minimal number of attributes and methods to be parsed by electronic solvers.

basis: str
property fermionic_hamiltonian
fock: array
fock_frag_copy: array
property frozen_mos

This property returns MOs indexes for the frozen orbitals. It was written to take into account if one of the two possibilities (occ or virt) is None. In fact, list + None, None + list or None + None return an error. An empty list cannot be sent because PySCF mp2 returns “IndexError: list index out of range”.

Returns:

list – MOs indexes frozen (occupied + virtual).

frozen_orbitals: list
mean_field: <module 'pyscf.scf' from '/Users/valentinsenicourt/Desktop/virtualenvs/test_release_0.4.2/lib/python3.10/site-packages/pyscf/scf/__init__.py'>
molecule: <module 'pyscf.gto' from '/Users/valentinsenicourt/Desktop/virtualenvs/test_release_0.4.2/lib/python3.10/site-packages/pyscf/gto/__init__.py'>
n_active_electrons: int
n_active_mos: int
n_active_sos: int
one_ele: array
q: int
spin: int
t_list: list
to_pyscf(basis=None)

Method to output the PySCF molecule.

Returns

pyscf.gto.Mole: PySCF molecule.

two_ele: array
uhf: bool

Module contents