fix recenter and fix spring

I want to simulate this system:
rectangular box divided in two parts by a piston, each of this part is filled with a LJ 2D gas. The piston is made of a certain number of rigid bodies linked in series by springs.
The two gases have unequal initial temperatures, and I want to observe the relaxation of the temperatures with time through the conducting piston.
As the motion of the piston as a whole can alter the relaxation process I want to fix it.
I tried with "fix recenter" but this seems to alter un-physically the dynamics as also explained in the fix recenter page on the website. The piston kinetic energy increase and also the total energy of the system increase with time, while the system is isolated.
So I was thinking about using "fix spring". Is it possible to bound with a spring to its initial position only the center of mass of the piston and not each single rigid body forming the piston?
If not is there any alternative for what I want to do?

Stefano D.S.

I want to simulate this system:
rectangular box divided in two parts by a piston, each of this part is
filled with a LJ 2D gas. The piston is made of a certain number of
rigid bodies linked in series by springs.
The two gases have unequal initial temperatures, and I want to observe
the relaxation of the temperatures with time through the conducting
piston.
As the motion of the piston as a whole can alter the relaxation
process I want to fix it.
I tried with "fix recenter" but this seems to alter un-physically the
dynamics as also explained in the fix recenter page on the website.

I would suspect that fix recenter is a bad choice because it would
seem to completely prevent the movement of the piston. But then I
realized that you have multiple rigid bodies in what you are calling
the "piston", so I'm not sure what is going on.

The piston kinetic energy increase and also the total energy of the
system increase with time, while the system is isolated.

Strange. Here is one potential issue: Do you have warning message
similar to this?

  "WARNING: One or more atoms are time integrated more than once"
(If so, then this is bad, and you should fix this error, regardless of
whether you use "fix recenter". To do that, re-read the documentation
for fix rigid carefully.)

So I was thinking about using "fix spring". Is it possible to bound
with a spring to its initial position only the center of mass of the
piston and not each single rigid body forming the piston?
If not is there any alternative for what I want to do?

I have not used "fix spring", but that sounds correct to me. (You
just have to be careful to use the "group" command define a group
which includes all of the atoms in all of the rigid bodies which make
up your piston system.)

Have you tried it? Is this not working?

Hi, thanks for the reply

Quoting Andrew Jewett <[email protected]>:

I want to simulate this system:
rectangular box divided in two parts by a piston, each of this part is
filled with a LJ 2D gas. The piston is made of a certain number of
rigid bodies linked in series by springs.
The two gases have unequal initial temperatures, and I want to observe
the relaxation of the temperatures with time through the conducting
piston.
As the motion of the piston as a whole can alter the relaxation
process I want to fix it.
I tried with "fix recenter" but this seems to alter un-physically the
dynamics as also explained in the fix recenter page on the website.

I would suspect that fix recenter is a bad choice because it would
seem to completely prevent the movement of the piston. But then I
realized that you have multiple rigid bodies in what you are calling
the "piston", so I'm not sure what is going on.

The piston kinetic energy increase and also the total energy of the
system increase with time, while the system is isolated.

Strange. Here is one potential issue: Do you have warning message
similar to this?

  "WARNING: One or more atoms are time integrated more than once"
(If so, then this is bad, and you should fix this error, regardless of
whether you use "fix recenter". To do that, re-read the documentation
for fix rigid carefully.)

No I don't have any warning, I set carefully the others fix to prevent this problem.

So I was thinking about using "fix spring". Is it possible to bound
with a spring to its initial position only the center of mass of the
piston and not each single rigid body forming the piston?
If not is there any alternative for what I want to do?

I have not used "fix spring", but that sounds correct to me. (You
just have to be careful to use the "group" command define a group
which includes all of the atoms in all of the rigid bodies which make
up your piston system.)

Have you tried it? Is this not working?

---

I haven't tried yet this option, and I was writing exactly because I was not sure about how fix spring works. I had a quick view at the dcumentation but it's not still clear to me if a fix the whole piston group to a spring, will be it fixed as a whole (its center of mass fixed to its initial position) or will be each single rigid body which constitute the "piston" fixed to its own initial position? So N springs for N rigid bodies or one spring for the whole?

One detail which was not clear from your email:
I am assuming you removed the rotational degrees of freedom for (each
layer of) the piston.
Is this correct?

yes all the rotational degrees are removed

I can respond to that point at least...
There is no way for fix spring to know about which atoms belong to
each rigid body. (The code for fix rigid and fix spring do not
secretly share information.) The spring force will only be applied
to the atoms in the group. So it depends on which group you use. If
you define a single group which includes all of the atoms in all N of
the rigid bodies, then the same force should be applied to all of the
atoms in that entire group.

   ...for my answer, I am looking at this text:
The tether style attaches a spring between a fixed point x,y,z and the
center of mass of the fix group of atoms. The equilibrium position of
the spring is R0. At each timestep the distance R from the center of
mass of the group of atoms to the tethering point is computed, taking
account of wrap-around in a periodic simulation box. A restoring force
of magnitude K (R - R0) Mi / M is applied to each atom in the group
where K is the spring constant, Mi is the mass of the atom, and M is
the total mass of all atoms in the group. Note that K thus represents
the total force on the group of atoms, not a per-atom force.
http://lammps.sandia.gov/doc/fix_spring.html

   In addition, I am also looking at the code for "fix_spring.cpp",
near lines 169 and 283. If you don't have the LAMMPS code, there's a
link to the CFDEM version (which is up to date) at:
https://github.com/CFDEMproject/LAMMPS/blob/master/src/fix_spring.cpp

The test for group membership is accomplished using:
if (mask[i] & groupbit)
You can see that the same force is applied to all of the atoms in that group.

Cheers
Andrew

It is not clear to me from your description how
you want the piston to move. What forces act
on the atoms or bodies in the piston and
does the piston move as a single entity
or its rigid body components do?

As a general rule I would initially use no constraining
fixes (like recenter and fix spring) and see what happens.

Steve