qstack.spahm.rho.dmb_rep_atom

Functions for SPAHM(a) computation.

Implements various models: pure, SAD-diff, occupation-corrected, Löwdin partitioning.

Provides:

models_dict: Dictionary of available models.

qstack.spahm.rho.dmb_rep_atom.coefficients_symmetrize_MR2021(maxlen, c, atoms, idx, ao, _, _M, only_i)[source]

Symmetrize density fitting coefficients using MR2021 method.

Reference:

J. T. Margraf, K. Reuter, “Pure non-local machine-learned density functional theory for electron correlation”, Nat. Commun. 12, 344 (2021), doi:10.1038/s41467-020-20471-y

Parameters:
  • maxlen (int) – Maximum feature length.

  • c (list) – List of coefficient arrays per atom.

  • atoms (list[str]) – Atoms in molecule (from pyscf Mole.elements).

  • idx (dict) – Pair indices per element.

  • ao (dict) – Angular momentum info per element.

  • _ – Unused (for interface compatibility).

  • _M – Unused (for interface compatibility).

  • only_i (list[int]) – List of atom indices to use.

Returns:

2D array (n_atoms, max_features) with zero-padding.

Return type:

numpy ndarray

qstack.spahm.rho.dmb_rep_atom.coefficients_symmetrize_long(maxlen, c_df, atoms, idx, ao, ao_len, M, _)[source]

Symmetrize coefficients for long Löwdin models.

For each atom, use contributions from the said atom as well as all other atoms.

Parameters:
  • maxlen (int) – Maximum feature length.

  • c_df (list) – List of coefficient arrays per atom.

  • atoms (list[str]) – Atoms in molecule (from pyscf Mole.elements).

  • idx (dict) – Pair indices per element.

  • ao (dict) – Angular momentum info per element.

  • ao_len (dict) – Basis set sizes per element.

  • M (dict) – Metric matrices per element.

  • _ – Unused (for interface compatibility).

Returns:

2D array (n_atoms, max_features) with zero-padding.

Return type:

numpy ndarray

qstack.spahm.rho.dmb_rep_atom.coefficients_symmetrize_short(maxlen, c, atoms, idx, ao, _, M, only_i)[source]

Symmetrize coefficients for each atom.

For each atom, use contributions from the said atom.

Parameters:
  • maxlen (int) – Maximum feature length.

  • c (list) – List of coefficient arrays per atom.

  • atoms (list[str]) – Atoms in molecule (from pyscf Mole.elements).

  • idx (dict) – Pair indices per element.

  • ao (dict) – Angular momentum info per element.

  • _ – Unused (for interface compatibility).

  • M (dict) – Metric matrices per element.

  • only_i (list[int]) – List of atom indices to use.

Returns:

2D array (n_atoms, max_features) with zero-padding.

Return type:

numpy ndarray

qstack.spahm.rho.dmb_rep_atom.get_basis_info(atom_types, auxbasis)[source]

Gather auxiliary basis information for all atom types.

Computes overlap matrices, basis function indices, and metric matrices needed for atomic density fitting.

Parameters:
  • atom_types (list) – List of element symbols (e.g., [‘C’, ‘H’, ‘O’]).

  • auxbasis (str or dict) – Auxiliary basis set specification.

Returns:

(ao, ao_len, idx, M) where: - ao (dict): Angular momentum info per element. - ao_len (dict): Basis set size per element. - idx (dict): Pair indices for symmetrization per element. - M (dict): Metric matrices (2D numpy ndarray) per element.

Return type:

tuple

qstack.spahm.rho.dmb_rep_atom.get_model(arg)[source]

Return density fitting and symmetrization functions for specified model.

Parameters:

arg (str) – Model name. Available options: - ‘pure’: Pure density fitting - ‘occup’: Occupation-corrected density fitting. - ‘sad-diff’: Superposition of Atomic Densities difference. - ‘lowdin-short’: Short Löwdin partitioning with slicing. - ‘lowdin-long’: Long Löwdin partitioning with slicing. - ‘lowdin-short-x’: Short Löwdin. - ‘lowdin-long-x’: Long Löwdin. - ‘mr2021’: Method from Margraf & Reuter 2021.

Returns:

(density_fitting_function, symmetrization_function, maxlen_function).
  • density_fitting_function (callable): Function performing density fitting.

    Args:

    mol (pyscf Mole): Molecule object. dm (numpy ndarray): Density matrix (2D). auxbasis (str or dict): Auxiliary basis set. only_i (list[int]): List of atom indices to use.

    Returns:

    list: Density fitting coefficients per atom (1D numpy ndarrays).

  • symmetrization_function (callable): Function for symmetrizing coefficients.

    Args:

    maxlen (int): Maximum feature length. c (numpy ndarray): Density fitting coefficients (1D). atoms (list[str]): Atoms in molecule (from pyscf Mole.elements). idx (dict): Pair indices per element. ao (dict): Angular momentum info per element. ao_len (dict): Basis set sizes per element. M (dict): Metric matrices per element (2D numpy ndarrays). only_i (list[int]): List of atom indices to use.

    Returns:

    numpy ndarray: Symmetrized atomic feature vectors.

  • maxlen_function (callable): Function computing max. feature size.

    Args:

    idx (dict): Pair indices per element. elements (list[str]): Elements for which representation is computed.

    Returns:

    int: Maximum feature length.

Return type:

tuple

Raises:

RuntimeError – If model name is not recognized.