betaFeedback

WorksPhysics and Astronomy

Path-probability gradients for optimizing force fields against dynamical observables

Abstract

Machine learning force fields inherit the errors of the electronic-structure methods used to generate their training data, and refining them against experimental measurements provides a direct route beyond this limit. However, such refinement remains difficult for dynamical observables because differentiating chaotic molecular trajectories yields unstable gradients. Here, we introduce PathGrad, which differentiates Langevin path probabilities instead of the trajectories themselves. The resulting gradient estimator is accumulated on the fly from thermal noise and force derivatives, and its variance remains stable as the trajectory length increases. We validated the gradient estimator against finite-difference calculations and used it to fine-tune molten-copper and water potentials against experimental diffusion coefficients together with structural constraints. For water, jointly optimizing diffusion and the oxygen-oxygen radial distribution function also improves the predictions of shear viscosity and rotational relaxation, neither of which is included in the optimization objective. Alignment at a single temperature also improves the apparent activation energies of multiple dynamical observables, bringing their temperature dependences closer to experiments. Moreover, the optimized potential exhibits smaller force errors relative to an independent, higher-level quantum-chemical reference, indicating that alignment with experiments improves the fidelity of the potential energy surface beyond the fitted targets. PathGrad thus establishes a general framework for incorporating experimental observables directly into force field optimizations.

main.pdf

framework for incorporating experimental observables directly into force field optimizations.

Introduction

The predictive accuracy of molecular dynamics (MD) simulation depends on the quality of the force field. Classical empirical force fields are often constructed from physically motivated functional forms and fitted to a combination of quantum-mechanical calculations and experimental observables. Machine learning force fields greatly increase the flexibility of the potential energy surface and can reproduce ab initio energies and forces with high accuracy[1]. Nevertheless, a machine learning force field trained only in a bottom-up manner inherits the limitations of its reference electronic-structure method. Recent experimental benchmarks have highlighted this discrepancy, revealing that a potential that accurately fits quantum-mechanical forces is not guaranteed to reproduce experimental observables[2]. This motivates an increasingly important direction: refining force fields directly against experimental measurements[3].

Recent approaches have demonstrated the feasibility of experimental alignment using time-independent observables. Differentiable Trajectory Reweighting (DiffTRe) enables the optimization of machine learning force fields against static observables without differentiating molecular trajectories[4]. Subsequent studies have combined quantum-mechanical and experimental data to refine machine learning force fields[5], and experimental density alignment has improved the prediction of properties of liquid electrolytes[6]. However, despite these advances in aligning static experimental properties, directly incorporating dynamical observables, such as diffusion coefficient and viscosity, into force field optimization remains considerably more challenging.

Dynamical observables provide information about molecular motion and relaxation processes that cannot be fully characterized by static properties alone. Unlike static structural and thermodynamic quantities, which can be evaluated from instantaneous configurations sampled at equilibrium, dynamical observables depend on the temporal correlation along molecular trajectories. A natural approach is to differentiate these trajectories with respect to the force field parameters. However, molecular dynamics is inherently chaotic and small parameter perturbations can lead to exponentially growing trajectory sensitivities, making long-time gradient estimation numerically unstable[7]. Recent methods based on adjoint differentiation[8] and reversible molecular simulation[9] have enabled the use of dynamical observables in force field optimizations. Nevertheless, these approaches retain the sensitivity of individual trajectories to parameter perturbations and typically require truncation of gradient propagation or correlation functions to control numerical instabilities. Such approximations can compromise gradient accuracy, particularly for observables governed by long-time dynamics.

A conceptually different route is to differentiate the probability of a path rather than the path itself. Such score-function (likelihood-ratio) estimators [10, 11] do not inherit the sensitivity of chaotic dynamics. For Langevin dynamics, the path probability follows from the Girsanov/Onsager–Machlup action and has been used for path reweighting [12, 13] and parametric sensitivity analysis [14, 15]. Bolhuis et al. [16] used path reweighting to impose rate constants on force field parameters, but only for overdamped dynamics of low-dimensional models with up to two parameters. Whether the path score can drive many-parameter force field optimization against transport coefficients has remained open.

Here we develop PathGrad, a path-probability gradient framework for optimizing force fields against experimental dynamical observables. Building on likelihood-ratio sensitivity analysis, PathGrad evaluates parameter gradients from the probability measure of discretized Langevin trajectories, using thermal noise and force derivatives accumulated during simulation. Because static observables enter through the same covariance form with the configurational score, dynamical and structural targets can be optimized together. We first validate the estimator on a two-dimensional toy model against finite differences, and then apply PathGrad to an embedded-atom model (EAM) [17] of molten copper and a neuroevolution potential (NEP) [18] for water. For molten copper, PathGrad finetunes a 12-parameter EAM potential to the experimental diffusion coefficient while preserving the lattice constant and bulk modulus. For water, an NEP model is optimized against the experimental diffusion coefficient and O–O radial distribution function (RDF). The O–H and H–H RDFs, the shear viscosity, and the rotational relaxation time also improve, although none of them enters the loss. Remarkably, alignment at a single temperature also improves the apparent activation energies of these dynamical observables, bringing their temperature dependences into substantially better agreement with experiment. Moreover, the force error relative to the CCSD(T)-level reference data is decreased, which provides evidence that this experimental alignment improves the fidelity of the potential energy surface beyond the fitted targets. These results support PathGrad as a general framework for refining force fields directly against experimental observables.

Results

Path-probability gradient (PathGrad). We consider a force field Fθ(r)=−∇rUθ(r)\mathbf{F}_{\theta}(\mathbf{r}) = -\nabla_{\mathbf{r}}U_{\theta}(\mathbf{r}) with parameters θ\theta, where r\mathbf{r} denotes the coordinates of all particles in the system. Static properties like pressure and radial distribution functions depend only on r\mathbf{r} and θ\theta, while dynamical properties like diffusion coefficient depend on the whole trajectory Γ={rt}\Gamma= \{\mathbf{r}_{t}\}. The gradient of an observable OO against the parameters can be calculated using

∇θ⟨O⟩θ=⟨∇θO⟩θ+⟨(O−⟨O⟩)∇θlog⁡pθ⟩θ(1)\nabla_\theta\langle O\rangle_\theta= \langle\nabla_\theta O\rangle_\theta+ \langle(O-\langle O\rangle)\nabla_\theta\log p_\theta\rangle_\theta \tag*{(1)}

where pθp_\theta is the probability density function. For static observables, this reduces to the thermodynamic-fluctuation formula underlying ensemble-reweighting schemes such as DiffTRe[4]. For dynamical observables, the most intuitive way is to consider the dynamical observable as a function of the initial positions and the force field parameters. In this case, we need to differentiate the trajectory directly using methods like differentiable simulation[19, 20]. However, along MD trajectories, the variance of this gradient grows exponentially with trajectory length, thereby hindering its practical applicability. To overcome this limitation, we propose to treat the whole trajectory instead of the initial positions as random variable. In this case, the first term on the right hand side of Eq. (1) vanishes, and now the goal is to derive the probability density for a trajectory. We consider the discretized Langevin dynamics

rn+1=rn+vnΔt(2)\mathbf{r}_{n+1} = \mathbf{r}_n + \mathbf{v}_n \Delta t \tag*{(2)}
vn+1=vn+[Fθ(rn)M−γvn]Δt+2γkBTΔtM ξn(3)\mathbf{v}_{n+1} = \mathbf{v}_n + \left[\frac{\mathbf{F}_\theta(\mathbf{r}_n)}{M} - \gamma\mathbf{v}_n\right]\Delta t + \sqrt{\frac{2\gamma k_{\mathrm{B}}T\Delta t}{M}}\,\boldsymbol{\xi}_n \tag*{(3)}

where ξn∼N(0,I)\boldsymbol{\xi}_n \sim\mathcal{N}(0,\mathbf{I}) are independent standard Gaussian vectors. For simplicity of presentation we use the Euler-Maruyama scheme here; the numerical implementation uses the A-BO Langevin integrator[21, 22] detailed in the Supplemental Material. For a trajectory Γ={rn,vn}\Gamma= \{\mathbf{r}_n, \mathbf{v}_n\}, the noise at each step can be inferred by inverting Eq. (3):

ξn(Γ,θ)=MΔt2γkBT[vn+1−vnΔt+γvn−Fθ(rn)M](4)\boldsymbol{\xi}_n(\Gamma,\theta) = \sqrt{\frac{M\Delta t}{2\gamma k_{\mathrm{B}}T}}\left[\frac{\mathbf{v}_{n+1}-\mathbf{v}_n}{\Delta t}+\gamma\mathbf{v}_n-\frac{\mathbf{F}_\theta(\mathbf{r}_n)}{M}\right] \tag*{(4)}

Since each ξn\boldsymbol{\xi}_n is a standard Gaussian, the path probability with given initial conditions r0\mathbf{r}_0 and v0\mathbf{v}_0 is

