diff --git a/gbasis/evals/density.py b/gbasis/evals/density.py index a72772ec..0cdd96e1 100644 --- a/gbasis/evals/density.py +++ b/gbasis/evals/density.py @@ -69,7 +69,7 @@ def evaluate_density( points, transform=None, threshold=1.0e-8, - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return the density of the given basis set at the given points. @@ -104,8 +104,7 @@ def evaluate_density( The absolute value below which negative density values are acceptable. Any negative density value with an absolute value smaller than this threshold will be set to zero. screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -137,7 +136,7 @@ def evaluate_deriv_reduced_density_matrix( points, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return the derivative of the first-order reduced density matrix at the given points. @@ -192,8 +191,7 @@ def evaluate_deriv_reduced_density_matrix( and "direct" makes reference to specific implementation of first and second order derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -241,7 +239,7 @@ def evaluate_deriv_density( points, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return the derivative of density of the given transformed basis set at the given points. @@ -291,8 +289,7 @@ def evaluate_deriv_density( and "direct" makes reference to specific implementation of first and second order derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -357,7 +354,7 @@ def evaluate_density_gradient( points, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return the gradient of the density evaluated at the given points. @@ -397,8 +394,7 @@ def evaluate_density_gradient( and "direct" makes reference to specific implementation of first and second order derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -448,7 +444,7 @@ def evaluate_density_laplacian( points, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return the Laplacian of the density evaluated at the given points. @@ -486,8 +482,7 @@ def evaluate_density_laplacian( and "direct" makes reference to specific implementation of first and second order derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -565,7 +560,7 @@ def evaluate_density_hessian( points, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return the Hessian of the density evaluated at the given points. @@ -611,8 +606,7 @@ def evaluate_density_hessian( and "direct" makes reference to specific implementation of first and second order derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -719,7 +713,7 @@ def evaluate_posdef_kinetic_energy_density( transform=None, deriv_type="general", threshold=1.0e-8, - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return evaluations of positive definite kinetic energy density at the given points. @@ -765,8 +759,7 @@ def evaluate_posdef_kinetic_energy_density( The absolute value below which negative density values are acceptable. Any negative density value with an absolute value smaller than this threshold will be set to zero. screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -808,7 +801,7 @@ def evaluate_general_kinetic_energy_density( alpha, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Return evaluations of general form of the kinetic energy density at the given points. @@ -846,8 +839,7 @@ def evaluate_general_kinetic_energy_density( and "direct" makes reference to specific implementation of first and second order derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that diff --git a/gbasis/evals/eval.py b/gbasis/evals/eval.py index de06e235..6c2fa110 100644 --- a/gbasis/evals/eval.py +++ b/gbasis/evals/eval.py @@ -55,7 +55,7 @@ class Eval(BaseOneIndex): """ @staticmethod - def construct_array_contraction(contractions, points, screen_basis=True, tol_screen=1e-8): + def construct_array_contraction(contractions, points, screen_basis=False, tol_screen=1e-8): r"""Return the evaluations of the given contractions at the given coordinates. Parameters @@ -69,8 +69,7 @@ def construct_array_contraction(contractions, points, screen_basis=True, tol_scr Rows correspond to the points and columns correspond to the :math:`x, y, \text{and} z` components. screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that @@ -145,7 +144,7 @@ def construct_array_contraction(contractions, points, screen_basis=True, tol_scr return output -def evaluate_basis(basis, points, transform=None, screen_basis=True, tol_screen=1e-8): +def evaluate_basis(basis, points, transform=None, screen_basis=False, tol_screen=1e-8): r"""Evaluate the basis set in the given coordinate system at the given points. Parameters @@ -164,8 +163,7 @@ def evaluate_basis(basis, points, transform=None, screen_basis=True, tol_screen= and index 0 of the array for contractions. Default is no transformation. screen_basis : bool, optional - Whether to screen out points with negligible contributions. Default value is True - (enable screening). + Whether to screen out points with negligible contributions. Default value is False. tol_screen : float Screening tolerance for excluding evaluations. Points with values below this tolerance will not be evaluated (they will be set to zero). Internal computed quantities that diff --git a/gbasis/evals/eval_deriv.py b/gbasis/evals/eval_deriv.py index 5bd8edcd..9d51e252 100644 --- a/gbasis/evals/eval_deriv.py +++ b/gbasis/evals/eval_deriv.py @@ -58,7 +58,7 @@ class EvalDeriv(BaseOneIndex): @staticmethod def construct_array_contraction( - contractions, points, orders, deriv_type="general", screen_basis=True, tol_screen=1e-8 + contractions, points, orders, deriv_type="general", screen_basis=False, tol_screen=1e-8 ): r"""Return the array associated with a set of contracted Cartesian Gaussians. @@ -82,7 +82,7 @@ def construct_array_contraction( contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional Whether to screen out points that are too far from the contraction center. Default value - is True (enable screening). + False. tol_screen : float Screening tolerance for excluding points. This value, together with the minimum contraction parameters, determines a cutoff distance. Points @@ -177,7 +177,7 @@ def evaluate_deriv_basis( orders, transform=None, deriv_type="general", - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): r"""Evaluate the derivative of the basis set in the given coordinate system at the given points. @@ -220,7 +220,7 @@ def evaluate_deriv_basis( derivatives for generalized contraction (_eval_first_second_order_deriv_contractions()). screen_basis : bool, optional Whether to screen out points that are too far from the contractions center to contribute to - the result above the given tolerance. Default value is True (enable screening). + the result above the given tolerance. Default value is False. tol_screen : float Screening tolerance for excluding points. This value, together with the minimum contraction parameters, determines a cutoff distance. Points diff --git a/gbasis/evals/stress_tensor.py b/gbasis/evals/stress_tensor.py index 6a33ac51..76994c07 100644 --- a/gbasis/evals/stress_tensor.py +++ b/gbasis/evals/stress_tensor.py @@ -1,4 +1,5 @@ """Module for computing properties related to the stress tensor.""" + from gbasis.evals.density import ( evaluate_density_laplacian, evaluate_deriv_density, @@ -8,7 +9,16 @@ # TODO: need to be tested against reference -def evaluate_stress_tensor(one_density_matrix, basis, points, alpha=1, beta=0, transform=None): +def evaluate_stress_tensor( + one_density_matrix, + basis, + points, + alpha=1, + beta=0, + transform=None, + screen_basis=False, + tol_screen=1e-8, +): r"""Return the stress tensor evaluated at the given coordinates. Stress tensor is defined here as: @@ -70,6 +80,13 @@ def evaluate_stress_tensor(one_density_matrix, basis, points, alpha=1, beta=0, t beta : {int, float} Second parameter of the stress tensor. Default value is 0. + screen_basis : bool, optional + Whether to screen out points with negligible contributions. Default value is False. + tol_screen : float + Screening tolerance for excluding evaluations. Points with values below this tolerance + will not be evaluated (they will be set to zero). Internal computed quantities that + affect the results below this tolerance will also be ignored to speed up the + evaluation. Default value is 1e-8. Returns ------- @@ -99,6 +116,8 @@ def evaluate_stress_tensor(one_density_matrix, basis, points, alpha=1, beta=0, t basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if alpha != 1: output[i, j] += (1 - alpha) * evaluate_deriv_reduced_density_matrix( @@ -108,6 +127,8 @@ def evaluate_stress_tensor(one_density_matrix, basis, points, alpha=1, beta=0, t basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if i == j and beta != 0: output[i, j] -= ( @@ -118,6 +139,8 @@ def evaluate_stress_tensor(one_density_matrix, basis, points, alpha=1, beta=0, t basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) ) output[j, i] = output[i, j] @@ -125,7 +148,16 @@ def evaluate_stress_tensor(one_density_matrix, basis, points, alpha=1, beta=0, t # TODO: need to be tested against reference -def evaluate_ehrenfest_force(one_density_matrix, basis, points, alpha=1, beta=0, transform=None): +def evaluate_ehrenfest_force( + one_density_matrix, + basis, + points, + alpha=1, + beta=0, + transform=None, + screen_basis=False, + tol_screen=1e-8, +): r"""Return the Ehrenfest force. Ehrenfest force is the negative of the divergence of the stress tensor: @@ -183,6 +215,13 @@ def evaluate_ehrenfest_force(one_density_matrix, basis, points, alpha=1, beta=0, beta : {int, float} Second parameter of the stress tensor. Default value is 0. + screen_basis : bool, optional + Whether to screen out points with negligible contributions. Default value is False. + tol_screen : float + Screening tolerance for excluding evaluations. Points with values below this tolerance + will not be evaluated (they will be set to zero). Internal computed quantities that + affect the results below this tolerance will also be ignored to speed up the + evaluation. Default value is 1e-8. Returns ------- @@ -211,6 +250,8 @@ def evaluate_ehrenfest_force(one_density_matrix, basis, points, alpha=1, beta=0, basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if alpha != 1: output[i] -= (1 - alpha) * evaluate_deriv_reduced_density_matrix( @@ -220,6 +261,8 @@ def evaluate_ehrenfest_force(one_density_matrix, basis, points, alpha=1, beta=0, basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if alpha != 0.5: output[i] -= (1 - 2 * alpha) * evaluate_deriv_reduced_density_matrix( @@ -229,6 +272,8 @@ def evaluate_ehrenfest_force(one_density_matrix, basis, points, alpha=1, beta=0, basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if beta != 0: output[i] += ( @@ -240,6 +285,8 @@ def evaluate_ehrenfest_force(one_density_matrix, basis, points, alpha=1, beta=0, basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) ) return output.T @@ -254,6 +301,8 @@ def evaluate_ehrenfest_hessian( beta=0, transform=None, symmetric=False, + screen_basis=False, + tol_screen=1e-8, ): r"""Return the Ehrenfest Hessian. @@ -326,6 +375,13 @@ def evaluate_ehrenfest_hessian( Flag for symmetrizing the Hessian. If True, then the Hessian is symmetrized by averaging it with its transpose. Default value is False. + screen_basis : bool, optional + Whether to screen out points with negligible contributions. Default value is False. + tol_screen : float + Screening tolerance for excluding evaluations. Points with values below this tolerance + will not be evaluated (they will be set to zero). Internal computed quantities that + affect the results below this tolerance will also be ignored to speed up the + evaluation. Default value is 1e-8. Returns ------- @@ -356,6 +412,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) output[i, j] += alpha * evaluate_deriv_reduced_density_matrix( 2 * orders_one, @@ -364,6 +422,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if alpha != 1: output[i, j] -= (1 - alpha) * evaluate_deriv_reduced_density_matrix( @@ -373,6 +433,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) output[i, j] -= (1 - alpha) * evaluate_deriv_reduced_density_matrix( 2 * orders_one + orders_two, @@ -381,6 +443,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if alpha != 0.5: output[i, j] -= (1 - 2 * alpha) * evaluate_deriv_reduced_density_matrix( @@ -390,6 +454,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) output[i, j] -= (1 - 2 * alpha) * evaluate_deriv_reduced_density_matrix( orders_one + orders_two, @@ -398,6 +464,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) if beta != 0: output[i, j] += ( @@ -409,6 +477,8 @@ def evaluate_ehrenfest_hessian( basis, points, transform=transform, + screen_basis=screen_basis, + tol_screen=tol_screen, ) ) if symmetric: diff --git a/gbasis/integrals/angular_momentum.py b/gbasis/integrals/angular_momentum.py index 9f6503bc..ff01dc72 100644 --- a/gbasis/integrals/angular_momentum.py +++ b/gbasis/integrals/angular_momentum.py @@ -60,7 +60,7 @@ class AngularMomentumIntegral(BaseTwoIndexSymmetric): @staticmethod def construct_array_contraction( - contractions_one, contractions_two, screen_basis=True, tol_screen=1e-8 + contractions_one, contractions_two, screen_basis=False, tol_screen=1e-8 ): """Return the integrals over the angular momentum operator of the given contractions. @@ -73,7 +73,7 @@ def construct_array_contraction( Contracted Cartesian Gaussians (of the same shell) associated with the second index of the angular momentum integral. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance @@ -183,7 +183,7 @@ def construct_array_contraction( return -1j * np.transpose(output, (3, 2, 4, 1, 0)) -def angular_momentum_integral(basis, transform=None, screen_basis=True, tol_screen=1e-8): +def angular_momentum_integral(basis, transform=None, screen_basis=False, tol_screen=1e-8): r"""Return the integral over :math:`hat{L}` of the given basis set. .. math:: @@ -218,7 +218,7 @@ def angular_momentum_integral(basis, transform=None, screen_basis=True, tol_scre and index 0 of the array for contractions. Default is no transformation. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance diff --git a/gbasis/integrals/kinetic_energy.py b/gbasis/integrals/kinetic_energy.py index 3276abee..eb016633 100644 --- a/gbasis/integrals/kinetic_energy.py +++ b/gbasis/integrals/kinetic_energy.py @@ -55,7 +55,7 @@ class KineticEnergyIntegral(BaseTwoIndexSymmetric): @staticmethod def construct_array_contraction( - contractions_one, contractions_two, screen_basis=True, tol_screen=1e-8 + contractions_one, contractions_two, screen_basis=False, tol_screen=1e-8 ): """Return the evaluations of the given contractions at the given coordinates. @@ -68,7 +68,7 @@ def construct_array_contraction( Contracted Cartesian Gaussians (of the same shell) associated with the second index of the kinetic energy integral. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance @@ -146,7 +146,7 @@ def construct_array_contraction( return -0.5 * np.sum(output, axis=0) -def kinetic_energy_integral(basis, transform=None, screen_basis=True, tol_screen=1e-8): +def kinetic_energy_integral(basis, transform=None, screen_basis=False, tol_screen=1e-8): r"""Return kinetic energy integral of the given basis set. .. math:: @@ -174,7 +174,7 @@ def kinetic_energy_integral(basis, transform=None, screen_basis=True, tol_screen and index 0 of the array for contractions. Default is no transformation. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance diff --git a/gbasis/integrals/moment.py b/gbasis/integrals/moment.py index 682c95d3..e2f9a6d3 100644 --- a/gbasis/integrals/moment.py +++ b/gbasis/integrals/moment.py @@ -56,7 +56,7 @@ def construct_array_contraction( contractions_two, moment_coord, moment_orders, - screen_basis=True, + screen_basis=False, tol_screen=1e-8, ): """Return the evaluations of the given contractions at the given coordinates. @@ -76,7 +76,7 @@ def construct_array_contraction( Note that a two dimensional array must be given, even if there is only one set of orders of the moment. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance @@ -188,7 +188,7 @@ class if the first four indices correspond to the segmented contraction and the def moment_integral( - basis, moment_coord, moment_orders, transform=None, screen_basis=True, tol_screen=1e-8 + basis, moment_coord, moment_orders, transform=None, screen_basis=False, tol_screen=1e-8 ): r"""Return moment integral of the given basis set. @@ -217,7 +217,7 @@ def moment_integral( and index 0 of the array for contractions. Default is no transformation. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance diff --git a/gbasis/integrals/momentum.py b/gbasis/integrals/momentum.py index 86a2fc37..b505a0b8 100644 --- a/gbasis/integrals/momentum.py +++ b/gbasis/integrals/momentum.py @@ -57,7 +57,7 @@ class MomentumIntegral(BaseTwoIndexSymmetric): @staticmethod def construct_array_contraction( - contractions_one, contractions_two, screen_basis=True, tol_screen=1e-8 + contractions_one, contractions_two, screen_basis=False, tol_screen=1e-8 ): """Return the integrals over the momentum operator of the given contractions. @@ -70,7 +70,7 @@ def construct_array_contraction( Contracted Cartesian Gaussians (of the same shell) associated with the second index of the momentum energy integral. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance @@ -140,7 +140,7 @@ def construct_array_contraction( return -1j * np.transpose(output, (1, 2, 3, 4, 0)) -def momentum_integral(basis, transform=None, screen_basis=True, tol_screen=1e-8): +def momentum_integral(basis, transform=None, screen_basis=False, tol_screen=1e-8): r"""Return integral over momentum operator of the given basis set. .. math:: @@ -166,7 +166,7 @@ def momentum_integral(basis, transform=None, screen_basis=True, tol_screen=1e-8) Default is no transformation. Default is no transformation. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance diff --git a/gbasis/integrals/overlap.py b/gbasis/integrals/overlap.py index 7ee3c9ce..d5b7b69f 100644 --- a/gbasis/integrals/overlap.py +++ b/gbasis/integrals/overlap.py @@ -53,7 +53,7 @@ class Overlap(BaseTwoIndexSymmetric): @staticmethod def construct_array_contraction( - contractions_one, contractions_two, screen_basis=True, tol_screen=1e-8 + contractions_one, contractions_two, screen_basis=False, tol_screen=1e-8 ): """Return the evaluations of the given contractions at the given coordinates. @@ -66,7 +66,7 @@ def construct_array_contraction( Contracted Cartesian Gaussians (of the same shell) associated with the second index of the overlap. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance @@ -134,7 +134,7 @@ def construct_array_contraction( )[0] -def overlap_integral(basis, transform=None, screen_basis=True, tol_screen=1e-8): +def overlap_integral(basis, transform=None, screen_basis=False, tol_screen=1e-8): r"""Return overlap integral of the given basis set. .. math:: @@ -154,7 +154,7 @@ def overlap_integral(basis, transform=None, screen_basis=True, tol_screen=1e-8): and index 0 of the array for contractions. Default is no transformation. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance diff --git a/gbasis/integrals/overlap_asymm.py b/gbasis/integrals/overlap_asymm.py index 0a4c80a6..28f61f9d 100644 --- a/gbasis/integrals/overlap_asymm.py +++ b/gbasis/integrals/overlap_asymm.py @@ -65,7 +65,7 @@ class OverlapAsymmetric(BaseTwoIndexAsymmetric): def overlap_integral_asymmetric( - basis_one, basis_two, transform_one=None, transform_two=None, screen_basis=True, tol_screen=1e-8 + basis_one, basis_two, transform_one=None, transform_two=None, screen_basis=False, tol_screen=1e-8 ): r"""Return overlap integrals between two basis sets. @@ -94,7 +94,7 @@ def overlap_integral_asymmetric( and index 0 of the array for contractions. Default is no transformation. screen_basis : bool, optional - A toggle to enable or disable screening. Default value is True to enable screening. + A toggle to enable or disable screening. Default value is False. tol_screen : float, optional The tolerance used for screening overlap integrals. `tol_screen` is combined with the minimum contraction exponents to compute a cutoff which is compared to the distance diff --git a/tests/test_stress_tensor.py b/tests/test_stress_tensor.py index a9ef3f56..da45c979 100644 --- a/tests/test_stress_tensor.py +++ b/tests/test_stress_tensor.py @@ -1,4 +1,5 @@ """Test gbasis.evals.stress_tensor.""" + from gbasis.evals.density import ( evaluate_density_laplacian, evaluate_deriv_density, @@ -15,7 +16,9 @@ from utils import find_datafile, HortonContractions -def test_evaluate_stress_tensor(): +@pytest.mark.parametrize("screen_basis", [True, False]) +@pytest.mark.parametrize("tol_screen", [1e-8]) +def test_evaluate_stress_tensor(screen_basis, tol_screen): """Test gbasis.evals.stress_tensor.evaluate_stress_tensor.""" basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem")) coords = np.array([[0, 0, 0]]) @@ -29,10 +32,47 @@ def test_evaluate_stress_tensor(): with pytest.raises(TypeError): evaluate_stress_tensor(np.identity(40), basis, points, 1, 0j, np.identity(40)) - test_a = evaluate_stress_tensor(np.identity(40), basis, points, 0, 0, np.identity(40)) - test_b = evaluate_stress_tensor(np.identity(40), basis, points, 1, 0, np.identity(40)) - test_c = evaluate_stress_tensor(np.identity(40), basis, points, 1, 2, np.identity(40)) - test_d = evaluate_stress_tensor(np.identity(40), basis, points, 0.5, 2, np.identity(40)) + test_a = evaluate_stress_tensor( + np.identity(40), + basis, + points, + 0, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_b = evaluate_stress_tensor( + np.identity(40), + basis, + points, + 1, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_c = evaluate_stress_tensor( + np.identity(40), + basis, + points, + 1, + 2, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_d = evaluate_stress_tensor( + np.identity(40), + basis, + points, + 0.5, + 2, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + # compute reference without screening for i in range(3): for j in range(3): orders_i = np.array([0, 0, 0]) @@ -41,10 +81,22 @@ def test_evaluate_stress_tensor(): orders_j[j] += 1 temp1 = evaluate_deriv_reduced_density_matrix( - orders_i, orders_j, np.identity(40), basis, points, np.identity(40) + orders_i, + orders_j, + np.identity(40), + basis, + points, + np.identity(40), + screen_basis=False, ) temp2 = evaluate_deriv_reduced_density_matrix( - orders_j, orders_i, np.identity(40), basis, points, np.identity(40) + orders_j, + orders_i, + np.identity(40), + basis, + points, + np.identity(40), + screen_basis=False, ) temp3 = evaluate_deriv_reduced_density_matrix( orders_i + orders_j, @@ -53,6 +105,7 @@ def test_evaluate_stress_tensor(): basis, points, np.identity(40), + screen_basis=False, ) temp4 = evaluate_deriv_reduced_density_matrix( orders_i + orders_j, @@ -61,20 +114,28 @@ def test_evaluate_stress_tensor(): basis, points, np.identity(40), + screen_basis=False, ) if i == j: - temp5 = evaluate_density_laplacian(np.identity(40), basis, points, np.identity(40)) + temp5 = evaluate_density_laplacian( + np.identity(40), basis, points, np.identity(40), screen_basis=False + ) else: temp5 = 0 - assert np.allclose(test_a[:, i, j], 0.5 * temp3 + 0.5 * temp4) - assert np.allclose(test_b[:, i, j], -0.5 * temp1 - 0.5 * temp2) - assert np.allclose(test_c[:, i, j], -0.5 * temp1 - 0.5 * temp2 - temp5) + # check that non screened reference matches screened result within tol_screen + assert np.allclose(test_a[:, i, j], 0.5 * temp3 + 0.5 * temp4, atol=tol_screen) + assert np.allclose(test_b[:, i, j], -0.5 * temp1 - 0.5 * temp2, atol=tol_screen) + assert np.allclose(test_c[:, i, j], -0.5 * temp1 - 0.5 * temp2 - temp5, atol=tol_screen) assert np.allclose( - test_d[:, i, j], -0.25 * temp1 - 0.25 * temp2 + 0.25 * temp3 + 0.25 * temp4 - temp5 + test_d[:, i, j], + -0.25 * temp1 - 0.25 * temp2 + 0.25 * temp3 + 0.25 * temp4 - temp5, + atol=tol_screen, ) -def test_evaluate_ehrenfest_force(): +@pytest.mark.parametrize("screen_basis", [True, False]) +@pytest.mark.parametrize("tol_screen", [1e-8]) +def test_evaluate_ehrenfest_force(screen_basis, tol_screen): """Test gbasis.evals.stress_tensor.evaluate_ehrenfest_force.""" basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem")) coords = np.array([[0, 0, 0]]) @@ -88,16 +149,53 @@ def test_evaluate_ehrenfest_force(): with pytest.raises(TypeError): evaluate_ehrenfest_force(np.identity(40), basis, points, 1, 0j, np.identity(40)) - test_a = evaluate_ehrenfest_force(np.identity(40), basis, points, 0, 0, np.identity(40)) - test_b = evaluate_ehrenfest_force(np.identity(40), basis, points, 1, 0, np.identity(40)) - test_c = evaluate_ehrenfest_force(np.identity(40), basis, points, 0.5, 0, np.identity(40)) - test_d = evaluate_ehrenfest_force(np.identity(40), basis, points, 0, 2, np.identity(40)) + test_a = evaluate_ehrenfest_force( + np.identity(40), + basis, + points, + 0, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_b = evaluate_ehrenfest_force( + np.identity(40), + basis, + points, + 1, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_c = evaluate_ehrenfest_force( + np.identity(40), + basis, + points, + 0.5, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_d = evaluate_ehrenfest_force( + np.identity(40), + basis, + points, + 0, + 2, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) for j in range(3): ref_a = np.zeros(points.shape[0]) ref_b = np.zeros(points.shape[0]) ref_c = np.zeros(points.shape[0]) ref_d = np.zeros(points.shape[0]) + # compute reference without screening orders_j = np.array([0, 0, 0]) orders_j[j] += 1 for i in range(3): @@ -105,10 +203,22 @@ def test_evaluate_ehrenfest_force(): orders_i[i] += 1 temp1 = evaluate_deriv_reduced_density_matrix( - 2 * orders_i, orders_j, np.identity(40), basis, points, np.identity(40) + 2 * orders_i, + orders_j, + np.identity(40), + basis, + points, + np.identity(40), + screen_basis=False, ) temp2 = evaluate_deriv_reduced_density_matrix( - orders_i, orders_i + orders_j, np.identity(40), basis, points, np.identity(40) + orders_i, + orders_i + orders_j, + np.identity(40), + basis, + points, + np.identity(40), + screen_basis=False, ) temp3 = evaluate_deriv_reduced_density_matrix( 2 * orders_i + orders_j, @@ -117,25 +227,40 @@ def test_evaluate_ehrenfest_force(): basis, points, np.identity(40), + screen_basis=False, ) temp4 = evaluate_deriv_reduced_density_matrix( - orders_i + orders_j, orders_i, np.identity(40), basis, points, np.identity(40) + orders_i + orders_j, + orders_i, + np.identity(40), + basis, + points, + np.identity(40), + screen_basis=False, ) temp5 = evaluate_deriv_density( - 2 * orders_i + orders_j, np.identity(40), basis, points, np.identity(40) + 2 * orders_i + orders_j, + np.identity(40), + basis, + points, + np.identity(40), + screen_basis=False, ) ref_a += temp3 + temp4 ref_b += -temp1 - temp2 ref_c += -0.5 * temp1 - 0.5 * temp2 + 0.5 * temp3 + 0.5 * temp4 ref_d += temp3 + temp4 - temp5 - assert np.allclose(test_a[:, j], -ref_a) - assert np.allclose(test_b[:, j], -ref_b) - assert np.allclose(test_c[:, j], -ref_c) - assert np.allclose(test_d[:, j], -ref_d) + # check that non screened reference matches screened result within tol_screen + assert np.allclose(test_a[:, j], -ref_a, atol=tol_screen) + assert np.allclose(test_b[:, j], -ref_b, atol=tol_screen) + assert np.allclose(test_c[:, j], -ref_c, atol=tol_screen) + assert np.allclose(test_d[:, j], -ref_d, atol=tol_screen) -def test_evaluate_ehrenfest_hessian(): +@pytest.mark.parametrize("screen_basis", [True, False]) +@pytest.mark.parametrize("tol_screen", [1e-8]) +def test_evaluate_ehrenfest_hessian(screen_basis, tol_screen): """Test gbasis.evals.stress_tensor.evaluate_ehrenfest_hessian.""" basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem")) coords = np.array([[0, 0, 0]]) @@ -151,10 +276,48 @@ def test_evaluate_ehrenfest_hessian(): with pytest.raises(TypeError): evaluate_ehrenfest_hessian(np.identity(40), basis, points, 1, 0j, np.identity(40)) - test_a = evaluate_ehrenfest_hessian(np.identity(40), basis, points, 0, 0, np.identity(40)) - test_b = evaluate_ehrenfest_hessian(np.identity(40), basis, points, 1, 0, np.identity(40)) - test_c = evaluate_ehrenfest_hessian(np.identity(40), basis, points, 0.5, 0, np.identity(40)) - test_d = evaluate_ehrenfest_hessian(np.identity(40), basis, points, 0, 2, np.identity(40)) + test_a = evaluate_ehrenfest_hessian( + np.identity(40), + basis, + points, + 0, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_b = evaluate_ehrenfest_hessian( + np.identity(40), + basis, + points, + 1, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_c = evaluate_ehrenfest_hessian( + np.identity(40), + basis, + points, + 0.5, + 0, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + test_d = evaluate_ehrenfest_hessian( + np.identity(40), + basis, + points, + 0, + 2, + np.identity(40), + screen_basis=screen_basis, + tol_screen=tol_screen, + ) + + # compute reference without screening for j in range(3): for k in range(3): ref_a = np.zeros(points.shape[0]) @@ -177,6 +340,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp2 = evaluate_deriv_reduced_density_matrix( 2 * orders_i, @@ -185,6 +349,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp3 = evaluate_deriv_reduced_density_matrix( orders_i + orders_k, @@ -193,6 +358,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp4 = evaluate_deriv_reduced_density_matrix( orders_i, @@ -201,6 +367,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp5 = evaluate_deriv_reduced_density_matrix( 2 * orders_i + orders_j + orders_k, @@ -209,6 +376,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp6 = evaluate_deriv_reduced_density_matrix( 2 * orders_i + orders_j, @@ -217,6 +385,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp7 = evaluate_deriv_reduced_density_matrix( orders_i + orders_j + orders_k, @@ -225,6 +394,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp8 = evaluate_deriv_reduced_density_matrix( orders_i + orders_j, @@ -233,6 +403,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) temp9 = evaluate_deriv_density( 2 * orders_i + orders_j + orders_k, @@ -240,6 +411,7 @@ def test_evaluate_ehrenfest_hessian(): basis, points, np.identity(40), + screen_basis=False, ) ref_a += temp5 + temp6 + temp7 + temp8 @@ -255,18 +427,30 @@ def test_evaluate_ehrenfest_hessian(): + 0.5 * temp8 ) ref_d += temp3 + temp4 + temp5 + temp6 - temp9 - assert np.allclose(test_a[:, j, k], -ref_a) - assert np.allclose(test_b[:, j, k], -ref_b) - assert np.allclose(test_c[:, j, k], -ref_c) - assert np.allclose(test_d[:, j, k], -ref_d) + assert np.allclose(test_a[:, j, k], -ref_a, atol=tol_screen) + assert np.allclose(test_b[:, j, k], -ref_b, atol=tol_screen) + assert np.allclose(test_c[:, j, k], -ref_c, atol=tol_screen) + assert np.allclose(test_d[:, j, k], -ref_d, atol=tol_screen) + # check symmetry if requested assert np.allclose( evaluate_ehrenfest_hessian( - np.identity(40), basis, points, 0, 0, np.identity(40), symmetric=True + np.identity(40), + basis, + points, + 0, + 0, + np.identity(40), + symmetric=True, + screen_basis=False, ), ( - evaluate_ehrenfest_hessian(np.identity(40), basis, points, 0, 0, np.identity(40)) + evaluate_ehrenfest_hessian( + np.identity(40), basis, points, 0, 0, np.identity(40), screen_basis=False + ) + np.swapaxes( - evaluate_ehrenfest_hessian(np.identity(40), basis, points, 0, 0, np.identity(40)), + evaluate_ehrenfest_hessian( + np.identity(40), basis, points, 0, 0, np.identity(40), screen_basis=False + ), 1, 2, )