Center of box

I want to put my PDMS molecule in the center of simulation box? How can I do that please

You have complete control over the coordinates of your molecule and the box dimensions from the LAMMPS input script. For more specific instructions you have to provide what you are currently using as input and how you detect that you are not getting the desired result.

Hi @fryad,

As @akohlmey said, it is a bit difficult to give you helpful advice without a bit more details on your simulation inputs and what you try to achieve. General considerations can still be helpful depending on your situation:

  • If you have molecules coordinates in a given format (PDB for example) you will need to convert it to a LAMMPS input file. You can either do it yourself following the format specification detailed here or look at some automated tools such as moltemplate. You can then create your system and define your box such as the molecule is in the middle.
  • If you already have a datafile with a molecule defined and you would like to move it to the center of you box, you might be interested in the displace_atoms command (doc here). If you can define a group composed of all the atoms of your molecule (using types of index of the atoms), you can combine it with compute com (doc here) which computes the center of mass of a group of atoms and use variables to store the difference wrt box center. A quick and dirty example could look something like:
group pdms type 1 2 3 # Or any other types that compose your molecule. This is up to you.
compute COM pdms com
variable dx equal "lx/2.-c_COM[1]"
variable dy equal "ly/2.-c_COM[2]"
variable dz equal "lz/2.-c_COM[3]"
thermo_style custom v_dx
run 0
displace_atoms all move ${dx} ${dy} ${dz} units box

Note that you can run this commands and write a data file just after if you just want to move your molecule to the center of your simulation box.

  • If you want to keep the molecule at the center of the box during a simulation, then you can read the documentation of the fix recenter command.

Similarly to some of your previous posts, do not hesitate to provide longer message and minimal script of what you are trying to achieve. The more details you give, the more interested people can help.

Dears akohlmey and Germain
many thanks for your advises really I appreciate it. I already creates molecule file and the I will follow your instructions hope I get the result

With a molecule file it is embarrassingly simple to create the molecule at the center:

Just create the box in such a way that the origin is the center, i.e. by using the same extent in positive and negative direction. Then the coordinates for placing the molecule are 0.0 0.0 0.0. Can’t get any easier. Just requires a little looking at the manual.

Many thanks I solve it by displace_atom command