GROMACS Energy (.edr) Parser¶
Parser for GROMACS energy (.edr) files.
- class kbkit.io.edr.EdrParser(path: str | Path)[source]¶
Bases:
objectInterface for extracting energy properties from GROMACS .edr files.
Wraps gmx energy to provide access to available properties in .edr file. Supports additional properties, configurational_enthalpy and fluctuation properties (heat capacity and isothermal compressibility). Note that the fluctuation properties return a float object rather than a timeseries.
- GROMACS_UNITS: ClassVar = {'density': 'kg/m^3', 'enthalpy': 'kJ/mol', 'kinetic-en': 'kJ/mol', 'potential': 'kJ/mol', 'pressure': 'bar', 'temperature': 'K', 'time': 'ps', 'total-energy': 'kJ/mol', 'volume': 'nm^3'}¶
- DEFAULT_UNITS: ClassVar = {'cp': 'kJ/mol/K', 'cv': 'kJ/mol/K', 'density': 'kg/m^3', 'enthalpy': 'kJ/mol', 'isothermal-compressibility': '1/kPa', 'kinetic-en': 'kJ/mol', 'molar-volume': 'cm^3/mol', 'number-density': 'molecule/nm^3', 'potential': 'kJ/mol', 'pressure': 'kPa', 'temperature': 'K', 'time': 'ps', 'total-energy': 'kJ/mol', 'volume': 'nm^3'}¶
- get_gmx_property(name: str, avg: bool = False, **kwargs) tuple | float[source]¶
Extract gromacs property from energy file.
- available_properties() list[str][source]¶
Return a list of available energy properties in the .edr file(s).
- get(name: str, start_time: float = 0, units: str | None = None) ndarray[source]¶
Extract time series data for a given property.
- Parameters:
- Returns:
np.ndarray – Array of values.
.. note:: – Filters data based on start_time for reproducibility.
- molar_volume(nmol: int, volume: float = 0, start_time: float = 0, units: str | None = None) ndarray | float[source]¶
Calculate molar volume of a simulation.
If ensemble is NVT, i.e., volume is not accessible in .edr file, an input volume is required (i.e., read from bottom of .gro file in
SystemProperties).- Parameters:
- Returns:
Molar volume of molecular simulation.
- Return type:
np.ndarray
- configurational_enthalpy(volume: float = 0, start_time: float = 0, units: str | None = None) ndarray[source]¶
Calculate enthalpy from potential energy.
If ensemble is NVT, i.e., volume is not accessible in .edr file, an input volume is required (i.e., read from bottom of .gro file in
SystemProperties).- Parameters:
- Returns:
Enthalpy of molecular simulation.
- Return type:
np.ndarray
Notes
Enthalpy, \(H\), is calculated from potential energy (\(U\)) according to:
\[H = U + pV\]- where:
\(p\) is pressure
\(V\) is volume
- molar_enthalpy(nmol: int, volume: float = 0, start_time: float = 0, units: str | None = None) ndarray[source]¶
Calculate molar enthalpy.
- Parameters:
- Returns:
Configurational enthalpy normalized by the total number of molecules.
- Return type:
np.ndarray
See also
- cp(nmol: int, volume: float = 0, start_time: float = 0, units: str | None = None) float[source]¶
Calculate constant pressure heat capacity from
configurational_enthalpy().- Parameters:
- Returns:
Constant pressure heat capacity.
- Return type:
Notes
Constant pressure heat capacity, \(c_p\) is calculated according to:
\[\begin{split}\begin{aligned} c_p &= \frac{\langle H^2 \rangle - \langle H \rangle ^2}{k_B T^2} \\ &= \frac{\sigma_H^2}{k_B T^2} \end{aligned}\end{split}\]- where:
\(\langle H^2 \rangle - \langle H \rangle ^2\) is the variance of the enthalpy (also writted as \(\sigma_H^2\))
\(k_B\) is Boltzmann constant
\(T\) is absolute temperature
- cv(nmol: int, start_time: float = 0, units: str | None = None) float[source]¶
Calculate constant volume heat capacity.
- Parameters:
- Returns:
Constant volume heat capacity.
- Return type:
Notes
Constant volume heat capacity, \(c_v\) is calculated according to:
\[\begin{split}\begin{aligned} c_v &= \frac{\langle U^2 \rangle - \langle U \rangle ^2}{k_B T^2} \\ &= \frac{\sigma_U^2}{k_B T^2} \end{aligned}\end{split}\]- where:
\(\langle U^2 \rangle - \langle U \rangle ^2\) is the variance of the potential (also writted as \(\sigma_U^2\))
\(k_B\) is Boltzmann constant
\(T\) is absolute temperature