qstack.fields.moments¶
Multipole moment computation functions.
- qstack.fields.moments.first(mol, rho)[source]¶
Compute the first moment of a molecular density needed for dipole moments.
$$int r rho(r) dr$$
- Parameters:
mol (pyscf Mole) – pyscf Mole object.
rho (numpy ndarray) – 2D (mol.nao×mol.nao) density matrix or 1D (mol.nao) fitting coefficients.
- Returns:
Electronic dipole moment vector (3 components).
- Return type:
numpy ndarray
- Raises:
RuntimeError – If rho is not 1D or 2D.
- qstack.fields.moments.r2_c(mol, rho, moments=(0, 1, 2), per_atom=False)[source]¶
Compute the zeroth ( \(<1>\) ), first ( \(<r>\) ), and second ( \(<r^{2}>\)) moments of a fitted density.
\[\begin{split}<1> = \int \rho d r \quad ; \quad <r> = \\int \hat{r} \rho d r \quad ; \quad <r^{2}> = \int \hat{r}^{2} \rho d r\end{split}\]- Parameters:
mol (pyscf Mole) – pyscf Mole object.
rho (numpy ndarray) – 1D array of density-fitting coefficients. Can be None to compute AO integrals instead.
moments (tuple) – Moments to compute (0, 1, and/or 2).
per_atom (bool) – If return AO integrals / moments per atom.
- Returns:
If rho!=None, values representing the requested moments, possibly containing: - float: Zeroth moment (integrated density). - numpy ndarray: First moment (3-component dipole vector). - float: Second moment (mean square radius). If rho is None, arrays representing the requested moments in AO basis so that
they can be contracted with the coefficients usin (returned array)@(rho).
if rho is None and per_atom is True: 0st moment: (mol.nao, mol.natm) 1st moment: (3, mol.nao, mol.natm) 2nd moment: (mol.nao, mol.natm)
if rho is None and per_atom is False: 0st moment: (mol.nao,) 1st moment: (3, mol.nao) 2nd moment: (mol.nao,)
if rho is not None and per_atom is True: 0st moment: (mol.natm,) 1st moment: (3, mol.natm) 2nd moment: (mol.natm,)
- Return type:
tuple
- Raises:
NotImplementedError – If a moment > 2 is requested.