pθ(Γ∣r0,v0)=∏nexp⁡[−12ξn(Γ,θ)2](5)p_\theta(\Gamma\mid\mathbf{r}_0,\mathbf{v}_0) = \prod_n \exp\left[-\frac{1}{2}\boldsymbol{\xi}_n(\Gamma,\theta)^2\right] \tag*{(5)}

Note that the normalization constant can be ignored since Eq. (1) doesn’t require the probability density to be normalized. This probability density becomes the Onsager–Machlup action in the limit Δt→0\Delta t \to0. The total probability is pθ(Γ)=pθ(Γ∣r0,v0) pθ(r0,v0)p_\theta(\Gamma) = p_\theta(\Gamma\mid\mathbf{r}_0,\mathbf{v}_0)\,p_\theta(\mathbf{r}_0,\mathbf{v}_0) where pθ(r0,v0)p_\theta(\mathbf{r}_0,\mathbf{v}_0) is the Boltzmann distribution. The gradient of the log probability is

∇θlog⁡pθ(Γ)=Sθ[Γ]−β∇θU(r0)(6)\nabla_\theta\log p_\theta(\Gamma)=S_\theta[\Gamma]-\beta\nabla_\theta U(\mathbf{r}_0) \tag*{(6)}

where Sθ[Γ]=∇θlog⁡pθ(Γ∣r0,v0)S_\theta[\Gamma]=\nabla_\theta\log p_\theta(\Gamma\mid\mathbf{r}_0,\mathbf{v}_0) is the path score function. From Eq. (4) and Eq. (5), we have

Sθ[Γ]=Δt2γMkBT∑nξn⋅∇θFθ(rn)(7)S_\theta[\Gamma]=\sqrt{\frac{\Delta t}{2\gamma M k_{\mathrm{B}}T}}\sum_n \xi_n\cdot\nabla_\theta F_\theta(\mathbf{r}_n) \tag*{(7)}

This path score Sθ[Γ]S_\theta[\Gamma] is computed on the fly accumulating ξn\xi_n and ∇θFθ(rn)\nabla_\theta F_\theta(\mathbf{r}_n) stepwise during a standard Langevin simulation. It requires no derivative through the trajectory, thereby avoiding the Lyapunov instability of chaotic dynamics. The fine-tuning process is as follows: in each iteration, we run multiple independent simulations in parallel. During the simulation, we not only evolve the positions and velocities, but also accumulate the path score function according to Eq. (7). Then we calculate the dynamics observables for each simulation, and use Eq. (1) to calculate the gradient.

Toy model. We first validate the path-score estimator on a system for which the gradient can be independently estimated by finite differences. A single particle evolves under Langevin dynamics on a two-dimensional corrugated potential U(x,y;θ)=−θ[cos⁡(πx)+cos⁡(πy)]U(x,y;\theta)=-\theta[\cos(\pi x)+\cos(\pi y)], where θ\theta sets the height of the barriers between adjacent minima (Figure 1a). Increasing θ\theta suppresses thermally activated hopping and lowers the diffusion coefficient DD, so ∂D/∂θ<0\partial D/\partial\theta<0. We propagate KK independent trajectories from r0=(0,0)\mathbf{r}_0=(0,0) and estimate DD from their mean-squared displacement (MSD).

Figure 1. Path-score differentiation on a two-dimensional toy model. (a) Corrugated potential U(x,y;θ)=−θ[cos⁡(πx)+cos⁡(πy)]U(x,y;\theta)=-\theta[\cos(\pi x)+\cos(\pi y)] with θ=0.5\theta=0.5. Darker regions denote lower potential energy; the barrier between neighboring minima is 2θ2\theta. (b) Twenty-four illustrative Langevin trajectories starting from rest at the origin, colored by their path score Sθ[Γi]S_\theta[\Gamma_i]. The gradient is determined by the covariance between the diffusion estimate and the path score. (c) Estimates of ∂D/∂θ\partial D/\partial\theta from PathGrad and direct trajectory differentiation as a function of the number of trajectories per batch. Points and error bars denote the mean and sample standard deviation over five independent batches. The blue dashed line and shaded band show the finite-difference reference, −1.261±0.093-1.261\pm0.093, obtained from five batches with K=2000K=2000.

Figure 1b illustrates different trajectories. Each trajectory Γi\Gamma_i is colored by its path score Sθ[Γi]=∂θlog⁡pθ[Γi]S_\theta[\Gamma_i]=\partial_\theta\log p_\theta[\Gamma_i]. A positive score means that a small increase in θ\theta increases the relative likelihood of this path, whereas a negative score means that its likelihood decreases. Trajectories that diffuse farther tend to have negative scores, whereas less mobile trajectories tend to have positive scores. Their negative covariance ⟨(Di−⟨D⟩) ∂θlog⁡pθ[Γi]⟩\langle(D_i-\langle D\rangle)\,\partial_\theta\log p_\theta[\Gamma_i]\rangle therefore gives ∂D/∂θ<0\partial D/\partial\theta<0. The covariance quantifies how a small change in θ\theta redistributes the probability between high- and low-mobility paths.

Figure 1c compares the path-score estimator with direct trajectory differentiation as the batch size KK increases. The path-score estimate converges to the finite-difference reference, and its statistical uncertainty decreases approximately as 1/K1/\sqrt{K}. In contrast, direct trajectory differentiation remains highly variable even at K=2000K=2000, giving −0.06±6.94-0.06\pm6.94, whose spread is much larger than the gradient value itself. Near a barrier top, the dynamics contains an unstable direction, so small parameter perturbations can be strongly amplified and can sharply alter the timing or occurrence of a crossing event [7, 23]. Path-score differentiation estimates the gradient from changes in the statistical weights of sampled paths, and therefore avoids propagating this trajectory sensitivity.

Fine-tuning an embedded-atom potential for molten copper. The embedded-atom model (EAM) of Mishin et al. 17 was fitted to lattice structure, elastic properties, and ab initio data, and accurately describes defects in copper. Here we use a 12-parameter analytic representation fitted to the Mishin potential (Methods), which reproduces the crystalline lattice properties while failing to reproduce the experimental diffusion coefficient of the melt. We use it as a first atomistic demonstration, fine-tuning the potential to recover the target diffusion coefficient while preserving its structural fidelity.

Specifically, we fine-tune the potential against three targets simultaneously: the diffusion coefficient DD, the lattice constant a0a_0, and the bulk modulus BB. The structural constraints are applied through derivatives of the total energy U(L)U(L) of a 4×4×44\times4\times4 FCC supercell with respect to its side length LL. At the equilibrium supercell side L0=4a0L_0=4a_0 the pressure vanishes, giving the bulk modulus as B=(9L)−1∂2U∂L2∣L=L0B = (9L)^{-1}\left.\frac{\partial^2 U}{\partial L^2}\right|_{L=L_0}. The combined loss is

L=λ1(D−Dtarget)2+[λ2(∂U∂L)2+λ3(∂2U∂L2−9BL)2]L=L0,(8)\mathcal{L} = \lambda_1\left(D-D_{\mathrm{target}}\right)^2+\left[\lambda_2\left(\frac{\partial U}{\partial L}\right)^2+\lambda_3\left(\frac{\partial^2 U}{\partial L^2}-9BL\right)^2\right]_{L=L_0}, \tag*{(8)}

where DtargetD_{\mathrm{target}} is the experimental target[24, 25, 26, 27] and λ1\lambda_1, λ2\lambda_2, λ3\lambda_3 are adjustable weights.

The optimization trajectory is shown in Figure 2. The diffusion coefficient starts from a larger value and converges to the target within the first few hundred iterations. The structural constraint is transiently perturbed while DD is being corrected and is then gradually restored over subsequent iterations.

Figure 2. Fine-tuning the EAM potential for molten copper. (a) Langevin diffusion estimate DD versus optimization iteration, with the experimental target Dtarget=4.3×10−9 m2 s−1D_{\mathrm{target}} = 4.3 \times10^{-9}\,\mathrm{m^2\,s^{-1}} (dashed). (b) Equilibrium lattice constant a0a_0 and (c) bulk modulus BB versus optimization iteration, with targets a0=3.615 A˚a_0 = 3.615\,\text{\AA} and B=140 GPaB = 140\,\mathrm{GPa} (dashed).

Fine-tuning a machine learning force field for water. We next apply PathGrad to a machine learning force field, where the parameter space is larger and the potential is more flexible. The neuroevolution potential (NEP)[18] offers high computational efficiency while retaining fidelity to reference quantum chemistry data. When trained on MB-pol reference data[28] [29] that approach the accuracy of CCSD(T), which is the benchmark "gold standard" of molecular quantum chemistry30, an NEP model can accurately reproduce the experimental RDF, density, and diffusion coefficient of water31. When trained on density functional theory (DFT) data with the SCAN meta-generalized-gradient-approximation functional32,33, however, the diffusion coefficient is significantly lower than the experimental target (Supplementary Table S2). Starting from a publicly available NEP model34 trained on the SCAN dataset35, we fine-tune it to recover the experimental diffusion coefficient while simultaneously fitting the O–O radial distribution function (RDF) to prevent structural degradation, using the combined loss

