# LAMMPS: How to Compute Fluid Viscosity

The theory is described in “Poiseuille flow to measure the viscosity of particle model fluids” by J. A. Backer et al. Below I describe how to use this approach in LAMMPS.

(1) Run LAMMPS with the following script

(2) Open vel-visc and copy in a separate document data for one time step.

(3) Open gnuplot, type:

The result should be something like:

(4) From analytical solution for the problem, it is known that $v(x)=\alpha (D x - x^2)$. Where $\alpha=pg/(2n)$, p - is numeric density(3.0 in our case, determined by custom lattice), g is driving force (0.055), n - dynamic viscosity. In order to find alpha we will use gnuplot’s fit command. As you might see on the Figure above, there are 2 parabolas. I pick the left one, so the analytical solution look like $v(x)=\alpha*(14x + x^2)$. Then type

The result should be $\alpha=0.0278$, thus viscosity n=2.68 in DPD units. The plot with velocities from simulation and with the fitting plot should look like that: