Cascella-Group-UiO / HyMD

Massively parallel hybrid particle-field molecular dynamics in Python.
https://cascella-group-uio.github.io/HyMD/
GNU Lesser General Public License v3.0
25 stars 7 forks source link

Errors when running HyMD #143

Closed Lun4m closed 2 years ago

Lun4m commented 2 years ago

Simply trying to run examples from the tutorials repo I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/manuel/Projects/HyMD/hymd/__main__.py", line 2, in <module>
    main()
  File "/home/manuel/Projects/HyMD/hymd/main.py", line 425, in main
    store_data(
  File "/home/manuel/Projects/HyMD/hymd/file_io.py", line 417, in store_data
    np.sum(np.cross(positions, forces), axis=0), MPI.SUM
  File "<__array_function__ internals>", line 5, in cross
  File "/home/manuel/.local/lib/python3.9/site-packages/numpy/core/numeric.py", line 1598, in cross
    axisb = normalize_axis_index(axisb, b.ndim, msg_prefix='axisb')
numpy.AxisError: axisb: axis -1 is out of bounds for array of dimension 0

which is a bit puzzling, since I never had this error before and neither positions nor forces should be empty arrays?

If I comment out the angular_momentum and torque calculation I get:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/manuel/Projects/HyMD/hymd/__main__.py", line 2, in <module>
    main()
  File "/home/manuel/Projects/HyMD/hymd/main.py", line 425, in main
    store_data(
  File "/home/manuel/Projects/HyMD/hymd/file_io.py", line 543, in store_data
    data = data_fmt.format(
IndexError: Replacement index 15 out of range for positional args tuple

which simply means the 15 in the following line should be set to 14 https://github.com/Cascella-Group-UiO/HyMD/blob/58847618e0558a8a9fc7c56b4261e19380c559fc/hymd/file_io.py#L471

mortele commented 2 years ago

Have to look into this. I changed the 14 because I added the electrostatic energy to the output, which was disabled by default. Seemed to work locally on my machine, but I'll check it out in a clean environment.

mortele commented 2 years ago

Ok, the problem is

https://github.com/Cascella-Group-UiO/HyMD/blob/58847618e0558a8a9fc7c56b4261e19380c559fc/hymd/main.py#L425-L433

forces are only passed to store_data if the args.force_output flag is set. Otherwise None is sent and the numpy cross product fails.

I will fix this and the formatting bug in the output today.

mortele commented 2 years ago

Seems this is still happening in v1.0.2. 🤔

mortele commented 2 years ago

Oh, yes

https://github.com/Cascella-Group-UiO/HyMD/blob/638e3cd681f2f094611545a409810b391d4bb9f2/hymd/main.py#L431-L439

the

forces_out if args.force_output else None

need to be changed to just forces_out now that the logic for file output was moved into store_data.

mortele commented 2 years ago

Ok fixed for real now in #149