vayesta.dmet

Submodules

vayesta.dmet.dmet

class vayesta.dmet.dmet.Options(store_eris: bool = True, global_frag_chempot: float | None = None, dm_with_frozen: bool = False, bath_options: dict = <factory>, solver_options: dict = <factory>, symmetry_tol: float = 1e-06, symmetry_mf_tol: float = 1e-05, screening: str | None = None, iao_minao: str = 'auto', maxiter: int = 30, charge_consistent: bool = True, max_elec_err: float = 0.0001, conv_tol: float = 1e-06, diis: bool = True, mixing_param: float = 0.5, mixing_variable: str = 'hl rdm', oneshot: bool = False)[source]

Bases: Options

Options for DMET calculations.

iao_minao: str = 'auto'
dm_with_frozen: bool = False
maxiter: int = 30
charge_consistent: bool = True
max_elec_err: float = 0.0001
conv_tol: float = 1e-06
diis: bool = True
mixing_param: float = 0.5
mixing_variable: str = 'hl rdm'
oneshot: bool = False
solver_options: dict
asdict(deepcopy=False)
classmethod change_dict_defaults(field, **kwargs)
static dict_with_defaults(**kwargs)
get(attr, default=None)

Dictionary-like access to attributes. Allows the definition of a default value, of the attribute is not present.

classmethod get_default(field)
classmethod get_default_factory(field)
global_frag_chempot: float = None
items()
keys()
replace(**kwargs)
screening: str | None = None
store_eris: bool = True
symmetry_mf_tol: float = 1e-05
symmetry_tol: float = 1e-06
update(**kwargs)
values()
bath_options: dict
class vayesta.dmet.dmet.DMETResults(cluster_sizes: numpy.ndarray = None, e_corr: float = None)[source]

Bases: object

cluster_sizes: ndarray = None
e_corr: float = None
class vayesta.dmet.dmet.DMET(mf, solver='CCSD', log=None, **kwargs)[source]

Bases: Embedding

Fragment

alias of DMETFragment

class Options(store_eris: bool = True, global_frag_chempot: float | None = None, dm_with_frozen: bool = False, bath_options: dict = <factory>, solver_options: dict = <factory>, symmetry_tol: float = 1e-06, symmetry_mf_tol: float = 1e-05, screening: str | None = None, iao_minao: str = 'auto', maxiter: int = 30, charge_consistent: bool = True, max_elec_err: float = 0.0001, conv_tol: float = 1e-06, diis: bool = True, mixing_param: float = 0.5, mixing_variable: str = 'hl rdm', oneshot: bool = False)

Bases: Options

Options for DMET calculations.

asdict(deepcopy=False)
classmethod change_dict_defaults(field, **kwargs)
charge_consistent: bool = True
conv_tol: float = 1e-06
static dict_with_defaults(**kwargs)
diis: bool = True
dm_with_frozen: bool = False
get(attr, default=None)

Dictionary-like access to attributes. Allows the definition of a default value, of the attribute is not present.

classmethod get_default(field)
classmethod get_default_factory(field)
global_frag_chempot: float = None
iao_minao: str = 'auto'
items()
keys()
max_elec_err: float = 0.0001
maxiter: int = 30
mixing_param: float = 0.5
mixing_variable: str = 'hl rdm'
oneshot: bool = False
replace(**kwargs)
screening: str | None = None
store_eris: bool = True
symmetry_mf_tol: float = 1e-05
symmetry_tol: float = 1e-06
update(**kwargs)
values()
solver_options: dict
bath_options: dict
valid_solvers = ['MP2', 'CISD', 'CCSD', 'FCI', 'FCI-SPIN0', 'FCI-SPIN1']
property e_tot
kernel()[source]

Run DMET calculation.

calc_electron_number_defect(chempot, nelec_target, parent_fragments, nsym, construct_bath=True)[source]
update_vcorr(fock, curr_rdms)[source]
get_impurity_coeffs()[source]
print_results()[source]
print_clusters()[source]

Print fragments of calculations.

make_rdm1(*args, **kwargs)[source]

Make democratically partitioned one-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg, Lowdin-AO or IAO+PAO fragmentation).

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_mf (bool, optional) – Add the mean-field contribution to the density-matrix (double counting is accounted for). Is only used if partition = ‘dm’. Default: False.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm1 – Alpha- and beta one-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

tuple of (n, n) arrays

make_rdm2(*args, **kwargs)[source]

Make democratically partitioned two-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg. Lowdin-AO (SAO) or IAO+PAO fragmentation).

Energies can be evaluated as follows from the 1-DM and 2-DM:

1) Literature DMET energy: >>> e_nuc = mol.energy_nuc() >>> hcore = mf.get_hcore() >>> eris = pyscf.ao2mo.kernel(mol, mf.mo_coeff, compact=False).reshape([mol.nao]*4) >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)

…or in terms of the (approximated) cumulant: >>> vhf = mf.get_veff() >>> ddm1 = 2*dm1 - mf.make_rdm1() >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*ddm2) + np.sum(vhf*ddm1)/2

2) Improved DMET energy (same as emb.get_dmet_energy(part_cumulant=True)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the (approximated) cumulant: >>> fock = mf.get_fock() >>> ddm1 = emb.make_rdm1_demo(ao_basis=True, with_mf=False) >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=True) >>> e_tot = mf.e_tot + np.sum(fock*ddm1) + np.sum(eris*ddm2)/2

3) Improved DMET energy with true cumulant (same as emb.get_dmet_energy(part_cumulant=True, approx_cumulant=False)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=False) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the cumulant: >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=False) >>> fcorr = mf.get_fock(dm=dm1) >>> e_tot = e_nuc + np.sum((hcore+fcorr)*dm1)/2 + np.sum(eris*ddm2)/2

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_dm1 (bool, optional) – If True, the non-cumulant part of the 2-DM will be added. See also approx_cumulant. Default: False.

  • part_cumulant (bool, optional) – If False, the mixed non-cumulant contributions, “DM1(MF) * [DM1(corr)-DM1(MF)]”, will be projected symmetrically between both factors. This will return a 2-DM will evaluates to the DMET-energy of the literature. If True, only the second factor will be projected. This will generally give better expectation values and is the recommended setting. Default: True.

  • approx_cumulant (bool or int, optional) – If True, the cumulant of the 2-DM will be approximated and contain the non-cumulant contribution “delta[DM1(corr)-DM1(MF)]^2”. This value is ignored if part_cumulant is False and with_dm1 is True. Default: True.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm2 – Two-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

(n, n, n, n) array

get_corrfunc(kind, dm1=None, dm2=None, **kwargs)[source]

Get expectation values <P(A) S_z P(B) S_z>, where P(X) are projectors onto atoms X.

TODO: MPI

Parameters:

atoms (list[int] or list[list[int]], optional) – Atom indices for which the spin-spin correlation function should be evaluated. If set to None (default), all atoms of the system will be considered. If a list is given, all atom pairs formed from this list will be considered. If a list of two lists is given, the first list contains the indices of atom A, and the second of atom B, for which <Sz(A) Sz(B)> will be evaluated. This is useful in cases where one is only interested in the correlation to a small subset of atoms. Default: None

Returns:

corr – Atom projected correlation function.

Return type:

array(N,M)

brueckner_scmf(*args, **kwargs)

Decorator for Brueckner-DMET.

build_screened_eris(*args, **kwargs)

Generates renormalised coulomb interactions for use in local cluster calculations. Currently requires unrestricted system.

Parameters:
  • emb (Embedding) – Embedding instance.

  • fragments (list of vayesta.qemb.Fragment subclasses, optional) – List of fragments for the calculation, used to define local interaction spaces. If None, emb.get_fragments(sym_parent=None) is used. Default: None.

  • cderi_ov (np.array or tuple of np.array, optional.) – Cholesky-decomposed ERIs in the particle-hole basis of mf. If mf is unrestricted this should be a list of arrays corresponding to the different spin channels.

  • calc_ecorrection (bool, optional.) – Whether to calculate a nonlocal energy correction at the level of RPA

  • npoints (int, optional) – Number of points for numerical integration. Default: 48.

  • log (logging.Logger, optional) – Logger object. If None, the logger of the emb object is used. Default: None.

