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

IndexError: list index out of range #397

Open
ghost opened this issue Oct 17, 2023 · 3 comments
Open

IndexError: list index out of range #397

ghost opened this issue Oct 17, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 17, 2023

No description provided.

@ghost ghost changed the title AttributeError: 'LammpsParser' object has no attribute 'nb_types' IndexError: list index out of range Oct 17, 2023
@mattwthompson
Copy link
Collaborator

Could you also post the files you used to generate this error? My guess without looking at the code is that dihedral_style opls is not implemented

@ctk3b
Copy link
Member

ctk3b commented Oct 17, 2023

I believe opls is actually implemented:

elif dihedral == FourierDihedral:

Hard to tell without the input file but the error suggests that the dihedral coefficients are insufficiently or incorrectly specified or that InterMol does not have support for the format in which you specified them.

@roar40
Copy link

roar40 commented Jun 19, 2024

I have encountered the same problem with opls type dihedrals. I added some print() commands to intermol/forces/forcefunctions.py.

Here is my test input for imidazole molecule:
Data file:
LAMMPS data file via write_data, version 2 Aug 2023, timestep = 0, units = real

8 atoms
8 bonds
11 angles
1 dihedrals
0 impropers

8 atom types
8 bond types
11 angle types
11 dihedral types

0 5.5 xlo xhi
0 13 ylo yhi
0 2 zlo zhi

Masses

1 14.007
2 12.011
3 14.007
4 12.011
5 12.011
6 1.008
7 1.008
8 1.008

Pair Coeffs

1 0.17 3.25
2 0.07 3.55
3 0.17 3.25
4 0.07 3.55
5 0.07 3.55
6 0.03 2.42
7 0.03 2.42
8 0.03 2.42

Bond Coeffs

1 367 1.08
2 367 1.08
3 367 1.08
4 477 1.343
5 427 1.381
6 488 1.335
7 410 1.394
8 520 1.37

Angle Coeffs

1 70 109.8
2 70 110
3 35 120
4 35 120
5 70 120
6 35 120
7 35 128.2
8 70 111
9 35 121.6
10 35 130.7
11 70 106.3

Dihedral Coeffs

1 0.0 4.65 0.0 0.0

Atoms

1 1 1 -0.257 2.3095844 3.33866316 1
2 1 2 0.275 1.51946258 2.23032123 1
3 1 6 0.078 0.4394873 2.22842121 1
4 1 3 -0.5629999999999999 2.2932654 1.16993296 1
5 1 4 0.185 3.57943166 1.55862099 1
6 1 7 0.075 4.43789688 0.90333109 1
7 1 5 -0.286 3.61532385 2.90202147 1
8 1 8 0.187 4.50017903 3.52131861 1

Velocities

1 0 0 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 0 0 0

Bonds

1 4 1 2
2 5 1 7
3 6 2 4
4 1 2 3
5 7 4 5
6 8 5 7
7 2 5 6
8 3 7 8

Angles

1 1 2 1 7
2 3 1 2 3
3 4 3 2 4
4 5 1 2 4
5 2 2 4 5
6 6 4 5 6
7 7 6 5 7
8 8 4 5 7
9 9 1 7 8
10 10 5 7 8
11 11 1 7 5

Dihedrals

1 1 4 2 1 7

Input file:

units real
atom_style full

dimension 3
boundary p p p

pair_style lj/cut/coul/long 11.0 11.0
pair_modify mix geometric

bond_style harmonic
angle_style harmonic
dihedral_style opls
improper_style harmonic

special_bonds lj/coul 0.0 0.0 0.5
kspace_style pppm 0.0001

read_data Imi.data

Error:

