Averages and fluctuations#
Formulae for averaging#
Note: this section was taken from ref 179.
When analyzing a MD trajectory averages
of a quantity
Unfortunately this formula is numerically not very accurate, especially
when
with
Using (488) and
(490) one has to go through the series of
and the partial variance
It can be shown that
and
For
and for
where we have used the relation
Using formulae (496) and (497) the average
and the fluctuation
can be obtained by one sweep through the data.
Implementation#
In GROMACS the instantaneous energies
Part of a Simulation#
It is not uncommon to perform a simulation where the first part, e.g. 100 ps, is taken as equilibration. However, the averages and fluctuations as printed in the log file are computed over the whole simulation. The equilibration time, which is now part of the simulation, may in such a case invalidate the averages and fluctuations, because these numbers are now dominated by the initial drift towards equilibrium.
Using (493) and (494) the average and standard deviation over part of the trajectory can be computed as:
or, more generally (with
Note that implementation of this is not entirely trivial, since
energies are not stored every time step of the simulation. We therefore
have to construct
Combining two simulations#
Another frequently occurring problem is, that the fluctuations of two
simulations must be combined. Consider the following example: we have
two simulations (A) of
When we want to compute the partial variance from the two components we
have to make a correction
if we define
and thus
or
all the
we recognize the three partial sums on the second line and use (503) to obtain:
if we check this by inserting
Summing energy terms#
The gmx energy program
can also sum energy terms into one, e.g. potential + kinetic = total.
For the partial averages this is again easy if we have
For the fluctuations it is less trivial again, considering for example that the fluctuation in potential and kinetic energy should cancel. Nevertheless we can try the same approach as before by writing:
if we fill in (492):
which we can expand to:
the terms with
or
If we now expand the first term using (510) we obtain:
which we can reformulate to:
or
which gives
Since we need all data points xmgr
this is not
built-in in GROMACS.