psi-rking / optking

optking: A molecular geometry optimization program
BSD 3-Clause "New" or "Revised" License
20 stars 14 forks source link

iteration numbering in psi #83

Closed loriab closed 1 year ago

loriab commented 1 year ago

I noticed the top of the convergence grep '~' table wasn't getting printed with optking. It looks like it's because iternum starts with 1, while the printing is set up to add the suffix when the iternum is 0. I can "fix" it easily enough with the change in the snippet below, but I don't know if that would throw off other entry points/users. Maybe psi4 driver needs to decrement the iteration number before it hits optking instead? Second snippet is output of tu3 if I do the selfish edit in optking. :-)

Anyways, not a big deal, just letting you know.

convcheck.py

    suffix = "~\n" if conv_info.get("iternum") == 1 else "\n"
    print(f"LAB EDIT {conv_info.get('iternum')=} {suffix=}")
(sss-py310cf) psilocaluser@bash:psinet:/psi/gits/hrw-occ/objdir_ssspy310cf: (cf_iterations) stage/bin/psi4 ../tests/tu3-h2o-opt/input.dat 
LAB EDIT conv_info.get('iternum')=1 suffix='~\n'
LAB EDIT conv_info.get('iternum')=1 suffix='~\n'
LAB EDIT conv_info.get('iternum')=1 suffix='~\n'
LAB EDIT conv_info.get('iternum')=2 suffix='\n'
LAB EDIT conv_info.get('iternum')=2 suffix='\n'
LAB EDIT conv_info.get('iternum')=2 suffix='\n'
LAB EDIT conv_info.get('iternum')=3 suffix='\n'
LAB EDIT conv_info.get('iternum')=3 suffix='\n'
LAB EDIT conv_info.get('iternum')=3 suffix='\n'
Optimizer: Optimization complete!
    Nuclear repulsion energy..............................................................PASSED
    Reference energy......................................................................PASSED
(sss-py310cf) psilocaluser@bash:psinet:/psi/gits/hrw-occ/objdir_ssspy310cf: (cf_iterations) grep '~' ../tests/tu3-h2o-opt/input.out 
    ----------------------------------------------------------------------------------------------~
       Step    Total Energy     Delta E     Max Force     RMS Force      Max Disp      RMS Disp   ~
    ----------------------------------------------------------------------------------------------~
      Convergence Criteria     1.00e-06 *    3.00e-04 *             o    1.20e-03 *             o~
    ----------------------------------------------------------------------------------------------~
         1     -76.02663274   -7.60e+01      1.52e-02      1.25e-02 o    2.74e-02      2.28e-02 o  ~
         2     -76.02702267   -3.90e-04      1.79e-03      1.43e-03 o    1.01e-02      5.95e-03 o  ~
         3     -76.02703273   -1.01e-05      1.40e-04 *    8.49e-05 o    7.75e-04 *    4.47e-04 o  ~
psi-rking commented 1 year ago

I ran a test. The initial suffix ~ was present in the .log output but not in .out. The code is hard to track here, but it looks like the first time it is called, only the log file gets written to. I tried changing to

suffix = "~\n" if conv_info.get("iternum") == 1 else "\n"

and now .log and .out agree. Do you see any issues @AlexHeide ? If not, I'll work this into my current pull request.

AlexHeide commented 1 year ago

Checking for iter_num == 1 looks right to me.