Skip to content

Conversation

@ncrubin
Copy link
Collaborator

@ncrubin ncrubin commented Jul 5, 2023

Resolves bug #127 which notices the incorrect usage of inplace.

Also udpate the exact time evolution algorithm so FQE warns the user when the Taylor or Chebyshev expansions do not converge.

ncrubin added 4 commits July 5, 2023 14:50
Resolves bug #127 which notices the incorrect usage of inplace.

Also udpate the exact time evolution algorithm so FQE warns the
user when the Taylor or Chebyshev expansions do not converge.
The Taylor expansion and Chebyshev expansion code
had a hard stop at 30 terms and the interface to
`apply_generated_unitary` had a true zero as the
accuracy (which is never achieved in practice).

Adjusting the code such that we no longer require
true zero but instead numerical zero of 1.E-15
revealed a number of problems associated with
taking a very long time and possible issues with
inplace evolution.  I will open issues for these
after this PR.

The algorithms update for Givens rotation and
doubles evolution now no longer uses inplace
evolution which seems to behave correctly.
inplace is behaving weirdly so for now overwrite the wavefunction
in the appropriate `algorithms'
When running tests for debugging I added a main
to run individual tests locally.  I am now removing it.
@ncrubin
Copy link
Collaborator Author

ncrubin commented Jul 6, 2023

@awhite862 can you request to review this?

Copy link
Contributor

@awhite862 awhite862 left a comment

Choose a reason for hiding this comment

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

Just a few minor things. The only major thing is fixing the reference data in the tests. Looks good otherwise!

else:
base = self

max_expansion = max(30, expansion)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you remove the max expansion order, maybe add a check (raise a ValueError or something) if it is unreasonably large?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add a check for expansion being an integer. That way the user can't input a np.nan, np.inf, float...something that would make the loop fail.

from tests.unittest_data.generate_openfermion_molecule import (
build_lih_moleculardata,)

import pytest
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate import?


if __name__ == "__main__":
test_evolve_spinful_fermionop()
# test_evolve_spinful_fermionop()
Copy link
Contributor

Choose a reason for hiding this comment

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

remove comment

import fqe
from fqe.hamiltonians import general_hamiltonian
from tests.unittest_data.build_nh_data import build_nh_data
import pytest
Copy link
Contributor

Choose a reason for hiding this comment

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

import order: pytest should go with the other 3rd party imports

# 'apply_array', 'apply_sparse', 'apply_diagonal', 'apply_quadratic',
# 'apply_dc'
# ]])
@pytest.mark.skip(reason="Test seems to be failing due to bad reference_data")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you put the skip above the parametrize it just skips all of them and you don't need to comment them out

@ncrubin ncrubin requested a review from awhite862 July 6, 2023 23:57
from tests.unittest_data.generate_openfermion_molecule import (
build_lih_moleculardata,)

import pytest
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

woops this should go above

import copy
from tests.unittest_data.build_lih_data import build_lih_data
from fqe.algorithm import davidson
import pytest
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this too

Copy link
Contributor

@awhite862 awhite862 left a comment

Choose a reason for hiding this comment

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

lgtm!

@ncrubin ncrubin merged commit 11c165f into master Jul 7, 2023
@ncrubin ncrubin deleted the alog_fixes branch July 7, 2023 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants