vayesta.ewf

Submodules

vayesta.ewf.ewf

class vayesta.ewf.ewf.Options(store_eris: bool = True, global_frag_chempot: float | None = None, dm_with_frozen: bool = False, bath_options: dict = <factory>, bosonic_bath_options: dict = <factory>, solver_options: dict = <factory>, symmetry_tol: float = 1e-06, symmetry_mf_tol: float = 1e-05, screening: str | None = None, ext_rpa_correction: str | None = None, match_cluster_fock: bool = False, iao_minao: str = 'auto', project_eris: bool = False, project_init_guess: bool = True, energy_functional: str = 'wf', calc_e_wf_corr: bool = True, calc_e_dm_corr: bool = False, t_as_lambda: bool | None = None, store_wf_type: str | None = None, bsse_correction: bool = True, bsse_rmax: float = 5.0, nelectron_target: int | None = None, sc_mode: int = 0, coupled_iterations: bool = False, _debug_wf: str | None = None)[source]

Bases: Options

Options for EWF calculations.

iao_minao: str = 'auto'
bath_options: dict
project_eris: bool = False
project_init_guess: bool = True
energy_functional: str = 'wf'
calc_e_wf_corr: bool = True
calc_e_dm_corr: bool = False
t_as_lambda: bool = None
store_wf_type: str = None
bsse_correction: bool = True
bsse_rmax: float = 5.0
nelectron_target: int = None
sc_mode: int = 0
coupled_iterations: bool = False
asdict(deepcopy=False)
classmethod change_dict_defaults(field, **kwargs)
static dict_with_defaults(**kwargs)
dm_with_frozen: bool = False
ext_rpa_correction: str | None = 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)
global_frag_chempot: float = None
items()
keys()
match_cluster_fock: 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()
bosonic_bath_options: dict
solver_options: dict
class vayesta.ewf.ewf.EWF(mf, solver='CCSD', log=None, **kwargs)[source]

Bases: Embedding

class Fragment(*args, **kwargs)

Bases: Fragment

class Flags(is_envelop: bool = True, is_secfrag: bool = False, bath_parent_fragment_id: Union[int, NoneType] = None, external_corrections: Union[List[Any], NoneType] = <factory>, test_extcorr: bool = False)

Bases: Flags

bath_parent_fragment_id: int | None = None
is_envelop: bool = True
is_secfrag: bool = False
test_extcorr: bool = False
external_corrections: List[Any] | None
class Options(bath_options: dict = None, bosonic_bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, match_cluster_fock: bool = None, auxiliary: bool = False, coupled_fragments: list = <factory>, sym_factor: float = 1.0, t_as_lambda: bool = None, bsse_correction: bool = None, bsse_rmax: float = None, sc_mode: int = None, nelectron_target: float = None, nelectron_target_atol: float = 1e-06, nelectron_target_rtol: float = 1e-06, calc_e_wf_corr: bool = None, calc_e_dm_corr: bool = None, store_wf_type: str = None, wf_factor: Union[int, NoneType] = None, c_cas_occ: numpy.ndarray = None, c_cas_vir: numpy.ndarray = None, tcc_fci_opts: dict = <factory>)

Bases: Options

asdict(deepcopy=False)
auxiliary: bool = False
bath_options: dict = None
bosonic_bath_options: dict = None
bsse_correction: bool = None
bsse_rmax: float = None
c_cas_occ: ndarray = None
c_cas_vir: ndarray = None
calc_e_dm_corr: bool = None
calc_e_wf_corr: bool = 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()
match_cluster_fock: bool = None
nelectron_target: float = None
nelectron_target_atol: float = 1e-06
nelectron_target_rtol: float = 1e-06
replace(**kwargs)
sc_mode: int = None
screening: str | None = None
solver_options: dict = None
store_eris: bool = None
store_wf_type: str = None
sym_factor: float = 1.0
t_as_lambda: bool = None
update(**kwargs)
values()
wf_factor: int | None = None
tcc_fci_opts: dict
coupled_fragments: list
class Results(fid: int = None, converged: bool = None, e_corr: float = None, e_corr_rpa: float = None, wf: vayesta.core.types.wf.wf.WaveFunction = None, pwf: vayesta.core.types.wf.wf.WaveFunction = None, moms: tuple = None, e_corr_dm2cumulant: float = None, n_active: int = None, ip_energy: numpy.ndarray = None, ea_energy: numpy.ndarray = None)

Bases: Results

converged: bool = None
property dm1

Cluster 1DM

property dm2

Cluster 2DM

e_corr: float = None
e_corr_dm2cumulant: float = None
e_corr_rpa: float = None
ea_energy: ndarray = None
fid: int = None
ip_energy: ndarray = None
moms: tuple = None
n_active: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
add_external_corrections(fragments, correction_type='tailor', projectors=1, test_extcorr=False, low_level_coul=True)

Add tailoring or external correction from other fragment solutions to CCSD solver.

Parameters:
  • fragments (list) – List of solved or auxiliary fragments, used for the correction.

  • correction_type (str, optional) –

    Type of correction:

    ’tailor’: replace CCSD T1 and T2 amplitudes with FCI amplitudes. ‘delta-tailor’: Add the difference of FCI and CCSD T1 and T2 amplitudes ‘external’: externally correct CCSD T1 and T2 amplitudes from FCI T3 and T4 amplitudes.

    Default: ‘tailor’.

  • projectors (int, optional) – Maximum number of projections applied to the occupied dimensions of the amplitude corrections. Default: 1.

  • test_extcorr (bool, optional) – Whether to perform additional checks on the external corrections.

  • low_level_coul (bool, optional) – This is an option specific to the ‘external’ correction. If True, then the T3V term is contracted with integrals spanning the ‘low-level’ (i.e. CCSD) solver, i.e. the cluster being constrained. If False, then the T3V term is contracted with the integrals in the ‘high-level’ (i.e. FCI) solver, i.e. the cluster providing the constraints. In general, there should be a slight speed increase, and slight loss of accuracy for the low_level_coul=False option, but in practice, we find only minor differences. Default: True

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)
check_solver(solver)
clear_external_corrections()

