Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codes using factorial2 function #129

Closed
yingxingcheng opened this issue Jun 29, 2023 · 2 comments · Fixed by #138
Closed

Codes using factorial2 function #129

yingxingcheng opened this issue Jun 29, 2023 · 2 comments · Fixed by #138
Labels
bug Something isn't working

Comments

@yingxingcheng
Copy link

yingxingcheng commented Jun 29, 2023

Describe the bug
The factorial2 function in SciPy returns different values for negative inputs depending on the version. For versions older than 1.11.0, it returns 1, while for versions 1.11.0 and newer, it returns 0.

Code that utilizes the factorial2 function may encounter potential issues, such as those found in the contractions.py file:

    @property
    def norm_prim_cart(self):
        r"""Return the normalization constants of the Cartesian Gaussian primitives.

        For a Cartesian primitive with exponent :math:`\alpha_i`, the normalization constant is:

        .. math::
           N(\alpha_i, \vec{a}) = \sqrt {
           \left(\frac{2\alpha_i}{\pi}\right)^\frac{3}{2}
           \frac{(4\alpha_i)^{a_x + a_y + a_z}}{(2a_x - 1)!! (2a_y - 1)!! (2a_z - 1)!!}}

        Returns
        -------
        norm_prim_cart : np.ndarray(L, K)
            The normalization constants of the Cartesian Gaussian primitives.
            `L` is the number of contracted Cartesian Gaussian functions for the given angular
            momentum, i.e. :math:`(\ell + 1) * (\ell + 2) / 2`
            `K` is the number of exponents (i.e. primitives).

        """
        exponents = self.exps[np.newaxis, :]
        angmom_components_cart = self.angmom_components_cart[:, :, np.newaxis]

        return (
            (2 * exponents / np.pi) ** (3 / 4)
            * ((4 * exponents) ** (self.angmom / 2))
            / np.sqrt(np.prod(factorial2(2 * angmom_components_cart - 1), axis=1))
        )

An unwanted value will be returned when angmom_components_cart is 0, i.e., $s$ orbitals.

To Reproduce
Use SciPy with version $\geq 1.11.0$

@tovrstra
Copy link
Member

PaulWAyers added a commit that referenced this issue Sep 12, 2023
To address issue #129 for the time being, I've specified a maximum version of scipy in the setup.py.
@PaulWAyers
Copy link
Member

As a very tentative change, we can just specify the maximum scipy version as 1.10.1 or lower. That's a stopgap measure.

#131

@FarnazH FarnazH mentioned this issue Nov 17, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants