horton_part.utils module

Utility Functions

check_dens_monotonicity(dens, as_warn=True, logger=None, negative_cutoff=-1e-12)

Check the monotonicity of a density.

Parameters:
  • dens (1D np.ndarray) – The density needs to be checked. It could be a proatom density or a spherically average of AIM density.

  • as_warn (bool) – Whether treat this as a warning. The default is True.

  • logger (Optional[Logger]) – The logging object. The default is None.

  • negative_cutoff (float) – The value less than threshold is treated as negative. The default is NEGATIVE_CUTOFF

check_dens_negativity(dens, as_warn=False, logger=None, negative_cutoff=-1e-12)

Check if a density is non-negative.

Parameters:
  • dens (1D or 3D np.ndarray) – The density needs to be checked. It could be a proatom density or AIM density. It could be 1D on a radial grid or 3D on a molecular grid.

  • as_warn (bool) – Whether treat the error as a warning or not. The default is False.

  • logger (logging.Logger or None) – The logger object. The default is None.

  • negative_cutoff (float) – The value less than threshold is treated as negative. The default is NEGATIVE_CUTOFF

check_inputs(pro_atom_params, basis_functions, pro_atom_density)

Validate inputs

check_pars_negativity(pars, as_warn=True, logger=None, negative_cutoff=-1e-12)

Check if a density is non-negative.

Parameters:
  • pars (1D np.ndarray) – Pro-atom parameters It could be 1D on a radial grid or 3D on a molecular grid.

  • as_warn (bool) – Whether treat the error as a warning or not. The default is False.

  • logger (logging.Logger or None) – The logger object. The default is None.

  • negative_cutoff (float) – The value less than threshold is treated as negative. The default is NEGATIVE_CUTOFF

check_pars_population(propars, ref_pop, as_warn=True, logger=None, population_cutoff=0.0001)

Check the proatom parameters if the sum of them is equal to the reference population.

Parameters:
  • propars (1D or 3D np.ndarray) – The density needs to be checked. It could be a proatom density or AIM density. It could be 1D on a radial grid or 3D on a molecular grid.

  • ref_pop (float) – The reference population.

  • as_warn (bool) – Whether treat the error as a warning or not. The default is True.

  • logger (logging.Logger or None) – The logger object. The default is None.

  • population_cutoff (float) – The absolute tolerance.

check_pro_atom_parameters(pro_atom_params, basis_functions=None, total_population=None, pro_atom_density=None, check_monotonicity=True, check_negativity=True, check_propars_negativity=True, logger=None, negative_cutoff=-1e-12, population_cutoff=0.0001)

Check the validity of pro-atom parameters.

This function warns if any pro-atom parameters are negative and raises a RuntimeError if the pro-atom density contains negative values. It also warns if the sum of pro-atom parameters does not match the expected total atomic population.

Parameters:
  • pro_atom_params (ndarray) – Array of pro-atom parameters.

  • basis_functions (ndarray, optional) – Basis functions on the grid.

  • total_population (float, optional) – Total atomic population to compare against the sum of pro-atom parameters.

  • pro_atom_density (ndarray, optional) – Pre-calculated pro-atom density array. If not provided, it is calculated from pro_atom_params and basis_functions.

  • check_monotonicity (bool, optional) – Check if the density is monotonically decreased w.r.t. radial radius.

  • check_negativity (bool, optional) – Check if the density is non-negativity.

  • check_propars_negativity (bool, optional) – Check if the propars is negative.

  • logger (logging.Logger or None) – Logger object.

  • negative_cutoff (float) – Value that small than negative_cutoff is treated as negative number.

  • population_cutoff (float) – The threshold for the difference between test and real population.

Raises:

RuntimeError – If negative values are found in the pro-atom density.

Warning

UserWarning

If any pro-atom parameters are negative. If the sum of pro-atom parameters does not match the total_population.

Return type:

None

check_pro_atom_parameters_neg_pars(pro_atom_params, basis_functions=None, total_population=None, pro_atom_density=None, check_monotonicity=True, check_negativity=True, logger=None, negative_cutoff=-1e-12, population_cutoff=0.0001)

Validation for method with negative propars. See``check_pro_atom_parameters``.

check_pro_atom_parameters_non_neg_pars(pro_atom_params, basis_functions=None, total_population=None, pro_atom_density=None, logger=None, negative_cutoff=-1e-12, population_cutoff=0.0001)

Validation for method with non-negative propars. See``check_pro_atom_parameters``.

compute_quantities(density, pro_atom_params, basis_functions, density_cutoff, do_sick=True, do_ratio=True, do_ln_ratio=True)

Compute various quantities based on input density, pro-atom parameters, and basis functions.

densityndarray

The density array.

pro_atom_paramsndarray

Array of pro-atom parameters.

basis_functionsndarray

Array of basis functions.

density_cutofffloat, optional

The cutoff value for density and pro-atom density, below which values are considered negligible.

do_sick: bool

Mask sick values.

do_ratio: bool

Whether return the ratio :math:`

ho_a/ ho_a^0`.

do_ln_ratio: bool

Whether return the ratio :math:`ln (

ho_a/ ho_a^0)`.

pro_shells2D ndarray

Calculated pro-atom shell values.

pro_density1D ndarray

Calculated pro-atom density.

sick1D ndarray

Boolean array indicating where density or pro-density is below the cutoff.

ratio1D ndarray

Ratio of density to pro-atom density, with adjustments for sick values.

ln_ratio1D ndarray

Natural logarithm of the ratio, with adjustments for sick values.

fix_propars(exp_array, propars, delta)

Fix the propar of the most diffuse function when it is negative and Newton step delta is negative.

Parameters:
  • exp_array (2D np.ndarray) – The exponent values.

  • propars (2D np.ndarray) – The pro-atom parameters.

  • delta (1D np.ndarray) – The step of Newton method.

typecheck_geo(coordinates=None, numbers=None, pseudo_numbers=None, need_coordinates=True, need_numbers=True, need_pseudo_numbers=True)

Type check a molecular geometry specification

Parameters:
  • coordinates (2D np.ndarray) – A (N, 3) float array with Cartesian coordinates of the atoms.

  • numbers (1D np.ndarray) – A (N,) int vector with the atomic numbers.

  • pseudo_numbers (1D np.ndarray) – A (N,) float array with pseudo-potential core charges.

  • need_coordinates (bool) – When set to False, the coordinates can be None, are not type checked and not returned.

  • need_numbers (bool) – When set to False, the numbers can be None, are not type checked and not returned.

  • need_pseudo_numbers (bool) – When set to False, the pseudo_numbers can be None, are not type checked and not returned.

Returns:

  • [natom] + all arguments that were type checked. The

  • pseudo_numbers argument is converted to a floating point array.

wpart_schemes(scheme)

Return a part scheme by given its name.