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 with parameters , where denotes the coordinates of all particles in the system. Static properties like pressure and radial distribution functions depend only on and , while dynamical properties like diffusion coefficient depend on the whole trajectory . The gradient of an observable against the parameters can be calculated using
where 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
where 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 , the noise at each step can be inferred by inverting Eq. (3):
Since each is a standard Gaussian, the path probability with given initial conditions and is
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 . The total probability is where is the Boltzmann distribution. The gradient of the log probability is
where is the path score function. From Eq. (4) and Eq. (5), we have
This path score is computed on the fly accumulating and 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 , where sets the height of the barriers between adjacent minima (Figure 1a). Increasing suppresses thermally activated hopping and lowers the diffusion coefficient , so . We propagate independent trajectories from and estimate from their mean-squared displacement (MSD).
Figure 1. Path-score differentiation on a two-dimensional toy model. (a) Corrugated potential with . Darker regions denote lower potential energy; the barrier between neighboring minima is . (b) Twenty-four illustrative Langevin trajectories starting from rest at the origin, colored by their path score . The gradient is determined by the covariance between the diffusion estimate and the path score. (c) Estimates of 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, , obtained from five batches with .
Figure 1b illustrates different trajectories. Each trajectory is colored by its path score . A positive score means that a small increase in 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 therefore gives . The covariance quantifies how a small change in redistributes the probability between high- and low-mobility paths.
Figure 1c compares the path-score estimator with direct trajectory differentiation as the batch size increases. The path-score estimate converges to the finite-difference reference, and its statistical uncertainty decreases approximately as . In contrast, direct trajectory differentiation remains highly variable even at , giving , 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 , the lattice constant , and the bulk modulus . The structural constraints are applied through derivatives of the total energy of a FCC supercell with respect to its side length . At the equilibrium supercell side the pressure vanishes, giving the bulk modulus as . The combined loss is
where is the experimental target[24, 25, 26, 27] and , , 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 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 versus optimization iteration, with the experimental target (dashed). (b) Equilibrium lattice constant and (c) bulk modulus versus optimization iteration, with targets and (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
where is computed per frame as a Gaussian-smeared RDF (width Å) and 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 with .
The optimization results are shown in Figure 3. The diffusion coefficient rises from and reaches the training target of 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 K and g cm. (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 ( Å) and H–H ( Å). (d–f) Diffusion coefficient , shear viscosity and H–H rotational relaxation time 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 and the O–O RDF. The estimation windows and underlying curves are shown in Supplementary Fig. S2.
We then evaluated the shear viscosity and the second-order rotational relaxation time 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 , , and 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 , (b) shear viscosity and (c) rotational relaxation time 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 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.
| Quantity | Initial | Fine-tuned | Experiment |
| 40.86 | 19.44 | 18.25 | |
| 45.35 | 16.47 | 16.94 | |
| (HH) | 47.17 | 22.11 | 17.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 . 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 ps. The results for longer trajectories are presented in Supplementary Fig. S1. (b) Gradient standard deviation versus for 2 ps trajectories. Both methods estimate the gradient of the diffusion observable with respect to the potential parameters. (c) Diffusion coefficient versus . 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 ps.
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 , which sets a trade-off between gradient noise and dynamical fidelity. At fixed trajectory length, the variance of the path score scales as (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 interfere less with the intrinsic dynamics and yield results closer to those obtained in the microcanonical (NVE) ensemble. The value used here, , 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 .
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.
| Parameter | Molten Cu | water |
| (ps) | 1 | 2 |
| (ps) | ||
| (ps) | 1 | 1 |
| (K) | 1500 | 300 |
| (g cm) | 7.94 | 0.994 |
| ( m s) | ||
| 256 | 1536 | |
| 64 | 64 | |
Table S5. Simulation and optimization parameters. is the trajectory length used to evaluate , the time step, the Langevin friction, the thermostat temperature, the density, the number of atoms simulated, the number of independent trajectories used to estimate the gradient, and , 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 , , and . Each trajectory starts from rest at the potential minimum and is integrated for 2000 steps. Central finite differences use perturbations with common random numbers. The path-score covariance centers both and 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 (two parameters), a pair potential (eight parameters), and a host electron-density function (two parameters), where is the sum of neighbor electron densities. We simulate 256 copper atoms at K and mass density with and , using the combined loss in Eq. (8). The structural constraint is evaluated from the total energy of a FCC supercell (256 atoms) with side length evaluated at Å, corresponding to the experimental lattice constant Å and bulk modulus 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 with and trajectory length . The Langevin thermostat target is set to 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 is the neutron-scattering O–O RDF 36, Gaussian-smeared with width Å, and is evaluated per frame with the same kernel.
Transport-coefficient analysis The diffusion coefficient is defined by the Einstein relation:
where the angle brackets denote an average over both time origins and atoms. In practice, we extract 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 . Because the liquid water is isotropic, all components of can be combined to improve statistics 48, giving the running integral
where is the volume and the sum runs over all nine Cartesian component pairs , including both orders of off-diagonal indices, which accounts for the prefactor . In practice we accumulate the running integral over lag time and identify 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 :
where 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, is the rotational correlation time governing intramolecular spin–lattice relaxation42,43,49. We evaluate the integral numerically using the trapezoidal rule from 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 and denote a configuration of the system by , with probability density . For an observable that depends on and possibly on , its ensemble average is
Its parameter gradient is obtained from the quotient rule,
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 reweights observable fluctuations by the parameter sensitivity of the sampling distribution. Because the right-hand side of Eq. (13) involves only , and any additive constant in 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 , such as the radial distribution function (RDF), the sampling distribution is the Boltzmann distribution with , whose score is
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
which is the estimator underlying the DiffTRe method [6].
The RDF is evaluated per configuration as a Gaussian-smeared histogram:
where is the number density and is the smearing width (we use ). 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 by and write the multi-particle Langevin dynamics as
where and is a Wiener process.
A numerical integrator advances the phase point to over a time step by drawing Gaussian noise . For the integrators considered here, the noise can be inferred a posteriori from the stored positions and velocities, and the map from to the updated phase point has a parameter-independent Jacobian, as shown explicitly in § 5.2.2. The probability of a trajectory conditioned on the initial phase point is therefore, up to a parameter-independent factor,
Because Eq. (13) involves only , 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
We define the path score
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 , i.e., how the initial condition is treated. Two situations arise. If the initial phase point is held fixed, is parameter-independent and . If the initial condition is instead sampled from the equilibrium distribution of the force field,
the velocities follow the parameter-independent Maxwell–Boltzmann distribution, while the positions carry the configurational score of § 5.2, giving
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 together with the configurational score of its initial configuration.
For a dynamical observable 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 independent trajectories started from initial positions , we estimate
For a squared-error loss ,
A-BO Langevin splitting scheme
The numerical experiments in this work use the A-BO Langevin discretization [10, 11] of Eq. (17). For particle one step advancing to reads
with
and . 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,
The map from the noise to the new velocity is linear with determinant , where is the spatial dimension, while the position update is deterministic given the old velocity; the Jacobian relating 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]
Differentiating the logarithm gives the path score
In the small-time-step limit, and the prefactor reduces to , 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 is
The ordering of the A-BO integrator is important here. The position , and hence the force derivative evaluated at that position, is determined before the current noise 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 .
The same argument applies to correlations between different time steps. For , the force derivative at step may depend on the earlier trajectory and therefore on the earlier noises, but it is independent of the newly drawn noise . Averaging over this new noise makes the cross correlation between and 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
After equilibration, the average force-gradient norm is approximately stationary. Since , Eq. (32) shows that
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, . 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 , and the variance of the observable decreases as
Approximating the observable and score fluctuations as jointly Gaussian, the variance of their product satisfies
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 (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 . Because 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 fs, and Langevin dynamics at ps 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.
| (K) | Density (g cm) | Equilibration | Production |
| 288.15 | 0.99910 | 400 ps | 10 ns |
| 298.15 | 0.99704 | 200 ps | 5 ns |
| 308.15 | 0.99403 | 200 ps | 5 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
where denotes the self-diffusion coefficient , shear viscosity , or second-rank rotational relaxation time of the intramolecular H–H vector, is the gas constant, and is the activation energy. The negative sign applies to , while the positive sign applies to and .
We performed ordinary least-squares fits of versus 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: [17]; [18]; at 298.15 K [19, 20].
| Quantity | Set | 288.15 K | 298.15 K | 308.15 K |
| () | Initial | |||
| () | Fine-tuned | |||
| () | Experiment | 1.766 | 2.299 | 2.895 |
| (mPa s) | Initial | |||
| (mPa s) | Fine-tuned | |||
| (mPa s) | Experiment | 1.138 | 0.890 | 0.720 |
| (ps) | Initial | |||
| (ps) | Fine-tuned | |||
| (ps) | Experiment | 2.36 |
Table S3.
Figure S3. Figure S3: Arrhenius analysis of water dynamics over 288.15–308.15 K. (a) Diffusion coefficient , (b) shear viscosity and (c) second-rank rotational relaxation time of the intramolecular H–H vector, for the initial and fine-tuned models and experimental measurements. Results are plotted as versus , where represents , , or . 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.
| Iteration | () | (mPa s) | (ps) |
| 0 | |||
| 200 | |||
| 400 | |||
| 680 | |||
| Experiment | 2.299 | 0.890 | 2.36 |
Table S2. Transport coefficients at 298.15 K. , . Only and the O–O RDF entered the loss. Values are means standard deviation over five independent trajectories.
References
- [1]Glynn, P. W. Likelihood ratio gradient estimation for stochastic systems. Communications of the ACM 33, 75–84 (1990).DOI
- [2]Williams, R. J. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning 8, 229–256 (1992).
- [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]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]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]Thaler, S. & Zavadlav, J. Learning neural network potentials from experimental data via Differentiable Trajectory Reweighting. Nature Communications 12, 6884 (2021).DOI
- [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]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]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]Leimkuhler, B. & Matthews, C. Rational construction of stochastic numerical methods for molecular sampling. Applied Mathematics Research eXpress 2013, 34–56 (2013).
- [11]Leimkuhler, B. & Matthews, C. Robust and efficient configurational molecular sampling via langevin dynamics. The Journal of chemical physics 138 (2013).DOI
- [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]Melchionna, S. Design of quasisymplectic propagators for langevin dynamics. The Journal of Chemical Physics 127, 044108 (2007).pubmed.ncbi.nlm.nih.gov/17672682
- [14]Onsager, L. & Machlup, S. Fluctuations and irreversible processes. Physical Review 91, 1505–1512 (1953).DOI
- [15]Machlup, S. & Onsager, L. Fluctuations and irreversible process. ii. systems with kinetic energy. Physical Review 91, 1512–1515 (1953).DOI
- [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]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]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]Jonas, J., DeFries, T. & Wilbur, D. J. Molecular motions in compressed liquid water. The Journal of Chemical Physics 65, 582–588 (1976).DOI
- [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]Krynicki, K. Proton spin-lattice relaxation in pure water between 0°c and 100°c. Physica 32, 167–178 (1966).DOI
- [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]Meyer, A. Self-diffusion in liquid copper as seen by quasielastic neutron scattering. Physical Review B 81, 012102 (2010).DOI
- [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]Brillo, J. Thermophysical Properties of Multicomponent Liquid Alloys (De Gruyter Oldenbourg, 2016).
- [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]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]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