Remove all tailoring or external correction which were added via add_external_corrections.

property cluster
property contributes

True if fragment contributes to expectation values, else False.

copy(fid=None, name=None, **kwargs)

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

counterpoise_calculation(rmax, dm0=None, nimages=5, unit='A')
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_frag_hamil()
get_fragment_bsse(rmax=None, nimages=5, unit='A')
get_fragment_dmet_energy(dm1=None, dm2=None, h1e_eff=None, hamil=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.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • 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_energy(c1, c2, hamil=None, fock=None, c2ba_order='ba', axis1='fragment')

Calculate fragment correlation energy contribution from projected C1, C2.

Parameters:
  • c1 ((n(occ-CO), n(vir-CO)) array) – Fragment projected C1-amplitudes.

  • c2 ((n(occ-CO), n(occ-CO), n(vir-CO), n(vir-CO)) array) – Fragment projected C2-amplitudes.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • fock ((n(AO), n(AO)) array, optional) – Fock matrix in AO representation. If None, self.base.get_fock_for_energy() is used. Default: None.

Returns:

  • e_singles (float) – Fragment correlation energy contribution from single excitations.

  • e_doubles (float) – Fragment correlation energy contribution from double excitations.

  • e_corr (float) – Total fragment correlation energy contribution.

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_init_guess(init_guess, solver, cluster)
get_local_rpa_correction(hamil=None)
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_solver(solver=None)
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 hamil
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)
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_bosonic_bath_target()

Get the target space for bosonic bath orbitals. This can either be the DMET cluster or the full space, and can include a projection onto the fragment.

make_bosonic_cluster(m0_target)

Set bosonic component of the cluster.

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_fragment_dm1(t_as_lambda=False, sym_t2=True)

Currently CCSD only.

Without mean-field contribution!

make_fragment_dm2cumulant(t_as_lambda=False, sym_t2=True, sym_dm2=True, full_shape=True, approx_cumulant=True)

Currently MP2/CCSD only

make_fragment_dm2cumulant_energy(hamil=None, t_as_lambda=False, sym_t2=True, approx_cumulant=True)
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, reset_inactive=True)
property results
set_cas(iaos=None, c_occ=None, c_vir=None, minao='auto', dmet_threshold=None)

Set complete active space for tailored CCSD and active-space CC methods.

property symmetry_factor

Includes children of children, etc.

trimmed_name(length=10, add_dots=True)

Fragment name trimmed to a given maximum length.

class Options(store_eris: bool = True, global_frag_chempot: float | None = None, dm_with_frozen: bool = False, bath_options: dict = <factory>, bosonic_bath_options: dict = <factory>, solver_options: dict = <factory>, symmetry_tol: float = 1e-06, symmetry_mf_tol: float = 1e-05, screening: str | None = None, ext_rpa_correction: str | None = None, match_cluster_fock: bool = False, iao_minao: str = 'auto', project_eris: bool = False, project_init_guess: bool = True, energy_functional: str = 'wf', calc_e_wf_corr: bool = True, calc_e_dm_corr: bool = False, t_as_lambda: bool | None = None, store_wf_type: str | None = None, bsse_correction: bool = True, bsse_rmax: float = 5.0, nelectron_target: int | None = None, sc_mode: int = 0, coupled_iterations: bool = False, _debug_wf: str | None = None)

Bases: Options

Options for EWF calculations.

asdict(deepcopy=False)
bsse_correction: bool = True
bsse_rmax: float = 5.0
calc_e_dm_corr: bool = False
calc_e_wf_corr: bool = True
classmethod change_dict_defaults(field, **kwargs)
coupled_iterations: bool = False
static dict_with_defaults(**kwargs)
dm_with_frozen: bool = False
energy_functional: str = 'wf'
ext_rpa_correction: str | None = 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)
global_frag_chempot: float = None
iao_minao: str = 'auto'
items()
keys()
match_cluster_fock: bool = False
nelectron_target: int = None
project_eris: bool = False
project_init_guess: bool = True
replace(**kwargs)
sc_mode: int = 0
screening: str | None = None
store_eris: bool = True
store_wf_type: str = None
symmetry_mf_tol: float = 1e-05
symmetry_tol: float = 1e-06
t_as_lambda: bool = None
update(**kwargs)
values()
bath_options: dict
bosonic_bath_options: dict
solver_options: dict
fragmentation(*args, **kwargs)[source]
tailor_all_fragments()[source]
kernel()[source]

Run EWF.

get_global_t1(get_lambda=False, mpi_target=None, ao_basis=False, for_dm2=False)

Get global CCSD T1 amplitudes from fragment calculations.

Runtime: N(frag)/N(MPI) * N^2

Parameters:
  • get_lambda (bool, optional) – If True, return L1 amplitudes. Default: False.

  • mpi_target (int or None, optional) – If set to an integer, the result will only be available at the specified MPI rank. If set to None, an MPI allreduce will be performed and the result will be available at all MPI ranks. Default: None.

Returns:

t1 – Global T1 amplitudes.

Return type:

(n(occ), n(vir)) array

get_global_t2(get_lambda=False, symmetrize=True, mpi_target=None, ao_basis=False, for_dm2=False)

Get global CCSD T2 amplitudes from fragment calculations.

Runtime: N(frag)/N(MPI) * N^4

