Manuscript Offprint
arXiv:2610.12132A structure-preserving neural density functional for the ions of a polymer electrolyte
Abstract
Predicting the structure and response of inhomogeneous polymer electrolytes requires a description of ion correlations that retains molecular-scale accuracy while remaining transferable across spatial scales and geometries. We develop a neural density functional for electrolytes that preserves spatial symmetries, thermodynamic integrability and the Noether identities, with perfect screening recovered in stable, noncritical bulk states. Its nonlinear density dependence captures the concentration-dependent correlations missed by a pair closure, including a crossover from enhanced to suppressed long-wavelength number fluctuations at strong coupling. The functional describes density profiles at an untrained salt concentration and predicts bulk structure factors and the long-wavelength number response. Trained solely on planar density and internal-force profiles from molecular dynamics, the functional predicts ionic structure in larger domains and in two-dimensional external fields. On the same ion data, it is more accurate than three other neural density-functional architectures and keeps its accuracy with a quarter of the training runs, where the errors of the best alternative grow by about two thirds. The spatial transferability provides a necessary foundation for connecting molecular correlations to continuum predictions at larger scales.
Keywords: classical density functional theory | polymer electrolytes | many-body ion correlations | machine learning | force matching
1 Introduction
Salt-doped polymers are attractive solid electrolytes for lithium batteries, offering improved safety and mechanical stability over liquid electrolytes [1, 2]. Their performance, however, is difficult to predict, because adding salt increases the number of charge carriers but also changes ion correlations [3–6]: ions pair and cluster as the concentration grows [7–9], and measured cation transference numbers can even become negative [10]. At equilibrium, these correlations shape the ion distributions and density fluctuations. Describing these correlations is challenging because they arise on two length scales: in low-permittivity polymers the Bjerrum length can span several monomer diameters, while packing and solvation introduce correlations at shorter range. A theory of these correlations must therefore go beyond the Coulomb mean field and remain applicable as concentration and external fields vary. Molecular simulations capture such correlations accurately, and data-driven coarse-graining extends their time scales [11], but they remain limited to small domains of simple geometry. This calls for a continuum theory that retains their molecular fidelity while extending to the larger scales and more complex geometries of inhomogeneous electrolytes.
Classical density functional theory provides such a framework [12, 13]. A free-energy functional determines the equilibrium ion distributions through its first functional derivative and the bulk correlations through its second. The excess part of this functional is unknown, however, and has to be approximated. For electrolytes, analytical approximations combine fundamental measure theory for ion packing [14, 15] with electrostatic correlation terms based on the mean spherical approximation or a reference fluid [16–19]. These functionals are built on charged hard-sphere reference systems and do not include the solvation of ions by polymer chains. Theories of ion-containing polymers include this solvation through Born and self-energy terms [20–22] and treat ion correlations through liquid-state closures [23], each within its own analytical approximation.
Neural approaches instead learn the excess part from simulation data, either through the one-body direct correlation functions or as the excess free energy itself [24–26]. Local learning of the one-body correlations describes inhomogeneous fluids accurately,
*Correspondence: lyuliyao@ustc.edu.cn even in planar domains far larger than those used for training [24]. With a separate treatment of the long-range electrostatics it extends to ionic mixtures [25], and with machine-learned interatomic potentials to molecular liquids from first principles [27]. The learned correlations, however, are not guaranteed to derive from a free-energy functional, and they respect no spatial symmetry beyond translations on the training grid. Both properties matter. They make the predictions satisfy exact relations of statistical mechanics: pair correlations are symmetric, free-energy differences do not depend on the integration path, and the total internal force vanishes. They also restrict the functional to a narrower set of admissible forms, so that it can be learned from less data [28] and generalizes more reliably to unseen conditions.
Recent work has begun to build some of these properties in. Learning the free energy directly ensures integrability [26], and an equivariant formulation developed concurrently with the present work extends this approach by incorporating the spatial symmetries of a cubic grid [29]. The parameters of both are defined on a fixed grid, and both were developed for simple fluids without long-range electrostatics. Closest in form to the present work are learned functionals of weighted densities [30–32]. In particular, Kelley et al. [31] formulate a rotationally invariant scalar functional with smooth reciprocal-space kernels. It is trained on free energies and their functional derivatives, which for a molecular fluid require thermodynamic integration, and has been demonstrated for one-dimensional inhomogeneities. Thus, none of these approaches combines integrability, continuous spatial symmetry and long-range electrostatics in a functional that is learned from canonical simulations without free-energy or chemical-potential labels and transfers to other geometries independently of its training grid (Table 1).
In this paper, we construct a neural functional for the ions of a coarse-grained salt-doped polymer melt [6] (Fig. 1). The Coulomb interaction is kept analytically, and the remaining correlations are represented by a scalar functional of the cation and anion densities alone. This learned part is built from radial convolution kernels and a pointwise neural network, both defined in continuous space rather than on a grid. The chemical potentials are functional derivatives of the same scalar free-energy functional, so free-energy differences between density profiles do not depend on the integration path. The functional is invariant under all translations, rotations, and reflections. Therefore, the total internal force and torque vanish, as the Noether identities require [33]. Because the Coulomb term is explicit and the learned kernels are short ranged, the small-wavenumber charge correlations satisfy the perfect-screening sum rules [34] in stable, noncritical bulk states. Since no parameter refers to a grid or a box size, the trained functional can be evaluated in domains of other sizes and geometries.
We train this functional by matching species-resolved internal force densities measured in canonical molecular dynamics under static planar external potentials. The first Yvon–Born–Green equation connects these force densities to gradients of the interaction chemical potentials generated by the functional. This force-based supervision differs from fitting bulk pair correlations [26], fitting free energies obtained by thermodynamic integration [31], enforcing local chemical-potential balance [29, 35], matching the time evolution of density fields [36], or fitting measure-dependent forces to particle trajectories [37]. The spatially constant chemical potentials drop out on taking the gradient, so the loss constrains the functional across inhomogeneous ionic environments without chemical-potential labels. Neither bulk structure factors nor the associated number susceptibility enters the force-matching loss, making them tests of the learned free-energy curvature beyond the fitted forces.
We study two electrostatic coupling strengths, with Bjerrum lengths of about 8 and 30 monomer diameters. At both, the functional trained on planar profiles predicts ionic structure in larger boxes and under external potentials that vary in two directions. The same functional describes density profiles at an untrained salt concentration and predicts bulk structure factors and the long-wavelength number response. Its nonlinear density dependence captures concentration-dependent effective ion correlations missed by a fixed quadratic pair closure, including the crossover from enhanced to suppressed long-wavelength number fluctuations at strong coupling. Trained on the same ion data, it is more accurate than three other neural architectures and keeps its accuracy
Table 1. Structural guarantees and transferability of the learned functionals compared in this work, in their original formulations. √, guaranteed by construction (first four rows) or demonstrated without retraining (last three rows); N, verified numerically but not built in; G, holds only for the symmetry operations of the grid; X, neither built in nor reported.
| Property | Learned | Learned | This work | ||
|---|---|---|---|---|---|
| Sammüller et al. [24] | Bui-Cox [25] | Dijkman et al. [26] | Cheng [29] | ||
| Integrability | N | X | ✓ | ✓ | ✓ |
| Spatial symmetries | G | G | X | G | ✓ |
| Noether force/torque identities | N | X | X | X | ✓ |
| Long-range electrostatics | X | ✓ | X | X | ✓ |
| Larger domains | ✓ | ✓ | X | ✓ | ✓ |
| Nonplanar geometries | X | X | X | ✓ | ✓ |
| Grid-independent parameters | X | X | X | X | ✓ |
A Simulation data

B Functional and training

C Predictions
Density profiles from

Structure and number response

