This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

vp.liquids.md_nve

Molecular dynamics of Lennard-Jones atoms at constant N, V and E: velocity Verlet in a periodic cubic box, the potential cut and shifted at r_cut. A run returns the block and run averages of the energy, pressure and temperatures (cut-and-shifted, and with long-range corrections as an estimate for the full potential), the heat capacity from the kinetic energy's fluctuations, the fluctuation of the conserved energy, the final configuration, and, when it samples the trajectory, g(r), the velocity autocorrelation function, the mean-square displacement and the diffusion coefficient from each.

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.md_nve(*, n=256, density=0.75, temperature=1.0, r_cut=2.5, dt=0.005, nblock=10, nstep=1000, neighbors="all", seed=1, r_start=zeros(0, DIM), v_start=zeros(0, DIM), box_start=0.0, sample=0, gr_dr=0.02, nt=200, origin_interval=10)

Parameters

n : int, default 256
The number of atoms, 4 nc^3 for the fcc start (32, 108, 256, 500, 864, ...); ignored when r_start is given. Range: >= 32, <= 100000.
density : float, default 0.75
The number density N / V; sets the box side when r_start is not given. Range: > 0.
temperature : float, default 1.0
The temperature of the starting velocities (3N - 3 degrees of freedom). Range: > 0.
r_cut : float, default 2.5
The potential's cutoff, in sigma; at most half the box. Range: > 0.
dt : float, default 0.005
The time step, in units of sigma sqrt(m / epsilon). Range: > 0.
nblock : int, default 10
The number of blocks the run is averaged in. Range: >= 1, <= 100000.
nstep : int, default 1000
The steps per block (upstream's default is 20000). Range: >= 0, <= 100000000.
neighbors : str, default "all"
How pairs are found: "all" pairs, "link" lists of cells (needs a box of 3 r_cut or more), or "verlet" lists. Range: one of all, link, verlet.
seed : int, default 1
The seed of the starting velocities' random numbers. Range: >= 0, <= 2147483646.
r_start : ndarray[float64], default zeros(0, DIM)
A starting configuration (N, 3), in sigma, instead of the fcc lattice; box_start must come with it. Range: rank 2.
v_start : ndarray[float64], default zeros(0, DIM)
The starting velocities (N, 3) that go with r_start. Range: rank 2.
box_start : float, default 0.0
The box side of r_start, in sigma. Range: >= 0.
sample : int, default 0
Every this many steps, the configuration goes into g(r) and the correlation functions; 0: none. Range: >= 0, <= 100000000.
gr_dr : float, default 0.02
The bin width of g(r), in sigma. Range: > 0.
nt : int, default 200
The correlation functions run over 0 to nt samples apart. Range: >= 1, <= 1000000.
origin_interval : int, default 10
A time origin every this many samples. Range: >= 1, <= 1000000.

Returns

A frozen MDResult. Iterating it gives the fields below in order; it also has params, tests, log and check().

box : float
The box side, in sigma.
rho : float
The number density N / V.
e_cs : float
The energy per atom, cut-and-shifted potential, kinetic plus potential (conserved).
e_cs_err : float
Its standard error from the block averages (the scatter of a conserved quantity's block means).
p_cs : float
The pressure, cut-and-shifted potential.
p_cs_err : float
Its standard error from the block averages.
e_full : float
The energy per atom with the long-range correction: an estimate for the full potential.
e_full_err : float
Its standard error.
p_full : float
The pressure with the long-range correction.
p_full_err : float
Its standard error.
t_kin : float
The kinetic temperature, 2 K / (3N - 3).
t_kin_err : float
Its standard error.
t_config : float
The configurational temperature, |F|^2 / (lap U - 2 F.H.F / |F|^2).
t_config_err : float
Its standard error.
cv_cs : float
The heat capacity per atom from the fluctuations of the kinetic energy (Lebowitz, Percus and Verlet).
cv_cs_err : float
Its standard error.
conserved_msd : float
The mean-square deviation of the energy per atom within a block, averaged over blocks: zero for exact dynamics, about dt^4 for velocity Verlet.
blocks : ndarray[float64]
The block averages, one row per block, columns e_cs, p_cs, e_full, p_full, t_kin, t_config, cv_cs, conserved_msd (rank 2).
initial : ndarray[float64]
The same eight variables at the start (the last two are fluctuation terms of one step).
energy_series : ndarray[float64]
E_cs at every step.
r_final : ndarray[float64]
The final positions (N, 3), in sigma, in the box centered on the origin (rank 2).
v_final : ndarray[float64]
The final velocities (N, 3) (rank 2).
verlet_rebuilds : int
How many times the Verlet list was built (neighbors = "verlet").
gr_r : ndarray[float64]
The midpoints of the g(r) bins, in sigma.
gr : ndarray[float64]
G(r) at those midpoints.
vacf : ndarray[float64]
The velocity autocorrelation function <v(0) . v(t)> at corr_time.
rvcf : ndarray[float64]
<v(0) . (r(t) - r(0))>, whose derivative is the VACF and whose limit is 3 D.
msd : ndarray[float64]
The mean-square displacement <|r(t) - r(0)|^2>.
d_vacf : float
The diffusion coefficient, one third of the integral of the VACF over the range.
d_msd : float
The diffusion coefficient, one sixth of the slope of the MSD over the second half of the range.
corr_time : ndarray[float64]
The times of the correlation functions: 0 to nt samples, sample dt apart.

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
# 108 atoms at density 0.75 from an fcc lattice at T = 1, 2 blocks of 100 steps
r = vp.liquids.md_nve(n=108, nblock=2, nstep=100)
print(r.e_cs, r.p_cs, r.p_cs_err, r.t_kin, r.conserved_msd)
assert r.check()
-3.9319204101307355 -1.3108089735137647 0.3095019039543647 0.6025736821262984 1.730485088557998e-08

Each example ran as written when these pages were generated, and the output shown is what it printed.

Checked against

Eos
Thol et al., Journal of Physical and Chemical Reference Data 45, 023101 (2016) and International Journal of Thermophysics 36, 25 (2015), as eos_lj computes them
Tests
ports/liquids/test_liquids.py: every tolerance is stated beside its check
Upstream
md_nve_lj (and its md_nve_lj_ll and md_nve_lj_vl builds) 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

Credits

  • A port of the examples of Allen and Tildesley's Computer Simulation of Liquids, which are CC0-1.0.

Source