Parameters:
  • get_lambda (bool, optional) – If True, return L1 amplitudes. Default: False.

  • mpi_target (int or None, optional) – If set to an integer, the result will only be available at the specified MPI rank. If set to None, an MPI allreduce will be performed and the result will be available at all MPI ranks. Default: None.

Returns:

t2 – Global T2 amplitudes.

Return type:

(n(occ), n(occ), n(vir), n(vir)) array

get_global_l1(*args, t_as_lambda=None, **kwargs)[source]
get_global_l2(*args, t_as_lambda=None, **kwargs)[source]
t1_diagnostic(warntol=0.02)[source]
make_rdm1(*args, **kwargs)[source]
make_rdm2(*args, **kwargs)[source]
get_e_corr(functional=None, **kwargs)[source]
get_wf_corr_energy()[source]
get_dm_corr_energy(dm1='global-wf', dm2='projected-lambda', t_as_lambda=None, with_exxdiv=None)[source]
get_dm_corr_energy_e1(dm1='global-wf', t_as_lambda=None, with_exxdiv=None)[source]
get_dm_corr_energy_e2(dm2='projected-lambda', t_as_lambda=None)[source]

Correlation energy due to cumulant

get_ccsd_corr_energy(full_wf=False)[source]

Get projected correlation energy from partitioned CCSD WF.

This is the projected (T1, T2) energy expression, instead of the projected (C1, C2) expression used in PRX (the differences are very small).

For testing only, UHF and MPI not implemented

property e_tot

Total energy.

get_wf_energy(*args, **kwargs)[source]
get_dm_energy(*args, **kwargs)[source]
get_ccsd_energy(full_wf=False)[source]
get_fbc_energy(occupied=True, virtual=True)[source]

Get finite-bath correction (FBC) energy.

This correction consists of two independent contributions, one due to the finite occupied, and one due to the finite virtual space.

The virtual correction for a given fragment x is calculated as “E(MP2)[occ=D,vir=F] - E(MP2)[occ=D,vir=C]”, where D is the DMET cluster space, F is the full space, and C is the full cluster space. For the occupied correction, occ and vir spaces are swapped. Fragments which do not have a BNO bath are skipped.

Parameters:
  • occupied (bool, optional) – If True, the FBC energy from the occupied space is included. Default: True.

  • virtual (bool, optional) – If True, the FBC energy from the virtual space is included. Default: True.

Returns:

e_fbc – Finite bath correction (FBC) energy.

Return type:

float

get_intercluster_mp2_energy(*args, **kwargs)[source]
brueckner_scmf(*args, **kwargs)

Decorator for Brueckner-DMET.

build_bosonic_bath()
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.

  • store_m0 (bool, optional.) – Whether to store the local zeroth moment in the fragment class for use later.

  • 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.

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

build_screened_interactions(*args, **kwargs)

Build screened interactions, be they dynamic or static.

cas_fragmentation(**kwargs)

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

change_options(**kwargs)
check_fragment_symmetry(dm1, symtol=1e-06)

Check that the mean-field obeys the symmetry between fragments.

check_solver(solver)
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_nonlocal
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_cderi_exspace(ex_coeff, compact=False, blksize=None)
get_corrfunc(kind, dm1=None, dm2=None, atoms=None, projection='sao', dm2_with_dm1=None, use_symmetry=True, orbital_filter=None)

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', orbital_filter=None)

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_fragment_overlap_norm(fragments=None, occupied=True, virtual=True, norm=2)

Get matrix of overlap norms between fragments.

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

qpewdmet_scmf(*args, **kwargs)

Decorator for QP-EWDMET.

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.ewf.ewf.REWF

alias of EWF

vayesta.ewf.fragment

vayesta.ewf.fragment.get_fragment_mpi_rank(*args)
class vayesta.ewf.fragment.Options(bath_options: dict = None, bosonic_bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, match_cluster_fock: bool = None, auxiliary: bool = False, coupled_fragments: list = <factory>, sym_factor: float = 1.0, t_as_lambda: bool = None, bsse_correction: bool = None, bsse_rmax: float = None, sc_mode: int = None, nelectron_target: float = None, nelectron_target_atol: float = 1e-06, nelectron_target_rtol: float = 1e-06, calc_e_wf_corr: bool = None, calc_e_dm_corr: bool = None, store_wf_type: str = None, wf_factor: Union[int, NoneType] = None, c_cas_occ: numpy.ndarray = None, c_cas_vir: numpy.ndarray = None, tcc_fci_opts: dict = <factory>)[source]

Bases: Options

t_as_lambda: bool = None
bsse_correction: bool = None
bsse_rmax: float = None
sc_mode: int = None
nelectron_target: float = None
nelectron_target_atol: float = 1e-06
nelectron_target_rtol: float = 1e-06
calc_e_wf_corr: bool = None
calc_e_dm_corr: bool = None
store_wf_type: str = None
wf_factor: int | None = None
c_cas_occ: ndarray = None
c_cas_vir: ndarray = None
tcc_fci_opts: dict
asdict(deepcopy=False)
auxiliary: bool = False
bath_options: dict = None
bosonic_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()
match_cluster_fock: bool = None
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 vayesta.ewf.fragment.Fragment(*args, **kwargs)[source]

Bases: Fragment

class Options(bath_options: dict = None, bosonic_bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, match_cluster_fock: bool = None, auxiliary: bool = False, coupled_fragments: list = <factory>, sym_factor: float = 1.0, t_as_lambda: bool = None, bsse_correction: bool = None, bsse_rmax: float = None, sc_mode: int = None, nelectron_target: float = None, nelectron_target_atol: float = 1e-06, nelectron_target_rtol: float = 1e-06, calc_e_wf_corr: bool = None, calc_e_dm_corr: bool = None, store_wf_type: str = None, wf_factor: Union[int, NoneType] = None, c_cas_occ: numpy.ndarray = None, c_cas_vir: numpy.ndarray = None, tcc_fci_opts: dict = <factory>)

