Skip to content

Commit

Permalink
Merge pull request #11 from Schoyen/two-body-exp-val
Browse files Browse the repository at this point in the history
Add options for two-body operator when computing expectation values
  • Loading branch information
Schoyen authored Feb 15, 2021
2 parents 38480fb + 5e8f332 commit 3346434
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
python:
- '3.6'
- '3.7'
- '3.8'
install:
- pip install pipenv
- pipenv install --skip-lock
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ verify_ssl = true

[packages]
pytest = "*"
tdhf = {editable = true,git = "ssh://[email protected]/haakoek/tdhf.git"}
black = "*"
matplotlib = "*"
tqdm = "*"
Expand Down
8 changes: 6 additions & 2 deletions configuration_interaction/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def compute_one_body_density_matrix(self, K=0):

return rho_qp

def compute_two_body_expectation_value(self, op, K=0):
def compute_two_body_expectation_value(self, op, K=0, asym=True):
r"""Function computing the expectation value of a two-body operator.
For a given two-body operator :math:`\hat{A}`, we compute the
expectation value by
Expand All @@ -301,6 +301,10 @@ def compute_two_body_expectation_value(self, op, K=0):
density matrix, i.e., the number of basis functions ``l``.
K : int
The eigenstate to use for the two-body density matrix.
asym: bool
Toggle whether or not ``op`` is anti-symmetrized or not. This
determines the prefactor when tracing the two-body density matrix
with the two-body operator. Default is ``True``.
Returns
-------
Expand All @@ -314,7 +318,7 @@ def compute_two_body_expectation_value(self, op, K=0):
"""
rho_rspq = self.compute_two_body_density_matrix(K=K)

return 0.25 * self.np.tensordot(
return (0.25 if asym else 0.5) * self.np.tensordot(
op, rho_rspq, axes=((0, 1, 2, 3), (2, 3, 0, 1))
)

Expand Down

0 comments on commit 3346434

Please sign in to comment.