# 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

$P = \rho k_{B} T + \frac{1}{dV} \left \langle \sum_{i

where d is the dimensionality of the system (i.e. usually 3), ρ is the number density N/V, f(rij) is the force between particle i and j at a distance rij, 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

$p_{\beta\alpha} = \frac{1}{V}\left(\sum_{i=1}^{N} m_iv_{i\beta}v_{i\alpha} +\sum_{i=1}^{N}F_{i\beta}\alpha_i\right)$

where Fiβ 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,

$p = \frac{p_{xx} + p_{yy} + p_{zz}}{3} = \frac {1}{3V} \left( \left\langle\sum_{i=1}^{N}m_iv_i\cdot v_i\right\rangle + \left\langle\sum_{i=1}^{N}F_i\cdot r_i\right\rangle\right)$

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"

## Temperature

$k_{B}T = \left \langle \frac{2K}{f} \right \rangle = \frac{1}{(3N)}\sum_{i=1}^{N} mv_{i}^{2}$,

where f is the degree of freedom of the system.