L=(D−Dtarget)2+λS∑i[g(ri)−g0(ri)]2,(9)\mathcal{L} = (D - D_{\mathrm{target}})^2 + \lambda_S \sum_i [g(r_i) - g_0(r_i)]^2, \tag*{(9)}

where g(r)g(r) is computed per frame as a Gaussian-smeared RDF (width ε=0.1\varepsilon= 0.1 Å) and g0(r)g_0(r) is the neutron-scattering reference36 smoothed with the same width. Gaussian smearing provides a smooth, differentiable target and suppresses the high-variance binning noise of a conventional histogram. The RDF gradient follows from Eq. (1) using the configurational score −β∇θUθ(r)-\beta\nabla_\theta U_\theta(\mathbf{r}) with β=1/(kBT)\beta= 1/(k_\mathrm{B}T).

The optimization results are shown in Figure 3. The diffusion coefficient rises from 0.61×10−9 m2 s−10.61 \times10^{-9}\ \mathrm{m^2\,s^{-1}} and reaches the training target of 2.3×10−9 m2 s−12.3 \times10^{-9}\ \mathrm{m^2\,s^{-1}} after about 450 iterations (Figure 3a). The root-mean-square error (RMSE) of the RDF also decreases from 0.230 to 0.055 (Figure 3b). Correspondingly, the final O–O RDF visibly approaches the X-ray-scattering reference37 (Figure 4a), and the O–H and H–H RDFs, which are not constrained in the loss, also approach their experimental references (Figure 4b,Figure 4c). We also calculate the force RMSE relative to the CCSD(T)-level MB-pol reference dataset31 every 10 iterations (Figure 3c). The force RMSE is observed to decrease by 7.5% over the first 450 iterations, even though the CCSD(T) forces were not included in the loss. This suggests that correcting the dynamics does not come at the expense of force field fidelity; on the contrary, the fine-tuned model moves closer to the high-level reference in force space as well.

Figure 3. Fine-tuning the water potential. (a) Diffusion during optimization, with its target (dashed). (b) O–O RDF RMSE during optimization. (c) Force RMSE against the CCSD(T)-level reference 31, evaluated every 10 iterations.

Figure 4. Water structure and dynamics before and after fine-tuning. All results are evaluated at T=298.15T = 298.15 K and ρ=0.99704\rho= 0.99704 g cm−3^{-3}. (a–c) O–O, O–H and H–H RDFs for the initial and fine-tuned (at iteration 680) models. Blue dashed curves are experimental references: O–O from X-ray scattering at 299.5 K37; O–H and H–H from empirical potential structure refinement (EPSR) of scattering data at 298 K39. Shading shows the uncertainty or variation reported by the corresponding sources. Only intermolecular regions are shown for O–H (r≥1.3r \ge1.3 Å) and H–H (r≥2.0r \ge2.0 Å). (d–f) Diffusion coefficient DD, shear viscosity η\eta and H–H rotational relaxation time τ2\tau_2 at iterations 0, 200, 400 and 680. Symbols are means over five independent 5 ns trajectories and error bars are sample standard deviations. Some error bars are too small to be visible in the figure. Dashed lines are experimental values40–43. The optimization loss included only DD and the O–O RDF. The estimation windows and underlying curves are shown in Supplementary Fig. S2.

We then evaluated the shear viscosity η\eta and the second-order rotational relaxation time τ2\tau_2 of the intramolecular H–H vector against experimental measurements to determine whether fine-tuning improved the description of observables not included in the loss function. As shown in Figure 4d–Figure 4f, the initial model exhibits slow diffusion and reorientation and excessive viscosity; all properties improve after fine-tuning.

Because the model was fine-tuned using trajectories at a single temperature of 300 K, we also evaluated its performance at other temperatures. Without retraining, we evaluated DD, η\eta, and τ2\tau_2 at 288.15, 298.15 and 308.15 K, each at the experimental density at that temperature38 (Figure 5). Before fine-tuning, the discrepancy with experiment grows on cooling; after fine-tuning, the model stays close to the measured values over the whole 20 K window, although none of these temperatures entered the training. Notably, fine-tuning also brings the apparent activation energies of these dynamical observables substantially closer to experimental values (Supplementary Fig. S3 and Table S4). Thus, single-temperature experimental alignment improves not only the magnitudes of molecular transport and relaxation but also their temperature dependences, suggesting a physically meaningful refinement of the underlying potential energy surface.

Figure 5. Temperature transferability after fine-tuning at 300 K. (a) Diffusion coefficient DD, (b) shear viscosity η\eta and (c) rotational relaxation time τ2\tau_2 at 288.15, 298.15 and 308.15 K, before (initial, grey) and after (fine-tuned, orange) optimization at 300 K (Methods). Simulations at each temperature were performed in the NVT ensemble using the corresponding experimental density38. Symbols and error bars denote the mean and sample standard deviation, respectively, over five independent trajectories. Some error bars are too small to be visible in the figure. Experimental references40–43 are shown as triangles. Open triangles mark the τ2\tau_2 references at 288.15 and 308.15 K, digitized from a fitted experimental curve44 (see Supplementary Tab. S3).

Table S4: Apparent activation energies of water dynamics over 288.15–308.15 K. Values for initial and fine-tuned models and experiments were obtained from three-point Arrhenius fits at 288.15, 298.15 and 308.15 K (Figure S3). Experimental values were fitted using the reference data listed in Table S3. All activation energies are reported in kJ mol−1^{-1}.

QuantityInitialFine-tunedExperiment
DD40.8619.4418.25
η\eta45.3516.4716.94
τ2\tau_2 (HH)47.1722.1117.75

Table S4.

Discussion

Differentiating path probabilities rather than the trajectories themselves avoids the exponential growth of gradient variance with trajectory length that arises in chaotic molecular dynamics. For the NEP water model, the variance of direct trajectory differentiation over a 2 ps trajectory is already several orders of magnitude larger than the PathGrad variance (Figure 6a) and the gradient overflows numerically from the very first optimization step. The variance of the path score, by contrast, grows only linearly (see Supplemental Material), as expected for likelihood-ratio estimators[10] [45]. At the same time, the statistical error of a diffusion estimate averaged over time origins decreases with tt. These two trends largely compensate, so the variance of the gradient estimator depends only weakly on the trajectory length, as shown in Supplementary Figure S1.

Figure 6. Gradient standard deviation and dynamics of the initial NEP water model. (a) Gradient standard deviation versus trajectory length at γ=1\gamma= 1 ps−1^{-1}. The results for longer trajectories are presented in Supplementary Fig. S1. (b) Gradient standard deviation versus γ\gamma for 2 ps trajectories. Both methods estimate the gradient of the diffusion observable with respect to the potential parameters. (c) Diffusion coefficient DD versus γ\gamma. Each point is obtained from a single 5 ns trajectory using oxygen MSD fit. (d) All-atom velocity autocorrelation function (VACF), normalized by its ensemble mean at zero lag, at γ=1\gamma= 1 ps−1^{-1}.

Figure S1. Standard-deviation decomposition for the water gradient. (a) Sample standard deviation of diffusion coefficient across 128 trajectories. (b) Square root of the sample covariance trace of the accumulated dynamical path score. (c) Standard deviation of the gradient estimate.

An important practical consideration is the choice of the Langevin friction coefficient γ\gamma, which sets a trade-off between gradient noise and dynamical fidelity. At fixed trajectory length, the variance of the path score scales as 1/γ1/\gamma (Figure 6b), so smaller friction requires more independent trajectories for training. Larger friction gives less noisy gradients, but perturbs transport more strongly (Figure 6c). Smaller values of γ\gamma interfere less with the intrinsic dynamics and yield results closer to those obtained in the microcanonical (NVE) ensemble. The value used here, γ=1 ps−1\gamma= 1\ \mathrm{ps}^{-1}, is a common choice for Langevin thermostats and was also used for reversible simulation[9].

The length of each independent trajectory is another key parameter. Because the PathGrad variance remains almost unchanged with trajectory length (Figure 6a and Supplementary Figure S1), the trajectory length can be chosen by physical rather than numerical considerations: trajectories should be sufficiently long for the target observable to enter the relevant long-time dynamical regime. We selected 1 ps for copper and 2 ps for water according to the decay of the velocity autocorrelation function (VACF) (Figure 6d), which is sufficient for the diffusion coefficient. Observables with slower relaxation, such as shear viscosity or reorientation in supercooled liquids, require longer windows, and for these targets the weak length dependence of the PathGrad variance is a particular advantage. When additional computational resources were available, we increased the number of independent trajectories rather than their length, since the gradient variance decreases as 1/K1/K.

