I’m encountering an issue using ASE with the LAMMPSlib
calculator. I’m trying to calculate the potential energy of a system using a ReaxFF force field. My Python script is as follows:
My python script
from ase.io.lammpsdata import read_lammps_data
from ase.calculators.lammpslib import LAMMPSlib
atoms=read_lammps_data("ni210.dat", atom_style="charge", sort_by_id=True, Z_of_type={1:28})
log_file = "log.lammps"
lammps_header = ["units real",
"dimension 3",
"boundary p p p",
"atom_style charge",
"atom_modify map array sort 0 0"
]
lmpcmds = ["pair_style reaxff control checkqeq yes safezone 4.8 mincap 200",
"pair_coeff * * ffield Ni",
"fix fixqeqreax all qeq/reax 1 0.0 10.0 1.0e-6 reaxff"]
lmp=LAMMPSlib(log_file=log_file,
lammps_header=lammps_header,
lmpcmds=lmpcmds
)
atoms.calc=lmp
print("Energy ", atoms.get_potential_energy())
However, when I run the script, I get the following error:
Traceback (most recent call last):
File "D:\hobby\python\ASE\globalOptimization\lmpCalculatorASE\sharedlmp\lmppylib.py", line 26, in <module>
print("Energy ", atoms.get_potential_energy())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\hobby\python\ASE\globalOptimization\venv\Lib\site-packages\ase\atoms.py", line 755, in get_potential_energy
energy = self._calc.get_potential_energy(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\hobby\python\ASE\globalOptimization\venv\Lib\site-packages\ase\calculators\abc.py", line 24, in get_potential_energy
return self.get_property(name, atoms)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\hobby\python\ASE\globalOptimization\venv\Lib\site-packages\ase\calculators\calculator.py", line 538, in get_property
self.calculate(atoms, [name], system_changes)
File "D:\hobby\python\ASE\globalOptimization\venv\Lib\site-packages\ase\calculators\lammpslib.py", line 367, in calculate
self.propagate(atoms, properties, system_changes, 0)
File "D:\hobby\python\ASE\globalOptimization\venv\Lib\site-packages\ase\calculators\lammpslib.py", line 500, in propagate
assert len(ids) == len(atoms)
AssertionError
System Information:
- ASE Version:
3.23.0
- LAMMPS Version:
19 Nov 2024
- Python Version:
3.12.1
- OS:
windows 11
My data file is formatted for atom_style charge
and contains:
672 atoms
1 atom types
0.00000000 24.5405860 xlo xhi
0.00000000 31.3568106 ylo yhi
0.00000000 33.5817675 zlo zhi
Masses
1 58.69340 # Ni
Atoms
1 1 0.000000e+00 1.752899e+00 7.641550e+00 1.358177e+01
2 1 0.000000e+00 0.000000e+00 3.721949e+00 1.358177e+01
.........
672 1 0.000000e+00 2.278769e+01 2.880740e+01 4.958645e+00
Any advice or suggestions would be greatly appreciated. Thank you!