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

Ambiguous Tag in the output file when ran cell optimizations #3423

Closed
LePingKYXK opened this issue May 22, 2024 · 5 comments
Closed

Ambiguous Tag in the output file when ran cell optimizations #3423

LePingKYXK opened this issue May 22, 2024 · 5 comments

Comments

@LePingKYXK
Copy link

Dear CP2K developers,

I found an ambiguous tag in the output file (.out) when I ran cell optimizations. The details are presented as follows.

In the "Convergence check" section, when neither 'Max. gradient' nor 'RMS gradient' meets the convergence criteria, their tags are both displayed as "Conv. for gradients = No". For ease of reference, I have marked the position of the tags with arrows.

 --------  Informations at step =    62 ------------
  Optimization Method        =                 BFGS
  Total Energy               =      -699.7050944533
  Internal Pressure [bar]    =      -429.0176709974
  Real energy change         =        -0.0001072320
  Predicted change in energy =        -0.0000762510
  Scaling factor             =         0.4741653427
  Step size                  =         0.0110589295
  Trust radius               =         0.3779452266
  Decrease in energy         =                  YES
  Used time                  =               37.476

  Convergence check :
  Max. step size             =         0.0110589295
  Conv. limit for step size  =         0.0030000000
  Convergence in step size   =                   NO
  RMS step size              =         0.0029402551
  Conv. limit for RMS step   =         0.0015000000
  Convergence in RMS step    =                   NO
  Max. gradient              =         0.0009201371
  Conv. limit for gradients  =         0.0004500000
  Conv. for gradients        =                   NO    <--------      
  RMS gradient               =         0.0003096221
  Conv. limit for RMS grad.  =         0.0003000000                                                                                                                        
  Conv. for gradients        =                   NO    <========
  Pressure Deviation [bar]   =      -430.0309209974
  Pressure Tolerance [bar]   =       100.0000000000
  Conv. for  PRESSURE        =                   NO
 ---------------------------------------------------

The same tags of Conv. for gradients can lead to confusion.

Once the 'RMS gradient' meets the convergence criteria, however, it displays as "Conv. in RMS gradients". Please see below.

 --------  Informations at step =    63 ------------
  Optimization Method        =                 BFGS
  Total Energy               =      -699.7051809655
  Internal Pressure [bar]    =      -517.1321714658
  Real energy change         =        -0.0000865121
  Predicted change in energy =        -0.0000611498
  Scaling factor             =         0.4741653427
  Step size                  =         0.0082591465
  Trust radius               =         0.3779452266
  Decrease in energy         =                  YES
  Used time                  =               37.187

  Convergence check :
  Max. step size             =         0.0082591465
  Conv. limit for step size  =         0.0030000000
  Convergence in step size   =                   NO
  RMS step size              =         0.0022719608
  Conv. limit for RMS step   =         0.0015000000
  Convergence in RMS step    =                   NO
  Max. gradient              =         0.0010533890
  Conv. limit for gradients  =         0.0004500000
  Conv. for gradients        =                   NO    <--------
  RMS gradient               =         0.0002811560
  Conv. limit for RMS grad.  =         0.0003000000                                                                                                                        
  Conv. in RMS gradients     =                  YES    <========
  Pressure Deviation [bar]   =      -518.1454214658
  Pressure Tolerance [bar]   =       100.0000000000
  Conv. for  PRESSURE        =                   NO
 ---------------------------------------------------

As shown above, the CP2K program already includes the tag "Conv. in RMS gradients", which indicates that the RMS gradients have converged, contrasting the earlier ambiguous label "Conv. for gradients".

It is recommended that developers address the mentioned bug so that when 'RMS gradient' does not meet the convergence criteria, it displays as "Conv. in RMS gradients = No".

Thanks a lot.
Huan

@mkrack
Copy link
Member

mkrack commented May 22, 2024

I don't think this is a bug. Max. gradient and RMS gradient are two different convergence criteria besides the other ones listed. For convergence both criteria, the maximum (atomic) gradient as well as the root-mean-square (RMS) of all atomic gradients have to be below their requested threshold values, respectively. To avoid confusion,

  Max. gradient              =         0.0010533890
  Conv. limit for gradients  =         0.0004500000
  Conv. for gradients        =                   NO

could be changed to

  Max. gradient              =         0.0010533890
  Conv. limit for max. grad. =         0.0004500000
  Conv. for max. gradient    =                   NO

@LePingKYXK
Copy link
Author

I don't think this is a bug. Max. gradient and RMS gradient are two different convergence criteria besides the other ones listed. For convergence both criteria, the maximum (atomic) gradient as well as the root-mean-square (RMS) of all atomic gradients have to be below their requested threshold values, respectively. To avoid confusion,

  Max. gradient              =         0.0010533890
  Conv. limit for gradients  =         0.0004500000
  Conv. for gradients        =                   NO

could be changed to

  Max. gradient              =         0.0010533890
  Conv. limit for max. grad. =         0.0004500000
  Conv. for max. gradient    =                   NO

Thank you for your reply.
The threshold values are indeed different for Max. gradient and RMS gradient. But they share the same Conv. for gradients tags when neither of them meets the convergence criteria. That is the big problem when I try to write a Python script with regular expressions to check the convergence at each step.

  Max. gradient              =         0.0009201371
  Conv. limit for gradients  =         0.0004500000
  Conv. for gradients        =                   NO    <--------      
  RMS gradient               =         0.0003096221
  Conv. limit for RMS grad.  =         0.0003000000                                                                                                                        
  Conv. for gradients        =                   NO    <========

As I presented before, CP2K already has the Conv. in RMS gradients tag for indicating convergence of the RMS gradient, like

  RMS gradient               =         0.0002811560
  Conv. limit for RMS grad.  =         0.0003000000                                                                                                                        
  Conv. in RMS gradients     =                  YES    <========

Why not use it to denote non-convergence as well? like,

  RMS gradient               =         0.0003096221
  Conv. limit for RMS grad.  =         0.0003000000                                                                                                                        
  Conv. in RMS gradients     =                  NO    <========

This would provide consistency in the tagging system, making it easier to identify both the convergence and non-convergence states at a glance and easier for programming scripts.

@marci73
Copy link
Contributor

marci73 commented May 24, 2024

It is not a bug, just a typo in the output. The word RMS is missing

@mkrack
Copy link
Member

mkrack commented May 24, 2024

I will revise that output to avoid any ambiguity.

@LePingKYXK
Copy link
Author

I will revise that output to avoid any ambiguity.

Thank you very much.
I hope the next version of CP2K will incorporate this correction.

mkrack added a commit to mkrack/cp2k that referenced this issue May 24, 2024
* Tag and homogenize optimizer output
* Align optimizer output with MD output
* Fix ambiguous optimizer tags (cp2k#3423)
* Homogenize optimizer printout
mkrack added a commit that referenced this issue May 25, 2024
* Tag and homogenize optimizer output
* Align optimizer output with MD output
* Fix ambiguous optimizer tags (#3423)
* Homogenize optimizer printout
@mkrack mkrack closed this as completed May 30, 2024
MGraml pushed a commit to MGraml/cp2k that referenced this issue Jun 12, 2024
* Tag and homogenize optimizer output
* Align optimizer output with MD output
* Fix ambiguous optimizer tags (cp2k#3423)
* Homogenize optimizer printout
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

No branches or pull requests

3 participants