Machine-learning force fields are trained on ever larger electronic-structure datasets, yet their accuracy remains bounded by the reference method, usually density functional theory. Learning from experiment is the most direct route beyond this ceiling. The experimental observables that MD simulation predicts fall broadly into structural quantities and dynamical quantities. Configurational reweighting[4] already provides efficient and general gradients for structural observables, whereas differentiating dynamical observables remains a challenge[8, 9, 16]. PathGrad differentiates both structural and dynamical observables through a single, untruncated gradient estimator accumulated within a standard Langevin simulation. In principle, it applies to any observable that can be expressed as an average over finite-length Langevin paths. The water results suggest what this enables. In particular, the force error relative to CCSD(T)-level reference data decreased by about 7.5%, despite the absence of quantum-chemical data from the loss function. PathGrad is thus a unified gradient-based route to using both structural and dynamical experimental data as direct learning targets for machine-learning force fields, removing gradient instability that limits the time window of dynamical training targets.

Methods

Simulation and fine-tuning protocols All simulations use the Langevin A–BO discretization and the system-specific parameters are collected in Table S5.

ParameterMolten Cuwater
tt (ps)12
Δt\Delta t (ps)10−310^{-3}10−310^{-3}
γ\gamma (ps−1^{-1})11
TT (K)1500300
ρ\rho (g cm−3^{-3})7.940.994
DtargetD_{\mathrm{target}} (10−910^{-9} m2^2 s−1^{-1})4.3†4.3^{\dagger}2.3‡2.3^{\ddagger}
NatomsN_{\mathrm{atoms}}2561536
KK6464
αD\alpha_D10−410^{-4}10−310^{-3}
αstruct\alpha_{\mathrm{struct}}10−610^{-6}10−210^{-2}

Table S5. Simulation and optimization parameters. tt is the trajectory length used to evaluate DD, Δt\Delta t the time step, γ\gamma the Langevin friction, TT the thermostat temperature, ρ\rho the density, NatomsN_{\mathrm{atoms}} the number of atoms simulated, KK the number of independent trajectories used to estimate the gradient, and αD\alpha_D, αstruct\alpha_{\mathrm{struct}} the learning rates for the dynamical and structural loss terms. †Refs. [23, 24, 25, 26]; ‡Refs. [17, 27, 28].

Toy model. In dimensionless units, we set M=T=1M = T = 1, γ=0.5\gamma= 0.5, Δt=0.005\Delta t = 0.005 and θ=0.5\theta= 0.5. Each trajectory starts from rest at the potential minimum r0=(0,0)\mathbf{r}_0 = (0, 0) and is integrated for 2000 steps. Central finite differences use perturbations θ±0.02\theta\pm0.02 with common random numbers. The path-score covariance centers both DkD_k and Sθ[Γk]S_\theta[\Gamma_k] within each batch. Error bars report the sample standard deviation across the five independent batch estimates.

Copper. We use a 12-parameter analytic representation fitted to the EAM potential of Mishin [17], comprising an embedding function F(ρˉ)=FC[exp⁡(−Fkρˉ)−1]F(\bar{\rho}) = F_C[\exp(-F_k\bar{\rho}) - 1] (two parameters), a pair potential ψ(r)=∑i=14Ciexp⁡(−kir)\psi(r) = \sum_{i=1}^{4} C_i \exp(-k_i r) (eight parameters), and a host electron-density function ρ(r)=Cρexp⁡(−kρr)\rho(r) = C_\rho\exp(-k_\rho r) (two parameters), where ρˉ\bar{\rho} is the sum of neighbor electron densities. We simulate 256 copper atoms at T=1500T = 1500 K and mass density ρ=7.94 g cm−3\rho= 7.94\ \mathrm{g\ cm}^{-3} with γ=1 ps−1\gamma= 1\ \mathrm{ps}^{-1} and t=1 pst = 1\ \mathrm{ps}, using the combined loss in Eq. (8). The structural constraint is evaluated from the total energy U(L)U(L) of a 4×4×44 \times4 \times4 FCC supercell (256 atoms) with side length LL evaluated at L0=4a0=14.46L_0 = 4a_0 = 14.46 Å, corresponding to the experimental lattice constant a0=3.615a_0 = 3.615 Å and bulk modulus B=140B = 140 GPa 46,47. In each optimization step, the dynamical gradient is projected orthogonal to the structural gradient before updating the parameters.

Water. Starting from a publicly available NEP model 34 trained on DFT data generated with the SCAN functional 35, we simulate 512 water molecules (1536 atoms) at ρ=0.994 g cm−3\rho= 0.994\ \mathrm{g\ cm}^{-3} with γ=1 ps−1\gamma= 1\ \mathrm{ps}^{-1} and trajectory length t=2 pst = 2\ \mathrm{ps}. The Langevin thermostat target is set to T=300T = 300 K with initial velocities drawn from the Boltzmann distribution, resulting in a recorded kinetic temperature during training between 297 and 301 K (mean 299 K). The structural target g0(r)g_0(r) is the neutron-scattering O–O RDF 36, Gaussian-smeared with width ϵ=0.1\epsilon= 0.1 Å, and g(r)g(r) is evaluated per frame with the same kernel.

Transport-coefficient analysis The diffusion coefficient is defined by the Einstein relation:

D=lim⁡t→∞16t⟨∣r(t0+t)−r(t0)∣2⟩(10)D = \lim_{t \to\infty} \frac{1}{6t} \left\langle\left\lvert\mathbf{r}(t_0 + t) - \mathbf{r}(t_0) \right\rvert^2 \right\rangle \tag*{(10)}

where the angle brackets denote an average over both time origins t0t_0 and atoms. In practice, we extract DD by fitting the linear regime of the mean-squared displacement (MSD).

The shear viscosity of water is obtained from the Green–Kubo relation for the autocorrelation of the symmetric traceless stress tensor Παβ=(σαβ+σβα)/2−δαβtr⁡(σ)/3\Pi_{\alpha\beta} = (\sigma_{\alpha\beta} + \sigma_{\beta\alpha})/2 - \delta_{\alpha\beta}\operatorname{tr}(\sigma)/3. Because the liquid water is isotropic, all components of Π\Pi can be combined to improve statistics 48, giving the running integral

η(t)=V10kBT∫0t∑α,β⟨Παβ(t0)Παβ(t0+s)⟩t0 ds,\eta(t) = \frac{V}{10k_{\mathrm{B}}T} \int_{0}^{t} \sum_{\alpha,\beta} \langle\Pi_{\alpha\beta}(t_0)\Pi_{\alpha\beta}(t_0+s)\rangle_{t_0}\,\mathrm{d}s,

where VV is the volume and the sum runs over all nine Cartesian component pairs (α,β)(\alpha,\beta), including both orders of off-diagonal indices, which accounts for the prefactor 1/101/10. In practice we accumulate the running integral over lag time and identify η\eta with its plateau mean over 25–75 ps.

Molecular reorientation is characterized by the second-order Legendre time-correlation function of the unit intramolecular H–H vector u^\hat{u}:

τ2=∫0∞C2HH(t) dt,C2HH(t)=⟨P2(u^(t0)⋅u^(t0+t))⟩,(11)\tau_2 = \int_{0}^{\infty} C_2^{\mathrm{HH}}(t)\,\mathrm{d}t,\qquad C_2^{\mathrm{HH}}(t) = \left\langle P_2\left(\hat{u}(t_0)\cdot\hat{u}(t_0+t)\right)\right\rangle, \tag*{(11)}

where P2(x)=12(3x2−1)P_2(x) = \frac{1}{2}(3x^2-1) is the second Legendre polynomial, and the average is taken over all water molecules and time origins. In the extreme-narrowing regime applicable to liquid water near room temperature, τ2\tau_2 is the rotational correlation time governing intramolecular 1H{}^{1}\mathrm{H} spin–lattice relaxation42,43,49. We evaluate the integral numerically using the trapezoidal rule from t=0t = 0 out to a lag beyond which the integral no longer changes. At 298.15 K, the recorded windows are 149.5, 69.5, 39.5 and 29.5 ps for iterations 0, 200, 400 and 680, respectively; at 288.15 K the initial and fine-tuned windows are 349.5 and 49.5 ps, and at 308.15 K they are 149.5 and 29.5 ps.

Acknowledgements This work was supported by the National Natural Science Foundation of China (Grant No. 12404291) and the New Generation Artificial Intelligence National Science and Technology Major Project (2025ZD0121802). Z.W. and L.S. did this work during their internship at Shanghai Artificial Intelligence Laboratory.

Author contributions M.S. and R.S. conceived the idea and designed the study. L.S. and Z.W. developed the path-score formalism and implemented the code. Y.Z. performed the transport-coefficient simulations and analysis. X.G., R.S., and M.S. contributed to the analysis and provided scientific insights. L.S. wrote the first draft. All authors reviewed and approved the final manuscript.

Competing interests The authors declare no competing interests.

Correspondence Correspondence and requests for materials should be addressed to R.S. ([email protected]) or M.S. ([email protected]).

