qstack.basis_opt.basis_tools¶
Utility functions for basis set manipulation.
- qstack.basis_opt.basis_tools.cut_myelements(x, myelements, bf_bounds)[source]¶
Extract subset of array corresponding to specified elements.
- Parameters:
x (numpy.ndarray) – Input array.
myelements (list) – List of element symbols to extract.
bf_bounds (dict) – Dictionary mapping elements to their basis set bound indices.
- Returns:
Array containing x only for specified elements.
- Return type:
numpy.ndarray
- qstack.basis_opt.basis_tools.energy_mol(newbasis, moldata)[source]¶
Compute loss function (fitting error) for one molecule.
- Parameters:
newbasis (dict) – Basis set.
moldata (dict) – Dictionary containing molecular data.
- Returns:
Loss function value for the given basis.
- Return type:
float
- qstack.basis_opt.basis_tools.exp2basis(exponents, elements, basis)[source]¶
Convert exponents array to basis set format.
- Parameters:
exponents (numpy.ndarray) – Array of basis function exponents.
elements (list) – List of elements for which change the basis.
basis (dict) – Template basis set definition.
- Returns:
New basis set with updated exponents.
- Return type:
dict
- qstack.basis_opt.basis_tools.gradient_mol(nexp, newbasis, moldata)[source]¶
Compute loss function and gradient for one molecule with respect to basis exponents.
- Parameters:
nexp (int) – Number of exponents.
newbasis (dict) – Basis set.
moldata (dict) – Dictionary containing molecular data.
- Returns:
A tuple containing: - E (float): Loss function value. - dE_da (numpy.ndarray): Gradient of loss function with respect to exponents.
- Return type:
tuple