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_nvt

Molecular dynamics of Lennard-Jones atoms at constant N, V and T, the temperature held by a Nose-Hoover chain of three thermostats, integrated by the time-reversible splitting of Martyna, Tuckerman, Tobias and Klein (1996): velocity Verlet for the atoms, wrapped in quarter and half steps of the chain. The potential is cut and shifted at r_cut. A run returns the block and run averages of the energy, pressure and temperatures, the heat capacity from the energy's fluctuations, the conserved quantity of the extended system and its fluctuation, the final configuration, and, when it samples the trajectory, g(r), the correlation functions and the diffusion coefficient.

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_nvt(*, n=256, density=0.75, temperature=1.0, r_cut=2.5, tau=2.0, 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 thermostat's temperature, and that of the starting velocities. Range: > 0.
r_cut : float, default 2.5
The potential's cutoff, in sigma; at most half the box. Range: > 0.
tau : float, default 2.0
The thermostat's time scale: the chain's inertias are Q_1 = g T tau^2 and Q_j = T tau^2. 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 random numbers: the starting velocities, then (seeded again) the thermostat momenta. 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.
e_cs_err : float
Its standard error from the block averages.
p_cs : float
The pressure, cut-and-shifted potential (with the thermostat's T in the ideal part).
p_cs_err : float
Its standard error.
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.
t_config_err : float
Its standard error.
conserved : float
The conserved energy of the atoms and the chain, per atom.
cv_cs : float
The heat capacity per atom from the fluctuations of the energy, cut-and-shifted.
cv_cs_err : float
Its standard error.
cv_full : float
The same from the cut (not shifted) potential energy, an estimate for the full potential.
cv_full_err : float
Its standard error.
conserved_msd : float
The mean-square deviation of the conserved energy per atom within a block, averaged over blocks.
blocks : ndarray[float64]
The block averages, one row per block, columns e_cs, p_cs, e_full, p_full, t_kin, t_config, conserved, cv_cs, cv_full, conserved_msd (rank 2).
initial : ndarray[float64]
The same ten variables at the start.
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).
p_eta_final : ndarray[float64]
The chain's final momenta.
eta_final : ndarray[float64]
The chain's final coordinates.
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))>.
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
r = vp.liquids.md_nvt(n=108, temperature=1.0, nblock=2, nstep=100)
print(r.e_cs, r.e_cs_err, r.p_cs, r.t_kin, r.conserved)
assert r.check()
-3.9072718415796333 0.011529537798686807 -0.9698745980365139 0.6130806678103312 -3.8247874358589975

Each 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
md_nvt_lj (and its md_nvt_lj_ll build) 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