Figure 1. A learned density functional for the ions of a salt-doped polymer melt. (A) Molecular dynamics under a planar external potential provides ion densities and internal force densities . (B) The excess free energy is parameterized by radial kernels and a pointwise neural network and trained by matching internal force densities to MD; the ideal-gas and Coulomb contributions are included analytically. (C) Predicted density profiles for a held-out run, bulk charge structure, and number response at the smallest nonzero wavenumber, compared with MD.
with a quarter of the training runs, where the errors of the best alternative grow by about two thirds, while retaining its built-in structural identities.
2.1 Free-energy formulation
We consider a salt dissolved in a polymer melt. Treating the polymer implicitly, the ions are described by their number-density profiles , with , collected in . Within classical density functional theory, these profiles are governed by the intrinsic free-energy functional
where is the ideal-gas part, with thermal energy and thermal wavelength , and is the Coulomb mean-field energy of the charge density . The ionic charges are , with valences and elementary charge . is the vacuum permittivity and the uniform relative permittivity of the medium. The excess part contains all correlations beyond the ideal gas and the Coulomb mean field and is the unknown component of the theory. With the polymer integrated out, is the intrinsic free energy of the ions in a melt that stays in equilibrium with their densities, so the response of the chains to the ions is part of . The functional therefore refers to one host state and coupling strength, here the melt of 30-bead chains at and zero pressure at a given , and to the salt concentrations covered by the training data, 0.01 to 0.08 ion pairs per monomer, over which the melt volume adjusts to the salt content.
In external potentials , the equilibrium profiles minimize at fixed particle numbers, which gives the Euler–Lagrange equations
The first three terms are the functional derivatives of , and respectively. The mean electrostatic potential satisfies Poisson's equation, , the excess chemical potential is , and the chemical potentials are the Lagrange multipliers that fix the particle numbers.
Taking the gradient of Eq. 2 and combining it with the equilibrium force balance, the first equation of the Yvon–Born–Green hierarchy (derivation in Supplementary Information, section S2.2), gives
where is the equilibrium internal force density exerted on ions of species by the other ions and the polymer monomers, excluding the external force. Eq. 3 therefore relates a quantity sampled directly from the interaction forces in molecular dynamics to the functional, without chemical-potential labels. Since only the gradient of enters, force matching determines only up to terms linear in the particle numbers , which shift by constants.
2.2 The neural functional
We parameterize the excess free energy as
(4)
where denotes the species, are radial pair kernels and the neural network is evaluated pointwise on the vector of weighted densities of both ionic species,
Here denotes convolution, and the learned radial kernels probe the density profiles over multiple length scales. The first term is quadratic in the densities, with density-independent kernels, while the second term makes the effective correlations depend nonlinearly on the surrounding densities. Because the kernels are continuous functions of distance and acts pointwise, the functional is defined in continuous space: its parameters refer to no grid or box, and a discretization enters only when it is evaluated. The trainable parameters comprise the weights and biases of , the parameters defining the radial kernels , and the coefficients defining the pair kernels .
2.3 Properties of the neural functional
With the excess part of Eq. 4, the functional F of Eq. 1 has the following properties by construction (proofs in Supplementary Information, section S1).
First, because the network represents the scalar rather than the excess chemical potentials, the relation holds exactly. The Hessian of , which gives the pair direct correlation functions, is therefore symmetric, and excess free-energy differences between density profiles do not depend on the integration path.
Second, F is invariant under translations, rotations, and reflections, because all kernels are radial and acts pointwise. Since the internal force densities of Eq. 3 derive from this invariant scalar functional, Noether's theorem turns the invariance into global identities [33]: for any admissible density profile, the total internal force and torque vanish after integration over space and summation over species.
Third, the functional satisfies the perfect-screening sum rules in stable, noncritical homogeneous bulk states. The explicit Coulomb term fixes the small-wavenumber charge response, while the short-ranged learned contribution has a finite limit as . For an electroneutral monovalent electrolyte, this gives
where is the charge structure factor per unit volume, is the salt number density, is the Debye wavenumber, and is the Bjerrum length. The vanishing constant term and the coefficient encode the electroneutrality and Stillinger–Lovett second-moment conditions, respectively [34].
2.4 Training by force matching
We train by matching Eq. 3 to ion-density and internal force-density profiles from canonical molecular dynamics under static external potentials. For each run , we evaluate the right-hand side of Eq. 3 with on the sampled density profiles to obtain . For the planar profiles used here, we denote the force-density residual along in bin by . The parameters minimize the weighted squared residuals and the weighted squared Fourier amplitudes of the residuals,
(6)
where is the number of spatial bins and is the unnormalized discrete Fourier transform of the residual at wavenumber , with box length .
The first term weights each bin by the inverse variance of the MD estimate, , where is the standard error and its median over the bins of the run. The second term compensates for the factor by which Eq. 3 suppresses long-wavelength errors of in the force density; each run enters it with its mean bin weight (Methods).
3 Methods
3.1 Molecular dynamics
We simulate the coarse-grained model of Tsamopoulos and Wang [6]: 400 chains of 30 beads joined by FENE bonds [38], with 120 to 960 cation–anion pairs for to 0.08. Both ions interact with the monomers through the solvation potential of Hall and coworkers [5], of strength and range . Electrostatics uses PPPM [39] with dielectric constant 7.5 or 2. All runs use LAMMPS [40] with a Nosé–Hoover thermostat [41, 42] at and a time step of . Each state point is equilibrated at zero pressure and then simulated at the mean volume (Supplementary Information, section S2.1).
3.2 External potentials and profiles
The potentials consist of a part that acts equally on both species and a part that acts with opposite signs, like an applied electrostatic potential. They belong to four families that cover different length scales: Fourier series with wavenumbers for to 6, the same series with additional modes up to , periodic arrays of Gaussian wells, and long-wavelength modes with and 2. Each run is equilibrated in the field for to and then sampled for to , longer at higher concentration. Density and internal force density profiles are recorded on bins, with standard errors estimated from eight consecutive blocks of each trajectory.
3.3 Neural functional and training
The pair kernels and the weighted densities in Eq. 4 are built from six learned radial kernels , where are normalized Gaussians of widths 0.25 to and is a perceptron of with two hidden layers of 32 units and six outputs. The pair kernels are parameterized as , with learned coefficients . is a perceptron with two hidden layers of 128 units that acts on the 12 weighted densities. Both networks use softplus activations, and the functional has 19,641 parameters. The pair closure is the same functional without , which leaves 1,336 parameters. We minimize the loss with AdamW [43] (learning rate with cosine decay, weight decay ) for at most 4000 steps, with early stopping on the validation residual (Supplementary Information, section S2.2), and keep the parameters with the lowest validation residual. In the loss of Eq. 6, the median floor prevents bins with very small error bars from dominating the first term. In the second term, the division by offsets the factor that the gradient in Eq. 3 places on an error of at wavenumber ; the Fourier amplitudes are not resolved by bin, so each run is weighted by the mean of its bin weights.
3.4 Other learned functionals
For the comparison in Table 2, we adapt three published forms to the two ion species and the analytic Coulomb term and train them with the same data, splits and force-matching loss as our functional. The one-body network [24, 25] is a single perceptron with two hidden layers of 128 units that maps the densities of both species within of a point to and at that point. The lattice free energy [29] uses -invariant products of Cartesian density moments on voxels. Moments are resolved by species, and invariants are formed within and across species. For planar profiles, the densities are averaged onto the voxels, the sums over lateral stencil offsets are evaluated exactly, and the free energy is averaged over the registrations of the lattice with the profile. The window is chosen by the validation residual, which favors over , and the stencil radius is that of the original, (Supplementary Information, section S4.2). The convolutional free energy [26] passes the two densities, as input channels, through six periodic dilated convolutions (kernel 3, dilation 2, 16 to 64 channels), each followed by average pooling, and a linear read-out; all layers use softplus activations. The Lennard-Jones benchmark is the truncated and shifted fluid of ref. [29] ( , ) in a cubic box of side . Training uses the densities , 0.2, 0.4, 0.6 and 0.7, each with 22 planar potentials, and the density 0.5 is held out.
4 Results