Returns:

  • seris_ov (list of tuples of np.array) – List of spin-dependent screened (ov|ov), for each fragment provided.

  • delta_e (float) – Delta RPA correction computed as difference between full system RPA energy and cluster correlation energies; currently only functional in CAS fragmentations.

cas_fragmentation(**kwargs)

Initialize the quantum embedding method for the use of site fragments.

change_options(**kwargs)
check_fragment_symmetry(dm1, charge_tol=1e-06, spin_tol=1e-06)
communicate_clusters()

Communicate cluster orbitals between MPI ranks.

create_invsym_fragments(center, fragments=None, unit='Ang', **kwargs)

Create inversion symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of inversion-symmetry related fragments. These will have have the attributes sym_parent and sym_op set.

Return type:

list

create_mirrorsym_fragments(axis, center, fragments=None, unit='Ang', **kwargs)

Create mirror symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of mirror-symmetry related fragments. These will have have the attributes sym_parent and sym_op set.

Return type:

list

create_rotsym_fragments(order, axis, center, fragments=None, unit='Ang', **kwargs)

Create rotationally symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of rotationally-symmetry related fragments. These will have have the attributes sym_parent and sym_op set.

Return type:

list

create_symmetric_fragments(symmetry, fragments=None, symbol=None, mf_tol=None, check_mf=True)

Add rotationally or translationally symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: self.opts.symmetry_mf_tol.

Returns:

fragments – List of T-symmetry related fragments. These will have the attributes sym_parent and sym_op set.

Return type:

list

create_transsym_fragments(translation, fragments=None, **kwargs)

Create translationally symmetric fragments.

Parameters:
  • translation (array(3) of integers) – Each element represent the number of translation vector corresponding to the a0, a1, and a2 lattice vectors of the cell.

  • mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of T-symmetry related fragments. These will have the attributes sym_parent and sym_op set.

Return type:

list

property df
property e_mf

Total mean-field energy per unit cell (not folded supercell). Note that the input unit cell itself can be a supercell, in which case e_mf refers to this cell.

property e_nuc

Nuclear-repulsion energy per unit cell (not folded supercell).

get_atomic_charges(pop)
get_average_cluster_size(average='mean')
get_cderi(mo_coeff, compact=False, blksize=None)

Get density-fitted three-center integrals in MO basis.

get_corrfunc_mf(kind, dm1=None, atoms=None, projection='sao')

dm1 in MO basis

get_dmet_elec_energy(part_cumulant=True, approx_cumulant=True)

Calculate electronic DMET energy via democratically partitioned density-matrices.

Parameters:
  • part_cumulant (bool, optional) – If True, the 2-DM cumulant will be partitioned to calculate the energy. If False, the full 2-DM will be partitioned, as it is done in most of the DMET literature. True is recommended, unless checking for agreement with literature results. Default: True.

  • approx_cumulant (bool, optional) – If True, the approximate cumulant, containing (delta 1-DM)-squared terms, is partitioned, instead of the true cumulant, if part_cumulant=True. Default: True.

Returns:

e_dmet – Electronic DMET energy.

Return type:

float

get_dmet_energy(part_cumulant=True, approx_cumulant=True, with_nuc=True, with_exxdiv=True)

Calculate DMET energy via democratically partitioned density-matrices.

Parameters:
  • part_cumulant (bool, optional) – If True, the 2-DM cumulant will be partitioned to calculate the energy. If False, the full 2-DM will be partitioned, as it is done in most of the DMET literature. True is recommended, unless checking for agreement with literature results. Default: True.

  • approx_cumulant (bool, optional) – If True, the approximate cumulant, containing (delta 1-DM)-squared terms, is partitioned, instead of the true cumulant, if part_cumulant=True. Default: True.

  • with_nuc (bool, optional) – Include nuclear-repulsion energy. Default: True.

  • with_exxdiv (bool, optional) – Include divergent exact-exchange correction. Default: True.

Returns:

e_dmet – DMET energy.

Return type:

float

get_eris_array(mo_coeff, compact=False)

Get electron-repulsion integrals in MO basis as a NumPy array.

Parameters:

mo_coeff ([list(4) of] (n(AO), n(MO)) array) – MO coefficients.

Returns:

eris – Electron-repulsion integrals in MO basis.

Return type:

(n(MO), n(MO), n(MO), n(MO)) array

get_eris_object(postscf, fock=None)

Get ERIs for post-SCF methods.

For folded PBC calculations, this folds the MO back into k-space and contracts with the k-space three-center integrals..

Parameters:

postscf (one of the following PySCF methods: MP2, CCSD, RCCSD, DFCCSD) – Post-SCF method with attribute mo_coeff set.

Returns:

eris – ERIs which can be used for the respective post-scf method.

Return type:

_ChemistsERIs

get_exxdiv()

Get divergent exact-exchange (exxdiv) energy correction and potential.

Returns:

  • e_exxdiv (float) – Divergent exact-exchange energy correction per unit cell.

  • v_exxdiv (array) – Divergent exact-exchange potential correction in AO basis.

get_fock(dm1=None, with_exxdiv=True)

Fock matrix in AO basis.

get_fock_for_bath(dm1=None, with_exxdiv=True)

Fock matrix used for bath orbitals.

get_fock_for_energy(dm1=None, with_exxdiv=True)

Fock matrix used for energy evaluation.

get_fragments(fragments=None, options=None, flags=None, **filters)

Return all fragments which obey the specified conditions.

Parameters:

**filters – List of returned fragments will be filtered according to specified keyword arguments.

Returns:

fragments – List of fragments.

Return type:

list

Examples

Only returns fragments with mpi_rank 0, 1, or 2:

>>> self.get_fragments(mpi_rank=[0,1,2])

Only returns fragments with no symmetry parent:

>>> self.get_fragments(sym_parent=None)
get_hcore()

Core Hamiltonian (kinetic energy plus nuclear-electron attraction).

get_hcore_for_energy()

Core Hamiltonian used for energy evaluation.

get_lo_coeff(local_orbitals='lowdin', minao='auto')
get_max_cluster_size()
get_mean_cluster_size()
get_min_cluster_size()
get_ovlp()

AO-overlap matrix.

get_ovlp_power(power)

get power of AO overlap matrix.

For folded calculations, this uses the k-point sampled overlap, for better performance and accuracy.

Parameters:

power (float) – Matrix power.

Returns:

spow – Matrix power of AO overlap matrix

Return type:

(n(AO), n(AO)) array

get_symmetry_child_fragments(include_parents=False)

Returns a list of all fragments, which are children to symmetry related parent fragments.

Parameters:

include_parents (bool, optional) – If true, the parent fragment of each symmetry group is prepended to each symmetry sublist.

Returns:

children – A list with the length of the number of parent fragments in the system, each element being another list containing all the children fragments of the given parent fragment. Both the outer and inner lists are ordered in the same way that the fragments appear in self.fragments.

Return type:

list of lists

get_symmetry_parent_fragments()

Returns a list of all fragments, which are parents to symmetry related child fragments.

Returns:

parents – A list of all parent fragments, ordered in the same way as they appear in self.fragments.

Return type:

list

get_veff(dm1=None, with_exxdiv=True)

Hartree-Fock Coulomb and exchange potential in AO basis.

get_veff_for_energy(dm1=None, with_exxdiv=True)

Hartree-Fock potential used for energy evaluation.

has_complete_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal and complete.

has_complete_occupied_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal and complete in the occupied space.

has_complete_virtual_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal and complete in the virtual space.

property has_df
property has_exxdiv

Correction for divergent exact-exchange potential.

