Dear LAMMPS users,
I am simulating an all-atom model of an ionic liquid in the NVT ensemble. I want to calculate the global stress tensor of the system. I have done this in two different ways:
compute mypress all pressure thermo_temp
variable pxx equal c_thermo_press[1]
etc…
compute mystrss all stress/atom NULL
compute sxx all reduce sum c_mystrss[1]
variable sxx equal c_sxx/vol
etc…
For the off-diagonal components the pressure p_xy is simply the negative off the stress s_xy. For the diagonal however I find for each of the components a difference of
p_xx+s_xx=431.820590372 atmosphere
This is also the case if I use other keywords to calculate the contributions of the different interactions separately. Most surprisingly, if I use the “fix” keyword in the computes:
compute mypress all pressure NULL fix
compute mystrss all stress/atom NULL fix
While running a simulation with the “fix shake” command commented out, I find for every time step:
mypress = [-431.820590372, -431.820590372, -431.820590372, 0, 0, 0]
mystrss = [0, 0, 0, 0, 0, 0]
I am a bit confused about this. Does anybody know why this is the case?
Thanks in advance!
Arno
arno,
Dear LAMMPS users,
I am simulating an all-atom model of an ionic liquid in the NVT ensemble. I
want to calculate the global stress tensor of the system. I have done this
in two different ways:
compute mypress all pressure thermo_temp
variable pxx equal c_thermo_press[1]
etc...
compute mystrss all stress/atom NULL
compute sxx all reduce sum c_mystrss[1]
variable sxx equal c_sxx/vol
etc...
For the off-diagonal components the pressure p_xy is simply the negative off
the stress s_xy. For the diagonal however I find for each of the components
a difference of
p_xx+s_xx=431.820590372 atmosphere
i cannot reproduce this with the current (development) version of
LAMMPS. i've tested with melt/in.melt and a bulk spce box through
adding:
compute mypress all pressure thermo_temp
compute atomstr all stress/atom NULL
compute mystres all reduce sum c_atomstr[1] c_atomstr[2] c_atomstr[3]
c_atomstr[4] c_atomstr[5] c_atomstr[6]
variable sxx equal -c_mystres[1]/vol
variable syy equal -c_mystres[2]/vol
variable szz equal -c_mystres[3]/vol
variable sxy equal -c_mystres[4]/vol
variable sxz equal -c_mystres[5]/vol
variable syz equal -c_mystres[6]/vol
thermo_style custom step c_mypress[1] pxx v_sxx c_mypress[2] pyy v_syy &
c_mypress[3] pzz v_szz c_mypress[4] pxy v_sxy &
c_mypress[5] pxz v_sxz c_mypress[6] pyz v_syz
when reporting an issue, please always mention which version of LAMMPS
you are using and what platform you are running on; and - if your
version is different from the latest development version - try to
check out the current version and see, if you may have run into a
problem that has already been resolved.
This is also the case if I use other keywords to calculate the contributions
of the different interactions separately. Most surprisingly, if I use the
"fix" keyword in the computes:
compute mypress all pressure NULL fix
compute mystrss all stress/atom NULL fix
While running a simulation with the "fix shake" command commented out, I
find for every time step:
mypress = [-431.820590372, -431.820590372, -431.820590372, 0, 0, 0]
mystrss = [0, 0, 0, 0, 0, 0]
I am a bit confused about this. Does anybody know why this is the case?
i get all zeros in this case. so the only explanation is that there is
something different in your simulation; either you have something in
your script that has an impact that you didn't show us or you have a
version of LAMMPS with a bug that has since been fixed.
axel.
Dear all,
Thanks for your reply Axel,
For future reference I just wanted to mention that the difference between the pressure tensor and the stress tensor was caused by a “pair_modify tail yes” command in my script. It is of course kind of obvious that the long-range van der Waals correction to the pressure shows up in the pressure tensor but not in the stress tensor. However, it is counter intuitive to me that this correction is also included when calculating the pressure (tensor) due to contributions from non-van der Waals interactions, for example when using commands like:
compute mypress all pressure NULL fix
compute mypress all pressure NULL dihedral,
but I guess there is some reason for this.
Best regards,
Arno
PS: I see this behaviour in both recent (March 29) and older (November 26) lammps versions.
Dear all,
Thanks for your reply Axel,
For future reference I just wanted to mention that the difference between
the pressure tensor and the stress tensor was caused by a "pair_modify tail
yes" command in my script. It is of course kind of obvious that the
long-range van der Waals correction to the pressure shows up in the pressure
tensor but not in the stress tensor. However, it is counter intuitive to me
that this correction is also included when calculating the pressure (tensor)
due to contributions from non-van der Waals interactions, for example when
using commands like:
compute mypress all pressure NULL fix
compute mypress all pressure NULL dihedral,
but I guess there is some reason for this.
i would call this a bug. and it easily remedied by the following change:
diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp
index 8e57130..2fe7ca4 100644
--- a/src/compute_pressure.cpp
+++ b/src/compute_pressure.cpp
@@ -287,7 +287,7 @@ void ComputePressure::virial_compute(int n, int ndiag)
// LJ long-range tail correction
- if (force->pair && force->pair->tail_flag)
+ if (force->pair && pairflag && force->pair->tail_flag)
for (i = 0; i < ndiag; i++) virial[i] += force->pair->ptail * inv_volume;
}
axel.
agreed - this bug fix will be in today’s patch
thanks,
Steve