Figure 2. Density profiles predicted for runs excluded from parameter fitting, at two coupling strengths. Top row: ( ); bottom row: ( ). Columns: a periodic array of neutral Gaussian wells at , the strongest well at the untrained concentration , and a periodic array of Gaussian wells at . Cation densities relative to the mean; black curves and bands show MD averages and standard errors estimated from eight blocks. Poisson–Boltzmann theory (dotted), the pair closure (dashed) and the neural functional (solid) are obtained by solving the canonical Euler–Lagrange equation under the applied potential. Numbers give the relative error of each profile, averaged over cations and anions.
4.1 Density profiles and concentration transfer
We apply the method to a coarse-grained model of a salt-doped polymer melt [6]. The melt contains 400 bead–spring chains, each comprising 30 monomers of diameter . The cation and anion diameters are and , respectively, and both species are solvated by the monomers. The interaction potentials and model parameters are specified in Supplementary Information, section S2.1. We study two coupling strengths: at a dielectric constant of , the Bjerrum length is ; at , it is , nearly four times as large. At each dielectric constant, we simulate five salt concentrations, , and 0.08 cations per monomer, under static planar potentials acting on the ions. These potentials include superpositions of Fourier modes, periodic arrays of Gaussian wells, and modes with wavelengths equal to the box length, with amplitudes of up to a few . We train on 71 runs at and 82 at and hold out four runs at each concentration for testing (Supplementary
Information, section S2.1). The test set consists of these 20 held-out runs and 22 additional runs at c = 0.05, a concentration excluded from training.
We test the learned functional by solving Eq. 2 to predict equilibrium density profiles for the held-out runs (Fig. 2). We compare with two reference functionals. Poisson–Boltzmann theory is the mean-field limit . The pair closure serves as a quadratic reference: it keeps only the first term of Eq. 4, with density-independent kernels fitted to the same training data. Across all test runs, the mean relative errors of the neural functional are 1.2% at and 2.0% at , compared with 3.0% and 5.7% for the pair closure and 25% and 23% for Poisson–Boltzmann theory. At the untrained concentration , the mean relative errors are 0.85% and 0.98%, respectively. Much of this gap arises because one density-independent kernel has to describe all concentrations. At , a pair closure fitted at alone yields a profile error of 1.9% at that concentration, against about 3% for the jointly fitted closure and 1.0% for the neural functional (Supplementary Information, section S3.1). The effective correlations therefore depend on concentration, which we analyze below.
4.2 Transfer across domain sizes and geometries
Because its parameters refer to no grid or box, the trained functional can be evaluated in larger domains without changing its parameters. We test transfer to a box twice the training length using an aperiodic potential containing a mode at half the smallest training wavenumber (Fig. 3A). At both dielectric constants, the profile errors are 0.8% to 1.6%, against 2.4% to 6.2% for the pair closure. In a box four times the training length, a single mode at a quarter of the smallest training wavenumber gives profile errors of 0.5% to 1.3%, against 0.8% to 2.5% for the pair closure (Supplementary Information, section S4.1).
The training profiles vary only along one direction, but the functional is defined for general three-dimensional densities. We therefore apply six potentials that vary in x and y at c = 0.04: four periodic ones, including square lattices of rods and wavevectors oblique to the box axes, and two aperiodic ones that combine oblique plane waves with irregularly placed Gaussian wells and barriers (Fig. 3 B and C). For the aperiodic potentials, the relative profile errors of the predicted density maps are 1.8–3.1%, at the level of the MD noise of 1.7–3.0%, against 3.6–5.5% for the pair closure and 31–62% for Poisson–Boltzmann theory. For the periodic potentials, the errors are 0.6–3.7%, against 2.4–7.6% for the pair closure (Supplementary Information, section S4.1).
4.3 Bulk correlations and number response
In a uniform bulk state, density fluctuations are determined by the Hessian of the free energy, a quantity not used in training. We define the Fourier-space excess kernel as
Including the ideal-gas and Coulomb contributions, the Ornstein–Zernike relation gives
where are the partial structure factors per unit volume. Here contains the bulk densities, and is the valence vector.
Projecting onto the charge and number-density channels gives
where . At and to 0.08, the neural functional reproduces the zero-field MD charge and number structure factors with relative root-mean-square errors of 2.7–4.1% and 2.4–3.6%, respectively, over (Fig. 4A and B). At , the corresponding errors are 2.7–4.5% and 2.6–5.3%; the values at are listed in Supplementary Information, section S3.1.
We quantify the long-wavelength number response by , which equals 1 for an ideal solution. In the finite simulation box, we report at the smallest wavenumber . At , the MD estimate rises from at to at (Fig. 4D), describing enhanced number fluctuations at low concentration and suppressed fluctuations at high concentration. The neural functional reproduces this concentration dependence at both dielectric constants, whereas the pair closure gives at all concentrations at and misses the enhanced fluctuations.
A Density profile in a larger box
B MD
C Neural functional






Figure 3. Generalization to larger boxes and nonplanar density fields at c = 0.04. Rows correspond to and 2. (A) Cation density profiles in a box twice the training length under an aperiodic potential. Black curves and gray bands show MD averages and standard errors; blue dashed curves show the neural-functional prediction. (B, C) MD and predicted cation densities under an aperiodic two-dimensional potential of oblique plane waves and irregularly placed Gaussian wells and barriers, using a shared color scale within each row. All predictions use parameters trained on planar profiles in the original box.
To identify which correlations contribute most of the concentration dependence of , including the crossover at , we return to Eq. 7. At small wavenumbers, its Coulomb term strongly suppresses charge fluctuations, so the number channel nearly decouples and
where is the excess kernel in the number channel. Number fluctuations are therefore enhanced when , and suppressed when . A fixed quadratic pair closure has a density-independent , so keeps its sign at all concentrations. The neural term instead allows to vary with the surrounding ion densities. The number-channel kernel inferred from zero-field MD changes sign with concentration at , and the neural functional reproduces its concentration dependence at both dielectric constants (Fig. 5).
4.4 Comparison of learned architectures
We compare our functional with three published architectures: a one-body network that predicts excess chemical potentials directly from local density windows [24, 25], a convolutional free energy that maps the whole planar profile to a free energy [26], and a lattice free energy built from Cartesian moments of local density environments [29]. These forms differ in the structural properties guaranteed by their original formulations (Table 1). To test whether the differences affect predictive performance, we adapt each architecture to the two ion species and train it with the force-matching loss, data and splits of our functional. The comparison therefore tests the architectures under one training protocol, not the published methods with their own data and training targets (Methods and Supplementary Information, section S4.2). We use the present ionic system, where every form is given the same analytic Coulomb term as our functional, and, as a control, the truncated Lennard-Jones fluid of ref. [29], a one-component uncharged fluid of the kind for which these forms were developed. The forms are trained on the full training set and on about a quarter of it (Table 2).
A

B
C
D
Figure 4. Bulk structure and long-wavelength number response. (A, B) Normalized charge and number structure factors at and to 0.08. Points show zero-field MD results averaged over -shells; curves show predictions from Eq. 7. (C, D) Finite-wavenumber response factor at and 2. Solid curves show the neural functional and dashed curves the pair closure. The dotted line marks the ideal value . Neither quantity enters the force-matching loss.
MD estimate
neural functional
pair closure
A

B

