# Viscosity calculation using molecular dynamics simulations

I use the GROMACS software for MD simulations and I am trying to understand the calculation of viscosity using combinations of different ensembles and different methods.

For a non-equilibrium MD calculation using periodic perturbation of external shear, which is the best ensemble that can be used? My values appear similar for NVT and NPT but vary by a large amount with NVE ensemble. I am assuming that NVE gives the best results because of no influence of thermostat and barostat and all of the change in energy is captured in calculation of viscosity. Is my reasoning appropriate?

I got the answer to this question on the GROMACS forum which can be found here.

the thermostat influence in the non-equilibrium cosine perturbation approach is automatically taken care by GROMACS, which biases termperature rescaling based on the velocity profile of fluid particles. However, some thermostats will introduce additional ‘artificial’ viscosity, so your reasoning is correct, I believe. However, from a practical standpoint I don’t see the reason why one would want to compute a nominal value of viscosity from a NVE simulation, mainly because of two reasons:

• production runs are rarely NVE, so you would want to use a consistent value for viscosity (and the one from NVE would be incorrect).
• viscosity itself is a function of temperature, so I’m not sure if it makes sense from a purely physical standpoint to estimate if by fixing the total energy, rather than temperature.

When it comes to pressure, as far as I know it may be problematic to estimate viscosity from equilibrium NPT simulations (you want the cell volume not to fluctuate in order for the Green-Kubo formula to converge). I am not sure about non-equilibrium though; probably volume fluctuations are not a problem in NE.

• I converted the answer to community wiki since it a quote of an answer on another site, but thank you for adding it here so that other users can see how this was resolved.
– Tyberius
Commented Dec 29, 2021 at 15:12