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

Add dipole moment observable to hf #2173

Merged
merged 46 commits into from
Feb 23, 2022
Merged

Conversation

soranjh
Copy link
Contributor

@soranjh soranjh commented Feb 5, 2022

Context:
This PR adds functions required for constructing a differentiable dipole moment observable.

Description of the Change:

  • The function moment_matrix is added to qml.hf.matrices for constructing a multipole moment matrix of integrals for a set of basis functions.

  • The dipole module is created in qml.hf to host the following functions:
    dipole_integrals: computes the dipole moment integrals in the MO basis
    fermionic_dipole: computes the fermionic dipole moment
    dipole_moment: computes the qubit dipole moment
    fermionic_one: creates a fermionic operator from one-particle MO integrals
    qubit_operator: converts a fermionic observable to a PL qubit observable

Benefits:
This functionality is required for computing a differentiable dipole moment observable and to remove using external qchem libraries for computing dipole moment.

Possible Drawbacks:
NA

Related GitHub Issues:
NA

@soranjh soranjh added WIP 🚧 Work-in-progress qchem ⚛️ Related to the QChem package labels Feb 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2022

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Feb 5, 2022

Codecov Report

Merging #2173 (26cef3d) into qchem_refactor (ae6f984) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           qchem_refactor    #2173   +/-   ##
===============================================
  Coverage           99.26%   99.26%           
===============================================
  Files                 231      232    +1     
  Lines               18253    18350   +97     
===============================================
+ Hits                18119    18216   +97     
  Misses                134      134           
Impacted Files Coverage Δ
pennylane/hf/__init__.py 100.00% <100.00%> (ø)
pennylane/hf/dipole.py 100.00% <100.00%> (ø)
pennylane/hf/matrices.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae6f984...26cef3d. Read the comment docs.

Copy link
Contributor

@ixfoduap ixfoduap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great to me, I didn't find any major issues. Only points to address are:

  • let's think if we can find a better name than fermionic_one
  • I believe we should at least try to add gradient tests for the operators

pennylane/hf/dipole.py Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
tests/hf/test_dipole.py Show resolved Hide resolved
Copy link
Contributor

@obliviateandsurrender obliviateandsurrender left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Left a few doubts and comments.

pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
Copy link
Contributor

@agran2018 agran2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @soranjh ! Nice docstrings. I have left few suggestions.

pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Show resolved Hide resolved
Copy link
Contributor

@agran2018 agran2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @soranjh. Looks good! I have just left few minor comments.

pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
pennylane/hf/dipole.py Outdated Show resolved Hide resolved
@soranjh soranjh merged commit f5910fb into qchem_refactor Feb 23, 2022
@soranjh soranjh deleted the qchem_moment_observable branch February 23, 2022 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qchem ⚛️ Related to the QChem package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants