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

DL_POLY HISTORY may contain cells even for non-periodic simulations #3314

Closed
fiszczyp opened this issue May 20, 2021 · 0 comments · Fixed by #3312
Closed

DL_POLY HISTORY may contain cells even for non-periodic simulations #3314

fiszczyp opened this issue May 20, 2021 · 0 comments · Fixed by #3312

Comments

@fiszczyp
Copy link
Contributor

fiszczyp commented May 20, 2021

Expected behavior

If the DL_POLY HISTORY file starts like:

Test molecule                        
         0         0      2520                  101               509446
timestep         0      2520 0 0            0.000700            0.000000
       63.9987726600        0.0000000000        0.0000000000            
        0.0000000000       60.0000030000        0.0000000000            
        0.0000000000        0.0000000000       63.1569481800           
CT               1     12.011500      0.115000      0.000000            
   -0.5783592591        0.4774311051         18.27086368                
CA               2     12.011500     -0.115000      0.000000            
    -1.263279574        0.8116030738         16.92369799                
CA               3     12.011500     -0.115000      0.000000            

running:

u = mda.Universe('HISTORY', format='HISTORY')

should produce a Universe with 2520 atoms. The cell parameters might differ between timeframes.

Actual behavior

Raises:

ValueError: invalid literal for int() with base 10: '0.0000000000'.

This behaviour happens because HistoryReader in coordinates/DLPoly.py skips the cell dimensions only if not imcom == 0. imcom is the second integer in the second line of the file, i.e. zero. Such incom value implies no periodic boundary conditions (see DLPOLY manual). For this reason, it is reasonable for the HistoryReader to assume there are no cell dimensions and that the next line under the timestep ... line already defines an atom. So it assumes that the 63.9987726600 0.0000000000 0.0000000000 line is atom definition and tries to read 0.0000000000 as atom index (integer).

Such assumption makes sense, as non-periodic simulations do not need a cell. However, if (for whatever reason) the simulation used an ensemble with constant volume or pressure, a cell is nonetheless generated and appended for each timestep. Instead of using imcom == 0 as a flag for cell parameters being printed, the parser should actively check whether cell parameters are present or not.

Code to reproduce the behavior

Can be reproduced with a HISTORY file containing:

         0         0      3                  101               509446
timestep         0      3 0 0            0.000700            0.000000
       63.9987726600        0.0000000000        0.0000000000            
        0.0000000000       60.0000030000        0.0000000000            
        0.0000000000        0.0000000000       63.1569481800           
CT               1     12.011500      0.115000      0.000000            
   -0.5783592591        0.4774311051         18.27086368                
CA               2     12.011500     -0.115000      0.000000            
    -1.263279574        0.8116030738         16.92369799                
CA               3     12.011500     -0.115000      0.000000     ```

``` python
import MDAnalysis as mda

u = mda.Universe('HISTORY', format='HISTORY')

Current version of MDAnalysis

MDAnalysis 1.0.0, Python 3.7, Win 10 64-bit.

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

Successfully merging a pull request may close this issue.

1 participant