has_orthonormal_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal.

iao_fragmentation(minao='auto', **kwargs)

Initialize the quantum embedding method for the use of IAO fragments.

Parameters:

minao (str, optional) – IAO reference basis set. Default: ‘auto’

iaopao_fragmentation(minao='auto', **kwargs)

Initialize the quantum embedding method for the use of IAO+PAO fragments.

Parameters:

minao (str, optional) – IAO reference basis set. Default: ‘auto’

init_mf(mf)
is_rhf = True
is_uhf = False
loop()

Loop over fragments.

make_rdm1_demo(*args, **kwargs)

Make democratically partitioned one-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg, Lowdin-AO or IAO+PAO fragmentation).

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_mf (bool, optional) – Add the mean-field contribution to the density-matrix (double counting is accounted for). Is only used if partition = ‘dm’. Default: False.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm1 – One-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

(n, n) array

make_rdm2_demo(*args, **kwargs)

Make democratically partitioned two-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg. Lowdin-AO (SAO) or IAO+PAO fragmentation).

Energies can be evaluated as follows from the 1-DM and 2-DM:

1) Literature DMET energy: >>> e_nuc = mol.energy_nuc() >>> hcore = mf.get_hcore() >>> eris = pyscf.ao2mo.kernel(mol, mf.mo_coeff, compact=False).reshape([mol.nao]*4) >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)

…or in terms of the (approximated) cumulant: >>> vhf = mf.get_veff() >>> ddm1 = 2*dm1 - mf.make_rdm1() >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*ddm2) + np.sum(vhf*ddm1)/2

2) Improved DMET energy (same as emb.get_dmet_energy(part_cumulant=True)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the (approximated) cumulant: >>> fock = mf.get_fock() >>> ddm1 = emb.make_rdm1_demo(ao_basis=True, with_mf=False) >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=True) >>> e_tot = mf.e_tot + np.sum(fock*ddm1) + np.sum(eris*ddm2)/2

3) Improved DMET energy with true cumulant (same as emb.get_dmet_energy(part_cumulant=True, approx_cumulant=False)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=False) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the cumulant: >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=False) >>> fcorr = mf.get_fock(dm=dm1) >>> e_tot = e_nuc + np.sum((hcore+fcorr)*dm1)/2 + np.sum(eris*ddm2)/2

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_dm1 (bool, optional) – If True, the non-cumulant part of the 2-DM will be added. See also approx_cumulant. Default: False.

  • part_cumulant (bool, optional) – If False, the mixed non-cumulant contributions, “DM1(MF) * [DM1(corr)-DM1(MF)]”, will be projected symmetrically between both factors. This will return a 2-DM will evaluates to the DMET-energy of the literature. If True, only the second factor will be projected. This will generally give better expectation values and is the recommended setting. Default: True.

  • approx_cumulant (bool or int, optional) – If True, the cumulant of the 2-DM will be approximated and contain the non-cumulant contribution “delta[DM1(corr)-DM1(MF)]^2”. This value is ignored if part_cumulant is False and with_dm1 is True. Default: True.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm2 – Two-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

(n, n, n, n) array

property mo_coeff

Molecular orbital coefficients.

property mo_coeff_occ

Occupied MO coefficients.

property mo_coeff_vir

Virtual MO coefficients.

property mo_energy

Molecular orbital energies.

property mo_energy_occ

Occupied MO energies.

property mo_energy_vir

Virtual MO coefficients.

property mo_occ

Molecular orbital occupations.

property mol

Mole or Cell object.

property nao

Number of atomic orbitals.

property ncells

Number of primitive cells within supercell.

property nfrag

Number of fragments.

property nmo

Total number of molecular orbitals (MOs).

property nocc

Number of occupied MOs.

property nvir

Number of virtual MOs.

optimize_chempot(cpt_init=0.0, dm1func=None, dm1kwds=None, robust=False)
property pbc_dimension
pdmet_scmf(*args, **kwargs)

Decorator for p-DMET.

pop_analysis(dm1, mo_coeff=None, local_orbitals='lowdin', minao='auto', write=True, filename=None, filemode='a', orbital_resolved=False, mpi_rank=0)
Parameters:
  • dm1 ((N, N) array) – If mo_coeff is None, AO representation is assumed.

  • local_orbitals ({'lowdin', 'mulliken', 'iao+pao'} or array) – Kind of population analysis. Default: ‘lowdin’.

Returns:

pop – Population of atomic orbitals.

Return type:

  1. array

require_complete_fragmentation(message=None, incl_virtual=True, **kwargs)
reset(*args, **kwargs)
sao_fragmentation(**kwargs)

Initialize the quantum embedding method for the use of SAO (Lowdin-AO) fragments.

set_hcore(value)
set_ovlp(value)
set_veff(value)
site_fragmentation(**kwargs)

Initialize the quantum embedding method for the use of site fragments.

spinsym = 'restricted'
update_mf(mo_coeff, mo_energy=None, veff=None)

Update underlying mean-field object.

write_population(pop, filename=None, filemode='a', orbital_resolved=False)
vayesta.dmet.dmet.RDMET

alias of DMET

vayesta.dmet.fragment

