Incorrect order of QM atoms in CpmdScript.gmx_to_cpmd_idx with custom script
I believe that currently CpmdScript.gmx_to_cpmd_idx
assumes that the &MIMIC.OVERLAPS
section of cpmd.inp
is structured so that the column with the CPMD index is ordered (from 1 to n_atoms
). This is the bit of code
overlaps = self.MIMIC.OVERLAPS.splitlines()
natms = int(overlaps[0])
for i, line in enumerate(overlaps[1:]):
idx = int(line.split()[1])
topol.at[idx, 'type_id'] = -natms+i
When this assumption fails (e.g., with a custom cpmd.inp
), the function returns the incorrect indices. I think a more general solution for this would be
overlaps = self.MIMIC.OVERLAPS.splitlines()
natms = int(overlaps[0])
for line in overlaps[1:]:
line = line.split()
gmx_idx = int(line[1])
cpmd_idx = int(line[3])
topol.at[gmx_idx, 'type_id'] = -natms+cpmd_idx-1
If this is correct, I can open a PR with the fix.