I’m running LAMMPS Nov 3 2022 version.
There is a previous question that seems relevant, but it appears the code parts of the answer/question are missing, so I am posting my own version of the question.
I’m trying to use the compute com command to find the center of mass for a group of atoms, so I can center indents around this point. In particular, I am indenting Z-planes, so I want the Z-coordinate in particular. I’m trying to figure out how to properly call this, and I seem to be having trouble. The following are relevant lines. I’m wondering what I’m doing wrong, to (A) set a variable with the Z coordinate of the center-of-mass, and (B) print that variable.
Here are (I think) the relevant bits for the code:
group chrom type 1 2
fix 6 all adapt 1 pair soft a * * v_prefactor
fix 1 all nve/dotc/langevin 1.0 1.0 50.0 100 angmom 10
run 10000
unfix 1
compute CHCRM chrom com
variable centr equal c_CHCRM[3]
print "${centr}"
Error:
ERROR: Variable centr: Compute used in variable between runs is not current (src/variable.cpp:1452)
Last command: ${centr
My suspicion is that the following commands are much less correct (although obviously there is an issue in the code as it is). Still, I tried them, here are the alternatives:
compute CHCRM chrom com
variable centr equal c_CHCRM
print "${centr}"
Error:
ERROR: Variable centr: Compute global vector in equal-style variable formula (src/variable.cpp:1500)
Last command: ${centr
compute CHCRM chrom com
variable centr equal c_CHCRM (or c_CHCRM[3])
print "${centr}"
Error:
ERROR on proc 0: Substitution for illegal variable v_centr (src/input.cpp:650)
Last command: ${v_centr
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=1
:
system msg for write_line failure : Bad file descriptor