exception vayesta.dmet.fragment.DMETFragmentExit[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class vayesta.dmet.fragment.Results(fid: int = None, converged: bool = None, e_corr: float = None, wf: vayesta.core.types.wf.WaveFunction = None, pwf: vayesta.core.types.wf.WaveFunction = None, n_active: int = None, e1: float = None, e2: float = None, dm1: numpy.ndarray = None, dm2: numpy.ndarray = None)[source]

Bases: Results

n_active: int = None
e1: float = None
e2: float = None
dm1: ndarray = None
dm2: ndarray = None
converged: bool = None
e_corr: float = None
fid: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
class vayesta.dmet.fragment.DMETFragment(*args, **kwargs)[source]

Bases: Fragment

class Results(fid: int = None, converged: bool = None, e_corr: float = None, wf: vayesta.core.types.wf.WaveFunction = None, pwf: vayesta.core.types.wf.WaveFunction = None, n_active: int = None, e1: float = None, e2: float = None, dm1: numpy.ndarray = None, dm2: numpy.ndarray = None)

Bases: Results

converged: bool = None
dm1: ndarray = None
dm2: ndarray = None
e1: float = None
e2: float = None
e_corr: float = None
fid: int = None
n_active: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
kernel(solver=None, init_guess=None, eris=None, seris_ov=None, construct_bath=True, chempot=None)[source]

Run solver for a single BNO threshold.

Parameters:

solver ({'MP2', 'CISD', 'CCSD', 'CCSD(T)', 'FCI'}, optional) – Correlated solver.

Returns:

results

Return type:

DMETFragmentResults

get_solver_options(solver)[source]
get_dmet_energy_contrib(eris=None)[source]

Calculate the contribution of this fragment to the overall DMET energy.

TODO: use core.qemb.fragment.get_fragment_dmet_energy instead?

get_frag_hl_dm()[source]
get_nelectron_hl()[source]
class Flags(is_envelop: bool = True, is_secfrag: bool = False, bath_parent_fragment_id: int | NoneType = None)

Bases: object

bath_parent_fragment_id: int | None = None
is_envelop: bool = True
is_secfrag: bool = False
class Options(bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, coupled_fragments: list = <factory>, sym_factor: float = 1.0)

Bases: OptionsBase

asdict(deepcopy=False)
bath_options: dict = None
classmethod change_dict_defaults(field, **kwargs)
static dict_with_defaults(**kwargs)
dm_with_frozen: bool = None
get(attr, default=None)

Dictionary-like access to attributes. Allows the definition of a default value, of the attribute is not present.

classmethod get_default(field)
classmethod get_default_factory(field)
items()
keys()
replace(**kwargs)
screening: str | None = None
solver_options: dict = None
store_eris: bool = None
sym_factor: float = 1.0
update(**kwargs)
values()
coupled_fragments: list
add_tsymmetric_fragments(tvecs, symtol=1e-06)
Parameters:
  • tvecs (array(3) of integers) – Each element represent the number of translation vector corresponding to the a0, a1, and a2 lattice vectors of the cell.

  • symtol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of T-symmetry related fragments. These will be automatically added to base.fragments and have the attributes sym_parent and sym_op set.

Return type:

list

canonicalize_mo(*mo_coeff, fock=None, eigvals=False, sign_convention=True)

Diagonalize Fock matrix within subspace.

TODO: move to Embedding class

Parameters:
  • *mo_coeff (ndarrays) – Orbital coefficients.

  • eigenvalues (ndarray) – Return MO energies of canonicalized orbitals.

Returns:

  • mo_canon (ndarray) – Canonicalized orbital coefficients.

  • rot (ndarray) – Rotation matrix: np.dot(mo_coeff, rot) = mo_canon.

change_options(**kwargs)
property cluster
copy(fid=None, name=None, **kwargs)

Create copy of fragment, without adding it to the fragments list.

couple_to_fragment(frag)
couple_to_fragments(frags)
diagonalize_cluster_dm(*mo_coeff, dm1=None, norm=2, tol=0.0001)

Diagonalize cluster (fragment+bath) DM to get fully occupied and virtual orbitals.

Parameters:
  • *mo_coeff (array or list of arrays) – Orbital coefficients. If multiple are given, they will be stacked along their second dimension.

  • dm1 (array, optional) – Mean-field density matrix, used to separate occupied and virtual cluster orbitals. If None, self.mf.make_rdm1() is used. Default: None.

  • tol (float, optional) – If set, check that all eigenvalues of the cluster DM are close to 0 or 2, with the tolerance given by tol. Default= 1e-4.

Returns:

  • c_cluster_occ ((n(AO), n(occ cluster)) array) – Occupied cluster orbital coefficients.

  • c_cluster_vir ((n(AO), n(vir cluster)) array) – Virtual cluster orbital coefficients.

get_coeff_env()
get_fragment_dmet_energy(dm1=None, dm2=None, h1e_eff=None, eris=None, part_cumulant=True, approx_cumulant=True)

Get fragment contribution to whole system DMET energy from cluster DMs.

After fragment summation, the nuclear-nuclear repulsion must be added to get the total energy!

Parameters:
  • dm1 (array, optional) – Cluster one-electron reduced density-matrix in cluster basis. If None, self.results.dm1 is used. Default: None.

  • dm2 (array, optional) – Cluster two-electron reduced density-matrix in cluster basis. If None, self.results.dm2 is used. Default: None.

  • eris (array, optional) – Cluster electron-repulsion integrals in cluster basis. If None, the ERIs are reevaluated. Default: None.

  • part_cumulant (bool, optional) – If True, the 2-DM cumulant will be partitioned to calculate the energy. If False, the full 2-DM will be partitioned, as it is done in most of the DMET literature. True is recommended, unless checking for agreement with literature results. Default: True.

  • approx_cumulant (bool, optional) – If True, the approximate cumulant, containing (delta 1-DM)-squared terms, is partitioned, instead of the true cumulant, if part_cumulant=True. Default: True.

Returns:

e_dmet – Electronic fragment DMET energy.

Return type:

float

get_fragment_mf_energy()

Calculate the part of the mean-field energy associated with the fragment.

Does not include nuclear-nuclear repulsion!

get_fragment_mo_energy(c_active=None, fock=None)

Returns approximate MO energies, using the the diagonal of the Fock matrix.

Parameters:
  • c_active (array, optional) –

  • fock (array, optional) –

get_fragment_projector(coeff, c_proj=None, inverse=False)

Projector for one index of amplitudes local energy expression.

Cost: N^2 if O(1) coeffs , N^3 if O(N) coeffs

Parameters:
  • coeff (ndarray, shape(n(AO), N)) – Occupied or virtual orbital coefficients.

  • inverse (bool, optional) – Return 1-p instead. Default: False.

Returns:

p – Projection matrix.

Return type:

(n, n) array

get_fragments_with_overlap(tol=1e-08, **kwargs)

Get list of fragments which overlap both in occupied and virtual space.

get_mo_occupation(*mo_coeff, dm1=None)

Get mean-field occupation numbers (diagonal of 1-RDM) of orbitals.

Parameters:

mo_coeff (ndarray, shape(N, M)) – Orbital coefficients.

Returns:

occup – Occupation numbers of orbitals.

Return type:

ndarray, shape(M)

get_overlap(key)

Get overlap between cluster orbitals, fragment orbitals, or MOs.

The return value is cached but not copied; do not modify the array in place without creating a copy!

Examples: >>> s = self.get_overlap(‘cluster|mo’) >>> s = self.get_overlap(‘cluster|frag’) >>> s = self.get_overlap(‘mo[occ]|cluster[occ]’) >>> s = self.get_overlap(‘mo[vir]|cluster[vir]’)

get_symmetry_children(maxgen=None, **filters)
get_symmetry_error(frag, dm1=None)

Get translational symmetry error between two fragments.

get_symmetry_generations(maxgen=None, **filters)
get_symmetry_operation()
get_symmetry_parent()
get_symmetry_tree(maxgen=None, **filters)

Returns a recursive tree:

[(x, [children of x]), (y, [children of y]), …]

property id_name

Use this whenever a unique name is needed (for example to open a separate file for each fragment).

log_info()
loop_symmetry_children(arrays=None, axes=None, symtree=None, maxgen=None, include_self=False)

Loop over all symmetry related fragments, including children of children, etc.

Parameters:
  • arrays (ndarray or list[ndarray], optional) – If arrays are passed, the symmetry operation of each symmetry related fragment will be applied to this array along the axis given in axes.

  • axes (list[int], optional) – List of axes, along which the symmetry operation is applied for each element of arrays. If None, the first axis will be used.

make_bath()
make_cluster()
make_counterpoise_mol(rmax, nimages=1, unit='A', **kwargs)

Make molecule object for counterposise calculation.

WARNING: This has only been tested for periodic systems so far!

Parameters:
  • rmax (float) – All atom centers within range rmax are added as ghost-atoms in the counterpoise correction.

  • nimages (int, optional) – Number of neighboring unit cell in each spatial direction. Has no effect in open boundary calculations. Default: 5.

  • unit (['A', 'B']) – Unit for rmax, either Angstrom (A) or Bohr (B).

  • **kwargs – Additional keyword arguments for returned PySCF Mole/Cell object.

Returns:

mol_cp – Mole or Cell object with periodic boundary conditions removed and with ghost atoms added depending on rmax and nimages.

Return type:

pyscf.gto.Mole or pyscf.pbc.gto.Cell

make_tsymmetric_fragments(*args, **kwargs)
property mf
property mol
property n_frag

Number of fragment orbitals.

property n_symmetry_children

Includes children of children, etc.

property nelectron

Number of mean-field electrons.

plot3d(filename, gridsize=(100, 100, 100), **kwargs)

Write cube density data of fragment orbitals to file.

pop_analysis(cluster=None, dm1=None, **kwargs)
project_ref_orbitals(c_ref, c)

Project reference orbitals into available space in new geometry.

The projected orbitals will be ordered according to their eigenvalues within the space.

Parameters:
  • c (ndarray) – Orbital coefficients.

  • c_ref (ndarray) – Orbital coefficients of reference orbitals.

reset(reset_bath=True, reset_cluster=True, reset_eris=True)
property results
property symmetry_factor

Includes children of children, etc.

trimmed_name(length=10, add_dots=True)

Fragment name trimmed to a given maximum length.

vayesta.dmet.pdmet

vayesta.dmet.pdmet.update_mf(mf, dm1, canonicalize=True, inplace=False, damping=0.0, diis=None)[source]

p-DMET mean-field update.

vayesta.dmet.sdp_sc

vayesta.dmet.sdp_sc.perform_SDP_fit(nelec, fock, impurity_projectors, target_rdms, ovlp, log)[source]

Given all required information about the system, generate the correlation potential reproducing the local DM via a semidefinite program, as described in doi.org/10.1103/PhysRevB.102.085123. Initially use SCS solver, though others (eg. MOSEK) could be used if this runs into issues.

Note that initially we will only have a single impurity in each symmetry class, until the fragmentation routines are updated to include symmetry.

Parameters:
  • nelec (integer) – Number of electrons in the system.

  • fock (np.array) – Fock matrix of the full system, in the spatial orbital basis.

  • impurity_projectors (list of list of np.array) – For each class of symmetry-equivalent impurities, projection from the full spatial orbital basis to the impurity set.

  • target_rdms (list of np.array) – Impurity-local one-body density matrices for each class of impurities.

  • ovlp (np.array) – Overlap matrix of the AOs, so we can implicitly transform into the PAO basis.

vayesta.dmet.udmet

class vayesta.dmet.udmet.UDMET(mf, solver='CCSD', log=None, **kwargs)[source]

Bases: UEmbedding, DMET

Fragment

alias of UDMETFragment

update_vcorr(fock, curr_rdms)[source]
get_impurity_coeffs()[source]
class Options(store_eris: bool = True, global_frag_chempot: float | None = None, dm_with_frozen: bool = False, bath_options: dict = <factory>, solver_options: dict = <factory>, symmetry_tol: float = 1e-06, symmetry_mf_tol: float = 1e-05, screening: str | None = None, iao_minao: str = 'auto', maxiter: int = 30, charge_consistent: bool = True, max_elec_err: float = 0.0001, conv_tol: float = 1e-06, diis: bool = True, mixing_param: float = 0.5, mixing_variable: str = 'hl rdm', oneshot: bool = False)

Bases: Options

Options for DMET calculations.

asdict(deepcopy=False)
classmethod change_dict_defaults(field, **kwargs)
charge_consistent: bool = True
conv_tol: float = 1e-06
static dict_with_defaults(**kwargs)
diis: bool = True
dm_with_frozen: bool = False
get(attr, default=None)

Dictionary-like access to attributes. Allows the definition of a default value, of the attribute is not present.

classmethod get_default(field)
classmethod get_default_factory(field)
global_frag_chempot: float = None
iao_minao: str = 'auto'
items()
keys()
max_elec_err: float = 0.0001
maxiter: int = 30
mixing_param: float = 0.5
mixing_variable: str = 'hl rdm'
oneshot: bool = False
replace(**kwargs)
screening: str | None = None
store_eris: bool = True
symmetry_mf_tol: float = 1e-05
symmetry_tol: float = 1e-06
update(**kwargs)
values()
solver_options: dict
bath_options: dict
brueckner_scmf(*args, **kwargs)

Decorator for Brueckner-DMET.

build_screened_eris(*args, **kwargs)

Generates renormalised coulomb interactions for use in local cluster calculations. Currently requires unrestricted system.

Parameters:
  • emb (Embedding) – Embedding instance.

  • fragments (list of vayesta.qemb.Fragment subclasses, optional) – List of fragments for the calculation, used to define local interaction spaces. If None, emb.get_fragments(sym_parent=None) is used. Default: None.

  • cderi_ov (np.array or tuple of np.array, optional.) – Cholesky-decomposed ERIs in the particle-hole basis of mf. If mf is unrestricted this should be a list of arrays corresponding to the different spin channels.

  • calc_ecorrection (bool, optional.) – Whether to calculate a nonlocal energy correction at the level of RPA

  • npoints (int, optional) – Number of points for numerical integration. Default: 48.

  • log (logging.Logger, optional) – Logger object. If None, the logger of the emb object is used. Default: None.

Returns:

  • seris_ov (list of tuples of np.array) – List of spin-dependent screened (ov|ov), for each fragment provided.

  • delta_e (float) – Delta RPA correction computed as difference between full system RPA energy and cluster correlation energies; currently only functional in CAS fragmentations.

calc_electron_number_defect(chempot, nelec_target, parent_fragments, nsym, construct_bath=True)
cas_fragmentation(**kwargs)

Initialize the quantum embedding method for the use of site fragments.

change_options(**kwargs)
check_fragment_symmetry(dm1, charge_tol=1e-06, spin_tol=1e-06)
communicate_clusters()

Communicate cluster orbitals between MPI ranks.

create_invsym_fragments(center, fragments=None, unit='Ang', **kwargs)

Create inversion symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of inversion-symmetry related fragments. These will have have the attributes sym_parent and sym_op set.

Return type:

list

create_mirrorsym_fragments(axis, center, fragments=None, unit='Ang', **kwargs)

Create mirror symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of mirror-symmetry related fragments. These will have have the attributes sym_parent and sym_op set.

Return type:

list

create_rotsym_fragments(order, axis, center, fragments=None, unit='Ang', **kwargs)

Create rotationally symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of rotationally-symmetry related fragments. These will have have the attributes sym_parent and sym_op set.

Return type:

list

create_symmetric_fragments(symmetry, fragments=None, symbol=None, mf_tol=None, check_mf=True)

Add rotationally or translationally symmetric fragments.

Parameters:

mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: self.opts.symmetry_mf_tol.

Returns:

fragments – List of T-symmetry related fragments. These will have the attributes sym_parent and sym_op set.

Return type:

list

create_transsym_fragments(translation, fragments=None, **kwargs)

Create translationally symmetric fragments.

Parameters:
  • translation (array(3) of integers) – Each element represent the number of translation vector corresponding to the a0, a1, and a2 lattice vectors of the cell.

  • mf_tol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of T-symmetry related fragments. These will have the attributes sym_parent and sym_op set.

Return type:

list

property df
property e_mf

Total mean-field energy per unit cell (not folded supercell). Note that the input unit cell itself can be a supercell, in which case e_mf refers to this cell.

property e_nuc

Nuclear-repulsion energy per unit cell (not folded supercell).

property e_tot
get_atomic_charges(pop)
get_average_cluster_size(average='mean')
get_cderi(mo_coeff, compact=False, blksize=None)

Get density-fitted three-center integrals in MO basis.

get_corrfunc(kind, dm1=None, dm2=None, atoms=None, projection='sao', dm2_with_dm1=None, use_symmetry=True)

Get expectation values <P(A) S_z P(B) S_z>, where P(X) are projectors onto atoms X.

TODO: MPI

Parameters:

atoms (list[int] or list[list[int]], optional) – Atom indices for which the spin-spin correlation function should be evaluated. If set to None (default), all atoms of the system will be considered. If a list is given, all atom pairs formed from this list will be considered. If a list of two lists is given, the first list contains the indices of atom A, and the second of atom B, for which <Sz(A) Sz(B)> will be evaluated. This is useful in cases where one is only interested in the correlation to a small subset of atoms. Default: None

Returns:

corr – Atom projected correlation function.

Return type:

array(N,M)

get_corrfunc_mf(kind, dm1=None, atoms=None, projection='sao')

dm1 in MO basis

get_dmet_elec_energy(part_cumulant=True, approx_cumulant=True)

Calculate electronic DMET energy via democratically partitioned density-matrices.

Parameters:
  • part_cumulant (bool, optional) – If True, the 2-DM cumulant will be partitioned to calculate the energy. If False, the full 2-DM will be partitioned, as it is done in most of the DMET literature. True is recommended, unless checking for agreement with literature results. Default: True.

  • approx_cumulant (bool, optional) – If True, the approximate cumulant, containing (delta 1-DM)-squared terms, is partitioned, instead of the true cumulant, if part_cumulant=True. Default: True.

Returns:

e_dmet – Electronic DMET energy.

Return type:

float

get_dmet_energy(part_cumulant=True, approx_cumulant=True, with_nuc=True, with_exxdiv=True)

Calculate DMET energy via democratically partitioned density-matrices.

Parameters:
  • part_cumulant (bool, optional) – If True, the 2-DM cumulant will be partitioned to calculate the energy. If False, the full 2-DM will be partitioned, as it is done in most of the DMET literature. True is recommended, unless checking for agreement with literature results. Default: True.

  • approx_cumulant (bool, optional) – If True, the approximate cumulant, containing (delta 1-DM)-squared terms, is partitioned, instead of the true cumulant, if part_cumulant=True. Default: True.

  • with_nuc (bool, optional) – Include nuclear-repulsion energy. Default: True.

  • with_exxdiv (bool, optional) – Include divergent exact-exchange correction. Default: True.

Returns:

e_dmet – DMET energy.

Return type:

float

get_eris_array(mo_coeff, compact=False)

Get electron-repulsion integrals in MO basis as a NumPy array.

Parameters:

mo_coeff ([list(4) of] (n(AO), n(MO)) array) – MO coefficients.

Returns:

eris – Electron-repulsion integrals in MO basis.

Return type:

(n(MO), n(MO), n(MO), n(MO)) array

get_eris_array_uhf(mo_coeff, mo_coeff2=None, compact=False)

Get electron-repulsion integrals in MO basis as a NumPy array.

Parameters:

mo_coeff (tuple(2) of (n(AO), n(MO)) array) – MO coefficients.

Returns:

Electron-repulsion integrals in MO basis.

Return type:

eris

get_eris_object(postscf, fock=None)

Get ERIs for post-SCF methods.

For folded PBC calculations, this folds the MO back into k-space and contracts with the k-space three-center integrals..

Parameters:

postscf (one of the following post-SCF methods: MP2, CCSD, RCCSD, DFCCSD) – Post-SCF method with attribute mo_coeff set.

Returns:

eris – ERIs which can be used for the respective post-SCF method.

Return type:

_ChemistsERIs

get_exxdiv()

Get divergent exact-exchange (exxdiv) energy correction and potential.

Returns:

  • e_exxdiv (float) – Divergent exact-exchange energy correction per unit cell.

  • v_exxdiv (array) – Divergent exact-exchange potential correction in AO basis.

get_fock(dm1=None, with_exxdiv=True)

Fock matrix in AO basis.

get_fock_for_bath(dm1=None, with_exxdiv=True)

Fock matrix used for bath orbitals.

get_fock_for_energy(dm1=None, with_exxdiv=True)

Fock matrix used for energy evaluation.

get_fragments(fragments=None, options=None, flags=None, **filters)

Return all fragments which obey the specified conditions.

Parameters:

**filters – List of returned fragments will be filtered according to specified keyword arguments.

Returns:

fragments – List of fragments.

Return type:

list

Examples

Only returns fragments with mpi_rank 0, 1, or 2:

>>> self.get_fragments(mpi_rank=[0,1,2])

Only returns fragments with no symmetry parent:

>>> self.get_fragments(sym_parent=None)
get_hcore()

Core Hamiltonian (kinetic energy plus nuclear-electron attraction).

get_hcore_for_energy()

Core Hamiltonian used for energy evaluation.

get_lo_coeff(local_orbitals='lowdin', minao='auto')
get_max_cluster_size()
get_mean_cluster_size()
get_min_cluster_size()
get_ovlp()

AO-overlap matrix.

get_ovlp_power(power)

get power of AO overlap matrix.

For folded calculations, this uses the k-point sampled overlap, for better performance and accuracy.

Parameters:

power (float) – Matrix power.

Returns:

spow – Matrix power of AO overlap matrix

Return type:

(n(AO), n(AO)) array

get_symmetry_child_fragments(include_parents=False)

Returns a list of all fragments, which are children to symmetry related parent fragments.

Parameters:

include_parents (bool, optional) – If true, the parent fragment of each symmetry group is prepended to each symmetry sublist.

Returns:

children – A list with the length of the number of parent fragments in the system, each element being another list containing all the children fragments of the given parent fragment. Both the outer and inner lists are ordered in the same way that the fragments appear in self.fragments.

Return type:

list of lists

get_symmetry_parent_fragments()

Returns a list of all fragments, which are parents to symmetry related child fragments.

Returns:

parents – A list of all parent fragments, ordered in the same way as they appear in self.fragments.

Return type:

list

get_veff(dm1=None, with_exxdiv=True)

Hartree-Fock Coulomb and exchange potential in AO basis.

get_veff_for_energy(dm1=None, with_exxdiv=True)

Hartree-Fock potential used for energy evaluation.

has_complete_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal and complete.

has_complete_occupied_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal and complete in the occupied space.

has_complete_virtual_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal and complete in the virtual space.

property has_df
property has_exxdiv

Correction for divergent exact-exchange potential.

has_orthonormal_fragmentation(**kwargs)

Check if union of fragment spaces is orthonormal.

iao_fragmentation(minao='auto', **kwargs)

Initialize the quantum embedding method for the use of IAO fragments.

Parameters:

minao (str, optional) – IAO reference basis set. Default: ‘auto’

iaopao_fragmentation(minao='auto', **kwargs)

Initialize the quantum embedding method for the use of IAO+PAO fragments.

Parameters:

minao (str, optional) – IAO reference basis set. Default: ‘auto’

init_mf(mf)
is_rhf = False
is_uhf = True
kernel()

Run DMET calculation.

loop()

Loop over fragments.

make_rdm1(*args, **kwargs)

Make democratically partitioned one-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg, Lowdin-AO or IAO+PAO fragmentation).

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_mf (bool, optional) – Add the mean-field contribution to the density-matrix (double counting is accounted for). Is only used if partition = ‘dm’. Default: False.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm1 – Alpha- and beta one-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

