jhrmnn / pyberny

Molecular structure optimizer
Mozilla Public License 2.0
110 stars 21 forks source link

Issue on getting started #35

Closed andresilvapimentel closed 3 years ago

andresilvapimentel commented 3 years ago

Dear collaborators, I installed pyberny using python 3.9 version (I also installed on google colab). However, I run it using the command and the test file water.xyz (and the others as well): berny --init -f xyz ethanol.xyz

I got the error message (the same on google colab but using python 3.6): File "c:\users\user\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\user\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\User\AppData\Local\Programs\Python\Python39\Scripts\berny.exe__main__.py", line 7, in File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\berny\cli.py", line 109, in main init(args) File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\berny\cli.py", line 50, in init berny = get_berny(args) File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\berny\cli.py", line 38, in get_berny geom = geomlib.load(sys.stdin, args.format) File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\berny\geomlib.py", line 274, in load n = int(fp.readline()) ValueError: invalid literal for int() with base 10: '\x18\n'

I also tried the other usages indicated in the instructions (getting started), but it did not worked for me. It stopped reading the ethanol.xyz file as well. See the error message: Usage: from berny import Berny, geomlib from berny.solvers import MopacSolver

optimizer = Berny(geomlib.readfile('ethanol.xyz')) solver = MopacSolver() for geom in optimizer: energy, gradients = solver(geom) optimizer.send((energy, gradients)) relaxed = geom

Error message: TypeError Traceback (most recent call last)

in () 5 solver = MopacSolver() 6 for geom in optimizer: ----> 7 energy, gradients = solver(geom) 8 optimizer.send((energy, gradients)) 9 relaxed = geom TypeError: 'generator' object is not callable If I use the usage: from berny import Berny, geomlib, optimize from berny.solvers import MopacSolver The error message is: FileNotFoundError Traceback (most recent call last) in () 2 from berny.solvers import MopacSolver 3 ----> 4 relaxed = optimize(Berny(geomlib.readfile('ethanol.xyz')), MopacSolver()) FileNotFoundError: [Errno 2] No such file or directory: 'mopac': 'mopac' relaxed = optimize(Berny(geomlib.readfile('ethanol.xyz')), MopacSolver()) What am I doing wrong? Can anyone help me? Regards, Andre Pimentel
jhrmnn commented 3 years ago

Hi Andre. First, there was a bug in the CLI, unrelated to your problems, which I've just fixed and released in 0.6.3. So please before proceeding further, please update Pyberny with pip install -U pyberny.

I got the error message (the same on google colab but using python 3.6):

This is weird, and looks as if the xyz file was damaged. There is certainly no \x18 character in ethanol.xyz.

TypeError: 'generator' object is not callable

The documentation for this usage was outdated. I've fixed that as well, try running the up-to-date code. In any case, the optimize() API is preferable, if you don't need the flexibility of having the optimization loop unrolled.

FileNotFoundError: [Errno 2] No such file or directory: 'mopac': 'mopac'

It seems that you don't have Mopac installed on your system. Pyberny doesn't provide any functionality on its own, it has to be used with other programs that compute the energy and gradients, like Mopac.