Bases: Options

asdict(deepcopy=False)
auxiliary: bool = False
bath_options: dict = None
bosonic_bath_options: dict = None
bsse_correction: bool = None
bsse_rmax: float = None
c_cas_occ: ndarray = None
c_cas_vir: ndarray = None
calc_e_dm_corr: bool = None
calc_e_wf_corr: bool = 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()
match_cluster_fock: bool = None
nelectron_target: float = None
nelectron_target_atol: float = 1e-06
nelectron_target_rtol: float = 1e-06
replace(**kwargs)
sc_mode: int = None
screening: str | None = None
solver_options: dict = None
store_eris: bool = None
store_wf_type: str = None
sym_factor: float = 1.0
t_as_lambda: bool = None
update(**kwargs)
values()
wf_factor: int | None = None
tcc_fci_opts: dict
coupled_fragments: list
class Flags(is_envelop: bool = True, is_secfrag: bool = False, bath_parent_fragment_id: Union[int, NoneType] = None, external_corrections: Union[List[Any], NoneType] = <factory>, test_extcorr: bool = False)[source]

Bases: Flags

external_corrections: List[Any] | None
test_extcorr: bool = False
bath_parent_fragment_id: int | None = None
is_envelop: bool = True
is_secfrag: bool = False
class Results(fid: int = None, converged: bool = None, e_corr: float = None, e_corr_rpa: float = None, wf: vayesta.core.types.wf.wf.WaveFunction = None, pwf: vayesta.core.types.wf.wf.WaveFunction = None, moms: tuple = None, e_corr_dm2cumulant: float = None, n_active: int = None, ip_energy: numpy.ndarray = None, ea_energy: numpy.ndarray = None)[source]

Bases: Results

e_corr_dm2cumulant: float = None
n_active: int = None
ip_energy: ndarray = None
ea_energy: ndarray = None
moms: tuple = None
property dm1

Cluster 1DM

property dm2

Cluster 2DM

converged: bool = None
e_corr: float = None
e_corr_rpa: float = None
fid: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
set_cas(iaos=None, c_occ=None, c_vir=None, minao='auto', dmet_threshold=None)[source]

Set complete active space for tailored CCSD and active-space CC methods.

add_external_corrections(fragments, correction_type='tailor', projectors=1, test_extcorr=False, low_level_coul=True)[source]

Add tailoring or external correction from other fragment solutions to CCSD solver.

Parameters:
  • fragments (list) – List of solved or auxiliary fragments, used for the correction.

  • correction_type (str, optional) –

    Type of correction:

    ’tailor’: replace CCSD T1 and T2 amplitudes with FCI amplitudes. ‘delta-tailor’: Add the difference of FCI and CCSD T1 and T2 amplitudes ‘external’: externally correct CCSD T1 and T2 amplitudes from FCI T3 and T4 amplitudes.

    Default: ‘tailor’.

  • projectors (int, optional) – Maximum number of projections applied to the occupied dimensions of the amplitude corrections. Default: 1.

  • test_extcorr (bool, optional) – Whether to perform additional checks on the external corrections.

  • low_level_coul (bool, optional) – This is an option specific to the ‘external’ correction. If True, then the T3V term is contracted with integrals spanning the ‘low-level’ (i.e. CCSD) solver, i.e. the cluster being constrained. If False, then the T3V term is contracted with the integrals in the ‘high-level’ (i.e. FCI) solver, i.e. the cluster providing the constraints. In general, there should be a slight speed increase, and slight loss of accuracy for the low_level_coul=False option, but in practice, we find only minor differences. Default: True

clear_external_corrections()[source]

Remove all tailoring or external correction which were added via add_external_corrections.

get_init_guess(init_guess, solver, cluster)[source]
kernel(solver=None, init_guess=None)[source]
get_solver_options(solver)[source]
get_fragment_energy(c1, c2, hamil=None, fock=None, c2ba_order='ba', axis1='fragment')[source]

Calculate fragment correlation energy contribution from projected C1, C2.

Parameters:
  • c1 ((n(occ-CO), n(vir-CO)) array) – Fragment projected C1-amplitudes.

  • c2 ((n(occ-CO), n(occ-CO), n(vir-CO), n(vir-CO)) array) – Fragment projected C2-amplitudes.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • fock ((n(AO), n(AO)) array, optional) – Fock matrix in AO representation. If None, self.base.get_fock_for_energy() is used. Default: None.

Returns:

  • e_singles (float) – Fragment correlation energy contribution from single excitations.

  • e_doubles (float) – Fragment correlation energy contribution from double excitations.

  • e_corr (float) – Total fragment correlation energy contribution.

make_fragment_dm1(t_as_lambda=False, sym_t2=True)[source]

Currently CCSD only.

Without mean-field contribution!

make_fragment_dm2cumulant(t_as_lambda=False, sym_t2=True, sym_dm2=True, full_shape=True, approx_cumulant=True)[source]

Currently MP2/CCSD only

make_fragment_dm2cumulant_energy(hamil=None, t_as_lambda=False, sym_t2=True, approx_cumulant=True)[source]
get_fragment_bsse(rmax=None, nimages=5, unit='A')[source]
counterpoise_calculation(rmax, dm0=None, nimages=5, unit='A')[source]
add_tsymmetric_fragments(tvecs, symtol=1e-06)[source]
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)[source]

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)[source]
check_solver(solver)[source]
property cluster
property contributes

True if fragment contributes to expectation values, else False.