Supplementary Information for Path-probability gradients for optimizing force fields against dynamical observables

Zhongyao Wang; Lun Song; Yakun Zeng; Xingao Gong; Rui Shi; Mao Su

supplementary.pdf

Theory

Gradient of an ensemble average

We consider a force field with parameters θ\theta and denote a configuration of the system by r\mathbf{r}, with probability density pθ(r)p_\theta(\mathbf{r}). For an observable OO that depends on r\mathbf{r} and possibly on θ\theta, its ensemble average is

⟨O⟩θ=∫O(r,θ) pθ(r) dr∫pθ(r) dr.(12)\langle O\rangle_\theta= \frac{\int O(\mathbf{r},\theta)\,p_\theta(\mathbf{r})\,\mathrm{d}\mathbf{r}}{\int p_\theta(\mathbf{r})\,\mathrm{d}\mathbf{r}}. \tag*{(12)}

Its parameter gradient is obtained from the quotient rule,

∇θ⟨O⟩θ=∫(∇θO pθ+O ∇θpθ) dr∫pθ dr−∫∇θpθ dr∫O pθ dr(∫pθ dr)2=∫∇θO pθ dr∫pθ dr+∫O ∇θlog⁡pθ pθ dr∫pθ dr−∫∇θlog⁡pθ pθ dr∫pθ dr∫O pθ dr∫pθ dr=⟨∇θO⟩θ+⟨O ∇θlog⁡pθ⟩θ−⟨∇θlog⁡pθ⟩θ⟨O⟩θ=⟨∇θO⟩θ+⟨(O−⟨O⟩θ)∇θlog⁡pθ⟩θ.(13)\begin{aligned} \nabla_\theta\langle O\rangle_\theta &= \frac{\int(\nabla_\theta O\,p_\theta+O\,\nabla_\theta p_\theta)\,\mathrm{d}\mathbf{r}}{\int p_\theta\,\mathrm{d}\mathbf{r}}-\frac{\int\nabla_\theta p_\theta\,\mathrm{d}\mathbf{r}\int O\,p_\theta\,\mathrm{d}\mathbf{r}}{\left(\int p_\theta\,\mathrm{d}\mathbf{r}\right)^2}\\ &= \frac{\int\nabla_\theta O\,p_\theta\,\mathrm{d}\mathbf{r}}{\int p_\theta\,\mathrm{d}\mathbf{r}}+\frac{\int O\,\nabla_\theta\log p_\theta\,p_\theta\,\mathrm{d}\mathbf{r}}{\int p_\theta\,\mathrm{d}\mathbf{r}}-\frac{\int\nabla_\theta\log p_\theta\,p_\theta\,\mathrm{d}\mathbf{r}}{\int p_\theta\,\mathrm{d}\mathbf{r}}\frac{\int O\,p_\theta\,\mathrm{d}\mathbf{r}}{\int p_\theta\,\mathrm{d}\mathbf{r}}\\ &= \langle\nabla_\theta O\rangle_\theta+\langle O\,\nabla_\theta\log p_\theta\rangle_\theta-\langle\nabla_\theta\log p_\theta\rangle_\theta\langle O\rangle_\theta\\ &= \langle\nabla_\theta O\rangle_\theta+\left\langle\left(O-\langle O\rangle_\theta\right)\nabla_\theta\log p_\theta\right\rangle_\theta. \tag*{(13)} \end{aligned}

This is the score-function or likelihood-ratio gradient estimator used in stochastic simulation, operations research, and reinforcement learning [1, 2, 3, 4, 5]: the score ∇θlog⁡pθ\nabla_\theta\log p_\theta reweights observable fluctuations by the parameter sensitivity of the sampling distribution. Because the right-hand side of Eq. (13) involves only ∇θlog⁡pθ\nabla_\theta\log p_\theta, and any additive constant in log⁡pθ\log p_\theta drops out of the covariance, we may work with unnormalized densities throughout. In the following we apply Eq. (13) to two sampling distributions: the Boltzmann distribution of single configurations, which yields the configurational score used for structural observables such as the radial distribution function (§ 5.2), and the probability distribution over Langevin trajectories, which yields the path score used for dynamical observables such as the diffusion coefficient (Sec. S1.3).

Configurational score and structural observables

For a static observable Q(r)Q(\mathbf{r}), such as the radial distribution function (RDF), the sampling distribution is the Boltzmann distribution pθ(r)∝exp⁡[−βUθ(r)]p_\theta(\mathbf{r})\propto\exp[-\beta U_\theta(\mathbf{r})] with β=1/(kBT)\beta=1/(k_\mathrm{B}T), whose score is

∇θlog⁡pθ(r)=−β∇θUθ(r)+const,(14)\nabla_\theta\log p_\theta(\mathbf{r})=-\beta\nabla_\theta U_\theta(\mathbf{r})+\mathrm{const}, \tag*{(14)}

where the configuration-independent constant (the gradient of the log partition function) drops out of the covariance in Eq. (13). The gradient of a static ensemble average therefore reduces to the configurational form

∇θ⟨Q⟩θ=⟨∇θQ⟩θ−β⟨(Q−⟨Q⟩θ)∇θUθ⟩θ,(15)\nabla_\theta\langle Q\rangle_\theta=\langle\nabla_\theta Q\rangle_\theta-\beta\left\langle\left(Q-\langle Q\rangle_\theta\right)\nabla_\theta U_\theta\right\rangle_\theta, \tag*{(15)}

which is the estimator underlying the DiffTRe method [6].

The RDF g(r)g(r) is evaluated per configuration as a Gaussian-smeared histogram:

g(ri)=14πri2ρN∑a=1N∑b≠a12πε2exp⁡[−(ri−∣ra−rb∣)22ε2],(16)g(r_i)=\frac{1}{4\pi r_i^2\rho N}\sum_{a=1}^{N}\sum_{b\ne a}\frac{1}{\sqrt{2\pi\varepsilon^2}}\exp\left[-\frac{(r_i-\lvert\mathbf{r}_a-\mathbf{r}_b\rvert)^2}{2\varepsilon^2}\right], \tag*{(16)}

where ρ\rho is the number density and ε\varepsilon is the smearing width (we use ε=0.1 A˚\varepsilon=0.1\,\text{\AA}). The smearing provides a smooth RDF estimate and reduces binning noise. A conventional histogram would introduce discontinuous bin counts and high-variance shot noise.

Path score and dynamical observables

Dynamical observables such as the diffusion coefficient depend on the whole trajectory rather than on a single configuration. We therefore take the trajectory itself as the random variable in Eq. (13). Below we first discuss the general structure of the path probability and its score, including the treatment of the initial condition (Sec. S1.3.1), and then evaluate the score explicitly for the A-BO Langevin scheme used in our numerical implementation (§ 5.2.2).

Path probability, score function, and initial conditions

We denote the mass of particle ii by MiM_i and write the multi-particle Langevin dynamics as

dri=vi dt,dvi=Fi(r)Mi dt−γvi dt+2γkBTMi dWi,(17)\begin{aligned} \mathrm{d}\mathbf{r}_i &= \mathbf{v}_i\,\mathrm{d}t,\\ \mathrm{d}\mathbf{v}_i &= \frac{\mathbf{F}_i(\mathbf{r})}{M_i}\,\mathrm{d}t-\gamma\mathbf{v}_i\,\mathrm{d}t+\sqrt{\frac{2\gamma k_{\mathrm{B}}T}{M_i}}\,\mathrm{d}\mathbf{W}_i, \tag*{(17)} \end{aligned}

where Fi(r)=−∇riUθ(r)\mathbf{F}_i(\mathbf{r})=-\nabla_{\mathbf{r}_i}U_\theta(\mathbf{r}) and dWi\mathrm{d}\mathbf{W}_i is a Wiener process.

A numerical integrator advances the phase point z(n)=(r(n),v(n))\mathbf{z}^{(n)}=(\mathbf{r}^{(n)},\mathbf{v}^{(n)}) to z(n+1)\mathbf{z}^{(n+1)} over a time step Δt\Delta t by drawing Gaussian noise ξi(n)∼N(0,I)\boldsymbol{\xi}_i^{(n)}\sim\mathcal{N}(0,\mathbf{I}). For the integrators considered here, the noise can be inferred a posteriori from the stored positions and velocities, and the map from ξi(n)\boldsymbol{\xi}_i^{(n)} to the updated phase point has a parameter-independent Jacobian, as shown explicitly in § 5.2.2. The probability of a trajectory Γ\Gamma conditioned on the initial phase point z0=(r0,v0)\mathbf{z}_0=(\mathbf{r}_0,\mathbf{v}_0) is therefore, up to a parameter-independent factor,

pθ(Γ∣z0)∝∏i,nexp⁡(−∣ξi(n)∣22).(18)p_\theta(\Gamma\mid\mathbf{z}_0)\propto\prod_{i,n}\exp\left(-\frac{\left\lvert\boldsymbol{\xi}_i^{(n)}\right\rvert^2}{2}\right). \tag*{(18)}

