mirror of https://github.com/QMCPACK/qmcpack.git
Merge pull request #4759 from ye-luo/update-summit-recipe
Relax NaN check in TWF::calcRatioGrad
This commit is contained in:
commit
aec55c0f42
|
@ -633,12 +633,11 @@ int NonLocalECPotential::makeNonLocalMovesPbyP(ParticleSet& P)
|
||||||
//make a non-local move
|
//make a non-local move
|
||||||
if (oneTMove)
|
if (oneTMove)
|
||||||
{
|
{
|
||||||
int iat = oneTMove->PID;
|
const int iat = oneTMove->PID;
|
||||||
Psi.prepareGroup(P, P.getGroupID(iat));
|
Psi.prepareGroup(P, P.getGroupID(iat));
|
||||||
if (P.makeMoveAndCheck(iat, oneTMove->Delta))
|
|
||||||
{
|
|
||||||
GradType grad_iat;
|
GradType grad_iat;
|
||||||
Psi.calcRatioGrad(P, iat, grad_iat);
|
if (P.makeMoveAndCheck(iat, oneTMove->Delta) && Psi.calcRatioGrad(P, iat, grad_iat) != ValueType(0))
|
||||||
|
{
|
||||||
Psi.acceptMove(P, iat, true);
|
Psi.acceptMove(P, iat, true);
|
||||||
P.acceptMove(iat);
|
P.acceptMove(iat);
|
||||||
NonLocalMoveAccepted++;
|
NonLocalMoveAccepted++;
|
||||||
|
@ -658,9 +657,8 @@ int NonLocalECPotential::makeNonLocalMovesPbyP(ParticleSet& P)
|
||||||
const NonLocalData* oneTMove = nonLocalOps.selectMove(RandomGen(), tmove_xy_);
|
const NonLocalData* oneTMove = nonLocalOps.selectMove(RandomGen(), tmove_xy_);
|
||||||
if (oneTMove)
|
if (oneTMove)
|
||||||
{
|
{
|
||||||
if (P.makeMoveAndCheck(iat, oneTMove->Delta))
|
if (P.makeMoveAndCheck(iat, oneTMove->Delta) && Psi.calcRatioGrad(P, iat, grad_iat) != ValueType(0))
|
||||||
{
|
{
|
||||||
Psi.calcRatioGrad(P, iat, grad_iat);
|
|
||||||
Psi.acceptMove(P, iat, true);
|
Psi.acceptMove(P, iat, true);
|
||||||
P.acceptMove(iat);
|
P.acceptMove(iat);
|
||||||
NonLocalMoveAccepted++;
|
NonLocalMoveAccepted++;
|
||||||
|
@ -691,9 +689,8 @@ int NonLocalECPotential::makeNonLocalMovesPbyP(ParticleSet& P)
|
||||||
oneTMove = nonLocalOps.selectMove(RandomGen(), iat);
|
oneTMove = nonLocalOps.selectMove(RandomGen(), iat);
|
||||||
if (oneTMove)
|
if (oneTMove)
|
||||||
{
|
{
|
||||||
if (P.makeMoveAndCheck(iat, oneTMove->Delta))
|
if (P.makeMoveAndCheck(iat, oneTMove->Delta) && Psi.calcRatioGrad(P, iat, grad_iat) != ValueType(0))
|
||||||
{
|
{
|
||||||
Psi.calcRatioGrad(P, iat, grad_iat);
|
|
||||||
Psi.acceptMove(P, iat, true);
|
Psi.acceptMove(P, iat, true);
|
||||||
// mark all affected electrons
|
// mark all affected electrons
|
||||||
markAffectedElecs(P.getDistTableAB(myTableIndex), iat);
|
markAffectedElecs(P.getDistTableAB(myTableIndex), iat);
|
||||||
|
|
|
@ -618,6 +618,7 @@ TrialWaveFunction::ValueType TrialWaveFunction::calcRatioGrad(ParticleSet& P, in
|
||||||
r *= Z[i]->ratioGrad(P, iat, grad_iat);
|
r *= Z[i]->ratioGrad(P, iat, grad_iat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(r != PsiValueType(0)) // grad_iat is meaningful only when r is strictly non-zero
|
||||||
checkOneParticleGradientsNaN(iat, grad_iat, "TWF::calcRatioGrad");
|
checkOneParticleGradientsNaN(iat, grad_iat, "TWF::calcRatioGrad");
|
||||||
LogValueType logratio = convertValueToLog(r);
|
LogValueType logratio = convertValueToLog(r);
|
||||||
PhaseDiff = std::imag(logratio);
|
PhaseDiff = std::imag(logratio);
|
||||||
|
@ -694,10 +695,11 @@ void TrialWaveFunction::mw_calcRatioGrad(const RefVectorWithLeader<TrialWaveFunc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int iw = 0; iw < wf_list.size(); iw++)
|
for (int iw = 0; iw < wf_list.size(); iw++)
|
||||||
|
{
|
||||||
wf_list[iw].PhaseDiff = std::imag(std::arg(ratios[iw]));
|
wf_list[iw].PhaseDiff = std::imag(std::arg(ratios[iw]));
|
||||||
|
if (ratios[iw] != PsiValueType(0))
|
||||||
for (const GradType& grads : grad_new.grads_positions)
|
checkOneParticleGradientsNaN(iat, grad_new.grads_positions[iw], "TWF::mw_calcRatioGrad");
|
||||||
checkOneParticleGradientsNaN(iat, grads, "TWF::mw_calcRatioGrad");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrialWaveFunction::printGL(ParticleSet::ParticleGradient& G, ParticleSet::ParticleLaplacian& L, std::string tag)
|
void TrialWaveFunction::printGL(ParticleSet::ParticleGradient& G, ParticleSet::ParticleLaplacian& L, std::string tag)
|
||||||
|
|
|
@ -328,8 +328,8 @@ public:
|
||||||
* It returns a complex value if the wavefunction is complex.
|
* It returns a complex value if the wavefunction is complex.
|
||||||
* @param P the active ParticleSet
|
* @param P the active ParticleSet
|
||||||
* @param iat the index of a particle moved to the new position.
|
* @param iat the index of a particle moved to the new position.
|
||||||
* @param grad_iat gradients
|
* @param grad_iat gradients. The consumer must verify if ratio is non-zero.
|
||||||
* @return ratio value
|
* @return ratio value. The caller must reject zero ratio moves.
|
||||||
*/
|
*/
|
||||||
ValueType calcRatioGrad(ParticleSet& P, int iat, GradType& grad_iat);
|
ValueType calcRatioGrad(ParticleSet& P, int iat, GradType& grad_iat);
|
||||||
|
|
||||||
|
@ -337,9 +337,9 @@ public:
|
||||||
* It returns a complex value if the wavefunction is complex.
|
* It returns a complex value if the wavefunction is complex.
|
||||||
* @param P the active ParticleSet
|
* @param P the active ParticleSet
|
||||||
* @param iat the index of a particle moved to the new position.
|
* @param iat the index of a particle moved to the new position.
|
||||||
* @param grad_iat real space gradient for iat
|
* @param grad_iat real space gradient for iat. The consumer must verify if ratio is non-zero.
|
||||||
* @param spingrad_iat spin gradient for iat
|
* @param spingrad_iat spin gradient for iat. The consumer must verify if ratio is non-zero.
|
||||||
* @return ratio value
|
* @return ratio value. The caller must reject zero ratio moves.
|
||||||
*/
|
*/
|
||||||
ValueType calcRatioGradWithSpin(ParticleSet& P, int iat, GradType& grad_iat, ComplexType& spingrad_iat);
|
ValueType calcRatioGradWithSpin(ParticleSet& P, int iat, GradType& grad_iat, ComplexType& spingrad_iat);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue