-
Notifications
You must be signed in to change notification settings - Fork 44
WoC: Final combined implementation (Weeks 1–5) #236
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
base: master
Are you sure you want to change the base?
Changes from all commits
df21116
15bb7f7
76d843d
ff83f68
2736394
9019e15
a1a43c3
07791e2
30adfdd
274c5bc
8808549
c7f4855
f35fb6c
6699cab
5713d20
fae8598
c0d035a
a0070c8
da9e530
446e674
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| """Base class for arrays that depend on four contracted Gaussians.""" | ||
|
|
||
| import abc | ||
| import itertools as it | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| """Collection of modules that compute different integrals of the contractions.""" | ||
|
|
||
| from .density import compute_intracule | ||
| from .density import compute_extracule |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| """Multipole moment integrals involving Contracted Cartesian Gaussians.""" | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,137 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Density API built on top of the arbitrary-order Gaussian overlap engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| This module provides high-level routines for constructing matrices of | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gaussian overlap integrals between shells. These matrices serve as | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| building blocks in density-related calculations such as intracule and | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| extracule analysis. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| The overlap integrals are evaluated using the arbitrary-order Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlap engine implemented in ``arbitrary_order_overlap``. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import numpy as np | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| from .overlap_n import arbitrary_order_overlap | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def compute_intracule(shells): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compute pairwise intracule overlap matrix between Gaussian shells. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| This function constructs a matrix whose elements correspond to | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| two-center overlap integrals between Gaussian basis functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Each matrix element represents the overlap integral | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| .. math:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| S_{ij} = \\int \\phi_i(\\mathbf{r}) \\phi_j(\\mathbf{r}) \\, d\\mathbf{r} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| where :math:`\\phi_i` and :math:`\\phi_j` are Cartesian Gaussian basis | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| functions centered on different atoms or centers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| The overlap integrals are evaluated using the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| :func:`arbitrary_order_overlap` engine, which computes Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlap tensors of arbitrary order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| shells : list[GeneralizedContractionShell] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| List of Gaussian shells defining the basis functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| numpy.ndarray | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Array of shape ``(n, n)`` containing pairwise Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlap integrals between shells. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Notes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ----- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| The intracule matrix is constructed by evaluating pairwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| two-center overlap integrals between Gaussian shells. Each | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| integral is extracted from the sparse tensor returned by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| arbitrary-order overlap engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| References | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helgaker, T., Jørgensen, P., Olsen, J. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Molecular Electronic-Structure Theory*, Wiley (2000). | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Szabo, A., Ostlund, N. S. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Modern Quantum Chemistry*, Dover (1996). | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| n = len(shells) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = np.zeros((n, n)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| for i in range(n): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for j in range(n): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| tensor = arbitrary_order_overlap([shells[i], shells[j]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Extract scalar overlap value from sparse tensor returned by | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # the arbitrary-order overlap engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = tensor.data[0] if tensor.nnz > 0 else 0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am sorry, but I don't understand this function. Needs more documentation. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| result[i, j] = value | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+70
to
+76
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def compute_extracule(shells): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why have two functions that do the same? |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compute pairwise extracule overlap matrix between Gaussian shells. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| This function constructs a matrix of pairwise overlap integrals | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| between Gaussian shells using the arbitrary-order overlap engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Each matrix element corresponds to the two-center Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlap integral | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| .. math:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| S_{ij} = \\int \\phi_i(\\mathbf{r}) \\phi_j(\\mathbf{r}) \\, d\\mathbf{r} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| where :math:`\\phi_i` and :math:`\\phi_j` are Cartesian Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| basis functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| shells : list[GeneralizedContractionShell] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| List of Gaussian shells defining the basis functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| numpy.ndarray | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Array of shape ``(n, n)`` containing pairwise Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlap integrals between shells. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Notes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ----- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| This function provides an API wrapper around the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| :func:`arbitrary_order_overlap` routine for density-related | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| calculations involving Gaussian basis functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| This function currently constructs the same overlap matrix as | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| :func:`compute_intracule`, but is provided as a separate API | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| entry point for extracule-related density calculations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| References | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helgaker, T., Jørgensen, P., Olsen, J. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Molecular Electronic-Structure Theory*, Wiley (2000). | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| n = len(shells) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = np.zeros((n, n)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| for i in range(n): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for j in range(n): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # evaluate two-center Gaussian overlap tensor between shells i and j | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| tensor = arbitrary_order_overlap([shells[i], shells[j]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # extract scalar overlap value from sparse tensor | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = tensor.data[0] if tensor.nnz > 0 else 0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| result[i, j] = value | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+123
to
+137
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| n = len(shells) | |
| result = np.zeros((n, n)) | |
| for i in range(n): | |
| for j in range(n): | |
| tensor = arbitrary_order_overlap([shells[i], shells[j]]) | |
| value = tensor.data[0] if tensor.nnz > 0 else 0.0 | |
| result[i, j] = value | |
| return result | |
| """ | |
| Compute the extracule density matrix. | |
| This function is currently not implemented. It previously duplicated | |
| the intracule implementation, which is misleading because the | |
| extracule and intracule are generally distinct quantities. | |
| """ | |
| raise NotImplementedError( | |
| "compute_extracule is not implemented: previous implementation " | |
| "was a placeholder duplicating compute_intracule." | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gbasis.integrals.densityintroduces new public APIs but the module and functions have no docstrings and no input validation (contrast with other integrals modules likeoverlap.py/point_charge.pywhich document parameters/returns and type-checkGeneralizedContractionShell). Adding docstrings and basic type/shape checks would make the API safer and consistent with the rest of the package.