peteboyd / lammps_interface

automatic generation of LAMMPS input files for molecular dynamics simulations of MOFs
MIT License
125 stars 63 forks source link

KeyError: 'OW' while using --insert-molecule #10

Closed zmzeng closed 6 years ago

zmzeng commented 6 years ago

Hi, I am encountered KeyError: 'OW' while using --insert-molecule while using --insert-molecule TIP4P water. The .cif file is Okey for convert by lammps_interface.

Thanks! Zhongming

[zeng@localhost lammps_interface]$ python lammps_interface.py HfBTB-MOL-Ni0.cif -ff UFF4MOF
Molecules found in the framework, separating.
WARNING: Molecule 1 with atoms (Ni, O, H, H, O, H, H) will be using the UFF4MOF force field as no  value was set for molecules. To prevent this warning set --molecule-ff=[some force field] on the command line.
Files created! -> /home/zeng/lammps_interface

[zeng@localhost lammps_interface]$ python lammps_interface.py HfBTB-MOL-Ni0.cif -ff UFF4MOF --insert-molecule TIP4P_Water
Molecules found in the framework, separating.
WARNING: Molecule 1 with atoms (Ni, O, H, H, O, H, H) will be using the UFF4MOF force field as no  value was set for molecules. To prevent this warning set --molecule-ff=[some force field] on the command line.
Traceback (most recent call last):
  File "lammps_interface.py", line 21, in <module>
    sim.write_lammps_files()
  File "/home/zeng/lammps_interface/lammps_interface/lammps_main.py", line 742, in write_lammps_files
    self.molecule_template(self.options.insert_molecule)
  File "/home/zeng/lammps_interface/lammps_interface/lammps_main.py", line 527, in molecule_template
    cutoff=self.options.cutoff)
  File "/home/zeng/lammps_interface/lammps_interface/ForceFields.py", line 3133, in __init__
    self.compute_force_field_terms()
  File "/home/zeng/lammps_interface/lammps_interface/ForceFields.py", line 53, in compute_force_field_terms
    self.compute_atomic_pair_terms()
  File "/home/zeng/lammps_interface/lammps_interface/ForceFields.py", line 61, in compute_atomic_pair_terms
    self.pair_terms(n, data, self.cutoff)
  File "/home/zeng/lammps_interface/lammps_interface/ForceFields.py", line 3138, in pair_terms
    data['pair_potential'].eps = UFF4MOF_DATA[data['force_field_type']][3]
KeyError: 'OW'
peteboyd commented 6 years ago

Hi Zhongming, Sorry for the delay. The reason you are getting an error is because it is searching for the TIP4P force field types in the UFF4MOF forcefield. To fix this you have to run the command: python lammps_interface.py -ff UFF4MOF --insert-molecule TIP4P_Water --molecule-ff TIP4P HfBTB-MOL-Ni0.cif

so just add the --molecule-ff TIP4P and it should work properly. Seems a little redundant, but the intention was that you could insert a general particle like 'methane' and then apply whatever force field you wanted to it with the --molecule-ff command.

Let me know if you still experience problems. Pete