copy(fid=None, name=None, **kwargs)[source]

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

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

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()[source]
get_frag_hamil()[source]
get_fragment_dmet_energy(dm1=None, dm2=None, h1e_eff=None, hamil=None, part_cumulant=True, approx_cumulant=True)[source]

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.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • 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()[source]

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)[source]

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)[source]

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)[source]

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

get_local_rpa_correction(hamil=None)[source]
get_mo_occupation(*mo_coeff, dm1=None)[source]

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)[source]

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(solver=None)[source]
get_symmetry_children(maxgen=None, **filters)[source]
get_symmetry_error(frag, dm1=None)[source]

Get translational symmetry error between two fragments.

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

Returns a recursive tree:

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

property hamil
property id_name

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

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

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()[source]
make_bosonic_bath_target()[source]

Get the target space for bosonic bath orbitals. This can either be the DMET cluster or the full space, and can include a projection onto the fragment.

make_bosonic_cluster(m0_target)[source]

Set bosonic component of the cluster.

make_cluster()[source]
make_counterpoise_mol(rmax, nimages=1, unit='A', **kwargs)[source]

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

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)[source]

Write cube density data of fragment orbitals to file.

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

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, reset_inactive=True)[source]
property results
property symmetry_factor

Includes children of children, etc.

trimmed_name(length=10, add_dots=True)[source]

Fragment name trimmed to a given maximum length.

vayesta.ewf.helper

vayesta.ewf.helper.orthogonalize_mo(c, s, tol=1e-06)[source]

Orthogonalize MOs, such that C^T S C = I (identity matrix).

Parameters:
  • c (ndarray) – MO orbital coefficients.

  • s (ndarray) – AO overlap matrix.

  • tol (float, optional) – Tolerance.

Returns:

c_out – Orthogonalized MO coefficients.

Return type:

ndarray

vayesta.ewf.uewf

class vayesta.ewf.uewf.UEWF(mf, solver='CCSD', log=None, **kwargs)[source]

Bases: EWF, UEmbedding

class Fragment(*args, **kwargs)

Bases: Fragment, UFragment

class Flags(is_envelop: bool = True, is_secfrag: bool = False, bath_parent_fragment_id: Union[int, NoneType] = None, external_corrections: Union[List[Any], NoneType] = <factory>, test_extcorr: bool = False)

Bases: Flags

bath_parent_fragment_id: int | None = None
is_envelop: bool = True
is_secfrag: bool = False
test_extcorr: bool = False
external_corrections: List[Any] | None
class Options(bath_options: dict = None, bosonic_bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, match_cluster_fock: bool = None, auxiliary: bool = False, coupled_fragments: list = <factory>, sym_factor: float = 1.0, t_as_lambda: bool = None, bsse_correction: bool = None, bsse_rmax: float = None, sc_mode: int = None, nelectron_target: float = None, nelectron_target_atol: float = 1e-06, nelectron_target_rtol: float = 1e-06, calc_e_wf_corr: bool = None, calc_e_dm_corr: bool = None, store_wf_type: str = None, wf_factor: Union[int, NoneType] = None, c_cas_occ: numpy.ndarray = None, c_cas_vir: numpy.ndarray = None, tcc_fci_opts: dict = <factory>)

Bases: Options

asdict(deepcopy=False)
auxiliary: bool = False
bath_options: dict = None
bosonic_bath_options: dict = None
bsse_correction: bool = None
bsse_rmax: float = None
c_cas_occ: ndarray = None
c_cas_vir: ndarray = None
calc_e_dm_corr: bool = None
calc_e_wf_corr: bool = 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()
match_cluster_fock: bool = None
nelectron_target: float = None
nelectron_target_atol: float = 1e-06
nelectron_target_rtol: float = 1e-06
replace(**kwargs)
sc_mode: int = None
screening: str | None = None
solver_options: dict = None
store_eris: bool = None
store_wf_type: str = None
sym_factor: float = 1.0
t_as_lambda: bool = None
update(**kwargs)
values()
wf_factor: int | None = None
tcc_fci_opts: dict
coupled_fragments: list
class Results(fid: int = None, converged: bool = None, e_corr: float = None, e_corr_rpa: float = None, wf: vayesta.core.types.wf.wf.WaveFunction = None, pwf: vayesta.core.types.wf.wf.WaveFunction = None, moms: tuple = None, e_corr_dm2cumulant: float = None, n_active: int = None, ip_energy: numpy.ndarray = None, ea_energy: numpy.ndarray = None)

Bases: Results

converged: bool = None
property dm1

Cluster 1DM

property dm2

Cluster 2DM

e_corr: float = None
e_corr_dm2cumulant: float = None
e_corr_rpa: float = None
ea_energy: ndarray = None
fid: int = None
ip_energy: ndarray = None
moms: tuple = None
n_active: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
add_external_corrections(fragments, correction_type='tailor', projectors=1, test_extcorr=False, low_level_coul=True)

Add tailoring or external correction from other fragment solutions to CCSD solver.

Parameters:
  • fragments (list) – List of solved or auxiliary fragments, used for the correction.

  • correction_type (str, optional) –

    Type of correction:

    ’tailor’: replace CCSD T1 and T2 amplitudes with FCI amplitudes. ‘delta-tailor’: Add the difference of FCI and CCSD T1 and T2 amplitudes ‘external’: externally correct CCSD T1 and T2 amplitudes from FCI T3 and T4 amplitudes.

    Default: ‘tailor’.

  • projectors (int, optional) – Maximum number of projections applied to the occupied dimensions of the amplitude corrections. Default: 1.

  • test_extcorr (bool, optional) – Whether to perform additional checks on the external corrections.

  • low_level_coul (bool, optional) – This is an option specific to the ‘external’ correction. If True, then the T3V term is contracted with integrals spanning the ‘low-level’ (i.e. CCSD) solver, i.e. the cluster being constrained. If False, then the T3V term is contracted with the integrals in the ‘high-level’ (i.e. FCI) solver, i.e. the cluster providing the constraints. In general, there should be a slight speed increase, and slight loss of accuracy for the low_level_coul=False option, but in practice, we find only minor differences. Default: True

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)
check_solver(solver)
clear_external_corrections()

