 # [lammps-users] fix viscosity

Hi there,

In both init() and end_of_step() of fix viscosity, the position of the hi slab is given by

slabhi_lo = boxlo + ((nbin-1)/2)*binsize;
slabhi_hi = boxlo + ((nbin-1)/2 + 1)*binsize;

I don’t think this is a good idea, since no matter nbin is even or odd, it will give an
asymmetric velocity profile, thus make it difficult to evaluate the viscosity. I would suggest
to use
slabhi_lo = boxlo + (nbin/2)*binsize;
slabhi_hi = boxlo + ((nbin/2 + 1)*binsize;
instead. This way the when nbin is even, the velocity profile would be symmetric; though it
would still be asymmetric if nbin is odd. Probably LAMMPS can check this number and
make it to be always even.

I think the same problem also exists in fix_thermal_conductivity.cpp

Thanks.

Lingti

Here is the comment and accompanying code:

// if nbin even, hi bin is just below half height
// if nbin odd, hi bin straddles half height

slabhi_lo = boxlo + ((nbin-1)/2)*binsize;
slabhi_hi = boxlo + ((nbin-1)/2 + 1)*binsize;

I think it does what the comment says. If there are
10 bins, the bin bounds will be from 0.4 to 0.5 times the
binsize. For 11 bins, the bin bounds will be from 0.5
to 0.6 times the binsize. I.e. those are the bounds
of the 5th and 6th bins respectively, counting the
1st bin as 1.

Steve

Yes, it does what is commented. But the resultant velocity profile is not symmetric.
If nbin=10, there will be 3 (5) bins below (above) the hi slab; if nbin=11, there will
be 4 (5) bins, respectively.

Now I see your point and agree it is a good
idea to insure symmetry in the velocity profile.

I just posted a patch for this - 26 Jun 08.

Thanks,
Steve