leeping / forcebalance

Systematic force field optimization.
Other
146 stars 75 forks source link

I/O error when parsing Tinker Output #247

Closed djperrefort closed 1 month ago

djperrefort commented 2 years ago

I'm running ForceBalance version 1.9.2 with tinker version 8.10.1. I'm able to get the calculation running, but it ultimately crashes with a ValueError:

$ ForceBalance.py optimize.in

... welcome message, ASCII tables, etc ...

Executing process:  python npt.py tinker 298.150 1.000                Output: npt.out

Received an error message:

[====] Error Message [====]
Traceback (most recent call last):
  File "npt.py", line 727, in <module>
    main()
  File "npt.py", line 428, in main
    prop_return = Liquid.molecular_dynamics(**MDOpts["liquid"])
  File "/.virtualenvs/forcebalance/lib/python3.7/site-packages/forcebalance/tinkerio.py", line 1013, in molecular_dynamics
    ecomp[key] = [float(s[-2])*4.184]
ValueError: could not convert string to float: 'Polarization'
[====] End o'Message [====]
 python npt.py tinker 298.150 1.000 gave a return code of 1 (it may have crashed)

Looking at the source code, it seems the error is raised while trying to parse the string output of tinker. I'm not clear on whether the tinker output changed between different versions.

If this is indeed a dependency version issue, can anyone provide a list of supported tinker versions?

cdpoon commented 1 year ago

I have just created a Singularity image for the latest version of ForceBalance from Github with Tinker8 and Tinker9. Run the tutorial, 006_ccl4_amoebe, gives the same error as the following.

Executing process:  python npt.py tinker 298.150 1.000                Output: npt.out
Received an error message:

[====] Error Message [====]
Traceback (most recent call last):
  File "/home/cdpoon/work/projects/liq-cryst/ccl4/006_ccl4_amoeba/optimize.tmp/ccl4-liquid/iter_0000/298.15K-1.0atm/npt.py", line 727, in <module>
    main()
  File "/home/cdpoon/work/projects/liq-cryst/ccl4/006_ccl4_amoeba/optimize.tmp/ccl4-liquid/iter_0000/298.15K-1.0atm/npt.py", line 428, in main
    prop_return = Liquid.molecular_dynamics(**MDOpts["liquid"])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/miniconda3/lib/python3.11/site-packages/forcebalance/tinkerio.py", line 1013, in molecular_dynamics
    ecomp[key] = [float(s[-2])*4.184]
                  ^^^^^^^^^^^^
ValueError: could not convert string to float: 'Polarization'
[====] End o'Message [====]
 python npt.py tinker 298.150 1.000 gave a return code of 1 (it may have crashed)

It looks to be the same error which is reported over a year ago. Is there a way to work around it?

leeping commented 1 year ago

Thanks @djperrefort and @cdpoon for your reports and I'm sorry for my slow response to this issue. I believe the problem is due to the FB code going out of date when parsing the output of TINKER's "analyze" program in the latest version.

I think have a local fix that works. It involves replacing all instances of these strings in tinkerio.py:

stdin="G,E,M" if strip.startswith(key):

with these lines (respectively):

stdin="G E M" if strip.startswith(key) and isfloat(s[-2]):

Please let me know if it works for you. I am also testing to see if I can reproduce the 006_ccl4_amoeba optimization result locally.

cdpoon commented 1 year ago

It works. With the local fix, 006_ccl4_amoeba runs to completion.