Remove all tailoring or external correction which were added via add_external_corrections.

property cluster
property contributes

True if fragment contributes to expectation values, else False.

copy(fid=None, name=None, **kwargs)

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

counterpoise_calculation(rmax, dm0=None, nimages=5, unit='A')
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_frag_hamil()
get_fragment_bsse(rmax=None, nimages=5, unit='A')
get_fragment_dmet_energy(dm1=None, dm2=None, h1e_eff=None, hamil=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.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • 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_energy(c1, c2, hamil=None, fock=None, axis1='fragment', c2ba_order='ba')

Calculate fragment correlation energy contribution from projected C1, C2.

Parameters:
  • c1 ((n(occ-CO), n(vir-CO)) array) – Fragment projected C1-amplitudes.

  • c2 ((n(occ-CO), n(occ-CO), n(vir-CO), n(vir-CO)) array) – Fragment projected C2-amplitudes.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • fock ((n(AO), n(AO)) array, optional) – Fock matrix in AO representation. If None, self.base.get_fock_for_energy() is used. Default: None.

Returns:

  • e_singles (float) – Fragment correlation energy contribution from single excitations.

  • e_doubles (float) – Fragment correlation energy contribution from double excitations.

  • e_corr (float) – Total fragment correlation energy contribution.

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_init_guess(init_guess, solver, cluster)
get_local_rpa_correction(hamil=None)
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(solver=None)
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 hamil
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)
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_bosonic_bath_target()

Get the target space for bosonic bath orbitals. This can either be the DMET cluster or the full space, and can include a projection onto the fragment.

make_bosonic_cluster(m0_target)

Set bosonic component of the cluster.

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_fragment_dm1(t_as_lambda=False, sym_t2=True)

Currently CCSD only.

Without mean-field contribution!

make_fragment_dm2cumulant(t_as_lambda=None, sym_t2=True, approx_cumulant=True, full_shape=True)

Currently MP2/CCSD only

make_fragment_dm2cumulant_energy(hamil=None, t_as_lambda=None, sym_t2=True, approx_cumulant=True)
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, reset_inactive=True)
property results
set_cas(iaos=None, c_occ=None, c_vir=None, minao='auto', dmet_threshold=None)

Set complete active space for tailored CCSD and active-space CC methods.

property symmetry_factor

Includes children of children, etc.

trimmed_name(length=10, add_dots=True)

Fragment name trimmed to a given maximum length.

get_global_t1(get_lambda=False, mpi_target=None, ao_basis=False)

Get global CCSD T1 from fragment calculations.

Parameters:
  • get_lambda (bool, optional) – If True, return L1 amplitudes. Default: False.

  • mpi_target (int or None, optional) – If set to an integer, the result will only be available at the specified MPI rank. If set to None, an MPI allreduce will be performed and the result will be available at all MPI ranks. Default: None.

Returns:

t1 – Global T1 amplitudes.

Return type:

tuple(2) of (n(occ), n(vir)) array

get_global_t2(get_lambda=False, symmetrize=True, mpi_target=None, ao_basis=False)

Get global CCSD T2 amplitudes from fragment calculations.

Parameters:
  • get_lambda (bool, optional) – If True, return L1 amplitudes. Default: False.

  • mpi_target (int or None, optional) – If set to an integer, the result will only be available at the specified MPI rank. If set to None, an MPI allreduce will be performed and the result will be available at all MPI ranks. Default: None.

Returns:

t2 – Global T2 amplitudes.

Return type:

tuple(3) of (n(occ), n(occ), n(vir), n(vir)) array

t1_diagnostic(warn_tol=0.02)[source]
d1_diagnostic()[source]

Global wave function diagnostic.

get_intercluster_mp2_energy(*args, **kwargs)[source]
class Options(store_eris: bool = True, global_frag_chempot: float | None = None, dm_with_frozen: bool = False, bath_options: dict = <factory>, bosonic_bath_options: dict = <factory>, solver_options: dict = <factory>, symmetry_tol: float = 1e-06, symmetry_mf_tol: float = 1e-05, screening: str | None = None, ext_rpa_correction: str | None = None, match_cluster_fock: bool = False, iao_minao: str = 'auto', project_eris: bool = False, project_init_guess: bool = True, energy_functional: str = 'wf', calc_e_wf_corr: bool = True, calc_e_dm_corr: bool = False, t_as_lambda: bool | None = None, store_wf_type: str | None = None, bsse_correction: bool = True, bsse_rmax: float = 5.0, nelectron_target: int | None = None, sc_mode: int = 0, coupled_iterations: bool = False, _debug_wf: str | None = None)

Bases: Options

Options for EWF calculations.

asdict(deepcopy=False)
bsse_correction: bool = True
bsse_rmax: float = 5.0
calc_e_dm_corr: bool = False
calc_e_wf_corr: bool = True
classmethod change_dict_defaults(field, **kwargs)
coupled_iterations: bool = False
static dict_with_defaults(**kwargs)
dm_with_frozen: bool = False
energy_functional: str = 'wf'
ext_rpa_correction: str | None = 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)
global_frag_chempot: float = None
iao_minao: str = 'auto'
items()
keys()
match_cluster_fock: bool = False
nelectron_target: int = None
project_eris: bool = False
project_init_guess: bool = True
replace(**kwargs)
sc_mode: int = 0
screening: str | None = None
store_eris: bool = True
store_wf_type: str = None
symmetry_mf_tol: float = 1e-05
symmetry_tol: float = 1e-06
t_as_lambda: bool = None
update(**kwargs)
values()
bath_options: dict
bosonic_bath_options: dict
solver_options: dict
brueckner_scmf(*args, **kwargs)

Decorator for Brueckner-DMET.

build_bosonic_bath()
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.

  • store_m0 (bool, optional.) – Whether to store the local zeroth moment in the fragment class for use later.

  • 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.

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

build_screened_interactions(*args, **kwargs)

Build screened interactions, be they dynamic or static.

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)

Check that the mean-field obeys the symmetry between fragments.

check_solver(solver)
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_nonlocal
property e_nuc

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

property e_tot

Total energy.

fragmentation(*args, **kwargs)
get_atomic_charges(pop)
get_average_cluster_size(average='mean')
get_ccsd_corr_energy(full_wf=False)

Get projected correlation energy from partitioned CCSD WF.

This is the projected (T1, T2) energy expression, instead of the projected (C1, C2) expression used in PRX (the differences are very small).

For testing only, UHF and MPI not implemented

get_ccsd_energy(full_wf=False)
get_cderi(mo_coeff, compact=False, blksize=None)
get_cderi_exspace(ex_coeff, compact=False, blksize=None)
get_corrfunc(kind, dm1=None, dm2=None, atoms=None, projection='sao', dm2_with_dm1=None, use_symmetry=True, orbital_filter=None)

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', orbital_filter=None)

dm1 in MO basis

get_dm_corr_energy(dm1='global-wf', dm2='projected-lambda', t_as_lambda=None, with_exxdiv=None)
get_dm_corr_energy_e1(dm1='global-wf', t_as_lambda=None, with_exxdiv=None)
get_dm_corr_energy_e2(dm2='projected-lambda', t_as_lambda=None)

Correlation energy due to cumulant

get_dm_energy(*args, **kwargs)
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_e_corr(functional=None, **kwargs)
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_fbc_energy(occupied=True, virtual=True)

Get finite-bath correction (FBC) energy.

This correction consists of two independent contributions, one due to the finite occupied, and one due to the finite virtual space.

The virtual correction for a given fragment x is calculated as “E(MP2)[occ=D,vir=F] - E(MP2)[occ=D,vir=C]”, where D is the DMET cluster space, F is the full space, and C is the full cluster space. For the occupied correction, occ and vir spaces are swapped. Fragments which do not have a BNO bath are skipped.

Parameters:
  • occupied (bool, optional) – If True, the FBC energy from the occupied space is included. Default: True.

  • virtual (bool, optional) – If True, the FBC energy from the virtual space is included. Default: True.

Returns:

e_fbc – Finite bath correction (FBC) energy.

Return type:

float

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_fragment_overlap_norm(fragments=None, occupied=True, virtual=True, norm=2)

Get matrix of overlap norms between fragments.

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_global_l1(*args, t_as_lambda=None, **kwargs)
get_global_l2(*args, t_as_lambda=None, **kwargs)
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.

get_wf_corr_energy()
get_wf_energy(*args, **kwargs)
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 EWF.

loop()

Loop over fragments.

make_rdm1(*args, **kwargs)
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_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

qpewdmet_scmf(*args, **kwargs)

Decorator for QP-EWDMET.

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'
tailor_all_fragments()
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.ewf.ufragment

class vayesta.ewf.ufragment.Fragment(*args, **kwargs)[source]

Bases: Fragment, UFragment

set_cas(iaos=None, c_occ=None, c_vir=None, minao='auto', dmet_threshold=None)[source]

Set complete active space for tailored CCSD and active-space CC methods.

get_fragment_energy(c1, c2, hamil=None, fock=None, axis1='fragment', c2ba_order='ba')[source]

Calculate fragment correlation energy contribution from projected C1, C2.

Parameters:
  • c1 ((n(occ-CO), n(vir-CO)) array) – Fragment projected C1-amplitudes.

  • c2 ((n(occ-CO), n(occ-CO), n(vir-CO), n(vir-CO)) array) – Fragment projected C2-amplitudes.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • fock ((n(AO), n(AO)) array, optional) – Fock matrix in AO representation. If None, self.base.get_fock_for_energy() is used. Default: None.

Returns:

  • e_singles (float) – Fragment correlation energy contribution from single excitations.

  • e_doubles (float) – Fragment correlation energy contribution from double excitations.

  • e_corr (float) – Total fragment correlation energy contribution.

make_fragment_dm2cumulant(t_as_lambda=None, sym_t2=True, approx_cumulant=True, full_shape=True)[source]

Currently MP2/CCSD only

make_fragment_dm2cumulant_energy(hamil=None, t_as_lambda=None, sym_t2=True, approx_cumulant=True)[source]
class Flags(is_envelop: bool = True, is_secfrag: bool = False, bath_parent_fragment_id: Union[int, NoneType] = None, external_corrections: Union[List[Any], NoneType] = <factory>, test_extcorr: bool = False)[source]

Bases: Flags

external_corrections: List[Any] | None
test_extcorr: bool = False
bath_parent_fragment_id: int | None = None
is_envelop: bool = True
is_secfrag: bool = False
class Options(bath_options: dict = None, bosonic_bath_options: dict = None, solver_options: dict = None, store_eris: bool = None, dm_with_frozen: bool = None, screening: Union[str, NoneType] = None, match_cluster_fock: bool = None, auxiliary: bool = False, coupled_fragments: list = <factory>, sym_factor: float = 1.0, t_as_lambda: bool = None, bsse_correction: bool = None, bsse_rmax: float = None, sc_mode: int = None, nelectron_target: float = None, nelectron_target_atol: float = 1e-06, nelectron_target_rtol: float = 1e-06, calc_e_wf_corr: bool = None, calc_e_dm_corr: bool = None, store_wf_type: str = None, wf_factor: Union[int, NoneType] = None, c_cas_occ: numpy.ndarray = None, c_cas_vir: numpy.ndarray = None, tcc_fci_opts: dict = <factory>)

