To Dr. Giacomo Fiorin,
First of all thank you for taking time out to reply to me. Yes I have tried to do so. Since lammps_extract_variable() can only extract equal or atom styled variables, so I have redefined
the string variables to equal style variables but then I get a different error during the run.
The error I get is :
ERROR: Library error: issuing LAMMPS command during run (…/library.cpp:229)
Last command: run 100
MPI Stub WARNING: MPI not yet initialized
INPUT FILE:
#Pub1 vacuum MC
units real
atom_style full
bond_style harmonic
angle_style harmonic
dihedral_style harmonic
special_bonds amber
pair_style lj/cut/coul/long 13
kspace_style ewald 0.000001
read_data data.read extra/bond/per/atom 30 extra/angle/per/atom 30 extra/dihedral/per/atom 30 extra/improper/per/atom 30 extra/special/per/atom 200
molecule pub1 data.mol
create_atoms 0 single -17.75125215 -9.703424300000009 -26.129375200000002 mol pub1 1 units box
ndx2group index.ndx
#velocity all create 298.0 745932
neigh_modify delay 0 every 1 check yes
group rotategroup id 1:1222
timestep 1
python end_of_step_callback here “”"
from future import print_function
from lammps import lammps
def end_of_step_callback(lammps_ptr):
lmp = lammps(ptr=lammps_ptr)
f = lmp.extract_atom(“grouparr”,0)
atom1 = f[2587]
atom2 = f[2588]
lmp.command("variable atom1 equal "+ str(atom1))
lmp.command("variable atom2 equal "+ str(atom2))
a1 = lmp.extract_variable(“atom1”,0,0)
a2 = lmp.extract_variable(“atom2”,0,0)
print ("set atom pair from python: “,a1,” ",a2)
print ("actual atom pair: “,atom1,” ",atom2)
“”"
variable atom1 equal 1222
variable atom2 equal 1224
#variable a1 equal ${atom1}
#variable a2 equal ${atom2}
variable x1 equal x[${atom1}]
variable y1 equal y[${atom1}]
variable z1 equal z[${atom1}]
variable x2 equal x[${atom2}]
variable y2 equal y[${atom2}]
variable z2 equal z[${atom2}]
variable orgx equal {x2}+{x1}/2
variable orgy equal {y2}+{y1}/2
variable orgz equal {z2}+{z1}/2
variable rx equal {x1}-{x2}
variable ry equal {y1}-{y2}
variable rz equal {z1}-{z2}
variable deg equal 5
fix 1 all python/invoke 1 end_of_step end_of_step_callback
fix 2 rotategroup move rotate {orgx} {orgy} {orgz} {rx} {ry} {rz} ${deg} units box
thermo 1
thermo_style custom step v_atom1 v_atom2
restart 100 restart_mc.1.bin restart_mc.2.bin
dump 2 all xtc 1 3md3_rigid_mc.xtc
dump 1 rotategroup custom 1 grp.out id
run 100