Figure 5. Concentration dependence of effective correlations. Combined correlation kernel versus concentration at (A) and 2 (B). Points show estimates from zero-field MD (Supplementary Information, section S3.2); solid curves show the neural functional and dashed curves the pair closure.
On the ions, our functional has the lowest held-out errors with the full training set, 1.50% and 3.11% at and 2, followed by the one-body network with 1.75% and 3.41%. The margin widens when the training set is reduced to a quarter. Our errors change little, to 1.55% and 3.56%, whereas those of the one-body network grow by about two thirds, to 3.00% and 5.55%, and 3 of its 20 held-out solutions at no longer converge (Supplementary Information, section S4.3). With a quarter of the runs, our functional is thus as accurate as the one-body network trained on all of them. The lattice free energy is less accurate, with 2.97% and 7.16% on the full training set, and its Euler–Lagrange iteration fails for 4 of the 42 test runs at and for 10 at , either by not converging or by collapsing onto a narrow density spike. The Lennard-Jones control at gives the same ordering: our error is with all runs and with a quarter, about half that of the best alternative in each case ( and ). The convolutional free energy, trained here by force matching on inhomogeneous profiles rather than by the pair-correlation matching of the original work, rarely yields a converged Euler–Lagrange solution in either system (Table 2 and Supplementary Information, section S4.4), so we do not rank it. These results are consistent with built-in integrability and symmetry reducing what must be learned from data.
The structural checks on the MD profiles show the differences of Table 1 in the adapted implementations (Table 2). The one-body network has net-force errors of up to , Jacobian asymmetries of up to and path-dependent free-energy differences of up to . The two free-energy baselines have symmetric Hessians, but their net-force errors reach and , since the Noether identity is not guaranteed without invariance under continuous translations. Our functional has a maximum net-force error of , with a symmetric Hessian and path-independent free-energy differences to numerical precision. On the same profiles resampled to and grids, its chemical potentials change by less than , those of the one-body network and the lattice free energy by , and the convolutional free energy cannot be evaluated (Supplementary Information, section S4.3).
5 Discussion
We construct a neural density functional for the ions of a salt-doped polymer melt that combines, by construction, integrability, continuous spatial symmetry, the Noether identities and an explicit treatment of long-range electrostatics, with parameters that refer to no grid. The neural functionals compared here each provide only some of these properties (Table 1). Trained only on planar force densities, the same functional predicts ionic structure in larger boxes and in fields that vary in two directions, describes an untrained salt concentration, and recovers bulk structure factors and the long-wavelength number response. Its nonlinear density dependence captures the concentration dependence of the effective ion correlations, including the sign change of the number-channel kernel at strong coupling, which a density-independent pair kernel cannot represent.
A natural next step is to apply the functional to transport. Although the functional describes equilibrium, it supplies the chemical potentials whose gradients drive ion fluxes in stochastic and dynamical density functional theories [44, 45]. Combined with a validated mobility model, it could predict conductivity and salt diffusion that include the ion correlations learned here. Such mobilities can themselves be learned from molecular dynamics [36]. The range of validity out of equilibrium is set by how close the unresolved degrees of freedom remain to their equilibrium distribution [46]. We also plan to apply the functional at electrode interfaces, where its three-dimensional, grid-independent form can be used once the boundary conditions and the polymer environment are specified.
Table 2. Profile errors and structural checks of the adapted baselines, our functional and the pair closure. Profile errors are mean relative errors (%) as in Fig. 2; the statistical errors of the MD profiles are about . “Quarter” denotes training on a quarter of the runs. Means exclude failed solutions (footnotes). Entries in parentheses are errors of the final iterates of Euler–Lagrange iterations that mostly did not converge (footnote ). Structural checks give maxima on the MD profiles of the ions: relative net internal force, Hessian asymmetry and path dependence of the free energy (Supplementary Information, section S4.3).
| Form | Parameters | Lennard-Jones | ions | Structural checks | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| all | quarter | held-out | quarter | Force | Hessian | Path | ||||||
| 2 | 7.5 | 2 | 7.5 | 2 | ||||||||
| Neural functional (this work) | 19,641 | 0.27 | 0.30 | 1.50 | 3.11 | 0.85 | 0.98 | 1.55 | 3.56 | |||
| One-body network [24, 25] | 32,514 | 0.64 | 0.70 | 1.75 | 3.41 | 1.01 | 0.85 | 3.00 | 5.55 | 0.14 | 0.55 | 0.009 |
| Lattice free energy [29] | 23,828 | 0.54 | 0.80 | 2.97 | 7.16 | 2.06 | 2.72 | 4.53 | 6.31 | |||
| Convolutional free energy [26] | 24,321 | (2.03) | (3.20) | (13.8) | (15.1) | (16.1) | (16.2) | - | - | 0.06 | ||
| Pair closure | 1,336 | 12.1 | - | 4.21 | 8.78 | 1.85 | 2.81 | - | - | exact | ||
With a quarter of the runs, it fails to converge for 3 of the 20 held-out ion runs at and for 1 of the 41 Lennard-Jones runs. Trained on all runs, it fails for 4 of the 42 ion test runs at (3 not converged, 1 collapsed) and for 10 at (6 not converged, 4 collapsed); trained on a quarter of the runs, it fails for 2 and 7 of the 20 held-out runs at and 2, respectively. Trained on all runs, it converges for 5 of the 42 ion test runs at , for none at , and for 7 of the 41 Lennard-Jones runs; it is not trained on a quarter of the ion runs.
Data Availability
The project repository is https://github.com/Lyuliyao/NDFT-polymer-electrolyte. It contains analysis and training code, processed molecular-dynamics profiles, model configurations, saved metrics and selected trained parameters.
References
[1] Daniel T Hallinan Jr and Nitash P Balsara. Polymer electrolytes. Annual review of materials research, 43(1):503–525, 2013.
[2] Vera Bocharova and Alexei P Sokolov. Perspectives for polymer electrolytes: a view from fundamentals of ionic conductivity. Macromolecules, 53(11):4141–4157, 2020.
[3] Chang Yun Son and Zhen-Gang Wang. Ion transport in small-molecule and polymer electrolytes. The Journal of Chemical Physics, 153(10):100903, 2020.
[4] Kara D Fong, Julian Self, Bryan D McCloskey, and Kristin A Persson. Ion correlations and their impact on transport in polymer-based electrolytes. Macromolecules, 54(6):2575–2591, 2021.
[5] Kuan-Hsuan Shen and Lisa M Hall. Ion conductivity and correlations in model salt-doped polymers: Effects of interaction strength and concentration. Macromolecules, 53(10):3655–3668, 2020.
[6] Alexandros J Tsamopoulos and Zhen-Gang Wang. Ion conductivity in salt-doped polymers: combined effects of temperature and salt concentration. ACS Macro Letters, 13(3):322–327, 2024.
[7] Oleg Borodin and Grant D Smith. Mechanism of ion transport in amorphous poly (ethylene oxide)/litfsi from molecular dynamics simulations. Macromolecules, 39(4):1620–1629, 2006.
[8] Nicola Molinari, Jonathan P Mailoa, and Boris Kozinsky. Effect of salt concentration on ion clustering and transport in polymer solid electrolytes: a molecular dynamics study of peo-litfsi. Chemistry of Materials, 30(18):6298–6306, 2018.
[9] Arthur France-Lanord and Jeffrey C Grossman. Correlations from ion pairing and the nernst-einstein equation. Physical review letters, 122(13):136001, 2019.
[10] Danielle M Pesko, Ksenia Timachova, Rajashree Bhattacharya, Mackensie C Smith, Irune Villaluenga, John Newman, and Nitash P Balsara. Negative transference numbers in poly (ethylene oxide)-based electrolytes. Journal of The Electrochemical Society, 164(11):E3569–E3575, 2017.
[11] Liyao Lyu and Huan Lei. Construction of coarse-grained molecular dynamics with many-body non-markovian memory. Physical Review Letters, 131(17):177301, 2023.
[12] Robert Evans. The nature of the liquid-vapour interface and other topics in the statistical mechanics of non-uniform, classical fluids. Advances in physics, 28(2):143–200, 1979.
[13] Jean-Pierre Hansen and Ian R McDonald. Theory of simple liquids: with applications to soft matter. Elsevier, 2013.
[14] Yaakov Rosenfeld. Free-energy model for the inhomogeneous hard-sphere fluid mixture and density-functional theory of freezing. Physical review letters, 63(9):980, 1989.
[15] Roland Roth. Fundamental measure theory for hard-sphere mixtures: a review. Journal of Physics: Condensed Matter, 22(6):063102, 2010.
[16] Yaakov Rosenfeld. Free energy model for inhomogeneous fluid mixtures: Yukawa-charged hard spheres, general interactions, and plasmas. The Journal of chemical physics, 98(10):8126–8148, 1993.
[17] Dirk Gillespie, Wolfgang Nonner, and Robert S Eisenberg. Coupling poisson–nernst–planck and density functional theory to calculate ion flux. Journal of Physics: Condensed Matter, 14(46):12129–12145, 2002.
[18] Andreas Härtel. Structure of electric double layers in capacitive systems and to what extent (classical) density functional theory describes it. Journal of Physics: Condensed Matter, 29(42):423002, 2017.
[19] Jian Jiang, Valeriy V Ginzburg, and Zhen-Gang Wang. Density functional theory for charged fluids. Soft Matter, 14(28):5878–5887, 2018.
[20] Zhen-Gang Wang. Fluctuation in electrolyte solutions: The self energy. Physical Review E—Statistical, Nonlinear, and Soft Matter Physics, 81(2):021501, 2010.
[21] Issei Nakamura, Nitash P Balsara, and Zhen-Gang Wang. Thermodynamics of ion-containing polymer blends and block copolymers. Physical review letters, 107(19):198301, 2011.
[22] Issei Nakamura and Zhen-Gang Wang. Salt-doped block copolymers: ion distribution, domain spacing and effective parameter. Soft Matter, 8(36):9356–9367, 2012.
[23] Charles E Sing, Jos W Zwanikken, and Monica Olvera de la Cruz. Electrostatic control of block copolymer morphology. Nature materials, 13(7):694–698, 2014.
[24] Florian Sammüller, Sophie Hermann, Daniel de Las Heras, and Matthias Schmidt. Neural functional theory for inhomogeneous fluids: Fundamentals and applications. Proceedings of the National Academy of Sciences, 120(50):e2312484120, 2023.
[25] Anna T Bui and Stephen J Cox. Learning classical density functionals for ionic fluids. Physical Review Letters, 134(14):148001, 2025.
[26] Jacobus Dijkman, Marjolein Dijkstra, René Van Roij, Max Welling, Jan-Willem van de Meent, and Bernd Ensing. Learning neural free-energy functionals with pair-correlation matching. Physical Review Letters, 134(5):056103, 2025.
[27] Anna T Bui and Stephen J Cox. A unified machine-learning framework for ab initio multiscale modeling of liquids. Proceedings of the National Academy of Sciences, 123(30):e2610049123, 2026.
[28] Simon Batzner, Albert Musaelian, Lixin Sun, Mario Geiger, Jonathan P Mailoa, Mordechai Kornbluth, Nicola Molinari, Tess E Smidt, and Boris Kozinsky. E (3)-equivariant graph neural networks for data-efficient and accurate interatomic potentials. Nature communications, 13(1):2453, 2022.
[29] Bingqing Cheng. Equivariant learning of a transferable three-dimensional classical density functional. arXiv preprint arXiv:2608.13506, 2026.
[30] Lin Shang-Chun and Martin Oettel. A classical density functional from machine learning and a convolutional neural network. SciPost Physics, 6(2):025, 2019.
[31] Michelle M Kelley, Joshua Quinton, Kamron Fazel, Nima Karimitari, Christopher Sutton, and Ravishankar Sundararaman. Bridging electronic and classical density-functional theory using universal machine-learned functional approximations. The Journal of Chemical Physics, 161(14), 2024.
[32] Felix Glitsch, Jens Weimar, and Martin Oettel. Neural density functional theory in higher dimensions with convolutional layers. Physical Review E, 111(5):055305, 2025.
[33] Sophie Hermann and Matthias Schmidt. Noether's theorem in statistical mechanics. Communications Physics, 4(1):176, 2021.
[34] Frank H Stillinger Jr and Ronald Lovett. General restriction on the distribution of ions in electrolytes. The Journal of Chemical Physics, 49(5):1991–1994, 1968.
[35] Florian Sammüller and Matthias Schmidt. Determining the chemical potential via universal density functional learning. Physical Review Letters, 136(6):068202, 2026.
[36] Mengyi Chen, Peichen Zhong, Zihan Zhang, and Qianxiao Li. Learning ab initio phase-field models. arXiv preprint arXiv:2610.01432, 2026.
[37] Liyao Lyu, Xinyue Yu, and Hayden Schaeffer. Mvnn: A measure-valued neural network for learning mckean-vlasov dynamics from particle data. Journal of Computational Physics, 569:115467, 2027. ISSN 0021-9991.
[38] Kurt Kremer and Gary S. Grest. Dynamics of entangled linear polymer melts: A molecular-dynamics simulation. J. Chem. Phys., 92: 5057–5086, 1990. doi: 10.1063/1.458541.
[39] Roger W Hockney and James W Eastwood. Computer simulation using particles. CRC Press, 2021.
[40] Aidan P Thompson, H Metin Aktulga, Richard Berger, Dan S Bolintineanu, W Michael Brown, Paul S Crozier, Pieter J In't Veld, Axel Kohlmeyer, Stan G Moore, Trung Dac Nguyen, et al. Lammps-a flexible simulation tool for particle-based materials modeling at the atomic, meso, and continuum scales. Computer physics communications, 271:108171, 2022.
[41] Shuichi Nosé. A unified formulation of the constant temperature molecular dynamics methods. The Journal of chemical physics, 81(1): 511–519, 1984.
[42] William G Hoover. Canonical dynamics: Equilibrium phase-space distributions. Physical review A, 31(3):1695, 1985.
[43] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
[44] David S Dean. Langevin equation for the density of a system of interacting langevin processes. Journal of Physics A: Mathematical and General, 29(24):L613–L617, 1996.
[45] Yael Avni, Ram M Adar, David Andelman, and Henri Orland. Conductivity of concentrated electrolytes. Physical Review Letters, 128(9): 098002, 2022.
[46] Liyao Lyu and Huan Lei. On the generalization ability of coarse-grained molecular dynamics models for nonequilibrium processes. Multiscale Modeling & Simulation, 23(2):816–837, 2025.
Supplementary Information
A structure-preserving neural density functional for the ions of a polymer electrolyte
S1. Properties that hold by construction
The ions are described by their number densities , collected in , with valences . Energies are in units of and charges in units of . The free energy of the main text is
with the charge density in units of e, and the neural functional is
with symmetric pair kernels . The radial kernels have the form , where are normalized Gaussians with six widths from to , and is a smooth learned function of . For bounded , the Gaussian envelope ensures that as . The same decay holds for the at-most-linear growth of the softplus networks used here. The kernels and are therefore integrable with finite radial moments. Their Fourier transforms are real, even, smooth functions of , with and .
For numerical evaluation, the radial Fourier integral is truncated at and computed by midpoint quadrature with spacing :
where is evaluated by its limiting value 1 at . In planar geometry, the weighted densities are evaluated as products in Fourier space, .
The pointwise map is a multilayer perceptron with smooth softplus activations and a linear output, so it is twice continuously differentiable and has no explicit dependence on position or direction. As in the main text, denotes all learned parameters: the coefficients and the weights of and . We write for the interaction chemical potential and for the internal force density.
With and evaluated at , and since a radial kernel is its own adjoint under convolution, the first and second derivatives of the many-body term are
At uniform density the Hessian is a constant symmetric matrix, and the bulk kernel of the excess functional is
Proposition 1 (translation and rotation covariance). Let with act on points by and on densities by . For every such transformation compatible with the domain and every density field specified above:
i ,
ii
iii
Proof. The weighted densities are scalar fields: substituting in
where . Since has no explicit dependence on position, the covariance of the weighted densities and the substitution give
Thus the many-body term is invariant. The pair term and are double integrals of radial kernels and are invariant by the same two substitutions. This is (i).
Applying (i) to and using the linearity of gives
Differentiating with respect to at yields
Substituting on the left-hand side and rearranging, we obtain
Since this holds for every perturbation ,
which proves (ii).
By (ii) and the chain rule, . Multiplying by gives (iii).
The proof includes reflections. No equivariant architecture is needed, because the covariance of the force follows from the invariance of one scalar.
Proposition 2 (integrability). For every density field specified above,
so the direct correlation functions satisfy , and in the bulk is real and depends on only.
Proof. Since is twice continuously differentiable,
Using Eq. S3, the symmetry of the many-body Hessian follows explicitly:
where the last equality follows by relabelling .
The pair and Coulomb contributions to the interaction Hessian are also symmetric:
Combining these contributions gives
In a uniform state, , so Eq. S4 gives
The Fourier transforms of the real radial kernels are real and depend only on ; hence the same holds for .
Lemma (Helmholtz condition). A family on a convex set of densities is a functional gradient, , if and only if . In that case, with ,
independent of the path.
Proof. Necessity follows from the symmetry of second derivatives: if , then
For sufficiency, keep fixed and define by Eq. S6, with . Since
functional differentiation gives
By the assumed symmetry,
Moreover, the chain rule along gives
Combining these identities, we obtain
Thus , and its line integral along any smooth path between two densities equals the difference in at the endpoints, establishing path independence.
Eq. S6 is the functional line integration used by neural functionals that learn the one-body direct correlation function directly. Such a network has no reason to satisfy the Helmholtz condition exactly, and the value of Eq. S6 then depends on the path. The scalar form of Eq. 4 satisfies it identically.
Proposition 3 (Noether sum rules). For every density field specified above, in or out of equilibrium:
i
ii on , ,
Proof. We use the Einstein summation convention for Cartesian indices.
(i) For a translation by a,
Differentiating Proposition 1(i) with respect to gives
Since this holds for each Cartesian component,
(ii) On , let be a rotation by angle about the unit vector . Then
Using rotational invariance and , integration by parts gives
Since is arbitrary,
The screening sum rules follow from the bulk linear response of the same functional. For a uniform stationary state with densities , write and . Linearizing the Euler–Lagrange equation and Fourier transforming gives for . Thus the response matrix defined by satisfies
This is the Ornstein–Zernike relation , with . For a stable uniform state, the fluctuation-response relation identifies as the structure factor, . The explicit Coulomb term and the regular small-k behavior of yield the following screening identities.
Proposition 4 (perfect-screening sum rules). Let be the short-range part of in Eq. S7. If is invertible and , then for every learned
where is the charge structure factor, and .
Proof. By the small-k expansions of the radial kernels and Eq. S4,
Since is invertible, remains invertible for sufficiently small k, with
Consequently,
Equation S7 can be written as
Applying the Sherman–Morrison formula gives
The denominator is nonzero for sufficiently small because it tends to .
Contracting with on both sides yields
Since and ,
Expanding the reciprocal therefore gives
Using , we obtain
For any fixed vector , the same inverse formula gives
Finally,
SO
This proves both screening identities.
The leading coefficient is the Stillinger–Lovett second-moment condition [1]. It is fixed by the explicit Coulomb term, while short-range correlations enter at order .
S2. Data, force matching and prediction
S2.1 Model and data
The molecular dynamics model and simulation protocol are described in the main text. The additional interaction parameters are the FENE bond constants and , the Lennard-Jones mixing rule , and a cutoff for monomer pairs. Interactions involving ions are purely repulsive apart from electrostatics and the ion–monomer solvation potential [2, 3],
with , and . Each concentration is equilibrated at zero pressure and sampled at its mean volume. The two dielectric constants use the same interaction parameters apart from electrostatics. Four runs at each training concentration are held out, covering the different potential families, and three further runs are used for validation. Densities and internal force densities are recorded on bins. Profile uncertainties use eight time blocks. Internal-force blocks are formed as before computing their standard error.
S2.2 Force matching
Let denote all particle coordinates and the corresponding configurational measure. The normalized canonical distribution is
and the one-body density is
Using and integrating by parts over , we obtain
The boundary term vanishes for periodic boundaries (with the periodic delta function), or for sufficiently decaying distributions. For ,
Substitution therefore gives
Since the delta function fixes ,
Defining the internal force density by
we recover the local force balance [4, 5],
Taking the gradient of the Euler–Lagrange equation and using Eq. S9 yields , the force-matching relation of the main text.
The six Gaussian envelope widths are 0.250, 0.330, 0.435, 0.574, 0.758 and 1.000. The pointwise network receives , with , and its output contributes to the free energy. Other architecture parameters are given in the main text. The kernel range and activation were selected using only the validation profiles at .
Training uses full batches and the AdamW schedule specified in the main text, with the learning rate decaying to over at most 4000 steps. Validation is evaluated every 20 steps. Early stopping uses a patience of 1000 steps after at least 200 steps, and the best validation parameters are retained. Table S1 compares training with and without the Fourier term, using the same architecture and data splits. The Fourier term modestly improves the long-wavelength amplitudes and leaves the profile errors unchanged; the change in is within the MD uncertainty.
Table S1. Loss ablation with and without the Fourier term weighted by . The amplitude ratio is the predicted over MD amplitude of the mode summed over the six long-wavelength training runs at . At this concentration, MD gives and at and 2, respectively. The last two columns give the amplitude deficit of the driven mode of the cation density in boxes two and four times the training length, where this mode has wavenumber and , respectively (section S4.1). Values before and after the slash correspond to neutral () and mixed neutral/charged (, ) external potentials, respectively.
| Fourier term | Ratio at | Profile (%) | ||||
|---|---|---|---|---|---|---|
| 7.5 | without | 0.95 | 4.56 | 1.45 | 18 / 8 | 13 / 8 |
| 7.5 | with | 0.96 | 4.47 | 1.50 | 16 / 6 | 11 / 6 |
| 2 | without | 0.87 | 3.85 | 3.09 | 11 / 10 | 15 / 17 |
| 2 | with | 0.92 | 3.70 | 3.11 | 7 / 7 | 12 / 14 |
S2.3 Predictions and uncertainty
At fixed particle numbers, the predicted planar profiles satisfy
where is the cross-sectional area. The chemical potentials enforcing particle numbers drop out. We solve for using Anderson acceleration with history eight and mixing parameter 0.1 [6, 7]. The charge residual is preconditioned by [8]. Convergence requires the maximum density change divided by to be below . Profile errors are , averaged over runs.
The bulk kernel follows by automatic differentiation of at uniform density along a one-bin perturbation of species , followed by Fourier transformation. Equation S7 gives . The neural functionals used for the main results have no negative eigenvalues of at the sampled concentrations and wavenumbers of a box eight times longer than the simulation box.
MD structure factors are obtained from zero-field runs. For each frame, we compute the microscopic Fourier densities
For the homogeneous system at nonzero wavevectors, . The number structure factor is therefore
where and the average is over time and wavevector directions with the same magnitude. The charge structure factor is defined in the same way from . The uncertainty of is a standard error from time blocks, corrected for the autocorrelation time. At , and its uncertainty are obtained from nine independent runs at each concentration; at , from a single run.
S3. Predictive accuracy and many-body correlations
S3.1 Predictions across concentrations
Table S2 collects the concentration-resolved force residuals and profile errors at both dielectric constants. The force residual is the first term of the force-matching loss of the main text, averaged over bins, species and runs. With these weights, a model that reproduces the MD forces exactly would give . Table S3 gives the corresponding bulk structure-factor errors and finite-wavenumber number response. The lowest concentration at strong coupling is the least accurate state for the number structure factor. The representative profiles and structure factors are shown in the main text.
Table S2. Predictions by concentration. Force residual and relative profile error in percent (cation / anion), averaged over held-out runs. At all 22 runs are untrained.
| NF | NF profile (%) | Pair | Pair profile (%) | ||
|---|---|---|---|---|---|
| 7.5 | 0.01 | 0.559 | 3.5 / 2.7 | 1.82 | 5.7 / 8.6 |
| 7.5 | 0.02 | 0.574 | 1.8 / 1.4 | 3.25 | 4.9 / 7.4 |
| 7.5 | 0.04 | 0.573 | 1.2 / 0.8 | 2.12 | 2.7 / 3.2 |
| 7.5 | 0.05 | 0.606 | 1.0 / 0.7 | 1.67 | 2.0 / 1.7 |
| 7.5 | 0.06 | 0.615 | 0.9 / 0.6 | 0.82 | 1.5 / 1.0 |
| 7.5 | 0.08 | 0.837 | 1.4 / 0.8 | 2.94 | 5.2 / 1.9 |
| 2 | 0.01 | 0.693 | 9.2 / 8.9 | 6.28 | 14.9 / 15.7 |
| 2 | 0.02 | 0.618 | 2.8 / 2.6 | 20.50 | 14.9 / 15.8 |
| 2 | 0.04 | 2.559 | 1.6 / 2.3 | 20.21 | 6.6 / 7.1 |
| 2 | 0.05 | 0.748 | 1.0 / 0.9 | 5.62 | 2.1 / 3.5 |
| 2 | 0.06 | 0.865 | 1.1 / 0.9 | 2.42 | 1.0 / 2.9 |
| 2 | 0.08 | 1.154 | 1.3 / 0.5 | 19.88 | 3.7 / 5.2 |
Table S3. Bulk predictions at both dielectric constants. Structure-factor errors are relative rms deviations in percent over the MD wavevectors up to , shown as neural functional / pair closure. uses the MD uncertainty procedure of section S2.3.
| error | error | |||||
|---|---|---|---|---|---|---|
| 7.5 | 0.01 | 4.8 / 12.2 | 6.7 / 18.0 | 1.20 ± 0.06 | 1.34 | 1.96 |
| 7.5 | 0.02 | 4.1 / 12.6 | 3.6 / 16.1 | 1.97 ± 0.07 | 2.22 | 2.91 |
| 7.5 | 0.04 | 2.7 / 7.8 | 2.6 / 8.4 | 4.38 ± 0.15 | 4.47 | 4.76 |
| 7.5 | 0.05 | 3.6 / 5.2 | 2.8 / 4.3 | 5.42 ± 0.15 | 5.53 | 5.65 |
| 7.5 | 0.06 | 3.8 / 4.7 | 2.8 / 3.4 | 6.42 ± 0.26 | 6.73 | 6.51 |
| 7.5 | 0.08 | 3.9 / 13.0 | 2.4 / 13.5 | 9.26 ± 0.26 | 9.08 | 8.12 |
| 2 | 0.01 | 9.9 / 22.1 | 25.6 / 52.2 | 0.42 ± 0.07 | 0.31 | 1.84 |
| 2 | 0.02 | 4.5 / 31.6 | 5.3 / 38.3 | 0.98 ± 0.10 | 0.97 | 2.68 |
| 2 | 0.04 | 2.7 / 30.1 | 2.6 / 18.7 | 3.14 ± 0.56 | 3.70 | 4.32 |
| 2 | 0.05 | 3.5 / 23.8 | 2.7 / 8.1 | 4.41 ± 0.49 | 5.14 | 5.12 |
| 2 | 0.06 | 2.7 / 15.3 | 3.1 / 7.7 | 6.09 ± 0.91 | 6.77 | 5.88 |
| 2 | 0.08 | 2.7 / 10.4 | 2.8 / 42.1 | 11.05 ± 0.81 | 10.36 | 7.33 |
A pair closure can reproduce profiles at a single concentration but cannot adjust its bulk kernel with density. At , fitting only gives a held-out residual of 0.70 and cation/anion profile errors of 2.5/1.3%. Its held-out residual rises to 1.30 when and 0.02 are added, to 1.55 after adding , and to 2.19 after adding . This comparison motivates the density-dependent correlations of the neural functional.
S3.2 Number response
For , write the regular part of in the orthonormal number and charge basis, and . In the energy units of section S1,
Inverting Eq. S7 gives
The last term accounts for coupling between number and charge fluctuations. It vanishes as and contributes 1–4% of at in the reported models. Neglecting that correction yields the MD estimate used in the main text,
Multiplying by restores energy units.
S4. Transfer and comparisons with other functionals
S4.1 Larger boxes and nonplanar densities
At and both dielectric constants, we test transfer without retraining using the models trained on planar profiles. The tests include four aperiodic potentials absent from training, applied in a box twice the training length. They combine irregular Gaussian wells and barriers with Fourier modes at and between the training wavenumbers, with amplitudes within the trained range. Two contain no wavelength longer than the training box. The other two add a mode at with a peak-to-peak amplitude of , in the neutral part alone or in the neutral and charged parts. The neural functional reproduces the density profiles with relative errors of without the long mode and with it, compared with for the pair closure.
In a box four times the training length, a single mode at is applied in the neutral part alone or in the neutral and charged parts (Table S4). The amplitude deficit is , where is the amplitude of the driven mode of the cation density and the MD value is the long-time limit of a relaxation fit to its time series.
Table S4. Box four times the training length: relative profile errors and amplitude deficits of the driven mode (both in %), shown as neural functional / pair closure.
| potential | Profile error | Amplitude deficit | |
|---|---|---|---|
| 7.5 | neutral | 0.80 / 1.09 | 11 / 15 |
| 7.5 | neutral and charged | 0.55 / 0.81 | 6 / 11 |
| 2 | neutral | 1.21 / 2.41 | 12 / 23 |
| 2 | neutral and charged | 1.31 / 2.51 | 14 / 25 |
Six potentials varying in and test transfer beyond planar geometry: an egg carton, neutral and charged Gaussian rods on a square lattice, a checkerboard with oblique wavevectors, and two aperiodic potentials. Aperiodic I combines six irregularly placed Gaussian wells and barriers and two oblique plane waves in the neutral part with three charged Gaussian wells. Aperiodic II combines three oblique plane waves and three Gaussian barriers with four irregularly placed charged wells. All amplitudes remain within the trained range. Single bins of the MD maps carry a sampling noise of 5–6%, so Table S5 reports the relative profile error on the Fourier modes that MD resolves, those with amplitudes above three standard errors, together with the MD noise level of the same quantity. On the aperiodic potentials, the neural functional reaches this noise level, with errors of 1.8–3.1% against noise levels of 1.7–3.0%, while the pair closure errs by 3.6–5.5% and Poisson–Boltzmann theory by 31–62%. On the periodic potentials, its errors are 0.6–3.7%, against 2.4–7.6% for the pair closure. The largest error occurs for the charged rods at , 3.7% against 5.0% for the pair closure.
Table S5. Two-dimensional potentials at : relative profile errors (%) of the density maps predicted by the functionals trained on planar profiles. As for the planar profiles, the error is , averaged over cations and anions. It is evaluated on the Fourier modes of the maps that MD resolves, those with amplitudes above three standard errors (their number for both species is given), because single bins of the MD maps carry a sampling noise of 5–6%. The last column gives the MD noise level of the same quantity; an error at this level means agreement within the MD precision.
| potential | resolved modes | neural functional | pair closure | PB | MD noise | |
|---|---|---|---|---|---|---|
| 7.5 | egg carton | 32 | 1.0 | 3.5 | 40 | 1.0 |
| neutral rods | 115 | 2.1 | 3.7 | 68 | 1.3 | |
| charged rods | 102 | 1.3 | 2.4 | 26 | 1.2 | |
| checkerboard | 54 | 1.2 | 2.9 | 42 | 1.1 | |
| aperiodic I | 327 | 3.1 | 3.6 | 61 | 3.0 | |
| aperiodic II | 218 | 3.0 | 4.1 | 33 | 2.6 | |
| 2 | egg carton | 10 | 0.6 | 6.4 | 33 | 0.4 |
| neutral rods | 114 | 2.2 | 5.4 | 70 | 1.1 | |
| charged rods | 96 | 3.7 | 5.0 | 15 | 1.0 | |
| checkerboard | 20 | 1.3 | 7.6 | 34 | 0.6 | |
| aperiodic I | 235 | 2.4 | 4.3 | 62 | 2.3 | |
| aperiodic II | 154 | 1.8 | 5.5 | 31 | 1.7 |
S4.2 Original formulations, adaptations and comparison protocol
Table 1 of the main text refers to the original formulations. The one-body networks of refs. [9, 10] apply a single network to a sliding window of a planar density profile on a fixed grid. They are therefore equivariant under translations by the grid spacing and can be applied to planar domains larger than their training boxes. Ref. [9] includes mirror symmetry only through data augmentation and verifies the thermal Noether sum rules and the symmetry of the pair direct correlation function numerically. Ref. [10] trains separate networks for cations and anions, so their cross derivatives need not coincide, and verifies the contact theorem instead. The convolutional free energy of ref. [11] applies average pooling after each layer to an input of fixed length, which breaks invariance under lattice translations and ties the model to the training box and grid. Ref. [12] builds invariance under the cubic point group into finite-range environments on a fixed voxel grid and demonstrates transfer to larger cells and three-dimensional geometries at unchanged grid spacing. For the present functional, the guarantees hold for the continuous formulation (section S1); their finite-grid residuals are reported in section S4.3, and transfer to larger boxes and nonplanar densities in section S4.1.
Common protocol. Each adapted form replaces only the excess free energy of our functional or, for the one-body network, its excess chemical potentials . Its input is the density profile on the bins of the MD data, continued periodically and divided by ( for the Lennard-Jones fluid). For the ions, the Coulomb mean field is kept analytic, as in our functional, so each network represents only the excess part. All forms are trained with the force-matching loss, optimizer, step budget and model selection of our functional, on the same splits (71 training runs at and 82 at ). The comparison therefore tests the architectures under one training protocol, not the published methods with their own data and training targets.
One-body network. Refs. [9, 10] fit the one-body direct correlation function , obtained from grand-canonical simulations at known chemical potential, with a perceptron that acts on a window of the density profile. In ref. [9], the window spans at a resolution of (513 inputs) and the perceptron has three hidden layers of 512 units with smooth activations. Ref. [10] adds the long-range electrostatics through local molecular field theory. Our adaptation maps the cation and anion densities in a window of around , values, to both excess chemical potentials and with a single perceptron instead of one network per species. The perceptron has two hidden layers of 128 units with SiLU activations (32,514 parameters). The two outputs share hidden features, but and are not constrained to agree. The output enters force matching only through the force density , so canonical data without chemical-potential labels suffice. A window of (47,874 parameters) gives a validation residual 4% and 40% larger at and 2, and about ten times larger for the Lennard-Jones fluid.
Lattice free energy. Ref. [12] writes the excess free energy of a one-component fluid on a cubic grid of spacing and voxel volume as . The features are built from the Cartesian moments A_1(g) = \sum_q \rho_g + q_x q_x^l_x q_y^l_y q_z^l_z with , summed with unit weight over the 122 nonzero integer offsets with . Products of up to two moments, averaged over the 48 elements of , give 15 invariants. Both read-outs have hidden layers of 32 and 16 SiLU units and also take the temperature (1,762 parameters in total). We form the moments separately for cations and anions. The first-order invariants of each species and the second-order invariants within and across species, averaged over and with vanishing and duplicate forms removed, give 47 invariants (15 for one species, as in the original). Both read-outs have one output per species, and , where is the cross-sectional area and the bin width. The voxel density is the average of the profile over the five bins ( ) centred on bin . For a planar density, the lateral sums in the moments reduce to fixed weights, with C_1(q_z) = \sum_{q_x, q_y} q_x^l_x q_y^l_y q_z^l_z over the stencil, which are evaluated exactly; six of the 47 invariants (two of the 15) then vanish identically. Every bin is a voxel centre, so averages the lattice free energy over the registrations of the lattice on the bin grid and is invariant under translations by one bin. Densities are divided by , each invariant by its root-mean-square value over the training profiles, and temperature is not an input. The read-out is widened to two hidden layers of 128 units, the width of our read-out, while keeps 32 and 16 (23,828 parameters). The excess chemical potentials follow by automatic differentiation and are trained by force matching. We keep the stencil radius of the original, . A radius of , with the same invariants and number of parameters, raises the validation residual sevenfold at and 27-fold for the Lennard-Jones fluid. At , it lowers the validation residual by about a quarter and the mean held-out profile error from 7.2% to 5.2%, but the Euler–Lagrange solution fails for 15 instead of 10 of the 42 test runs.
Convolutional free energy. Ref. [11] represents the excess free energy of a one-component fluid on 320 grid points ( ) by six periodic dilated convolutions (kernel size 3, dilation 2, channels 16, 16, 32, 32, 64, 64), each followed by average pooling over two points, and a scalar output. Its stated size of about 24,400 parameters implies a linear read-out of the flattened final feature map, 64 channels at five positions; the activation is not specified. The network is trained by pair-correlation matching: rows of its Hessian are fitted to the laterally integrated direct correlation functions of bulk grand-canonical simulations, together with an offset term for the first derivative. We keep the convolution and pooling stack. The input has two channels, and (one for the Lennard-Jones fluid), padding is periodic and the activations are softplus. Pooling drops an odd last point, so six poolings leave three positions for any grid of 192 to 255 bins, which covers all boxes here (243 to 250 bins for the ions, 240 for the Lennard-Jones fluid). A linear layer maps the final features to (24,321 parameters). The network is trained by force matching on the inhomogeneous profiles instead of by pair-correlation matching on bulk data.
Lennard-Jones fluid. The truncated and shifted fluid has , and . It has a single species and no Coulomb term, so each form takes one density; the forms then have 18,861 (ours), 24,577 (one-body network), 19,426 (lattice free energy) and 24,273 (convolutional free energy) parameters. The planar potentials use the same families as the ion data, 22 per density. One run each at 0.5 and violates the force balance beyond its sampling error and is discarded. At the trained densities 0.1, 0.2, 0.4, 0.6 and , four runs per density are held out and three are used for validation, which leaves 74 training runs; the 21 runs at are never trained. This comparison tests the adapted implementations on a simple fluid, but does not isolate the cause of their different performance on the ions.
S4.3 Data efficiency and structural consistency
Table S6 reports nested, stratified fractions of the ion training data, with validation and test runs fixed. The comparison in the main text uses these same fits.
Table S6. Data efficiency on the ions. Mean relative profile errors (%) of the held-out runs / of the runs at the untrained concentration , for the training fractions shown. Means exclude Euler–Lagrange solutions that do not converge or collapse onto a density spike (error above 50%). The one-body window is and the lattice stencil radius is .
| Training fraction | Neural functional | One-body network | Lattice free energy | |
|---|---|---|---|---|
| 7.5 | 0.25 | 1.55 / 0.92 | 3.00 / 2.18 | 4.53 / 3.98 |
| 7.5 | 0.5 | 1.48 / 0.84 | 2.09 / 1.27 | 3.72 / 3.32 |
| 7.5 | 1 | 1.50 / 0.85 | 1.75 / 1.01 | 2.97 / 2.06 |
| 2 | 0.25 | 3.56 / 1.28 | 5.55 / 1.96 | 6.31 / 5.12 |
| 2 | 0.5 | 3.45 / 1.02 | 4.95 / 1.24 | 6.00 / 2.54 |
| 2 | 1 | 3.11 / 0.98 | 3.41 / 0.85 | 7.16 / 2.72 |
Structural errors in Table S7 are evaluated on the MD profiles. The relative net internal force is , including Coulomb forces. Integrability is tested by for . Reflection error is , with . Path dependence is on closed paths through held-out profiles. The continuum identities of section S1 and their finite-grid residuals are distinct from predictive accuracy.
Grid independence is tested by evaluating each form, with unchanged parameters, on the test profiles resampled by band-limited interpolation from the bins to grids of and . The rms change of relative to its variation over the box, averaged over the 42 test runs of each , is below on the finer and on the coarser grid for the neural functional (maxima and ), and below and for the pair closure. The one-body network changes by and the lattice free energy by , because their window and voxel are fixed numbers of bins; the convolutional free energy cannot be evaluated, because its read-out fixes the number of grid points.
Table S7. Structural errors for the selected implementations. Values are maxima over runs and state points. Parentheses give arithmetic means over runs where available.
| Form | Net force | Jacobian asymmetry | Reflection | Path dependence | |
|---|---|---|---|---|---|
| Neural functional | 7.5 | ||||
| Neural functional | 2 | ||||
| One-body network | 7.5 | 0.14 (0.008) | 0.55 (0.31) | 0.38 | 0.008 |
| One-body network | 2 | 0.08 (0.005) | 0.46 (0.25) | 0.16 | 0.009 |
| Lattice free energy | 7.5 | ||||
| Lattice free energy | 2 |
S4.4 Convolutional free-energy baseline
Table S8 compares the convolutional free energy of section S4.2 with our functional, both trained by force matching on the same data. Its scalar output preserves integrability, but pooling and the read-out break translation and reflection invariance, so its bulk Hessian is not diagonal in and a bulk structure factor is not uniquely defined. The convolutional form has larger force residuals, and few of its Euler–Lagrange solutions converge. Since the original work trains this architecture by pair-correlation matching on bulk data, these results characterize the architecture under force matching, not the published method.
Table S8. Force-matching comparison of the neural and convolutional free energies. Structure-factor errors are the largest relative rms errors across (). Profile errors in parentheses are those of final iterates that mostly did not converge.
| Form | Held-out | Profile (%) | EL converged | error (%) | |
|---|---|---|---|---|---|
| 7.5 | neural functional | 0.63 | 1.50 | 42/42 | 4.1 / 3.6 |
| 7.5 | convolutional | 83.4 | 5/42 | ||
| 2 | neural functional | 1.18 | 3.11 | 42/42 | 4.5 / 5.3 |
| 2 | convolutional | 97.0 | 0/42 |
Convolutional profile errors include Euler–Lagrange iterations that did not converge. EL counts cover all 42 test runs.
Supplementary References
[1] Frank H Stillinger Jr and Ronald Lovett. General restriction on the distribution of ions in electrolytes. The Journal of Chemical Physics, 49(5):1991–1994, 1968.
[2] Alexandros J Tsamopoulos and Zhen-Gang Wang. Ion conductivity in salt-doped polymers: combined effects of temperature and salt concentration. ACS Macro Letters, 13(3):322–327, 2024.
[3] Kuan-Hsuan Shen and Lisa M Hall. Ion conductivity and correlations in model salt-doped polymers: Effects of interaction strength and concentration. Macromolecules, 53(10):3655–3668, 2020.
[4] Salomé M Tschopp, Florian Sammüller, Sophie Hermann, Matthias Schmidt, and Joseph M Brader. Force density functional theory in-and out-of-equilibrium. Physical Review E, 106(1):014115, 2022.
[5] Jean-Pierre Hansen and Ian R McDonald. Theory of simple liquids: with applications to soft matter. Elsevier, 2013.
[6] Donald G Anderson. Iterative procedures for nonlinear integral equations. Journal of the ACM (JACM), 12(4):547–560, 1965.
[7] Homer F Walker and Peng Ni. Anderson acceleration for fixed-point iterations. SIAM Journal on Numerical Analysis, 49(4):1715–1735, 2011.
[8] GP Kerker. Efficient iteration scheme for self-consistent pseudopotential calculations. Physical Review B, 23(6):3082, 1981.
[9] Florian Sammüller, Sophie Hermann, Daniel de Las Heras, and Matthias Schmidt. Neural functional theory for inhomogeneous fluids: Fundamentals and applications. Proceedings of the National Academy of Sciences, 120(50):e2312484120, 2023.
[10] Anna T Bui and Stephen J Cox. Learning classical density functionals for ionic fluids. Physical Review Letters, 134(14):148001, 2025.
[11] Jacobus Dijkman, Marjolein Dijkstra, René Van Roij, Max Welling, Jan-Willem van de Meent, and Bernd Ensing. Learning neural free-energy functionals with pair-correlation matching. Physical Review Letters, 134(5):056103, 2025.
[12] Bingqing Cheng. Equivariant learning of a transferable three-dimensional classical density functional. arXiv preprint arXiv:2608.13506, 2026.