Bases: Options

asdict(deepcopy=False)
auxiliary: bool = False
bath_options: dict = None
bosonic_bath_options: dict = None
bsse_correction: bool = None
bsse_rmax: float = None
c_cas_occ: ndarray = None
c_cas_vir: ndarray = None
calc_e_dm_corr: bool = None
calc_e_wf_corr: bool = 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()
match_cluster_fock: bool = None
nelectron_target: float = None
nelectron_target_atol: float = 1e-06
nelectron_target_rtol: float = 1e-06
replace(**kwargs)
sc_mode: int = None
screening: str | None = None
solver_options: dict = None
store_eris: bool = None
store_wf_type: str = None
sym_factor: float = 1.0
t_as_lambda: bool = None
update(**kwargs)
values()
wf_factor: int | None = None
tcc_fci_opts: dict
coupled_fragments: list
class Results(fid: int = None, converged: bool = None, e_corr: float = None, e_corr_rpa: float = None, wf: vayesta.core.types.wf.wf.WaveFunction = None, pwf: vayesta.core.types.wf.wf.WaveFunction = None, moms: tuple = None, e_corr_dm2cumulant: float = None, n_active: int = None, ip_energy: numpy.ndarray = None, ea_energy: numpy.ndarray = None)[source]

Bases: Results

e_corr_dm2cumulant: float = None
n_active: int = None
ip_energy: ndarray = None
ea_energy: ndarray = None
moms: tuple = None
property dm1

Cluster 1DM

property dm2

Cluster 2DM

converged: bool = None
e_corr: float = None
e_corr_rpa: float = None
fid: int = None
pwf: WaveFunction = None
wf: WaveFunction = None
add_external_corrections(fragments, correction_type='tailor', projectors=1, test_extcorr=False, low_level_coul=True)[source]

Add tailoring or external correction from other fragment solutions to CCSD solver.

Parameters:
  • fragments (list) – List of solved or auxiliary fragments, used for the correction.

  • correction_type (str, optional) –

    Type of correction:

    ’tailor’: replace CCSD T1 and T2 amplitudes with FCI amplitudes. ‘delta-tailor’: Add the difference of FCI and CCSD T1 and T2 amplitudes ‘external’: externally correct CCSD T1 and T2 amplitudes from FCI T3 and T4 amplitudes.

    Default: ‘tailor’.

  • projectors (int, optional) – Maximum number of projections applied to the occupied dimensions of the amplitude corrections. Default: 1.

  • test_extcorr (bool, optional) – Whether to perform additional checks on the external corrections.

  • low_level_coul (bool, optional) – This is an option specific to the ‘external’ correction. If True, then the T3V term is contracted with integrals spanning the ‘low-level’ (i.e. CCSD) solver, i.e. the cluster being constrained. If False, then the T3V term is contracted with the integrals in the ‘high-level’ (i.e. FCI) solver, i.e. the cluster providing the constraints. In general, there should be a slight speed increase, and slight loss of accuracy for the low_level_coul=False option, but in practice, we find only minor differences. Default: True

add_tsymmetric_fragments(tvecs, symtol=1e-06)[source]
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)[source]
check_solver(solver)[source]
clear_external_corrections()[source]

Remove all tailoring or external correction which were added via add_external_corrections.

property cluster
property contributes

True if fragment contributes to expectation values, else False.

copy(fid=None, name=None, **kwargs)[source]

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

counterpoise_calculation(rmax, dm0=None, nimages=5, unit='A')[source]
couple_to_fragment(frag)[source]
couple_to_fragments(frags)[source]
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()[source]
get_frag_hamil()[source]
get_fragment_bsse(rmax=None, nimages=5, unit='A')[source]
get_fragment_dmet_energy(dm1=None, dm2=None, h1e_eff=None, hamil=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.

  • hamil (ClusterHamiltonian object.) – Object representing cluster hamiltonian, possibly including cached ERIs.

  • 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)[source]

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

get_init_guess(init_guess, solver, cluster)[source]
get_local_rpa_correction(hamil=None)[source]
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)[source]

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(solver=None)[source]
get_solver_options(solver)[source]
get_symmetry_children(maxgen=None, **filters)[source]
get_symmetry_error(frag, dm1=None)

Get translational symmetry error between two fragments.

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

Returns a recursive tree:

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

property hamil
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)[source]
log_info()
loop_symmetry_children(arrays=None, axes=None, symtree=None, maxgen=None, include_self=False)[source]

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()[source]
make_bosonic_bath_target()[source]

Get the target space for bosonic bath orbitals. This can either be the DMET cluster or the full space, and can include a projection onto the fragment.

make_bosonic_cluster(m0_target)[source]

Set bosonic component of the cluster.

make_cluster()[source]
make_counterpoise_mol(rmax, nimages=1, unit='A', **kwargs)[source]

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_fragment_dm1(t_as_lambda=False, sym_t2=True)[source]

Currently CCSD only.

Without mean-field contribution!

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)[source]

Write cube density data of fragment orbitals to file.

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

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, reset_inactive=True)[source]
property results
property symmetry_factor

Includes children of children, etc.

trimmed_name(length=10, add_dots=True)[source]

Fragment name trimmed to a given maximum length.

Module contents

Embedded wave function (EWF) method Author: Max Nusspickel email: max.nusspickel@gmail.com

vayesta.ewf.EWF(mf, *args, **kwargs)[source]

Determine restricted or unrestricted by inspection of mean-field object