vp.liquids.pair_distribution
The pair distribution function g(r) of a set of configurations of N atoms in a periodic cubic box: a histogram of every pair's separation (nearest image) out to half the box, divided by what an ideal gas of the same density would give in each spherical shell.
Part of the distribution vipyr-liquids; it runs from a checkout of the
repository. Planned on PyPI as pip install vipyr-liquids.
Signature
vp.liquids.pair_distribution(*, n=32, box=3.4943, frames=..., dr=0.02) Parameters
- n : int, default
32 - The atoms in each configuration. Range: >= 2, <= 1000000.
- box : float, default
3.4943 - The box side, in sigma. Range: > 0.
- frames : ndarray[float64], default
fcc_positions(32, 3.4943) - The configurations one after another, (frames x n, 3), positions in sigma; by default one fcc lattice of 32 atoms filling the box. Range: rank 2.
- dr : float, default
0.02 - The bin width, in sigma. Range: > 0.
Returns
A frozen PairDistributionResult. Iterating it gives the fields below in order; it also has
params, tests, log and check().
- r_mid : ndarray[float64]
- The midpoints of the bins, in sigma.
- g : ndarray[float64]
- G(r) at those midpoints.
- nframes_used : int
- The configurations read.
Raises
- vipyr.ParameterError
- A ValueError: an argument outside its range, choices, rank or shape, or one of a group given without the rest; its .param names the argument.
- TypeError
- An argument of the wrong type, or an unknown keyword.
- vipyr.VivBuildError
- An ImportError: no C compiler, or the program's C does not build.
- RuntimeError
- The program stops with its own message (a combination it rejects, or no convergence where the program treats that as an error).
Examples
import vipyr as vp
m = vp.liquids.md_nve(n=108, nblock=1, nstep=50)
r = vp.liquids.pair_distribution(n=108, box=m.box, frames=m.r_final, dr=0.05)
print(r.r_mid[r.g.argmax()]) # the first peak, near 1.1 sigma
assert r.check() 1.075Each example ran as written when these pages were generated, and the output shown is what it printed.
Checked against
- Tests
- ports/liquids/test_liquids.py: every tolerance is stated beside its check
- Upstream
- pair_distribution of https://github.com/Allen-Tildesley/examples at 4818bc82, built with gfortran -O2 by ports/liquids/oracle/build.py; same bits from the same start and random numbers
Credits
- A port of the examples of Allen and Tildesley's Computer Simulation of Liquids, which are CC0-1.0.
Source
- Manifest: ports/liquids/pair_distribution.export.toml
- Viv: ports/liquids/pair_distribution.viv
- The defs it reaches and the calls between them: map of the code