Because Eq. (13) involves only ∇θlog⁡pθ\nabla_\theta\log p_\theta, the parameter-independent Jacobian factor and the overall normalization of the density drop out and need not be computed.

The full path probability factorizes as

pθ(Γ)=pθ(Γ∣z0) pθ(z0).(19)p_\theta(\Gamma)=p_\theta(\Gamma\mid\mathbf{z}_0)\,p_\theta(\mathbf{z}_0). \tag*{(19)}

We define the path score

Sθ[Γ]≡∇θlog⁡pθ(Γ∣z0)=−∑i,nξi(n)⋅∇θξi(n),(20)S_\theta[\Gamma]\equiv\nabla_\theta\log p_\theta(\Gamma\mid\mathbf{z}_0)=-\sum_{i,n}\boldsymbol{\xi}_i^{(n)}\cdot\nabla_\theta\boldsymbol{\xi}_i^{(n)}, \tag*{(20)}

whose explicit form depends on the integrator through the inferred noise and is derived in § 5.2.2. [7, 8, 9] The score thus records the accumulated mismatch between the noise required to generate the observed path under the original and perturbed force fields.

It remains to specify pθ(z0)p_\theta(\mathbf{z}_0), i.e., how the initial condition is treated. Two situations arise. If the initial phase point is held fixed, pθ(z0)p_\theta(\mathbf{z}_0) is parameter-independent and ∇θlog⁡pθ(Γ)=Sθ[Γ]\nabla_\theta\log p_\theta(\Gamma)=S_\theta[\Gamma]. If the initial condition is instead sampled from the equilibrium distribution of the force field,

pθ(z0)∝exp⁡[−β(Uθ(r0)+∑i12Mi∣vi,0∣2)],(21)p_\theta(\mathbf{z}_0)\propto\exp\left[-\beta\left(U_\theta(\mathbf{r}_0)+\sum_i\frac{1}{2}M_i\lvert\mathbf{v}_{i,0}\rvert^2\right)\right], \tag*{(21)}

the velocities follow the parameter-independent Maxwell–Boltzmann distribution, while the positions carry the configurational score of § 5.2, giving

∇θlog⁡pθ(Γ)=Sθ[Γ]−β∇θUθ(r0)(22)\nabla_\theta\log p_\theta(\Gamma)=S_\theta[\Gamma]-\beta\nabla_\theta U_\theta(\mathbf{r}_0) \tag*{(22)}

up to an additive constant. In the examples presented in this work, the initial configurations are drawn from the equilibrium distribution of the current force field, and both contributions are retained in practice: the diffusion gradient is evaluated with the total score (S11), so each trajectory contributes its accumulated path score Sθ[Γ]S_\theta[\Gamma] together with the configurational score −β∇θUθ(r0)-\beta\nabla_\theta U_\theta(\mathbf{r}_0) of its initial configuration.

For a dynamical observable O[Γ]O[\Gamma] with no explicit parameter dependence, the first term of Eq. (13) vanishes and the gradient is the covariance of the observable with the total score (S11). With KK independent trajectories {Γk}k=1K\{\Gamma_k\}_{k=1}^{K} started from initial positions rk,0\mathbf{r}_{k,0}, we estimate

Oˉ=1K∑k=1KO[Γk],∇θ⟨O⟩θ≈1K−1∑k=1K(O[Γk]−Oˉ)(Sθ[Γk]−β∇θUθ(rk,0)).(23)\bar{O}=\frac{1}{K}\sum_{k=1}^{K}O[\Gamma_k], \qquad\nabla_\theta\langle O\rangle_\theta\approx\frac{1}{K-1}\sum_{k=1}^{K}\left(O[\Gamma_k]-\bar{O}\right)\left(S_\theta[\Gamma_k]-\beta\nabla_\theta U_\theta(\mathbf{r}_{k,0})\right). \tag*{(23)}

For a squared-error loss L=(⟨O⟩θ−Otarget)2L=(\langle O\rangle_\theta-O_{\mathrm{target}})^2,

∇θL=2(⟨O⟩θ−Otarget)∇θ⟨O⟩θ(24)\nabla_\theta L=2(\langle O\rangle_\theta-O_{\mathrm{target}})\nabla_\theta\langle O\rangle_\theta \tag*{(24)}
≈2(Oˉ−Otarget)1K−1∑k=1K(O[Γk]−Oˉ)(Sθ[Γk]−β∇θUθ(rk,0)).\approx2(\bar{O}-O_{\mathrm{target}})\frac{1}{K-1}\sum_{k=1}^{K}\left(O[\Gamma_k]-\bar{O}\right)\left(S_\theta[\Gamma_k]-\beta\nabla_\theta U_\theta(\mathbf{r}_{k,0})\right).

A-BO Langevin splitting scheme

The numerical experiments in this work use the A-BO Langevin discretization [10, 11] of Eq. (17). For particle ii one step advancing (ri(n),vi(n))(\mathbf{r}_i^{(n)},\mathbf{v}_i^{(n)}) to (ri(n+1),vi(n+1))(\mathbf{r}_i^{(n+1)},\mathbf{v}_i^{(n+1)}) reads

ri(n+1)=ri(n)+vi(n)Δt,(25)\mathbf{r}_i^{(n+1)}=\mathbf{r}_i^{(n)}+\mathbf{v}_i^{(n)}\Delta t, \tag*{(25)}
vi(n+1)=c0vi(n)+c1,iξi(n)+c2,iFi,θ(r(n+1)),(26)\mathbf{v}_i^{(n+1)}=c_0\mathbf{v}_i^{(n)}+c_{1,i}\boldsymbol{\xi}_i^{(n)}+c_{2,i}\mathbf{F}_{i,\theta}(\mathbf{r}^{(n+1)}), \tag*{(26)}

with

c0=e−γΔt,c1,i=(1−c02)kBTMi,c2,i=1−c0γMi,(27)c_0=e^{-\gamma\Delta t},\qquad c_{1,i}=\sqrt{\frac{(1-c_0^2)k_{\mathrm{B}}T}{M_i}},\qquad c_{2,i}=\frac{1-c_0}{\gamma M_i}, \tag*{(27)}

and ξi(n)∼N(0,I)\boldsymbol{\xi}_i^{(n)}\sim\mathcal{N}(0,\mathbf{I}). This scheme applies a full position-drift step with the current velocity and then updates the velocity with the exact Ornstein–Uhlenbeck propagator for a constant force evaluated at the new position [12, 13].

The Gaussian noise can be inferred from the stored positions and velocities,

ξi(n)=1c1,i[vi(n+1)−c0vi(n)−c2,iFi,θ(r(n+1))].(28)\boldsymbol{\xi}_i^{(n)}=\frac{1}{c_{1,i}}\left[\mathbf{v}_i^{(n+1)}-c_0\mathbf{v}_i^{(n)}-c_{2,i}\mathbf{F}_{i,\theta}(\mathbf{r}^{(n+1)})\right]. \tag*{(28)}

The map from the noise ξi(n)\boldsymbol{\xi}_i^{(n)} to the new velocity is linear with determinant c1,idc_{1,i}^{d}, where dd is the spatial dimension, while the position update is deterministic given the old velocity; the Jacobian relating pθ(Γ∣z0)p_\theta(\Gamma\mid\mathbf{z}_0) to the Gaussian noise distribution is therefore parameter-independent, and Eq. (18) holds. Substituting (S17) into (S7) gives the discrete Onsager–Machlup action [14, 15]

pθ(Γ∣z0)∝exp⁡[−∑i12c1,i2∑n(vi(n+1)−c0vi(n)−c2,iFi,θ(r(n+1)))2].(29)p_\theta(\Gamma\mid\mathbf{z}_0)\propto\exp\left[-\sum_i\frac{1}{2c_{1,i}^{2}}\sum_n\left(\mathbf{v}_i^{(n+1)}-c_0\mathbf{v}_i^{(n)}-c_{2,i}\mathbf{F}_{i,\theta}(\mathbf{r}^{(n+1)})\right)^2\right]. \tag*{(29)}

Differentiating the logarithm gives the path score

Sθ[Γ]=∇θ(−12∑i,n∣ξi(n)∣2)=−∑i,nξi(n)⋅∇θξi(n)=∑i,nc2,ic1,iξi(n)⋅∇θFi,θ(r(n+1))=∑i,n1γ1−e−γΔt(1+e−γΔt)kBTMiξi(n)⋅∇θFi,θ(r(n+1)).(30)\begin{aligned} S_\theta[\Gamma] &= \nabla_\theta\left(-\frac{1}{2}\sum_{i,n}\left|\xi_i^{(n)}\right|^2\right) \\ &= -\sum_{i,n}\xi_i^{(n)}\cdot\nabla_\theta\xi_i^{(n)} \\ &= \sum_{i,n}\frac{c_{2,i}}{c_{1,i}}\xi_i^{(n)}\cdot\nabla_\theta F_{i,\theta}\left(r^{(n+1)}\right) \\ &= \sum_{i,n}\frac{1}{\gamma}\sqrt{\frac{1-e^{-\gamma\Delta t}}{(1+e^{-\gamma\Delta t})k_{\mathrm{B}}TM_i}}\xi_i^{(n)}\cdot\nabla_\theta F_{i,\theta}\left(r^{(n+1)}\right). \tag*{(30)} \end{aligned}