<class 'intermol.forces.harmonic_angle_type.HarmonicAngle'>
HarmonicAngle
[Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, BaseUnit(base_dim=BaseDimension("angle"), name="radian", symbol="rad"): -2.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("angle"), name="degree", symbol="deg"): 1.0})]
['k', 'theta']
['11', '70', '106.3']
{'k': Quantity(value=70.0, unit=kilocalorie/(moleradian**2))}
['11', '70', '106.3']
{'k': Quantity(value=70.0, unit=kilocalorie/(mole
radian**2)), 'theta': Quantity(value=106.3, unit=degree)}
<class 'intermol.forces.fourier_dihedral_type.FourierDihedral'>
FourierDihedral
[Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0})]
['c1', 'c2', 'c3', 'c4', 'c5']
['1', '0.0', '4.65', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole), 'c3': Quantity(value=0.0, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole), 'c3': Quantity(value=0.0, unit=kilocalorie/mole), 'c4': Quantity(value=0.0, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0']
Traceback (most recent call last):
File "/home/yr/InterMol/intermol/convert.py", line 811, in
main()
File "/home/yr/InterMol/intermol/convert.py", line 229, in main
system, prefix = _load_lammps(lammps_in=lammps_in)
File "/home/yr/InterMol/intermol/convert.py", line 605, in _load_lammps
system = lmp.load(in_file=lammps_in)
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/lammps/lammps_parser.py", line 34, in load
return parser.read()
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/lammps/lammps_parser.py", line 315, in read
self.read_data(self.data_file)
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/lammps/lammps_parser.py", line 421, in read_data
parsable_keywordskeyword
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/lammps/lammps_parser.py", line 726, in parse_dihedral_coeffs
self.parse_force_coeffs(data_lines, "Dihedral",
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/lammps/lammps_parser.py", line 701, in parse_force_coeffs
kwds = self.create_kwds_from_entries(fields, force_class,
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/lammps/lammps_parser.py", line 218, in create_kwds_from_entries
return ff.create_kwds_from_entries(self.unitvars, self.paramlist,
File "/home/yr/anaconda3/envs/Intermol/lib/python3.10/site-packages/intermol/forces/forcefunctions.py", line 143, in create_kwds_from_entries
kwds[p] = float(entries[offset+i]) * u[i]
IndexError: list index out of range

It seems that the program expects 5th coefficient for opls dihedral. When I change dihedral from 1 0.0 4.65 0.0 0.0 to 1 0.0 4.65 0.0 0.0 0.0 there is no error in the output:

<class 'intermol.forces.harmonic_angle_type.HarmonicAngle'>
HarmonicAngle
[Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, BaseUnit(base_dim=BaseDimension("angle"), name="radian", symbol="rad"): -2.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("angle"), name="degree", symbol="deg"): 1.0})]
['k', 'theta']
['11', '70', '106.3']
{'k': Quantity(value=70.0, unit=kilocalorie/(moleradian**2))}
['11', '70', '106.3']
{'k': Quantity(value=70.0, unit=kilocalorie/(mole
radian**2)), 'theta': Quantity(value=106.3, unit=degree)}
<class 'intermol.forces.fourier_dihedral_type.FourierDihedral'>
FourierDihedral
[Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0}), Unit({BaseUnit(base_dim=BaseDimension("amount"), name="mole", symbol="mol"): -1.0, ScaledUnit(factor=4.184, master=kilojoule, name='kilocalorie', symbol='kcal'): 1.0})]
['c1', 'c2', 'c3', 'c4', 'c5']
['1', '0.0', '4.65', '0.0', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole), 'c3': Quantity(value=0.0, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole), 'c3': Quantity(value=0.0, unit=kilocalorie/mole), 'c4': Quantity(value=0.0, unit=kilocalorie/mole)}
['1', '0.0', '4.65', '0.0', '0.0', '0.0']
{'c1': Quantity(value=0.0, unit=kilocalorie/mole), 'c2': Quantity(value=4.65, unit=kilocalorie/mole), 'c3': Quantity(value=0.0, unit=kilocalorie/mole), 'c4': Quantity(value=0.0, unit=kilocalorie/mole), 'c5': Quantity(value=0.0, unit=kilocalorie/mole)}
INFO 2024-06-19 13:08:45 Finished!

Output for dihedrals in .gro file:
[ dihedrals ]
; i j k l func
4 2 1 7 3 1.94556000e+01 -0.00000000e+00 -1.94556000e+01 -0.00000000e+00 -0.00000000e+00 -0.00000000e+00

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

No branches or pull requests

3 participants