Skip to content

Conversation

@florianjoerg
Copy link
Contributor

When writing a CHARMM PSF file which has Drude particles, I ran into an error if the NUMANISO section is zero, because the idx_section list is empty in this case. I attached a psf to reproduce the error.

idx_section = []

Traceback (most recent call last):
  File "/home/florian/software/ParmEd_fork/minimal_example/test.py", line 3, in <module>
    psf.write_psf("new.psf")
  File "/scratch/data/florian/anaconda3/envs/parmed/lib/python3.11/site-packages/parmed/formats/psf.py", line 345, in write
    if idx_section[-1] == "\n":
       ~~~~~~~~~~~^^^^
IndexError: list index out of range

My suggestion would be to execute lines 317 to 348 only if n_aniso != 0.

example.zip

@swails
Copy link
Contributor

swails commented Mar 23, 2023

Thanks!

@swails swails merged commit e1c647c into ParmEd:master Mar 23, 2023
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 this pull request may close these issues.

2 participants