-
Notifications
You must be signed in to change notification settings - Fork 150
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
Fix division by zero at geoopt #1170
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Igor S. Gerasimov <[email protected]>
Signed-off-by: Igor S. Gerasimov <[email protected]>
@@ -850,7 +850,7 @@ subroutine relax(env,iter,mol,anc,restart,maxcycle,maxdispl,ethr,gthr, & | |||
write(env%unit,'(5x,"change ",e18.7,1x,"Eh")') echng | |||
write(env%unit,'(3x,"gradient norm :",f14.7,1x,"Eh/α")',advance='no') gnorm | |||
write(env%unit,'(3x,"predicted",e18.7)',advance='no') depred | |||
write(env%unit,'(1x,"("f7.2"%)")') (depred-echng)/echng*100 | |||
write(env%unit,'(1x,"("f7.2"%)")') (depred-echng)/(echng+1e-34_wp)*100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you determine this fixed #500? At least in the example they attached, the gradient norm is also NaN.
I would probably say to just not even write the percentage difference if the actual echng
is effectively 0, rather than write an enormous value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found since I am using the same technique as for other issues. :-)
@@ -613,7 +613,11 @@ Subroutine dphidrPBC(mode,nat,xyz,i,j,k,l,vTrR,vTrB,vTrC,phi,& | |||
dphidrj=0 | |||
dphidrk=0 | |||
dphidrl=0 | |||
onenner=1.0d0/(nan*nbn) | |||
if (abs(nan*nbn).gt.eps) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth clarifying what the purpose of this check is. It seems like we would only reach this condition if for some reason the magnitude of one or both of these surface normals was very small. The earlier check already determines if the normals are nearly parallel.
Is there a specific example you have found that the code change here fixes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The earlier check already determines if the normals are nearly parallel.
You can be here if nan
or nbn
equal zero and then you divide by zero :)
Is there a specific example you have found that the code change here fixes?
Yep, you can detect this with input provided in #500.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised the example from #500 goes through this function. I assumed from the name it only applied for PBC structures, but the example from the issue is molecular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¯_(ツ)_/¯
Fixes #500