esipy.tools

Module Contents

Functions

wf_type(aom)

Checks the topology of the AOMs to obtain the type of wavefunction.

find_multiplicity(aom)

Checks the topology of the AOMs to get the difference between alpha and beta electrons.

load_file(file)

Loads a variable from a file.

save_file(file, save)

Saves a variable to a file.

find_distances(arr, geom)

Collects the distance between the atoms in ring connectivity.

find_dis(arr, aom)

Collects the DIs between the atoms in ring connectivity.

find_di(aom, i, j)

Collects the DI between two atoms.

find_di_no(aom, i, j)

Collects the DI between two atoms for correlated wavefunctions.

find_lis(arr, aom)

Collects the LIs between the atoms in ring connectivity.

find_ns(arr, aom)

Collects the atomic populations of all the atoms in the ring.

av1245_pairs(arr)

Collects the series of atoms that fulfill the 1-2-4-5 relationship for the AV1245 calculation.

mol_info([mol, mf, save, partition, connec])

Obtains information from the molecule and the calculation to complement the main code function without requiring the 'mol' and 'mf' objects.

build_connectivity([mat, threshold])

Build the connectivity dictionary based on the given atomic overlap matrices.

process_fragments(aom, rings[, done])

Processes fragments by combining AOMs and updating rings.

format_partition(partition)

format_short_partition(partition)

mapping(arr, perm)

Maps the elements of a list according to a permutation.

get_natorbs(mf, S)

Obtains the natural orbitals from the SCF calculation.

build_eta(mol)

Builds the eta matrices for the partitioning. They consist of a block-truncated matrix with all elements being

build_connec_rest(Smo[, thres])

build_connec_unrest(Smo[, thres])

build_connec_no(Smo[, thres])

find_rings(connec[, minlen, maxlen, exclude])

filter_connec(connec)

is_fused(arr, connec)

find_middle_nodes(connec2)

permute_aos_rows(mat, mole2)

Reorders FCHK AO rows to match PySCF's internal layout AND applies

esipy.tools.wf_type(aom)[source]

Checks the topology of the AOMs to obtain the type of wavefunction.

Parameters

aom – The Atomic Overlap Matrices (AOMs) in the MO basis.

Returns

A string with the type of wave function (‘rest’, ‘unrest’ or ‘no’).

esipy.tools.find_multiplicity(aom)[source]

Checks the topology of the AOMs to get the difference between alpha and beta electrons.

Parameters

aom (list of matrices) – The Atomic Overlap Matrices (AOMs) in the MO basis.

Returns

A string with the multiplicity of the calculations.

Return type

str

esipy.tools.load_file(file)[source]

Loads a variable from a file.

Parameters

file (str) – Contains the name or the path containing the variable.

Returns

The file loaded.

Return type

object

esipy.tools.save_file(file, save)[source]

Saves a variable to a file.

Parameters
  • file (object) – The variable to be stored.

  • save (str) – The name or the path where the variable will be saved.

Returns

None

esipy.tools.find_distances(arr, geom)[source]

Collects the distance between the atoms in ring connectivity.

Parameters
  • arr (list of int) – Indices of the atoms in ring connectivity.

  • geom (numpy.ndarray) – Geometry of the molecule as in mol.atom_coords().

Returns

List containing the distances of the members of the ring in Bohrs.

Return type

list of float

esipy.tools.find_dis(arr, aom)[source]

Collects the DIs between the atoms in ring connectivity.

Parameters
  • arr (list of int) – Indices of the atoms in ring connectivity.

  • aom (list of matrices) – The Atomic Overlap Matrices (AOMs) in the MO basis.

Returns

List containing the DIs of the members of the ring.

Return type

list of float

esipy.tools.find_di(aom, i, j)[source]

Collects the DI between two atoms.

Parameters
  • aom (list of matrices) – The Atomic Overlap Matrices (AOMs) in the MO basis.

  • i (int) – Index of the first atom.

  • j (int) – Index of the second atom.

Returns

DI between the atoms i and j.

Return type

float

esipy.tools.find_di_no(aom, i, j)[source]

Collects the DI between two atoms for correlated wavefunctions.

Parameters
  • aom (list of matrices) – The Atomic Overlap Matrices (AOMs) in the MO basis.

  • i (int) – Index of the first atom.

  • j (int) – Index of the second atom.

Returns

DI between the atoms i and j.

Return type

float

esipy.tools.find_lis(arr, aom)[source]

Collects the LIs between the atoms in ring connectivity.

Parameters
  • arr (list of int) – Indices of the atoms in ring connectivity.

  • aom (list of matrices) – The Atomic Overlap Matrices (AOMs) in the MO basis.

Returns

List containing the DIs of the members of the ring.

Return type

list of float

esipy.tools.find_ns(arr, aom)[source]

Collects the atomic populations of all the atoms in the ring.

Parameters
  • arr (list of int) – Indices of the atoms in ring connectivity.

  • aom (list of matrices) – The Atomic Overlap Matrices (AOMs) in the MO basis.

Returns

List containing the atomic populations of the members of the ring.

Return type

list of float

esipy.tools.av1245_pairs(arr)[source]

Collects the series of atoms that fulfill the 1-2-4-5 relationship for the AV1245 calculation.

Parameters

arr (list of int) – Indices of the atoms in ring connectivity.

Returns

List containing the series of atoms that fulfill the 1-2-4-5 relationship.

Return type

list of tuple

esipy.tools.mol_info(mol=None, mf=None, save=None, partition=None, connec=None)[source]

Obtains information from the molecule and the calculation to complement the main code function without requiring the ‘mol’ and ‘mf’ objects.

Parameters
  • mol (pyscf.gto.Mole) – PySCF Mole object.

  • mf (pyscf.scf.hf.SCF) – PySCF SCF object.

  • save (str) – String with the name of the file to save the information.

  • partition (str) – String with the name of the partition.

Returns

Dictionary with the information of the molecule and the calculation.

Return type

dict

esipy.tools.build_connectivity(mat=None, threshold=0.25)[source]

Build the connectivity dictionary based on the given atomic overlap matrices.

Parameters
  • mat – Atomic overlap matrices. If None, uses self.aom or builds meta-lowdin AOMs

  • threshold – Threshold for connectivity determination. Default is 0.25.

Returns

Dictionary representing atomic connectivity

esipy.tools.process_fragments(aom, rings, done=False)[source]

Processes fragments by combining AOMs and updating rings.

Parameters
  • aom – List of AOMs.

  • rings – List of rings (can include sets for fragments).

Returns

Updated AOMs, rings, and fragment AOMs.

Return type

tuple (list, list, list)

esipy.tools.format_partition(partition)[source]
esipy.tools.format_short_partition(partition)[source]
esipy.tools.mapping(arr, perm)[source]

Maps the elements of a list according to a permutation.

Parameters
  • arr (list) – List of elements.

  • perm (list of int) – Permutation of the elements.

Returns

List of elements corresponding to a given permutation.

Return type

list

esipy.tools.get_natorbs(mf, S)[source]

Obtains the natural orbitals from the SCF calculation.

Parameters
  • mf (pyscf.scf.hf.SCF) – PySCF SCF object.

  • S (numpy.ndarray) – Overlap matrix in an AO basis.

Returns

List containing the occupancies and the Natural Orbitals.

Return type

tuple of (numpy.ndarray, numpy.ndarray)

esipy.tools.build_eta(mol)[source]

Builds the eta matrices for the partitioning. They consist of a block-truncated matrix with all elements being zero except for the diagonal elements corresponding to the basis functions of a given atom, which are set to one.

Parameters

mol (pyscf.gto.Mole) – PySCF Mole object.

Returns

List containing the eta matrices for each atom.

Return type

list of numpy.ndarray

esipy.tools.build_connec_rest(Smo, thres=0.25)[source]
esipy.tools.build_connec_unrest(Smo, thres=0.25)[source]
esipy.tools.build_connec_no(Smo, thres=0.25)[source]
esipy.tools.find_rings(connec, minlen=6, maxlen=6, exclude=None)[source]
esipy.tools.filter_connec(connec)[source]
esipy.tools.is_fused(arr, connec)[source]
esipy.tools.find_middle_nodes(connec2)[source]
esipy.tools.permute_aos_rows(mat, mole2)[source]

Reorders FCHK AO rows to match PySCF’s internal layout AND applies normalization scaling for Cartesian basis sets.