tuple of (n, n) arrays

make_rdm1_demo(*args, **kwargs)

Make democratically partitioned one-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg, Lowdin-AO or IAO+PAO fragmentation).

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_mf (bool, optional) – Add the mean-field contribution to the density-matrix (double counting is accounted for). Is only used if partition = ‘dm’. Default: False.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm1 – Alpha- and beta one-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

tuple of (n, n) arrays

make_rdm2(*args, **kwargs)

Make democratically partitioned two-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg. Lowdin-AO (SAO) or IAO+PAO fragmentation).

Energies can be evaluated as follows from the 1-DM and 2-DM:

1) Literature DMET energy: >>> e_nuc = mol.energy_nuc() >>> hcore = mf.get_hcore() >>> eris = pyscf.ao2mo.kernel(mol, mf.mo_coeff, compact=False).reshape([mol.nao]*4) >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)

…or in terms of the (approximated) cumulant: >>> vhf = mf.get_veff() >>> ddm1 = 2*dm1 - mf.make_rdm1() >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*ddm2) + np.sum(vhf*ddm1)/2

2) Improved DMET energy (same as emb.get_dmet_energy(part_cumulant=True)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the (approximated) cumulant: >>> fock = mf.get_fock() >>> ddm1 = emb.make_rdm1_demo(ao_basis=True, with_mf=False) >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=True) >>> e_tot = mf.e_tot + np.sum(fock*ddm1) + np.sum(eris*ddm2)/2

3) Improved DMET energy with true cumulant (same as emb.get_dmet_energy(part_cumulant=True, approx_cumulant=False)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=False) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the cumulant: >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=False) >>> fcorr = mf.get_fock(dm=dm1) >>> e_tot = e_nuc + np.sum((hcore+fcorr)*dm1)/2 + np.sum(eris*ddm2)/2

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_dm1 (bool, optional) – If True, the non-cumulant part of the 2-DM will be added. See also approx_cumulant. Default: False.

  • part_cumulant (bool, optional) – If False, the mixed non-cumulant contributions, “DM1(MF) * [DM1(corr)-DM1(MF)]”, will be projected symmetrically between both factors. This will return a 2-DM will evaluates to the DMET-energy of the literature. If True, only the second factor will be projected. This will generally give better expectation values and is the recommended setting. Default: True.

  • approx_cumulant (bool or int, optional) – If True, the cumulant of the 2-DM will be approximated and contain the non-cumulant contribution “delta[DM1(corr)-DM1(MF)]^2”. This value is ignored if part_cumulant is False and with_dm1 is True. Default: True.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm2 – Two-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

(n, n, n, n) array

make_rdm2_demo(*args, **kwargs)

Make democratically partitioned two-particle reduced density-matrix from fragment calculations.

Warning: A democratically partitioned DM is only expected to yield reasonable results for full fragmentations (eg. Lowdin-AO (SAO) or IAO+PAO fragmentation).

Energies can be evaluated as follows from the 1-DM and 2-DM:

1) Literature DMET energy: >>> e_nuc = mol.energy_nuc() >>> hcore = mf.get_hcore() >>> eris = pyscf.ao2mo.kernel(mol, mf.mo_coeff, compact=False).reshape([mol.nao]*4) >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)

…or in terms of the (approximated) cumulant: >>> vhf = mf.get_veff() >>> ddm1 = 2*dm1 - mf.make_rdm1() >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=False, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*ddm2) + np.sum(vhf*ddm1)/2

2) Improved DMET energy (same as emb.get_dmet_energy(part_cumulant=True)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=True) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the (approximated) cumulant: >>> fock = mf.get_fock() >>> ddm1 = emb.make_rdm1_demo(ao_basis=True, with_mf=False) >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=True) >>> e_tot = mf.e_tot + np.sum(fock*ddm1) + np.sum(eris*ddm2)/2

3) Improved DMET energy with true cumulant (same as emb.get_dmet_energy(part_cumulant=True, approx_cumulant=False)): >>> dm1 = emb.make_rdm1_demo(ao_basis=True) >>> dm2 = emb.make_rdm2_demo(ao_basis=True, part_cumulant=True, approx_cumulant=False) >>> e_tot = e_nuc + np.sum(hcore*dm1) + np.sum(eris*dm2)/2

…or in terms of the cumulant: >>> ddm2 = emb.make_rdm2_demo(ao_basis=True, with_dm1=False, part_cumulant=True, approx_cumulant=False) >>> fcorr = mf.get_fock(dm=dm1) >>> e_tot = e_nuc + np.sum((hcore+fcorr)*dm1)/2 + np.sum(eris*ddm2)/2

Parameters:
  • ao_basis (bool, optional) – Return the density-matrix in the AO basis. Default: False.

  • with_dm1 (bool, optional) – If True, the non-cumulant part of the 2-DM will be added. See also approx_cumulant. Default: False.

  • part_cumulant (bool, optional) – If False, the mixed non-cumulant contributions, “DM1(MF) * [DM1(corr)-DM1(MF)]”, will be projected symmetrically between both factors. This will return a 2-DM will evaluates to the DMET-energy of the literature. If True, only the second factor will be projected. This will generally give better expectation values and is the recommended setting. Default: True.

  • approx_cumulant (bool or int, optional) – If True, the cumulant of the 2-DM will be approximated and contain the non-cumulant contribution “delta[DM1(corr)-DM1(MF)]^2”. This value is ignored if part_cumulant is False and with_dm1 is True. Default: True.

  • symmetrize (bool, optional) – Symmetrize the density-matrix at the end of the calculation. Default: True.

Returns:

dm2 – Two-particle reduced density matrix in AO (if ao_basis=True) or MO basis (default).

Return type:

(n, n, n, n) array

property mo_coeff

Molecular orbital coefficients.

property mo_coeff_occ

Occupied MO coefficients.

property mo_coeff_vir

Virtual MO coefficients.

property mo_energy

Molecular orbital energies.

property mo_energy_occ

Occupied MO energies.

property mo_energy_vir

Virtual MO coefficients.

property mo_occ

Molecular orbital occupations.

property mol

Mole or Cell object.

property nao

Number of atomic orbitals.

property ncells

Number of primitive cells within supercell.

property nfrag

Number of fragments.

property nmo

Total number of molecular orbitals (MOs).

property nocc

Number of occupied MOs.

property nvir

Number of virtual MOs.

optimize_chempot(cpt_init=0.0, dm1func=None, dm1kwds=None, robust=False)
property pbc_dimension
pdmet_scmf(*args, **kwargs)

Decorator for p-DMET.

pop_analysis(dm1, mo_coeff=None, local_orbitals='lowdin', write=True, minao='auto', mpi_rank=0, **kwargs)
Parameters:
  • dm1 ((N, N) array) – If mo_coeff is None, AO representation is assumed.

  • local_orbitals ({'lowdin', 'mulliken', 'iao+pao'} or array) – Kind of population analysis. Default: ‘lowdin’.

Returns:

pop – Population of atomic orbitals.

Return type:

  1. array

print_clusters()

Print fragments of calculations.

print_results()
require_complete_fragmentation(message=None, incl_virtual=True, **kwargs)
reset(*args, **kwargs)
sao_fragmentation(**kwargs)

Initialize the quantum embedding method for the use of SAO (Lowdin-AO) fragments.

set_hcore(value)
set_ovlp(value)
set_veff(value)
site_fragmentation(**kwargs)

Initialize the quantum embedding method for the use of site fragments.

spinsym = 'unrestricted'
update_mf(mo_coeff, mo_energy=None, veff=None)

Update underlying mean-field object.

valid_solvers = ['MP2', 'CISD', 'CCSD', 'FCI', 'FCI-SPIN0', 'FCI-SPIN1']
write_population(pop, filename=None, filemode='a', orbital_resolved=False)

vayesta.dmet.ufragment

class vayesta.dmet.ufragment.UDMETFragment(*args, **kwargs)[source]

Bases: UFragment, DMETFragment

set_cas(*args, **kwargs)[source]
get_frag_hl_dm()[source]
get_nelectron_hl()[source]
get_dmet_energy_contrib(eris=None)[source]

Calculate the contribution of this fragment to the overall DMET energy.

class Flags(is_envelop: bool = True, is_secfrag: bool = False, bath_parent_fragment_id: int | NoneType = None)

Bases: object

bath_parent_fragment_id: int | None = None
is_envelop: bool = True
is_secfrag: bool = False
class Options(bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, coupled_fragments: list = <factory>, sym_factor: float = 1.0)

Bases: OptionsBase

asdict(deepcopy=False)
bath_options: dict = None
classmethod change_dict_defaults(field, **kwargs)
static dict_with_defaults(**kwargs)
dm_with_frozen: bool = None
get(attr, default=None)

Dictionary-like access to attributes. Allows the definition of a default value, of the attribute is not present.

classmethod get_default(field)
classmethod get_default_factory(field)
items()
keys()
replace(**kwargs)
screening: str | None = None
solver_options: dict = None
store_eris: bool = None
sym_factor: float = 1.0
update(**kwargs)
values()
coupled_fragments: list
class Results(fid: int = None, converged: bool = None, e_corr: float = None, wf: vayesta.core.types.wf.WaveFunction = None, pwf: vayesta.core.types.wf.WaveFunction = None, n_active: int = None, e1: float = None, e2: float = None, dm1: numpy.ndarray = None, dm2: numpy.ndarray = None)

Bases: Results

converged: bool = None
dm1: ndarray = None
dm2: ndarray = None
e1: float = None
e2: float = None
e_corr: float = None
fid: int = None
n_active: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
add_tsymmetric_fragments(tvecs, symtol=1e-06)
Parameters:
  • tvecs (array(3) of integers) – Each element represent the number of translation vector corresponding to the a0, a1, and a2 lattice vectors of the cell.

  • symtol (float, optional) – Tolerance for the error of the mean-field density matrix between symmetry related fragments. If the largest absolute difference in the density-matrix is above this value, and exception will be raised. Default: 1e-6.

Returns:

fragments – List of T-symmetry related fragments. These will be automatically added to base.fragments and have the attributes sym_parent and sym_op set.