In the small-time-step limit, (1−e−γΔt)/(1+e−γΔt)→γΔt/2\left(1-e^{-\gamma\Delta t}\right)/\left(1+e^{-\gamma\Delta t}\right)\to\gamma\Delta t/2 and the prefactor reduces to Δt/(2γMikBT)\sqrt{\Delta t/(2\gamma M_i k_{\mathrm{B}}T)}, recovering the Euler–Maruyama form of the score presented in the main text.

Variance

The primary difficulty in differentiating dynamical observables is the growth of the gradient variance with the trajectory length. In direct differentiation through the equations of motion, derivatives are propagated recursively along the trajectory. In a chaotic many-body system, small changes in the force field may be rapidly amplified, causing the resulting trajectory derivatives to explode with simulation time.

The path-score method avoids propagating these trajectory derivatives. To examine its variance, we consider the small-time-step limit form of Eq. (30). The contribution from time step nn is

sn=∑iΔt2γMikBTξi(n)⋅∇θFi,θ(r(n+1)),Sθ=∑n=0Nt−1sn.(31)s_n=\sum_i\sqrt{\frac{\Delta t}{2\gamma M_i k_{\mathrm{B}}T}}\xi_i^{(n)}\cdot\nabla_\theta F_{i,\theta}\left(r^{(n+1)}\right),\qquad S_\theta=\sum_{n=0}^{N_t-1}s_n. \tag*{(31)}

The ordering of the A-BO integrator is important here. The position r(n+1)r^{(n+1)}, and hence the force derivative evaluated at that position, is determined before the current noise ξ(n)\xi^{(n)} is applied to update the velocity. Therefore, for a given trajectory history, the sign and direction of each score increment are determined by a newly drawn zero-mean Gaussian noise. Positive and negative contributions cancel on average, giving ⟨sn⟩=0\langle s_n\rangle=0.

The same argument applies to correlations between different time steps. For n<mn<m, the force derivative at step mm may depend on the earlier trajectory and therefore on the earlier noises, but it is independent of the newly drawn noise ξ(m)\xi^{(m)}. Averaging over this new noise makes the cross correlation between sns_n and sms_m vanish. The accumulated score therefore behaves as a random walk with configuration-dependent step sizes, rather than as an iteratively amplified trajectory derivative.

As a result, the score variance is the sum of the variances of its individual increments. Averaging over the unit Gaussian noise converts the squared noise projection into the squared norm of the force derivative, giving

Var⁡(Sθ)≃∑n=0Nt−1∑iΔt2γMikBT⟨∣∇θFi,θ(r(n+1))∣2⟩.(32)\operatorname{Var}(S_\theta)\simeq\sum_{n=0}^{N_t-1}\sum_i\frac{\Delta t}{2\gamma M_i k_{\mathrm{B}}T}\left\langle\left|\nabla_\theta F_{i,\theta}\left(r^{(n+1)}\right)\right|^2\right\rangle. \tag*{(32)}

After equilibration, the average force-gradient norm is approximately stationary. Since t=NtΔtt=N_t\Delta t, Eq. (32) shows that

Var⁡(Sθ)∝t.(33)\operatorname{Var}(S_\theta)\propto t. \tag*{(33)}

Thus, the path score has random-walk-like fluctuations whose variance grows linearly rather than exponentially with the trajectory length. The equilibrium initial-condition contribution in Eq. (22) adds a time-independent term and does not change this long-time scaling.

The gradient estimator involves the product of the score and the observable, δOtSθ\delta O_t S_\theta. We assume that the observable is evaluated by averaging over particles and time origins, and that the trajectory length substantially exceeds the relevant correlation time, as is standard practice in molecular dynamics simulations. Under this standard long-trajectory approximation, the number of effectively independent samples is proportional to tt, and the variance of the observable decreases as

Var⁡(δOt)∝1t.(34)\operatorname{Var}(\delta O_t) \propto\frac{1}{t}. \tag*{(34)}

Approximating the observable and score fluctuations as jointly Gaussian, the variance of their product satisfies

Var⁡(δOtSθ)=Var⁡(δOt)Var⁡(Sθ)+Cov⁡(δOt,Sθ)2≤2Var⁡(δOt)Var⁡(Sθ).(35)\operatorname{Var}(\delta O_t S_\theta) = \operatorname{Var}(\delta O_t)\operatorname{Var}(S_\theta) + \operatorname{Cov}(\delta O_t,S_\theta)^2 \leq2\operatorname{Var}(\delta O_t)\operatorname{Var}(S_\theta). \tag*{(35)}

Therefore, the dependence on trajectory length is expected to cancel. Longer trajectories increase the variance of the accumulated path score but simultaneously improve the statistical estimate of the observable. We assessed this compensation for the initial NEP water model using 128 separately equilibrated Langevin trajectories at γ=1 ps−1\gamma= 1\ \mathrm{ps}^{-1} (Supplementary Fig. S1). The diffusion standard deviation decreases with trajectory length, while the cumulative path-score standard deviation increases. The resulting standard deviation of the gradient shows a modest variation in this range.

It should be noted that the variance retains a dependence on the Langevin friction coefficient, which scales approximately as O(1/γ)O(1/\gamma). Because γ\gamma is fixed throughout the simulations, this dependence does not affect the trajectory length scaling considered here.

Additional results of validating the water potential.

To validate the fine-tuned water potential, we selected four checkpoints along the fine-tuning trajectory at iterations 0, 200, 400, and 680. We further evaluated the initial (iteration 0) and fine-tuned (iteration 680) models at 288.15 and 308.15 K to test temperature transferability.

For each model and temperature, five independent starting configurations were prepared by scaling the molecular positions to the cubic box length corresponding to the experimental density of liquid water at that temperature and atmospheric pressure [16], leaving intramolecular bond lengths and angles unchanged. All simulations use 512 water molecules (1536 atoms), a time step of Δt=1\Delta t = 1 fs, and Langevin dynamics at γ=1\gamma= 1 ps−1^{-1} at fixed volume. At 288.15 K, both the equilibration and production trajectories were lengthened to account for the slower decay of the stress autocorrelation in the initial model.

Supplementary Fig. S2 displays the underlying correlation functions and extraction windows at 298.15 K, averaged over the five independent production trajectories for each checkpoint. Supplementary Table S2 lists the three transport coefficients for the four checkpoints along the optimization iterations, and Supplementary Table S3 compares the initial and fine-tuned models across the three temperatures 288.15, 298.15 and 308.15 K. Every entry is the mean and sample standard deviation over five independent production trajectories with the simulation lengths specified in Table S1.

TT (K)Density (g cm−3^{-3})EquilibrationProduction
288.150.99910400 ps10 ns
298.150.99704200 ps5 ns
308.150.99403200 ps5 ns

Table S1. Water validation protocol. Production lengths are per trajectory; five trajectories are used for each available parameter set.

To quantify the temperature dependence of water dynamics, we analyzed the three dynamical observables using the Arrhenius relation

Q(T)=Q0exp⁡(±EaRT)(36)Q(T) = Q_0 \exp\left(\pm\frac{E_a}{RT}\right) \tag*{(36)}

where QQ denotes the self-diffusion coefficient DD, shear viscosity η\eta, or second-rank rotational relaxation time τ2\tau_2 of the intramolecular H–H vector, RR is the gas constant, and EaE_a is the activation energy. The negative sign applies to DD, while the positive sign applies to η\eta and τ2\tau_2.

We performed ordinary least-squares fits of ln⁡(Q/Qref)\ln(Q/Q_{\mathrm{ref}}) versus 1000/T1000/T at 288.15, 298.15 and 308.15 K, using the experimental density at each temperature. The resulting apparent activation energies, shown in Figure S3 and summarized in Table S4, characterize the temperature dependence over this 20 K interval. Experimental activation energies were obtained using the same fitting procedure applied to the reference data listed in Table S3. Fine-tuning brings the apparent activation energies of all three dynamical observables substantially closer to their experimental values, demonstrating improved temperature dependence beyond the training condition.

Table S3: Transferability across temperature. Initial and fine-tuned values at 288.15, 298.15 and 308.15 K, each at the experimental density of that temperature. Experimental references: DD [17]; η\eta [18]; τ2\tau_2 at 298.15 K [19, 20].

