[lammps-users] com compute to variable

Dear all,

I want to simulate a cnt being pulled out of a 9-cnts bundle.

I have generated the xyz file with the help of scikit nano and using airebo-m force field.

Each cnt has a molecule index in the read.file, so I can identify a group to pull out of the rest (in this case it will be molecule 5).

I want to recognize the com of the central cnt so to define a cylinder and apply a velocity in its edges.

Being com a global vector of length 3, I tried the following:

group inner molecule 5

compute inncom inner com

variable crdcom equal c_inncom[1]

print ${crdcom}

ERROR: Variable crdcom: Compute used in variable between runs is not current

Last command: ${crdcom

I have also tried to define a vector variable, and I get a different error.

variable crdcom vector c_inncom

ERROR on proc 0: Substitution for illegal variable crdcom

Can someone give a hint?

Thank you

Best Regards,

Marco

Many compute commands in LAMMPS do not actually compute something but rather make pre-computed data accessible or they depend on data that is only available during a run. Thus LAMMPS does not allow to trigger a compute execution in between runs. Sometimes this can be worked around by adding a “run 0 post no”, but that requires that there is a “consumer” like thermo output or a fix that will actually trigger executing the compute. Yet this is still unreliable, as any additional in between run commands can invalidate that.

That said, for computing the center of mass in a variable this is not necessary. Please try changing your variable definition to:

variable crdcom equal xcm(inner,x)

and remove the compute.

Axel.