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

Support for Christiansen Form hamiltonian #6560

Merged
merged 517 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
517 commits
Select commit Hold shift + click to select a range
b175112
small refactor
austingmhuang Dec 3, 2024
383c165
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 3, 2024
0f8ef1d
minor docstring changes
austingmhuang Dec 3, 2024
08e6b54
address black
austingmhuang Dec 3, 2024
3f5179d
black?
austingmhuang Dec 3, 2024
f0fc60b
imports
austingmhuang Dec 3, 2024
231e57a
imports
austingmhuang Dec 3, 2024
665c721
seems like it should work
austingmhuang Dec 3, 2024
2db06f6
Merge branch 'pes_class' into taylor_bosonic
austingmhuang Dec 3, 2024
e999e2f
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 4, 2024
9325ecd
resolve merge conf
austingmhuang Dec 4, 2024
ed55ada
fix again
austingmhuang Dec 4, 2024
403a829
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 4, 2024
43fb465
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 4, 2024
4e83fb4
Apply suggestions from code review
austingmhuang Dec 4, 2024
5af521d
resolve confs
austingmhuang Dec 4, 2024
4c7cdde
make private
austingmhuang Dec 4, 2024
3bdb75e
minor fix
austingmhuang Dec 4, 2024
4429020
some more comments
austingmhuang Dec 4, 2024
8b7b954
isort
austingmhuang Dec 4, 2024
c9ed974
fix
austingmhuang Dec 4, 2024
1baa937
black
austingmhuang Dec 4, 2024
b30ff1e
reformat for black
austingmhuang Dec 4, 2024
df19f3a
isort
austingmhuang Dec 5, 2024
b33a746
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 5, 2024
dcfa630
sklearn typo
austingmhuang Dec 5, 2024
3164836
fix
austingmhuang Dec 5, 2024
3905345
change uloc
austingmhuang Dec 5, 2024
2bc4904
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 5, 2024
f9b1fb1
finally... i debugged it
austingmhuang Dec 5, 2024
22ff770
temp
austingmhuang Dec 5, 2024
5cb0568
[skip ci] wait for freqs to be converted back to AU
austingmhuang Dec 5, 2024
d42fa56
isort
austingmhuang Dec 5, 2024
1b9a89e
undo black for ref file
austingmhuang Dec 5, 2024
e8a9dbf
formatting a little
austingmhuang Dec 5, 2024
e927be8
fixes
austingmhuang Dec 5, 2024
421399a
we dunnit
austingmhuang Dec 5, 2024
d071ef6
fix the sorts
austingmhuang Dec 5, 2024
c8d2b7a
move to labs
austingmhuang Dec 5, 2024
4cd2b95
codecov
austingmhuang Dec 5, 2024
9155158
remove c1c2
austingmhuang Dec 5, 2024
60632c8
3D dipole
austingmhuang Dec 5, 2024
b8de5a0
finally we have saved the city
austingmhuang Dec 6, 2024
e268c05
hdf5 files
austingmhuang Dec 6, 2024
f0189e2
delete file
austingmhuang Dec 6, 2024
0bbcb42
black/pylint
austingmhuang Dec 6, 2024
3dd4504
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 6, 2024
625cda6
isort
austingmhuang Dec 6, 2024
816cbb9
temp
austingmhuang Dec 6, 2024
4a44c1d
fix
austingmhuang Dec 6, 2024
38e7807
docstrings
austingmhuang Dec 6, 2024
8da50bd
fix docstrings some more
austingmhuang Dec 6, 2024
4e5ba1e
docstrings
austingmhuang Dec 6, 2024
d3b39c6
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 6, 2024
333f480
Update tests/qchem/vibrational/test_taylor_ham.py
austingmhuang Dec 6, 2024
7871c6a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 6, 2024
b7b1755
changes
austingmhuang Dec 6, 2024
ff07aeb
changes
austingmhuang Dec 6, 2024
839d85d
small fix
austingmhuang Dec 6, 2024
5437b8a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 6, 2024
bbbdceb
address comments
austingmhuang Dec 6, 2024
6dce96c
address comments
austingmhuang Dec 6, 2024
14bfc4f
code review comments for docstrings
austingmhuang Dec 6, 2024
de4404f
math equation
austingmhuang Dec 6, 2024
4daf734
Merge branch 'taylor_bosonic' into christiansen
austingmhuang Dec 9, 2024
5d071ad
Delete unnecessary code
austingmhuang Dec 6, 2024
c360750
what
austingmhuang Dec 9, 2024
ea3b0c1
fix keyword args
austingmhuang Dec 10, 2024
b146533
looks good for now
austingmhuang Dec 10, 2024
10a37ae
fixes
austingmhuang Dec 10, 2024
a3e072a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 10, 2024
55c06ba
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 10, 2024
7fa0eb0
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 10, 2024
163f989
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 10, 2024
fd798ba
address comments
austingmhuang Dec 10, 2024
f664e25
cleanup
austingmhuang Dec 10, 2024
b409f38
docstrings, changelog
austingmhuang Dec 10, 2024
bd76995
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 10, 2024
9b561e6
merge conf
austingmhuang Dec 10, 2024
5a2d143
H2S cform data
austingmhuang Dec 10, 2024
2c822c4
idk if this is best
austingmhuang Dec 10, 2024
8038a78
what changed
austingmhuang Dec 10, 2024
9f98c8d
Update doc/releases/changelog-dev.md
austingmhuang Dec 11, 2024
647d12b
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
53d604f
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
ab12465
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
8cf0ad2
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
31556db
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
2305c58
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
2d05fa5
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
8c7240f
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 11, 2024
3a6c16a
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 11, 2024
f7ac1cc
fixed
austingmhuang Dec 11, 2024
4eff2ba
rename
austingmhuang Dec 11, 2024
33cc89d
rename
austingmhuang Dec 11, 2024
efb316c
unit tests for important things
austingmhuang Dec 12, 2024
4a45dc2
docstrings
austingmhuang Dec 12, 2024
9877752
address comments
austingmhuang Dec 12, 2024
edcbdc0
fix dostrings address comments
austingmhuang Dec 12, 2024
c833604
char leng
austingmhuang Dec 12, 2024
d00ea10
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
b8544bd
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
e1ce9bf
allow sphinx to build
austingmhuang Dec 12, 2024
888a1f0
tuple docs
austingmhuang Dec 12, 2024
c005734
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 12, 2024
c7c7106
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
05c3f64
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
1d0c031
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
b8aed74
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
52daf12
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 12, 2024
96366d6
examples
austingmhuang Dec 12, 2024
68efc1e
examples done
austingmhuang Dec 13, 2024
11e5635
double check examples
austingmhuang Dec 13, 2024
e1eb7ab
AU
austingmhuang Dec 13, 2024
6c9996b
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
5c49995
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
7e750e7
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
21137dd
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
698311c
merge conf
austingmhuang Dec 13, 2024
ff56425
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 13, 2024
523c6b1
Merge branch 'taylor_bosonic' into christiansen
austingmhuang Dec 13, 2024
eb0be57
fixes to tests
austingmhuang Dec 13, 2024
9f1ebf0
use enumerate and stuff
austingmhuang Dec 13, 2024
1476368
comment
austingmhuang Dec 13, 2024
eddb33d
black
austingmhuang Dec 13, 2024
bb01fac
new docstrings
austingmhuang Dec 13, 2024
a6c7b0b
fix changelog
austingmhuang Dec 13, 2024
4f32f5b
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
986b09a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
590732a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
b77876d
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
f9a7c39
Update doc/releases/changelog-dev.md
austingmhuang Dec 13, 2024
1c6de33
address comments
austingmhuang Dec 13, 2024
37a9e64
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 13, 2024
a940eaf
isort
austingmhuang Dec 13, 2024
9a86647
docstrings
austingmhuang Dec 13, 2024
8594f66
isort
austingmhuang Dec 13, 2024
9abab5f
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
a03ec00
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
6b4f53f
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
f5cb43c
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
85c5d5a
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
f676468
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
1cc9fa2
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
1fe330e
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
df5977b
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
3c6019c
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
0da4c59
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
95d189d
fix docstrings
austingmhuang Dec 13, 2024
1afefc9
add todos
austingmhuang Dec 13, 2024
6376f56
black
austingmhuang Dec 13, 2024
a01a42f
address sphinx?
austingmhuang Dec 13, 2024
3d91117
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 13, 2024
356c0ec
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
1a9cfcf
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
4aed7cc
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
c7f5bc7
docstring
austingmhuang Dec 13, 2024
4050823
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 13, 2024
1f384e8
fix
austingmhuang Dec 13, 2024
5f4384b
fix
austingmhuang Dec 13, 2024
442e36e
fix
austingmhuang Dec 13, 2024
33508ab
yep
austingmhuang Dec 13, 2024
2c8b47e
yep
austingmhuang Dec 13, 2024
84fb0fb
fixes
austingmhuang Dec 13, 2024
3890b2b
Update doc/releases/changelog-dev.md
austingmhuang Dec 13, 2024
758528c
Update doc/releases/changelog-dev.md
austingmhuang Dec 13, 2024
4077212
hdf5 file
austingmhuang Dec 13, 2024
f946a6f
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
32c20d2
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
53993d5
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
0890c1a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
17ecc16
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
2e5a717
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
c4e11f4
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
c0caed8
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
52eb272
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
5172404
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
06466d5
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
4260a8f
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
7c08f42
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
20f6e75
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
0f994cd
fix docstrings a bit
austingmhuang Dec 13, 2024
b5f36e2
fix docstrings a bit
austingmhuang Dec 13, 2024
96a6e70
fix docstrings a bit
austingmhuang Dec 13, 2024
8010d09
docstrings
austingmhuang Dec 13, 2024
86a70b2
black
austingmhuang Dec 13, 2024
54a24d2
black
austingmhuang Dec 13, 2024
9cf1890
fix
austingmhuang Dec 13, 2024
5be8ed0
rc?
austingmhuang Dec 13, 2024
bd26c9d
isort
austingmhuang Dec 13, 2024
c237c2f
change back
austingmhuang Dec 13, 2024
ff96324
change back
austingmhuang Dec 13, 2024
e40173c
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
e661968
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
b48bc9c
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
8dbeb5a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
1b9477d
Update doc/releases/changelog-dev.md
austingmhuang Dec 13, 2024
dd140e7
address comments
austingmhuang Dec 13, 2024
10d5c7c
Documentation for current autograph support and sharp bits (#6678)
lillian542 Dec 13, 2024
d47698c
black
austingmhuang Dec 13, 2024
968d4f2
address sphinx?
austingmhuang Dec 13, 2024
83cf699
Update `qml.wires.Wires` to disallow `wires=None` (#6713)
andrijapau Dec 13, 2024
1ce4d0a
docstring
austingmhuang Dec 13, 2024
3655a7c
Add developer focused `run` function to `qml.workflow` module (#6657)
andrijapau Dec 13, 2024
42afafa
Try uv (#6662)
rashidnhm Dec 13, 2024
b0b2b7e
Update doc/releases/changelog-dev.md
austingmhuang Dec 13, 2024
539afa8
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
aafb85a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
a11edf9
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
db19902
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
49b2510
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
c9bac47
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
fd4d77a
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
76f6aaf
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
83f4295
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
90e80bd
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
063636f
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
c6c5253
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
61792e8
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
d95452b
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
4deff5b
fix docstrings a bit
austingmhuang Dec 13, 2024
1794a91
fix docstrings a bit
austingmhuang Dec 13, 2024
61c32d2
fix docstrings a bit
austingmhuang Dec 13, 2024
4566678
black
austingmhuang Dec 13, 2024
2591bfc
address comments
austingmhuang Dec 13, 2024
8aad05d
black
austingmhuang Dec 13, 2024
915b98e
Merge branch 'master' into taylor_bosonic
austingmhuang Dec 13, 2024
6265c3c
Update pennylane/qchem/vibrational/taylor_ham.py
austingmhuang Dec 13, 2024
f436e7e
what
austingmhuang Dec 13, 2024
5664507
merg conf
austingmhuang Dec 13, 2024
5ff4c81
change back
austingmhuang Dec 13, 2024
86128e4
change back
austingmhuang Dec 13, 2024
970b392
Merge branch 'master' into christiansen
austingmhuang Dec 13, 2024
a5d2b01
pylint rvert
austingmhuang Dec 13, 2024
eb7294b
truncate hamiltonian
austingmhuang Dec 13, 2024
f020247
Update pennylane/labs/vibrational/christiansen_ham.py
austingmhuang Dec 13, 2024
0bbe4fe
Update pennylane/labs/vibrational/christiansen_ham.py
austingmhuang Dec 13, 2024
c27992c
Update pennylane/labs/vibrational/christiansen_ham.py
austingmhuang Dec 13, 2024
a69435f
Update pennylane/labs/vibrational/christiansen_ham.py
austingmhuang Dec 13, 2024
33147a0
Update pennylane/labs/vibrational/christiansen_ham.py
austingmhuang Dec 13, 2024
1e8f378
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
cbabe63
Update pennylane/labs/vibrational/christiansen_utils.py
austingmhuang Dec 13, 2024
68fb284
fixes
austingmhuang Dec 13, 2024
bf260ae
whoops changelog
austingmhuang Dec 13, 2024
9d1c12e
Merge branch 'master' into christiansen
austingmhuang Dec 13, 2024
f40fe98
Merge branch 'master' into christiansen
austingmhuang Dec 13, 2024
d182b68
Merge branch 'master' into christiansen
austingmhuang Dec 13, 2024
330d9b2
smuggle
austingmhuang Dec 13, 2024
5d03fee
ci dependency
austingmhuang Dec 13, 2024
71e404d
Merge branch 'master' into christiansen
austingmhuang Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests-labs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ jobs:
python_version: '3.10'
pytest_test_directory: pennylane/labs/tests
additional_pip_packages: |
geometric mpi4py
geometric mpi4py h5py
${{ needs.default-dependency-versions.outputs.jax-version }}
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ such as `shots`, `rng` and `prng_key`.
symbolic operation classes.
[(#6592)](https://github.com/PennyLaneAI/pennylane/pull/6592)

* Added support to build a vibrational Hamiltonian in the Christiansen form.
[(#6560)](https://github.com/PennyLaneAI/pennylane/pull/6560)

<h3>Breaking changes 💔</h3>

* `qml.fourier.qnode_spectrum` no longer automatically converts pure numpy parameters to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
return {"foo": 1, "bar": 2}

@classmethod
def resource_rep(cls, foo, bar):

Check notice on line 120 in pennylane/labs/tests/resource_estimation/test_resource_operator.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/labs/tests/resource_estimation/test_resource_operator.py#L120

Disallowed name "bar" (disallowed-name)

Check notice on line 120 in pennylane/labs/tests/resource_estimation/test_resource_operator.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/labs/tests/resource_estimation/test_resource_operator.py#L120

Disallowed name "foo" (disallowed-name)
return re.CompressedResourceOp(cls, {"foo": foo, "bar": bar})

@staticmethod
def tracking_name(foo, bar):

Check notice on line 124 in pennylane/labs/tests/resource_estimation/test_resource_operator.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/labs/tests/resource_estimation/test_resource_operator.py#L124

Disallowed name "foo" (disallowed-name)

Check notice on line 124 in pennylane/labs/tests/resource_estimation/test_resource_operator.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/labs/tests/resource_estimation/test_resource_operator.py#L124

Disallowed name "bar" (disallowed-name)
return f"DummyClass({foo}, {bar})"

op = DummyClass()
op = DummyClass(wires=[1, 2, 3])
assert op.resource_rep_from_op() == op.__class__.resource_rep(**op.resource_params())
207 changes: 207 additions & 0 deletions pennylane/labs/tests/vibrational/test_christiansen_ham.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# Copyright 2018-2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit Tests for the Christiansen Hamiltonian construction functions."""

from pathlib import Path

import numpy as np
import pytest

from pennylane.bose.bosonic import BoseWord
from pennylane.labs.tests.vibrational.test_ref_files.cform_ops_data import (
cform_coeffs_ref,
cform_dipole_ref_x,
cform_ham_ref,
cform_ops_ref,
)
from pennylane.labs.vibrational.christiansen_ham import (
christiansen_bosonic,
christiansen_dipole,
christiansen_hamiltonian,
)
from pennylane.labs.vibrational.christiansen_utils import (
_cform_onemode,
_cform_onemode_dipole,
_cform_threemode,
_cform_threemode_dipole,
_cform_twomode,
_cform_twomode_dipole,
christiansen_integrals,
christiansen_integrals_dipole,
)
from pennylane.qchem.vibrational.vibrational_class import VibrationalPES

# Path is pennylane/labs/tests/vibrational/test_ref_files/H2S.hdf5
cform_file = Path(__file__).resolve().parent / "test_ref_files" / "H2S.hdf5"

# Path is pennylane/tests/qchem/vibrational/test_ref_files/H2S_3D_PES.hdf5
pes_file = (
Path(__file__).resolve().parent.parent.parent.parent.parent
/ "tests"
/ "qchem"
/ "vibrational"
austingmhuang marked this conversation as resolved.
Show resolved Hide resolved
/ "test_ref_files"
/ "H2S_3D_PES.hdf5"
)

h5py = pytest.importorskip("h5py")

with h5py.File(pes_file, "r") as f:
pes_onemode = np.array(f["pes_onemode"][()])
pes_twomode = np.array(f["pes_twomode"][()])
pes_threemode = np.array(f["pes_threemode"][()])

dipole_onemode = np.array(f["dipole_onemode"][()])
dipole_twomode = np.array(f["dipole_twomode"][()])
dipole_threemode = np.array(f["dipole_threemode"][()])
pes_object_3D = VibrationalPES(
freqs=np.array(f["freqs"][()]),
grid=np.array(f["grid"][()]),
uloc=np.array(f["uloc"][()]),
gauss_weights=np.array(f["gauss_weights"][()]),
pes_data=[pes_onemode, pes_twomode, pes_threemode],
dipole_data=[dipole_onemode, dipole_twomode, dipole_threemode],
localized=f["localized"][()],
dipole_level=f["dipole_level"][()],
)

pes_object_2D = VibrationalPES(
freqs=np.array(f["freqs"][()]),
grid=np.array(f["grid"][()]),
uloc=np.array(f["uloc"][()]),
gauss_weights=np.array(f["gauss_weights"][()]),
pes_data=[pes_onemode, pes_twomode],
dipole_data=[dipole_onemode, dipole_twomode],
localized=f["localized"][()],
dipole_level=2,
)

with h5py.File(cform_file, "r") as f:
H1 = f["H1"][()]
H2 = f["H2"][()]
H3 = f["H3"][()]
D1 = f["D1"][()]
D2 = f["D2"][()]
D3 = f["D3"][()]


def test_christiansen_bosonic():
"""Test that christiansen_bosonic produces the correct bosonic operator."""
christiansen_bos_op = christiansen_bosonic(one=H1, two=H2, three=H3)
christiansen_bos_op.simplify()

ops, coeffs = zip(*list(christiansen_bos_op.items()))

for i, ele in enumerate(cform_ops_ref):
cform_ops_ref[i] = BoseWord(ele)

assert list(ops) == cform_ops_ref
assert np.allclose(coeffs, cform_coeffs_ref, atol=1e-10)
assert len(christiansen_bos_op) == len(cform_ops_ref)


def test_christiansen_hamiltonian():
"""Test that christiansen_hamiltonian produces the expected hamiltonian."""
cform_ham = christiansen_hamiltonian(pes=pes_object_3D, n_states=4, cubic=True)
cform_ham.simplify()
assert len(cform_ham.pauli_rep) == 4160

# Tolerance is low here because values smaller than 1e-5 get converted to 0.0
# We only compare a small percentage of the Hamiltonian since there are many terms
assert all(
np.allclose(abs(cform_ham_ref.pauli_rep[term]), abs(coeff), atol=1e-4)
for term, coeff in list(cform_ham.pauli_rep.items())[:84]
)


def test_christiansen_dipole():
"""Test that christiansen_dipole produces the expected dipole operator coefficients."""
cform_dipole_x, _, _ = christiansen_dipole(pes=pes_object_2D, n_states=4)
assert len(cform_dipole_x.pauli_rep) == len(cform_dipole_ref_x)
assert all(
np.allclose(abs(cform_dipole_ref_x.pauli_rep[term]), abs(coeff), atol=1e-8)
for term, coeff in cform_dipole_x.pauli_rep.items()
)


def test_christiansen_integrals():
"""Test that christiansen_integrals produces the expected integrals."""
one, two, three = christiansen_integrals(pes=pes_object_3D, n_states=4, cubic=True)
assert np.allclose(abs(one), abs(H1), atol=1e-8)
assert np.allclose(abs(two), abs(H2), atol=1e-8)
assert np.allclose(abs(three), abs(H3), atol=1e-8)


def test_christiansen_integrals_dipole():
"""Test that christiansen_integrals_dipole produces the expected dipole integrals."""
one, two, three = christiansen_integrals_dipole(pes=pes_object_3D, n_states=4)
assert np.allclose(abs(one), abs(D1), atol=1e-8)
assert np.allclose(abs(two), abs(D2), atol=1e-8)
assert np.allclose(abs(three), abs(D3), atol=1e-8)


def test_cform_onemode():
"""Test that _cform_onemode produces the expected one-body integral."""
flattened_H1 = H1.ravel()
assert np.allclose(
abs(flattened_H1), abs(_cform_onemode(pes=pes_object_3D, n_states=4)), atol=1e-8
)


def test_cform_onemode_dipole():
"""Test that _cform_onemode_dipole produces the expected one-body dipole integral."""
flattened_D1 = D1.transpose(1, 2, 3, 0).ravel()
assert np.allclose(
abs(flattened_D1),
abs(_cform_onemode_dipole(pes=pes_object_3D, n_states=4).ravel()),
atol=1e-8,
)


def test_cform_threemode():
"""Test that _cform_threemode produces the expected three-body integral."""
flattened_H3 = H3.ravel()
assert np.allclose(
abs(flattened_H3), abs(_cform_threemode(pes=pes_object_3D, n_states=4)), atol=1e-8
)


def test_cform_threemode_dipole():
"""Test that _cform_threemode_dipole produces the expected three-body dipole integral."""
flattened_D3 = D3.transpose(1, 2, 3, 4, 5, 6, 7, 8, 9, 0).ravel()

assert np.allclose(
abs(flattened_D3),
abs(_cform_threemode_dipole(pes=pes_object_3D, n_states=4).ravel()),
atol=1e-8,
)


def test_cform_twomode():
"""Test that _cform_twomode produces the expected two-body integral."""
flattened_H2 = H2.ravel()
assert np.allclose(
abs(flattened_H2), abs(_cform_twomode(pes=pes_object_3D, n_states=4)), atol=1e-8
)


def test_cform_twomode_dipole():
"""Test that _cform_twomode_dipole produces the expected two-body dipole integral."""
flattened_D2 = D2.transpose(1, 2, 3, 4, 5, 6, 0).ravel()

assert np.allclose(
abs(flattened_D2),
abs(_cform_twomode_dipole(pes=pes_object_3D, n_states=4).ravel()),
atol=1e-8,
)
Binary file modified pennylane/labs/tests/vibrational/test_ref_files/H2S.hdf5
Binary file not shown.
24 changes: 24 additions & 0 deletions pennylane/labs/tests/vibrational/test_ref_files/cform_ops_data.py

Large diffs are not rendered by default.

Loading
Loading