QuantitySet288.15 K298.15 K308.15 K
DD (10−9 m2 s−110^{-9}\ \mathrm{m^2\ s^{-1}})Initial0.275±0.0050.275 \pm0.0050.507±0.0050.507 \pm0.0050.832±0.0110.832 \pm0.011
DD (10−9 m2 s−110^{-9}\ \mathrm{m^2\ s^{-1}})Fine-tuned1.602±0.0101.602 \pm0.0102.114±0.0182.114 \pm0.0182.712±0.0052.712 \pm0.005
DD (10−9 m2 s−110^{-9}\ \mathrm{m^2\ s^{-1}})Experiment1.7662.2992.895
η\eta (mPa s)Initial9.897±0.4829.897 \pm0.4824.977±0.2834.977 \pm0.2832.901±0.1852.901 \pm0.185
η\eta (mPa s)Fine-tuned1.346±0.0791.346 \pm0.0791.077±0.0711.077 \pm0.0710.861±0.0770.861 \pm0.077
η\eta (mPa s)Experiment1.1380.8900.720
τ2\tau_2 (ps)Initial26.51±0.7526.51 \pm0.7512.990±0.21412.990 \pm0.2147.396±0.0577.396 \pm0.057
τ2\tau_2 (ps)Fine-tuned3.208±0.0143.208 \pm0.0142.318±0.0112.318 \pm0.0111.763±0.0041.763 \pm0.004
τ2\tau_2 (ps)Experiment2.93∗2.93^{*}2.361.81∗1.81^{*}

Table S3.

Figure S3. Figure S3: Arrhenius analysis of water dynamics over 288.15–308.15 K. (a) Diffusion coefficient DD, (b) shear viscosity η\eta and (c) second-rank rotational relaxation time τ2\tau_{2} of the intramolecular H–H vector, for the initial and fine-tuned models and experimental measurements. Results are plotted as ln⁡(Q/Qref)\ln(Q/Q_{\mathrm{ref}}) versus 1000/T1000/T, where QQ represents DD, η\eta, or τ2\tau_{2}. Simulation symbols represent means over five independent NVT trajectories. The corresponding standard errors are too small for the error bars to be visible in the figure. Lines represent linear Arrhenius fits, from which the apparent activation energies reported in Table S4 are determined.

Figure S2. Extraction of water transport coefficients. (a) Mean MSD with the 20–100 ps fitting window shaded and linear fits over that window. (b) Mean viscosity running integral with its 25–75 ps plateau window shaded. (c) Mean H–H second-rank rotational correlation and (d) its running trapezoidal integral over each set’s sampled window. Curves are averages over five independent trajectories per parameter set.

IterationDD (10−9 m2 s−110^{-9}\ \mathrm{m^2\ s^{-1}})η\eta (mPa s)τ2\tau_2 (ps)
00.507±0.0050.507 \pm0.0054.98±0.284.98 \pm0.2812.99±0.2112.99 \pm0.21
2001.446±0.0071.446 \pm0.0071.59±0.081.59 \pm0.083.73±0.053.73 \pm0.05
4002.200±0.0252.200 \pm0.0250.99±0.120.99 \pm0.122.23±0.022.23 \pm0.02
6802.114±0.0182.114 \pm0.0181.08±0.071.08 \pm0.072.32±0.012.32 \pm0.01
Experiment2.2990.8902.36

Table S2. Transport coefficients at 298.15 K. T=298.15 KT = 298.15\ \mathrm{K}, ρ=0.99704 g cm−3\rho= 0.99704\ \mathrm{g\ cm^{-3}}. Only DD and the O–O RDF entered the loss. Values are means ±\pm standard deviation over five independent trajectories.

References

  1. [1]Glynn, P. W. Likelihood ratio gradient estimation for stochastic systems. Communications of the ACM 33, 75–84 (1990).DOI
  2. [2]Williams, R. J. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning 8, 229–256 (1992).
  3. [3]Kleijnen, J. P. & Rubinstein, R. Y. Optimization and sensitivity analysis of computer simulation models by the score function method. European Journal of Operational Research 88, 413–427 (1996).
  4. [4]Fu, M. C. Gradient estimation. In Henderson, S. G. & Nelson, B. L. (eds.) Simulation, vol. 13 of Handbooks in Operations Research and Management Science, chap. 19, 575–616 (Elsevier, 2006).
  5. [5]Mohamed, S., Rosca, M., Figurnov, M. & Minh, A. Monte carlo gradient estimation in machine learning. Journal of Machine Learning Research 21, 1–62 (2020).arxiv.org/abs/1906.10652
  6. [6]Thaler, S. & Zavadlav, J. Learning neural network potentials from experimental data via Differentiable Trajectory Reweighting. Nature Communications 12, 6884 (2021).DOI
  7. [7]Donati, L., Hartmann, C. & Keller, B. G. Girsanov reweighting for path ensembles and markov state models. The Journal of Chemical Physics 146, 244112 (2017).DOI
  8. [8]Kieninger, S., Ghy sbrecht, S. & Keller, B. G. Girsanov reweighting for simulations of underdamped langevin dynamics. Theory. arXiv preprint arXiv:2303.14696 (2023).arxiv.org/abs/2303.14696
  9. [9]Bolhuis, P. G., Brotzakis, Z. F. & Keller, B. G. Optimizing molecular potential models by imposing kinetic constraints with path reweighting. The Journal of Chemical Physics 159, 074102 (2023).DOI
  10. [10]Leimkuhler, B. & Matthews, C. Rational construction of stochastic numerical methods for molecular sampling. Applied Mathematics Research eXpress 2013, 34–56 (2013).
  11. [11]Leimkuhler, B. & Matthews, C. Robust and efficient configurational molecular sampling via langevin dynamics. The Journal of chemical physics 138 (2013).DOI
  12. [12]Paterlini, M. G. & Ferguson, D. M. Constant temperature simulations using the langevin equation with velocity verlet integration. Chemical Physics 236, 243–252 (1998).DOI
  13. [13]Melchionna, S. Design of quasisymplectic propagators for langevin dynamics. The Journal of Chemical Physics 127, 044108 (2007).pubmed.ncbi.nlm.nih.gov/17672682
  14. [14]Onsager, L. & Machlup, S. Fluctuations and irreversible processes. Physical Review 91, 1505–1512 (1953).DOI
  15. [15]Machlup, S. & Onsager, L. Fluctuations and irreversible process. ii. systems with kinetic energy. Physical Review 91, 1512–1515 (1953).DOI
  16. [16]Kell, G. S. Density, thermal expansivity, and compressibility of liquid water from 0 °c to 150 °c: Correlations and tables for atmospheric pressure and saturation reviewed and expressed on 1968 temperature scale. Journal of Chemical & Engineering Data 20, 97–105 (1975).
  17. [17]Holz, M., Heil, S. R. & Sacco, A. Temperature-dependent self-diffusion coefficients of water and six selected molecular liquids for calibration in accurate 1H NMR PFG measurements. Physical Chemistry Chemical Physics 2, 4740–4742 (2000).DOI
  18. [18]Korson, L., Drost-Hansen, W. & Millero, F. J. Viscosity of water at various temperatures. The Journal of Physical Chemistry 73, 34–39 (1969).DOI
  19. [19]Jonas, J., DeFries, T. & Wilbur, D. J. Molecular motions in compressed liquid water. The Journal of Chemical Physics 65, 582–588 (1976).DOI
  20. [20]Kumar, R. & Skinner, J. L. Water simulation model with explicit three-molecule interactions. The Journal of Physical Chemistry B 112, 8311–8318 (2008).DOI
  21. [21]Krynicki, K. Proton spin-lattice relaxation in pure water between 0°c and 100°c. Physica 32, 167–178 (1966).DOI
  22. [22]Lankhorst, D., Schriever, J. & Leyte, J. C. Determination of the rotational correlation time of water by proton NMR relaxation in ²H₂O and some related results. Berichte der Bunsengesellschaft für physikalische Chemie 86, 215–221 (1982).
  23. [23]Meyer, A. Self-diffusion in liquid copper as seen by quasielastic neutron scattering. Physical Review B 81, 012102 (2010).DOI
  24. [24]Meyer, A. The measurement of self-diffusion coefficients in liquid metals with quasielastic neutron scattering. In EPJ Web of Conferences, vol. 83, 01002 (EDP Sciences, 2015).DOI
  25. [25]Brillo, J. Thermophysical Properties of Multicomponent Liquid Alloys (De Gruyter Oldenbourg, 2016).
  26. [26]Hoyt, J., Sadigh, B., Asta, M. & Foiles, S. Kinetic phase field parameters for the cu–ni system derived from atomistic computations. Acta Materialia 47, 3181–3187 (1999). URL https://www.sciencedirect.com/science/article/pii/S1359645499001895.DOI
  27. [27]Mills, R. Self-diffusion in normal and heavy water in the range 1–45°. The Journal of Physical Chemistry 77, 685–688 (1973).DOI
  28. [28]Krynicki, K., Green, C. D. & Sawyer, D. W. Pressure and temperature dependence of self-diffusion in water. Faraday Discussions of the Chemical Society 66, 199–208 (1978).DOI

Paper details

vlnc:W_xcqwvwny
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents