[SPAM] How to get mass center coordinates of one molecule pair in lammps and match the molecule ID or group ID to corresponding molecule in visualization tools such as VMD or OVITO

Dear lammps users

I have 380 atoms and every 38 atoms are assigned to a group, thus I have 10 groups. Then I will treat every 2 groups as a pair. How to get the center mass coordinates (x,y,z) of each pair in lammps?

I also want to know how to match the molecule ID or group ID to corresponding molecule in visualization tools such as VMD or OVITO.

Sincerely

Fan Li

Dear lammps users

I have 380 atoms and every 38 atoms are assigned to a group, thus I have 10
groups. Then I will treat every 2 groups as a pair. How to get the center
mass coordinates (x,y,z) of each pair in lammps?

you can easily access the mass and center of mass for a group with
equal style variable expressions. computing the center of mass for
each pair from this information is a simple exercise in vector
algebra. since the identity of the groups won't change over a run, you
can just define the corresponding 45 expressions right away and output
them as thermo output or via fix print.

I also want to know how to match the molecule ID or group ID to
corresponding molecule in visualization tools such as VMD or OVITO.

if you output molecule ids (e.g. in a data or trajectory file), they
should be imported into VMD as "resid".
group assignment does not have a similar equivalence in what VMD
supports through its molecule file reader API. you *can* however,
output group membership via the gmask() property and then try to
import that through remapping of the LAMMPS trajectory reader or using
additional scripting. since VMD only has a few custom per atom
properties that can be used to store this info, that can only be used
to process a few groups at a time. if your groups are dynamic, things
get even more complicated... but that really is a question about
advanced VMD scripting and doesn't really belong to the LAMMPS mailing
list.

axel.

Or you could define an atom-style variable something like this

variable foo atom 1gmask(g1)+2gmask(g2)+3gmask()+4gmask() …

where g1 = group name for the first pair of lower-level groups, etc.

and use it as the arg to the compute chunk/atom command. Once

you have defined your 5 chunks, there are several chunk-related

computes. Including compute com/chunk.

Steve

Thanks axel and Steve.

Now I want to dump the group ID which I have defined. I want to output my 10 group ID in one dump command. So I can map them to corresponding molecules in OVITO. I have read the dump command in manual, it seems one can only dump one group ID in each dump command. How can I do this?

I have also read gmask(x) function in manual. But I find little information about it. So if it can be done by gmask(x) function. Would you mind giving more detailed information about it?

I am a beginner for Lammps, sorry for asking such basic questions.

Sincerely

Fan Li

Thanks axel and Steve.

Now I want to dump the group ID which I have defined. I want to output my 10
group ID in one dump command. So I can map them to corresponding molecules
in OVITO. I have read the dump command in manual, it seems one can only dump
one group ID in each dump command. How can I do this?

I have also read gmask(x) function in manual. But I find little information
about it. So if it can be done by gmask(x) function. Would you mind giving
more detailed information about it?

the gmask() function results in either 1.0 or 0.0 depending on whether
an atom is part of that group.
so you can define an atom style variable where you sum up over a term
of the kind group-factor*gmask(group-id) for all groups and then the
value for each atom will be the corresponding sum of the group-factor
values. if each atom only belongs to one group, you can assign a
per-group label.

as i mentioned earlier, using a molecule id is the more
straightforward approach.

I am a beginner for Lammps, sorry for asking such basic questions.

as a beginner, you need to learn to approach a non-trivial task in
stages and make experiments with individual parts until you understand
each step and can put the whole solution together. do not expect that
thinks are easy and straightforward to do, if you insist on complex
things. also don't expect that everything will be spelled out to the
last detail in either the manual or by people on the list. the more
complex an operation that you want to do, the more you need to expect
to do the bulk of figuring out how to do it yourself. what you are
asking for with outputting group assignments for atoms, definitely
counts as an advanced operation.

axel.

If you want one dump file with the atoms for

10 groups, you simply need to make a new group

that is the union of those 10 groups. See the group union

command.

Steve

Thanks for answering my questions and suggestions for a beginner.

I am clear about second questions now.

Now, I am trying to solve the first one. I have added the molecule pair into one group, thus I have 5 pair now. And then I try to use equal style variable expressions with xcm() function to get the position of center of mass of one group, and then I try to output them via thermo_style command, but it does not work. Here is my input, what is wrong.

Input

units real

boundary p p p

atom_style charge

read_restart coro-oh.restart.200000

pair_style reax/c NULL

pair_coeff * * ffield.reax C H O

group m1 id 1:76

variable cx equal xcm(m1,x)

variable cy equal xcm(m1,y)

variable cz equal xcm(m1,z)

neighbor 2.5 bin

neigh_modify delay 0 every 10 check no

fix 1 all nvt temp 300.53331 3000 10

fix 2 all qeq/reax 1 0.0 10.0 1.0e-6 reax/c

fix 3 all reax/c/species 1 1 100 species.tatb

fix 4 all reax/c/bonds 100 bonds.reaxc

thermo 100

thermo_style custom step temp epair etotal press v_cx v_cy v_cz

timestep 0.1

run 200

Thanks for answering my questions and suggestions for a beginner.

I am clear about second questions now.

Now, I am trying to solve the first one. I have added the molecule pair into
one group, thus I have 5 pair now. And then I try to use equal style
variable expressions with xcm() function to get the position of center of
mass of one group, and then I try to output them via thermo_style command,
but it does not work. Here is my input, what is wrong.

"it does not work" is a pointless and wholly unscientific way to
describe a problem. as a researcher, you have to *characterize* a
problem. remember, it is *your* task to find something out, not ours.

so *how* does it not work? do you get an error message? if yes, what
is it? which line of the input is failing? if the simulation runs, but
produces unexpected results, you have to explain (or better provide
proof of) what the results are and why you believe they are incorrect.

in general, if you want somebody to help you, you have to make it easy
to help you. don't just say "it doesn't work, you figure out why for
me". don't you feel that that is quite assuming and rather impolite.

axel.

Dear axel

Thanks for your suggestions. I am sorry for my behaviour. I will pay attention to my way of asking in the future post.

I have solved my problem now.

Sincerely
Fan Li