Dear Lammps users:
I have installed the latest lammps version with its python interface (lammps-22Aug18). I have tested it with the instruction in the manual. However, I cannot execute the fix python/invoke function correctly in the examples. The error code is:
python end_of_step_callback here “”"
from future import print_function
from lammps import lammps
def end_of_step_callback(lmp):
L = lammps(ptr=lmp)
t = L.extract_global(“ntimestep”, 0)
print("### END OF STEP ###", t)
def post_force_callback(lmp, v):
L = lammps(ptr=lmp)
t = L.extract_global(“ntimestep”, 0)
print("### POST_FORCE ###", t)
“”"
fix 1 all nve
fix 2 all python/invoke 50 end_of_step end_of_step_callback
fix 3 all python/invoke 50 post_force post_force_callback
The error message is
Exception AttributeError: “‘lammps’ object has no attribute ‘lmp’” in <bound method lammps.del of <lammps.lammps object at 0x2aae33f19f90>> ignored
In fact, in python, if I type
from lammps import lammps
lmp = lammps(ptr=lmpptr)
natoms = lmp.get_natoms()
It will tell me that name ‘lmpptr’ is not defined.
Can you give me some suggestions? Thank you!
Shijun Zhao