Thermodynamics¶
This module calculates the instantaneous values of thermodynamic state variables for the particles of a given group.
- class halmd.observables.thermodynamics(args)¶
Construct thermodynamics module.
- Parameters:
args (table) – keyword arguments
args.group – instance of
halmd.mdsim.particle_groupsargs.box – instance of
halmd.mdsim.boxargs.volume – a number or a nullary function yielding the reference volume (default:
box.volume)
The argument
volumeexpects a callablefunction(), which is used to query the reference volume of the particle group; the volume may change in the course of the simulation. Ifgrouprefers to the whole simulation domainbox.volumeis passed, which is the default:volume = function() return box.volume end -- convert box.volume into a callable, thereby capturing box
For a sub-domain, e.g., if
groupis an instance ofregion, returning a constant value may be appropriate.- particle_number()¶
Returns the number of particles \(N\) selected by
args.group.
- volume()¶
Returns the volume \(V\) as obtained from the function passed upon construction.
- density()¶
Returns the number density \(\rho = N / V\).
- kinetic_energy()¶
Returns the mean kinetic energy per particle: \(u_{\text{kin}} = \frac{1}{N} \sum_{i=1}^N \frac{1}{2} m_i \vec v_i^2\).
- potential_energy()¶
Returns the mean potential energy per particle: \(u_{\text{pot}} = \frac{1}{N} \sum_{i=1}^N U_{\text{tot}}(\vec r_i)\), where \(U_{\text{tot}}\) denotes the sum of external and pair potentials.
- internal_energy()¶
Returns the mean internal energy per particle: \(u_{\text{int}} = u_{\text{kin}} + u_{\text{pot}}\).
- pressure()¶
Returns the pressure computed from the virial: \(p = \rho (k_B T + \mathcal{V} / d)\).
- temperature()¶
Returns the instantaneous temperature as given by the kinetic energy: \(k_B T = 2 u_{\text{kin}} / d\).
- total_force()¶
Returns the total force: \(\vec F_{\text{tot}} = \sum_{i=1}^N \vec F_i\).
- center_of_mass_velocity()¶
Returns the centre-of-mass velocity: \(\vec v_{\text{cm}} = \sum_{i=1}^N m_i \vec v_i / \sum_{i=1}^N m_i\).
- center_of_mass()¶
Returns the centre of mass: \(\vec r_{\text{cm}} = \sum_{i=1}^N m_i \vec r_i' / \sum_{i=1}^N m_i\), where \(\vec r_i'\) refers to absolute particle positions, i.e., extended by their image vectors for periodic boundary conditions.
- mean_mass()¶
Returns the mean particle mass: \(\bar m = \frac{1}{N} \sum_{i=1}^N m_i\).
- virial()¶
Returns mean virial per particle as computed from the trace of the potential part of the stress tensor:
\[\mathcal{V} = - \frac{1}{2 N} \sum_{i \neq j} r_{ij} \, U'(r_{ij}) \, .\]
- stress_tensor()¶
Returns the elements of the stress tensor \(\Pi_{\alpha\beta}\) as a vector. The first \(d\) (= dimension) elements contain the diagonal followed by \(d(d-1)/2\) off-diagonal elements \(\Pi_{xy}, \Pi_{xz}, \dots, \Pi_{yz}, \dots\) The stress tensor is computed as
\[\Pi_{\alpha\beta} = \sum_{i=1}^N \left[ m_i v_{i\alpha} v_{i\beta} - \frac{1}{2}\sum_{j \neq i} \frac{r_{ij\alpha} r_{ij\beta}}{r_{ij}} \, U'(r_{ij}) \right] \/,\]where \(\vec r_{ij} = \vec r_i - \vec r_j\) in nearest image convention.
- dimension¶
Space dimension \(d\) of the simulation box as a number.
- group¶
Instance of
halmd.mdsim.particle_groupsused to construct the module.
- writer(args)¶
Write state variables to a file.
- Parameters:
args (table) – keyword arguments
args.file – instance of file writer
args.every (number) – sampling interval
args.location (string table) – location within file (optional)
args.fields (table) – data fields to be written (optional)
- Returns:
instance of group writer
The optional argument
locationspecifies a path in a structured file format like H5MD given as a table of strings. It defaults to{"observables", group.global and nil or group.label}.The optional table
fieldsspecifies which data fields are written. It may either be passed as an indexed table, e.g.{"pressure"}, or as a dictionary, e.g.,{p = "pressure"}; the table form is interpreted as{pressure = "pressure", …}. The keys denote the field names in the file and are appended tolocation. The values specify the data methods of thethermodynamicsmodule, i.e., all methods described above except fordimensionandgroup. The default is{"potential_energy", "pressure", "temperature", "center_of_mass_velocity"}.- disconnect()¶
Disconnect thermodynamics writer from observables sampler.