RE: How to maintain Density constant?

From: Tristan Croll (
Date: Thu Mar 06 2014 - 16:30:43 CST

Sorry for the really simple question, but have you set "wrapall on" in your NAMD config file? If you haven't, your system will appear to diffuse outwards when visualised in VMD, but NAMD will still be internally transforming all coordinates to keep them within the periodic box.

From: [] On Behalf Of Roy Fernando
Sent: Friday, 7 March 2014 3:28 AM
To: Kenno Vanommeslaeghe;
Subject: Re: namd-l: How to maintain Density constant?

Hi Kenno, Ivan,
Thanks for detailed explanations.
While I understand the fundamental physics part, what I was looking for is some insights about why my system displaying unphysical (or far from being physical) behaviors.
I am not simulating a gas, I am simulating a protein in a solution. This type of a system evolve under atmospheric pressure and therefore choosing a NPT simulation makes sense to me. When an NPT simulation is chosen I am allowing the system volume to fluctuate to maintain the pressure around 1atm. However, what I noticed was not a fluctuation. The density of the system dropped by 40% because the system dimensions has increased by 20%. I was trying to see if there are other processes that can be applied such as maintaining some ion concentration (this system is neutral to balance the charges). The density of the solution is expected to be around 1.1 g/cm^3 but I observed it to be around 0.6 g/cm^3
Thanks for your help.

On Thu, Mar 6, 2014 at 11:55 AM, Kenno Vanommeslaeghe <<>> wrote:
It's perfectly normal (and indeed unavoidable) in constant pressure simulations for the volume (and hence density) to equilibrate a bit, then fluctuate. As long as the change is not catastrophic (which was not indicated in Roy's e-mail), there's nothing to worry about. If the density is really important, one can run NVT, but then one has to give up control over the pressure.

On 03/06/2014 11:34 AM, Ivan Gregoretti wrote:
Thank you Kenno.

So, going back to try to help Roy.

1) Running MD simulations where you control both pressure and
temperature is routine. Kenno tells us that it makes no sense to also
try to impose a control on the volume. (Of course.)

2) Why is your system's density dropping? I wonder if the periodic
boundary conditions are properly set. I can picture a situation where
there is no boundary conditions and the molecules start to slowly
diffuse away from the center of mass of your system.


Ivan Gregoretti, PhD

On Thu, Mar 6, 2014 at 10:57 AM, Kenno Vanommeslaeghe
<<>> wrote:
On 03/06/2014 08:23 AM, Ivan Gregoretti wrote:

p V = n R T

with n being the number of molecules and V being volume. It's an ideal
gas state equation. Notice that n/V is your density.

In your molecular dynamics, n does not change, so, if you want to keep
the density constant, you need to run your simulation at constant

Do I get it right Kenno?

Mostly. We usually don't simulate gases, so the ideal gas law you brought up
is of very limited value, but there exist similar equations for liquids and
solid, and one thing they all have in common is that (assuming n is
constant) out of p, V and T (and also E and/or Q), you can set two to an
arbitrary value, but then you don't have control over the other one(s); this
is very fundamental and doesn't take advanced statistical mechanics to see.
There exist mechanisms in nature to impose *some* combinations of these
variables on a system, and these combinations ("ensembles" in thermodynamic
speak) are often implemented in MD engines. The "constant pressure and
volume" Roy asked for is not one of them; even if someone would somehow
implement it, it would be of no practical relevance. Besides, the
temperature would shift and fluctuate uncontrollably (remember, you can only
choose 2), which is probably not what Roy (or anyone else) wants.

This archive was generated by hypermail 2.1.6 : Wed Dec 31 2014 - 23:22:12 CST