Utility functions¶
periodictable.util¶
Helper functions
- periodictable.util.cell_volume(a=None, b=None, c=None, alpha=None, beta=None, gamma=None)¶
Compute cell volume from lattice parameters.
- Parameters:
- a, b, cfloat | Å
Lattice spacings. a is required. b and c default to a.
- alpha, beta, gammafloat | °
Lattice angles. alpha defaults to 90°. beta and gamma default to alpha.
- Returns:
- Vfloat | Å3
Cell volume
- Raises:
TypeError : missing or invalid parameters
The following formula works for all lattice types:
\[V = a b c \sqrt{1 - \cos^2 \alpha - \cos^2 \beta - \cos^2 \gamma + 2 \cos \alpha \cos \beta \cos \gamma}\]
- periodictable.util.parse_uncertainty(s)¶
Given a floating point value plus uncertainty return the pair (val, unc).
Format is val, val(unc), [nominal] or [low,high].
The val(unc) form is like 23.0035(12), but also 23(1), 23.0(1.0), or maybe even 23(1.0). This parser does not handle exponential notation such as 1.032(4)E10
The nominal form has zero uncertainty, as does a bare value.
The [low,high] form is assumed to be a rectangular distribution of 1-sigma equivalent width (high-low)/sqrt(12).
An empty string is returned as None,None rather than 0,inf.