Return type:

list

canonicalize_mo(*mo_coeff, fock=None, **kwargs)

Diagonalize Fock matrix within subspace.

Parameters:
  • *mo_coeff (ndarrays) – Orbital coefficients.

  • eigenvalues (ndarray) – Return MO energies of canonicalized orbitals.

Returns:

  • mo_canon (ndarray) – Canonicalized orbital coefficients.

  • rot (ndarray) – Rotation matrix: np.dot(mo_coeff, rot) = mo_canon.

change_options(**kwargs)
property cluster
copy(fid=None, name=None, **kwargs)

Create copy of fragment, without adding it to the fragments list.

couple_to_fragment(frag)
couple_to_fragments(frags)
diagonalize_cluster_dm(*mo_coeff, dm1=None, norm=1, **kwargs)

Diagonalize cluster (fragment+bath) DM to get fully occupied and virtual orbitals.

Parameters:
  • *mo_coeff (ndarrays) – Orbital coefficients.

  • tol (float, optional) – If set, check that all eigenvalues of the cluster DM are close to 0 or 1, with the tolerance given by tol. Default= 1e-4.

Returns:

  • c_cluster_occ (ndarray) – Occupied cluster orbitals.

  • c_cluster_vir (ndarray) – Virtual cluster orbitals.

get_coeff_env()
get_fragment_dmet_energy(dm1=None, dm2=None, h1e_eff=None, eris=None, part_cumulant=True, approx_cumulant=True)

Get fragment contribution to whole system DMET energy from cluster DMs.

After fragment summation, the nuclear-nuclear repulsion must be added to get the total energy!

Parameters:
  • dm1 (array, optional) – Cluster one-electron reduced density-matrix in cluster basis. If None, self.results.dm1 is used. Default: None.

  • dm2 (array, optional) – Cluster two-electron reduced density-matrix in cluster basis. If None, self.results.dm2 is used. Default: None.

  • eris (array, optional) – Cluster electron-repulsion integrals in cluster basis. If None, the ERIs are reevaluated. Default: None.

  • part_cumulant (bool, optional) – If True, the 2-DM cumulant will be partitioned to calculate the energy. If False, the full 2-DM will be partitioned, as it is done in most of the DMET literature. True is recommended, unless checking for agreement with literature results. Default: True.

  • approx_cumulant (bool, optional) – If True, the approximate cumulant, containing (delta 1-DM)-squared terms, is partitioned, instead of the true cumulant, if part_cumulant=True. Default: True.

Returns:

e_dmet – Electronic fragment DMET energy.

Return type:

float

get_fragment_mf_energy()

Calculate the part of the mean-field energy associated with the fragment.

Does not include nuclear-nuclear repulsion!

get_fragment_mo_energy(c_active=None, fock=None)

Returns approximate MO energies, using the the diagonal of the Fock matrix.

Parameters:
  • c_active (array, optional) –

  • fock (array, optional) –

get_fragment_projector(coeff, c_proj=None, **kwargs)

Projector for one index of amplitudes local energy expression.

Cost: N^2 if O(1) coeffs , N^3 if O(N) coeffs

Parameters:
  • coeff (ndarray, shape(n(AO), N)) – Occupied or virtual orbital coefficients.

  • inverse (bool, optional) – Return 1-p instead. Default: False.

Returns:

p – Projection matrix.

Return type:

(n, n) array

get_fragments_with_overlap(tol=1e-08, **kwargs)

Get list of fragments which overlap both in occupied and virtual space.

get_mo_occupation(*mo_coeff, dm1=None, **kwargs)

Get mean-field occupation numbers (diagonal of 1-RDM) of orbitals.

Parameters:

mo_coeff (ndarray, shape(N, M)) – Orbital coefficients.

Returns:

occ – Occupation numbers of orbitals.

Return type:

ndarray, shape(M)

get_overlap(key)

Get overlap between cluster orbitals, fragment orbitals, or MOs.

The return value is cached but not copied; do not modify the array in place without creating a copy!

Examples: >>> s = self.get_overlap(‘cluster|mo’) >>> s = self.get_overlap(‘cluster|frag’) >>> s = self.get_overlap(‘mo[occ]|cluster[occ]’) >>> s = self.get_overlap(‘mo[vir]|cluster[vir]’)

get_solver_options(solver)
get_symmetry_children(maxgen=None, **filters)
get_symmetry_error(frag, dm1=None)

Get translational symmetry error between two fragments.

get_symmetry_generations(maxgen=None, **filters)
get_symmetry_operation()
get_symmetry_parent()
get_symmetry_tree(maxgen=None, **filters)

Returns a recursive tree:

[(x, [children of x]), (y, [children of y]), …]

property id_name

Use this whenever a unique name is needed (for example to open a separate file for each fragment).

kernel(solver=None, init_guess=None, eris=None, seris_ov=None, construct_bath=True, chempot=None)

Run solver for a single BNO threshold.

Parameters:

solver ({'MP2', 'CISD', 'CCSD', 'CCSD(T)', 'FCI'}, optional) – Correlated solver.

Returns:

results

Return type:

DMETFragmentResults

log_info()
loop_symmetry_children(arrays=None, axes=None, symtree=None, maxgen=None, include_self=False)

Loop over all symmetry related fragments, including children of children, etc.

Parameters:
  • arrays (ndarray or list[ndarray], optional) – If arrays are passed, the symmetry operation of each symmetry related fragment will be applied to this array along the axis given in axes.

  • axes (list[int], optional) – List of axes, along which the symmetry operation is applied for each element of arrays. If None, the first axis will be used.

make_bath()
make_cluster()
make_counterpoise_mol(rmax, nimages=1, unit='A', **kwargs)

Make molecule object for counterposise calculation.

WARNING: This has only been tested for periodic systems so far!

Parameters:
  • rmax (float) – All atom centers within range rmax are added as ghost-atoms in the counterpoise correction.

  • nimages (int, optional) – Number of neighboring unit cell in each spatial direction. Has no effect in open boundary calculations. Default: 5.

  • unit (['A', 'B']) – Unit for rmax, either Angstrom (A) or Bohr (B).

  • **kwargs – Additional keyword arguments for returned PySCF Mole/Cell object.

Returns:

mol_cp – Mole or Cell object with periodic boundary conditions removed and with ghost atoms added depending on rmax and nimages.

Return type:

pyscf.gto.Mole or pyscf.pbc.gto.Cell

make_tsymmetric_fragments(*args, **kwargs)
property mf
property mol
property n_frag

Number of fragment orbitals.

property n_symmetry_children

Includes children of children, etc.

property nelectron

Number of mean-field electrons.

plot3d(filename, gridsize=(100, 100, 100), **kwargs)

Write cube density data of fragment orbitals to file.

pop_analysis(cluster=None, dm1=None, **kwargs)
project_ref_orbitals(c_ref, c)

Project reference orbitals into available space in new geometry.

The projected orbitals will be ordered according to their eigenvalues within the space.

Parameters:
  • c (ndarray) – Orbital coefficients.

  • c_ref (ndarray) – Orbital coefficients of reference orbitals.

reset(reset_bath=True, reset_cluster=True, reset_eris=True)
property results
property symmetry_factor

Includes children of children, etc.

trimmed_name(length=10, add_dots=True)

Fragment name trimmed to a given maximum length.

vayesta.dmet.updates

class vayesta.dmet.updates.Update[source]

Bases: object

class vayesta.dmet.updates.DIISUpdate(space_size=6, min_space_size=1)[source]

Bases: Update

update(params)[source]
class vayesta.dmet.updates.MixUpdate(alpha=1.0)[source]

Bases: Update

update(params)[source]

Module contents

Density Matrix Embedding Theory (DMET) method Author: Charles Scott email: cjcargillscott@gmail.com

vayesta.dmet.DMET(mf, *args, **kwargs)[source]

Determine restricted or unrestricted by inspection of mean-field object