Skip to content

Commit

Permalink
Add transform= keyword to cbasis integrals
Browse files Browse the repository at this point in the history
  • Loading branch information
msricher committed Apr 30, 2024
1 parent 8df478e commit a50f339
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions gbasis/integrals/libcint.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def make_int1e(
)

# Make instance-bound integral method
def int1e(notation="physicist", origin=None, inv_origin=None):
def int1e(notation="physicist", transform=None, origin=None, inv_origin=None):
# Handle ``notation`` argument
if notation not in ("physicist", "chemist"):
raise ValueError("``notation`` must be one of 'physicist' or 'chemist'")
Expand Down Expand Up @@ -755,11 +755,17 @@ def int1e(notation="physicist", origin=None, inv_origin=None):
# Apply permutation
out = out[self._permutations, :][:, self._permutations]

# Return normalized integrals
# Normalize integrals
if self.coord_type == "cartesian":
return np.einsum(norm_einsum, self._ovlp_minhalf, self._ovlp_minhalf, out)
else:
return out
out = np.einsum(norm_einsum, self._ovlp_minhalf, self._ovlp_minhalf, out)

# Apply transformation
if transform is not None:
out = np.tensordot(transform, out, (1, 0))
out = np.tensordot(transform, out, (1, 1))
out = np.swapaxes(out, 0, 1)

return out

# Return instance-bound integral method
return int1e
Expand Down Expand Up @@ -823,7 +829,7 @@ def make_int2e(
)

# Make instance-bound integral method
def int2e(notation="physicist", origin=None, inv_origin=None):
def int2e(notation="physicist", transform=None, origin=None, inv_origin=None):
# Handle ``notation`` argument
if notation == "physicist":
physicist = True
Expand Down Expand Up @@ -962,18 +968,26 @@ def int2e(notation="physicist", origin=None, inv_origin=None):
out = out[:, :, self._permutations]
out = out[:, :, :, self._permutations]

# Return normalized integrals
# Normalize integrals
if self.coord_type == "cartesian":
return np.einsum(
out = np.einsum(
norm_einsum,
self._ovlp_minhalf,
self._ovlp_minhalf,
self._ovlp_minhalf,
self._ovlp_minhalf,
out,
)
else:
return out

# Apply transformation
if transform is not None:
out = np.tensordot(transform, out, (1, 0))
out = np.tensordot(transform, out, (1, 1))
out = np.tensordot(transform, out, (1, 2))
out = np.tensordot(transform, out, (1, 3))
out = np.swapaxes(np.swapaxes(out, 0, 3), 1, 2)

return out

# Return instance-bound integral method
return int2e
Expand Down

0 comments on commit a50f339

Please sign in to comment.