Fix bug in TrialWaveFunction mw_evalGrad for spinor wave functions#4911
Merged
ye-luo merged 3 commits intoQMCPACK:developfrom Feb 1, 2024
Merged
Fix bug in TrialWaveFunction mw_evalGrad for spinor wave functions#4911ye-luo merged 3 commits intoQMCPACK:developfrom
ye-luo merged 3 commits intoQMCPACK:developfrom
Conversation
rcclay
previously approved these changes
Jan 31, 2024
Contributor
|
Test this please |
ye-luo
reviewed
Jan 31, 2024
| TWFGrads<CT> grads_z(num_wf); | ||
| ScopedTimer localtimer(wf_leader.WFC_timers_[VGL_TIMER + TIMER_SKIP * i]); | ||
| const auto wfc_list(extractWFCRefList(wf_list, i)); | ||
| wavefunction_components[i]->mw_evalGrad(wfc_list, p_list, iat, grads_z); |
Contributor
There was a problem hiding this comment.
Need a bit change. WFC::mw_evalGrad is not expected to depends on previous value of grads_z. This is different from single walker API. At
Set
spingrad_now[iw] to zero before calling evalGradWithSpin. grad_now[iw] has been directly overwritten.
Contributor
Author
There was a problem hiding this comment.
reverted TrialWaveFunction back and changed in WaveFunctionComponent.cpp
ye-luo
approved these changes
Jan 31, 2024
Contributor
|
Test this please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please review the developer documentation
on the wiki of this project that contains help and requirements.
Proposed changes
This PR fixes a bug I found when doing some testing of the spinor code using the batched drivers. Essentially, I saw errors in the energy and kinetic energy relative to legacy only if there is a jastrow present and only if drift was on. Ended up tracking it down to the fact that WaveFunctionComponents that do not use the spins do not touch the spin gradient component, which they shouldn't. However, the problem was that in the TWF::mw_evalGrad function, it was passing in the previous wave function components TWFGrad type. Since the Jastrow mw_evalGrad wasn't setting the spin component to zero, then the grads += grads_z ends up accumulating the first slater determinants value over and over again. So for 3 WF components, the spin gradient was 3x too large.
Fixed by simply moving the TWFGrad initialization into the loop.set zero before calling the single walker fallback.
Closes #4910
What type(s) of changes does this code introduce?
Delete the items that do not apply
Does this introduce a breaking change?
What systems has this change been tested on?
M1 mac
Checklist
Update the following with a yes where the items apply. If you're unsure about any of them, don't hesitate to ask. This is
simply a reminder of what we are going to look for before merging your code.