# softmatter:Thermodynamic Variables

For a given simulation, (e.g. NVE, NVT, NTP ) thermodynamic quantities can be calculated.

## Pressure

The following expression show how to calculate the average pressure of a closed volume. For derivations that show how to calculate the pressure as a local quantity, see [3]. For pair-wise additive interactions in a NVT, Pressure can be calculated[4], using the virial theorem as

where d is the dimensionality of the system (i.e. usually 3), ρ is the number density N/V, *f*(*r*_{ij}) is the force between particle i and j at a distance *r*_{i}*j*, and where the temperature can be directly calculated as described in the temperature section below.

These expressions can also be modified to compute the entire pressure or stress tensor, for which the off-diagonal terms represent the shear[3], and formulated using the total resultant force on a particle. *The Equation below only applies to systems that do not have periodic boundary conditions. Without periodic boundary conditions the force term on the right hand side is identical to the force term in first equation above. In perioidic boundary condition systems, the vector additions fail. '*
The tensor element inβ and α coordinate direction is

where *F*_{iβ} is the β component of the total resultant force on particle i. Note that α_{i} is the α component of the position vector for particle i. The scalar pressure is then the trace of the tensor divided by 3, or,

Note that this form is only appropriate for calculating the average pressure of a volume of particles. By using the two-body (or n-body) form, a more localized pressure can be calculated. Also note that the equation form above is technically defined for an NVE simulation as averages of different ensembles are slightly different. See [1] and [2] for more details. The error, however, is *O*(*N*^{ − 1}).

[1] Lebowitz, Percus, Verlet, "Ensemble Dependence of Fluctuations with Applications to Machine Computations", 1967 http://prola.aps.org/pdf/PR/v153/i1/p250_1

[2] M. P. Allen, D. J. Tildesley "Computer Simulation in Chemical Physics" 1993

[3] Heinz, Paul, Binder, Calculation of Local Pressure Tensors in system of Many Body Interactions, 2003, http://arxiv.org/pdf/cond-mat/0309014

[4] Frenkel, Smit "Understanding Molecular SImulations"

[5] http://pubs.acs.org/cgi-bin/article.cgi/jpchax/1996/100/i02/pdf/jp952646x.pdf?isMac=333435

## Temperature

,

where f is the degree of freedom of the system.