본문 펼치기
Learning classical density functionals for ionic fluids
Anna T. Bui <sup>1</sup> and Stephen J. Cox <sup>2, ∗</sup>
1 _Yusuf_ _Hamied_ _Department_ _of_ _Chemistry,_ _University_ _of_ _Cambridge,_
_Lensfield_ _Road,_ _Cambridge,_ _CB2_ _1EW,_ _United_ _Kingdom_
2 _Department_ _of_ _Chemistry,_ _Durham_ _University,_ _South_ _Road,_ _Durham,_ _DH1_ _3LE,_ _United_ _Kingdom_
(Dated: April 8, 2025)
Accurate and efficient theoretical techniques for describing ionic fluids are highly desirable for many
applications across the physical, biological and materials sciences. With a rigorous statistical mechanical
foundation, classical density functional theory (cDFT) is an appealing approach, but the competition
between strong Coulombic interactions and steric repulsion limits the accuracy of current approximate
functionals. Here, we extend a recently presented machine learning (ML) approach [Samm¨uller _et_ _al._,
Proc. Natl. Acad. Sci. USA, 120, e2312484120 (2023)] designed for systems with short-ranged
interactions to ionic fluids. By adopting ideas from local molecular field theory, the framework we
present amounts to using neural networks to learn the local relationship between the one-body direct
correlation functions and inhomogeneous density profiles for a “mimic” short-ranged system, with effects
of long-ranged interactions accounted for in a mean-field, yet well-controlled, manner. By comparing
to results from molecular simulations, we show that our approach accurately describes the structure
and thermodynamics of prototypical models for electrolyte solutions and ionic liquids, including sizeasymmetric and multivalent systems. The framework we present acts as an important step toward
extending ML approaches for cDFT to systems with accurate interatomic potentials.
The behavior of ionic fluids underlies a vast array of physical and biological phenomena as well as technological applications, ranging from electrolyte solutions controlling protein folding [1] to room-temperature ionic liquids in energy
storage devices [2]. A fundamental topic that continues
to attract enormous interest both experimentally [3–7] and
theoretically [8–13] is the structure and thermodynamics of
ions near charged interfaces, in particular, how the nature of
both the electrolyte and solid surface impacts the properties
of the electric double layer (EDL). Poisson–Boltzmann (PB)
theory and its linearized Debye-H¨uckel form provide the basis for much of our understanding of ionic fluids. Their
neglect of correlations arising from non-electrostatic interactions, however, restricts their validity to fluids of low ionic
strength.
Classical density functional theory (cDFT) [14–17] provides a natural framework for including correlations omitted
by PB theory, and has proven to be a powerful approach to
describe equilibrium structure and thermodynamics of fluids
in general. While in principle an exact theory, historically,
cDFT relies on making approximations for the excess intrinsic free energy functional Fintr <sup>(ex)[{</sup> <sup>_ȷ_</sup> <sup>}],</sup> <sup>where</sup> <sup>_ȷ_</sup> <sup>denotes</sup>
the one-body density of species __ . For hard sphere fluids, functionals based on Rosenfeld’s fundamental measure
theory (FMT) [18–21] have proven highly successful. For
simple liquids with square-well, Yukawa, or Lennard–Jones
interaction potentials, hard sphere mixtures act as suitable
reference systems, with effects of attractive interactions described reasonably well in a mean-field fashion [22–24]. In
contrast, existing functionals for ionic fluids are far less accurate, failing to adequately capture the interplay between
Coulombic and steric interactions [25–28]. In this Letter,
we present a strategy that utilizes machine learning (ML)
to construct accurate free energy functionals for ionic fluids.
The rapid advance of modern ML approaches means there
has been much recent interest in “learning” representations
Here we build on the
of the _exact_ Fintr <sup>(ex)[{</sup> <sup>_ȷ_</sup> <sup>}]</sup> <sup>[29–35].</sup>
method proposed by Samm¨uller _et_ _al._ [36], in which the
one-body direct correlation functions,
We initially focus our efforts on the prototypical model of
__ <sup>(1)(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}]) = −</sup> <sup>_<u>˛‹</u>_</sup> <sup><u>F</u></sup> _‹ȷ_ <u>intr</u> <sup>(ex)</sup> __
_c_ <sup>(1)</sup>
_‹ȷ_ <u>intr</u> <sup>(ex)</sup> __ ( <sup><u>[</u></sup> _r_ <sup><u>{</u></sup> ) <sup>_<u>ȷ</u>_</sup> <sup><u>}]</u></sup> _;_ (1)
are learned by generating inhomogeneous density profiles in
the presence of various external- and chemical potentials by
grand canonical (GC) simulations. This approach to cDFT,
dubbed “neural functional theory,” has been shown to outperform FMT-based approaches for both hard sphere fluids
and Lennard–Jones liquids in terms of both accuracy and
speed [36, 37].
Two key features underpin the success of the neural functional approach: (i) correlations in the fluid are short-ranged
(SR), such that the functional relationship between _c_ <sup>(1)</sup> and
(SR), such that the functional relationship between _c_ <sup>(1)</sup> and
{ _ȷ_ } is local; and (ii) the feasibility of GC simulations to
produce inhomogeneous density profiles of sufficient quality to form a reliable training set. Ionic fluids pose challenges on both fronts. First, the long-ranged (LR) nature
of the Coulomb potential leads to a nonlocal relationship
between _c_ <sup>(1)</sup>
and { _ȷ_ }. Second, GC simulations for ionic
between _c_ <sup>(1)</sup>
and { _ȷ_ }. Second, GC simulations for ionic
systems raise delicate questions concerning electroneutrality, with various schemes proposed that either insert individual ions or neutral pairs [38–42]. Even then, simulations
corresponding exactly to the GC ensemble where the number of each species can fluctuate are impractical, owing to
poor acceptance rates of trial insertion and deletion moves.
We circumvent both of these issues by adopting concepts
from local molecular field theory (LMFT) [43–47], which
has been shown to have close links to cDFT [48].
(a) (b) (c)
iv
iii
i
ii
Figure 1: Structure of the SR mimic RPM. (a) Training data for the neural functional are obtained from GCMC simulations with
(i) insertion/deletion, (ii) position swapping, (iii) displacement and (iv) mutation (identity exchange) moves. (b) The static structure
factors from cDFT agree well with results from molecular simulation across the whole range of _k_ for the SR system, shown for a
bulk system with _ff_ <sup>3</sup> _ȷ_ R _;_ ± = 0 _:_ 315. Inset: At low _k_, the SR system violates the perfect screening condition, whereas the LR system
obeys the Stillinger–Lovett sum rule (see Eq. 5). (c) For the applied external potentials (top), predictions of the ion density profiles
(bottom) are in excellent agreement with the simulation data.
an ionic fluid: the restricted primitive model (RPM) comprising oppositely charged hard spheres of equal diameter
_ff_, embedded in a uniform dielectric continuum. Later, we
will also present results for a primitive model (i.e., sizeasymmetric) and a multivalent system. The scheme we propose can be briefly summarized. First, by employing neural
networks, we find the one-body direct correlation functions
for a suitably chosen “mimic system” whose electrostatic
interactions are entirely short-ranged. Then, by leveraging
LMFT and its relation to cDFT, we account for the net
averaged effects of LR electrostatic interactions in a wellcontrolled fashion. When compared to molecular simulations, the framework we outline describes inhomogeneous
density profiles, the equation of state, and the properties
of the electric double layer in the presense of electric fields
with very high accuracy.
_cDFT_ _of_ _a_ _short-ranged_ _“mimic”_ _ionic_ _fluid._ Our
overall strategy follows that of LMFT, in which we consider
a suitably chosen mimic system whose interatomic interactions are entirely short-ranged, and, when subject to a suitably chosen one-body potential _ffi_ R, has the same one-body
densities as the system of interest with LR interactions (the
“full” system). For systems such as the RPM, where LR
interactions arise from the Coulomb potential, one adopts
the exact splitting
1 _=r_ = _v_ 0( _r_ ) + _v_ 1( _r_ ) _;_ (2)
with _v_ 0( _r_ ) = erfc( _»r_ ) _=r_ and _v_ 1( _r_ ) = erf( _»r_ ) _=r_ . The interatomic potential of the mimic system is then _v_ 0, and
the length scale _»_ <sup>−1</sup> is chosen such that the mimic system
accurately describes the SR correlations of the full system.
In the following, we will work with _»_ <sup>−1</sup> = 1 _:_ 8 _ff_ (see the
SM [49]). We will also indicate quantities pertaining to the
mimic system with a subscript “R” and focus on behaviors
at a reduced temperature _T_ <sup>∗</sup> = 0 _:_ 066, corresponding to supercritical conditions [50]. The one-body direct correlation
functions of the mimic system can be exactly written as
where Λ __, _—_ R _;_ and _q_ indicate the thermal de Broglie wavelength, chemical potential and point charge of species __,
respectively, _V_ R _;_ encompasses any non-electrostatic contributions to the external potential for species __ and, for now,
_ffi_ R is a general external electrostatic potential; we will later
discuss how _ffi_ R can be chosen such that _ȷ_ R _;_ ( _r_ ) = _ȷ_ ( _r_ ).
To learn the functional relationship for _c_ R <sup>(1)</sup> _;_ <sup>(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>}]),</sup>
we obtain data for the right hand side of Eq. 3 by measuring _ȷ_ R _;_ from simulations with known _˛V_ R _;_, _˛ffi_ R and
_˛—_ R _;_ . To this end, in line with Ref. 36, we perform GC
simulations in a planar geometry at different combinations
of { _˛V_ R _;_ }, _˛ffiR_ and { _˛—_ R _;_ }. Note that GC simulations
are essential for the purpose of evaluating Eq. 3 and, on
their own, canonical methods such as molecular dynamics
(MD) simulations are insufficient. The form of _v_ 0 means
that each particle of the mimic system can be considered
electroneutral, comprising both a point charge and a compensating Gaussian charge distribution [51]. As such, in
addition to translational moves, we can readily perform GC
particle insertions/deletions, along with semi-GC swapping
of “anions” and “cations” without needing to worry about
issues of electroneutrality [see Fig. 1(a)]. We have found
this highly beneficial to converging our simulations, full details of which are provided in the SM [49]. In total, ∼ 2500
simulations have been performed to gather training data.
For each species, __ = + or −, the neural network used
R _;_ <sup>(</sup> <sup>_z_</sup> <sup>)</sup> <sup>is</sup> <sup>struc-</sup>
to represent the relationship { _ȷ_ R _;_ ( _z_ )} → _c_ <sup>(1)</sup>
_c_ R <sup>(1)</sup> _;_
<sup>3</sup> __ <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>(</sup> <sup>_r_</sup> <sup>)+</sup> <sup>_˛V_</sup> <sup>R</sup> <sup>_;_</sup> <sup>(</sup> <sup>_r_</sup> <sup>)+</sup> <sup>_˛qffi_</sup> <sup>R(</sup> <sup>_r_</sup> <sup>)−</sup> <sup>_˛—_</sup> <sup>R</sup> <sup>_;;_</sup> <sup>(3)</sup>
R <sup>(1)</sup> _;_ <sup>(</sup> <sup>_r_</sup> <sup>) = ln Λ3</sup> __
tured as follows. The input layer has two channels that
are supplied with the discretized values of the cation and
anion density profiles in a window ∆ _z_ = 3 _:_ 6 _ff_ around the
particular value of _z_ . Following a fully-connected multilayer perceptron of three layers, the output layer consists
of a single node, which yields the predicted value of _c_ R <sup>(1)</sup> _;_
at position _z_ . For each ionic fluid considered, we train two
independent networks, one for the cation and one for the
anion. To reduce noise in the bulk structure predictions, we
also obtained models regularized with bulk two-body direct
correlation functions as proposed in Ref. 52. Details of our
training procedure are provided in the SM [49], and all data
are openly available [53].
We first assess the bulk structure predicted by the functional. On the basis of the neural network, we make use
of automatic differentiation and radial projection to obtain
the partial two-body direct correlation functions _c–_ <sup>(2)(</sup> <sup>_r_</sup> <sup>) (see</sup>
tem can be obtained by self-consistently solving the Euler–
Lagrange equation
+ _˛—_ R _;_ + _c_ R <sup>(1)</sup> _;_
R <sup>(1)</sup> _;_ <sup>(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>}])</sup>
_;_
Λ <sup>3</sup> __ <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>(</sup> <sup>_r_</sup> <sup>) = exp</sup>
“
- _˛V_ R _;_ ( _r_ ) − _˛qffiR_ ( _r_ )
_;_
(6)”
(6)
the partial two-body direct correlation functions _c–_ <sup>(2)(</sup> <sup>_r_</sup> <sup>) (see</sup>
Ref. [36] and the SM [49]). By solving the general Ornstein–
Zernike equation for mixtures [54, 55], we then obtain the
total correlation functions _h–_ <sup>(2)(</sup> <sup>_r_</sup> <sup>)</sup> <sup>and</sup> <sup>the</sup> <sup>corresponding</sup>
total correlation functions _h–_ <sup>(2)(</sup> <sup>_r_</sup> <sup>)</sup> <sup>and</sup> <sup>the</sup> <sup>corresponding</sup>
structure factors _S–_ ( _k_ ). We further quantify the degree of
coupling between number–number ( _SNN_ ), number–charge
( _SNZ_ ) and charge–charge ( _SZZ_ ) densities by appropriate
weighted summations
_SNN_ ( _k_ ) = _S_ ++( _k_ ) + 2 _S_ +−( _k_ ) + _S_ −−( _k_ ) _;_
(4)
_SNZ_ ( _k_ ) = _S_ ++( _k_ ) − _S_ −−( _k_ ) _;_
where _c_ R <sup>(1)</sup> _;_ <sup>is</sup> <sup>evaluated</sup> <sup>by</sup> <sup>the</sup> <sup>corresponding</sup> <sup>neural</sup> <sup>net-</sup>
work. As shown in Fig. 1(c) for a representative set of
external potentials, the resulting { _ȷ_ R _;_ ( _z_ )} from cDFT are
in excellent agreement with reference simulation data of the
mimic system.
_Accounting_ _for_ _long-ranged_ _electrostatics_ _with_
_LMFT._ Having established that the cDFT obtained from
the ML procedure is accurate for a SR variant of the RPM,
we turn our attention to incorporating the effects of LR
electrostatic interactions. To do so, we will use concepts
from LMFT. The premise of LMFT is that there exists a
potential _ffi_ R such that
_ȷ_ ( _r_ ; [ _ffi_ ] _;_ { _—_ }) = _ȷ_ R _;_ ( _r_ ; [ _ffi_ R] _;_ { _—_ R _;_ }) _:_ (7)
In Eq. 7, we have explicitly indicated the functional dependence of the densities on the external electrostatic potential
[60]. As shown in Ref. 48, when recast in a cDFT framework, LMFT relates the one-body direct correlation functions of the full and mimic systems through
_SZZ_ ( _k_ ) = _S_ ++( _k_ ) − 2 _S_ +−( _k_ ) + _S_ −−( _k_ ) _:_
_c_ <sup>(1)</sup>
R <sup>(1)</sup> _;_ <sup>(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}]) −</sup> <sup>_˛_</sup> <sup>∆</sup> <sup>_—_</sup> <sup>+</sup> <sup>_˛q_</sup> <sup>∆</sup> <sup>_ffi_</sup> <sup>(</sup> <sup>_r_</sup> <sup>)</sup> <sup>_;_</sup> <sup>(8)</sup>
Fig. 1(b) shows that the static structure factors obtained
from the functional are in excellent agreement with results
from a molecular dynamics simulation of the mimic system at the same bulk densities [56]. The symmetry of the
RPM is well-captured, reflected in _SNZ_ ( _k_ ) = 0. Moreover,
by comparing to results from a MD simulation of the full
system, we see that _SNN_ ( _k_ ) and _SZZ_ ( _k_ ) for the full and
mimic systems agree very well at sufficiently large _k_, confirming that our choice of _»_ <sup>−1</sup> = 1 _:_ 8 _ff_ is sufficient for the
mimic system to capture the SR correlations of the full system. Deviations of the SR system from the LR system only
manifest significantly in _SZZ_ ( _k_ ) at small _k_, in agreement
with previous works on the subject [46, 57]. In particular,
as shown in the inset, we see that _SZZ_ ( _k_ ) for the LR system
strictly obeys the Stillinger–Lovett sum rule [58, 59]
_c_ <sup>(1)(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}]) =</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_
which is an exact result. A key insight from LMFT [43, 44] is
that for an appropriate splitting of the potential (see Eq. 2),
∆ _ffi_ is well-approximated by a mean field form
∆ _ffi_ ( _r_ ) ≡ _ffi_ ( _r_ ) − _ffi_ R( _r_ ) = − <sup><u>1</u></sup> _›_
Z
d _r_ <sup>′</sup> _n_ ( _r_ <sup>′</sup> ) _v_ 1(| _r_ - _r_ <sup>′</sup> |) _;_ (9)
where _›_ is the dielectric constant of the continuum and
__ <sup>_qȷ_</sup> <sup>is</sup> <sup>the</sup> <sup>charge</sup> <sup>density.</sup> <sup>For</sup> <sup>homogeneous</sup>
systems, Rodgers and Weeks have also derived a thermodynamic correction for the total energy, from which a correc
_n_ = _n_ R = <sup>P</sup>
tion for the pressure follows [61],
_<u>kBT</u>_
∆ _P_ ≡ _P_ - _PR_ = − 2 _ı_ <sup>3</sup> <sup>_=_</sup> <sup>2</sup> _»_ <sup>−3</sup> <sup>_:_</sup> (10)
Based on Ref. 61, we have further derived a correction for
the chemical potential (see the SM [49]),
∆ _—_ ≡ _—_ - _—_ R _;_ = − _»_ <sup>−</sup> _<u>q</u>_ <sup>1</sup> _<u></u>_ <sup>2</sup> <sup>~~√~~</sup> _<u>ı</u>_ <sup>_:_</sup> (11)
We first consider the bulk thermodynamics of the RPM.
The equation of state for the LR system is obtained with
lim
_k_ →0
_<u>kk</u>_ <u>D</u> <sup>22</sup> <sup>_SZZ_</sup> <sup>(</sup> <sup>_k_</sup> <sup>) = 1</sup> <sup>_;_</sup> (5)
where _k_ D <sup>−1</sup>
where _k_ D <sup>−1</sup> is the Debye screening length. In contrast, for
the mimic system we observe _SZZ_ ( _k_ ) _>_ _k_ <sup>2</sup> _=k_ D <sup>2</sup> <sup>as</sup> <sup>_k_</sup> <sup>→</sup>
the mimic system we observe _SZZ_ ( _k_ ) _>_ _k_ <sup>2</sup> _=k_ D <sup>2</sup> <sup>as</sup> <sup>_k_</sup> <sup>→</sup>
0, indicative of a lack of screening. Consistent with the
dielectric response of a short-ranged water model [57], these
deviations appear at length scales far larger than the range
separation prescribed by 2 _ı»_ = 3 _:_ 5 _ff_ <sup>−1</sup> .
Turning to the ability of cDFT to predict inhomogeneous
structure, the equilibrium density profiles of the mimic sys
1 − _c_ R <sup>(1)</sup> _;_ <sup>[{</sup> <sup>_ȷ_</sup> <sup>}]</sup>
”
(12)
_P_ ({ _ȷ_ }) =
__
X
_k_ B _Tȷ_
“
- <sup><u>F</u></sup> <u>intr</u> <sup>(ex)</sup> _<u>;</u>_
<u>intr</u> <sup>(ex)</sup> _<u>;</u>_ <u>R</u> <sup>[{</sup> <sup>_ȷ_</sup> <sup><u>}]</u></sup>
<sup>[{</sup> <sup>_ȷ_</sup> <sup><u>}]</u></sup> +∆ _P;_
_V_
(a) (b) (c)
Figure 2: Structure and thermodynamics of the LR full system. cDFT for the RPM at _T_ <sup>∗</sup> = 0 _:_ 066 with effects of LR electrostatic
interactions accounted by LMFT shows excellent agreement with reference molecular simulation data for (a) the equation of state, (b)
ion density profiles confined in a slit and (c) with an applied external potential. In (a), we see that our cDFT approach outperforms
the prediction obtained by combining the Carnahan–Starling equation of state for hard-sphere fluids ( _P_ <sup>CS</sup> ) and the mean spherical
approximation ( _P_ <sup>MSA</sup> ). For the LR system in (c), the applied external potential acts over a much longer range and the chemical
potentials are shifted lower compared to the SR mimic system in Fig. 1(c) to yield _ȷ_ ( _z_ ) = _ȷ_ R _;_ ( _z_ ).
where the sum of the first two terms is the negative of
the grand potential density of the mimic system. The ex
intr _;_ R <sup>is</sup> <sup>accessible</sup> <sup>by</sup> <sup>functional</sup> <sup>line</sup> <sup>inte-</sup>
cess free energy F <sup>(ex)</sup>
gration. The result of this procedure, shown in Fig. 2(a),
agrees very well with reference simulation data. We also
see that, particularly at higher densities, Eq. 12 performs
significantly better than the analytical approximation that
results from adding the Carnahan–Starling equation of state
( _P_ <sup>CS</sup> ) [62] and the mean spherical approximation ( _P_ <sup>MSA</sup> )
[63, 64], despite the fact that _P_ <sup>CS</sup> + _P_ <sup>MSA</sup> forms the basis
for the vast majority of current state-of-the-art functionals
for ionic fluids [27, 28].
The advantages of cDFT combined with LMFT become
even clearer when inhomogeneous systems are considered.
The equilibrium densities of the full system are given by
+ _˛—_ + _c_ <sup>(1)</sup>
__ <sup>(1)(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}])</sup>
_;_
Λ <sup>3</sup> __ <sup>_ȷ_</sup> <sup>(</sup> <sup>_r_</sup> <sup>) = exp</sup>
Λ <sup>3</sup> __
“
- _˛V_ ( _r_ ) − _˛qffi_ ( _r_ )
results from our cDFT approach for the RPM confined between two repulsive walls for various values of _—_ + = _—_ −.
The density profiles are in very good agreement with reference canonical MD simulation data in which the number of
particles matches that obtained by integrating the density
profiles from cDFT. Our cDFT approach also works very
well in cases where the external potential contains an electrostatic component, as illustrated in Fig. 2(c). Here, the
full system is the LR counterpart of the mimic system shown
in Fig. 1(c), emphasizing the premise of LMFT (see Eq. 7).
_The_ _electric_ _double_ _layer_ _and_ _other_ _ionic_ _fluids._ The
results presented so far demonstrate that our cDFT approach provides an efficient and accurate route to the structure and thermodynamics of the RPM. As an application,
we turn our attention to the fundamental topic of ongoing
scientific interest: the electric double layer. We also show
that our approach is robust to choice of interatomic potential. Specifically, we also consider the primitive model (PM)
and a multivalent fluid.
As a simple model of an EDL-forming system, we consider the RPM confined between two repulsive walls, and
in the presence of an electric field _Ez_ along the _z_ direction. The electrostatic potential that the LR system feels
is _ffi_ ( _z_ ) = − _Ez_ _z_ . For the reference simulation data, the LR
system was simulated at constant _Ez_ using the finite-field
approach [65–71]. As shown in Fig. 3(a), the ion distributions from our cDFT approach are in excellent agreement
with the results from simulation. Notably, the cDFT accurately describes the strong oscillations in the density profiles
of co- and counter-ions. Moreover, as we detail in the SM
[49], our functional is thermodynamically consistent, satis
_;_
”
(13)
where the non-local functional _c_ <sup>(1)</sup>
where the non-local functional _c_ <sup>(1)</sup> is now given by Eq. 8, to
gether with Eq. 9 and Eq. 11. From a cDFT perspective, we
have captured all strong rapidly-varying short-ranged correlations with the neural networks for _c_ R <sup>(1)</sup> _;_ <sup>,</sup> <sup>while</sup> <sup>the</sup> <sup>effects</sup>
lations with the neural networks for _c_ R <sup>(1)</sup> _;_ <sup>,</sup> <sup>while</sup> <sup>the</sup> <sup>effects</sup>
of LR electrostatic interactions are incorporated in a meanfield, yet well-controlled fashion.
In practical terms, for a planar geometry, Eq. 9 can be
recast as
_;_ (14)
«
∆ _ffi_ ( _z_ ) = − _›L_ <sup><u>1</u></sup>
X _k_ ̸=0
<u>4</u> _<u>ı</u>_
_k_ <sup>2</sup> <sup>_n_</sup> <sup>˜(</sup> <sup>_k_</sup> <sup>) exp(</sup> <sup>_ikz_</sup> <sup>) exp</sup>
„
- 4 <sup>_<u>k</u>_</sup> _»_ <sup>22</sup>
where _n_ ˜ denotes a Fourier component of _n_, and _L_ is the
total length of the periodic cell. In Fig. 2(b), we show the
(a)
(b)
(c)
~~2~~
2
~~2~~
<u>2</u>
2
~~2~~
2
2
2
Figure 3: Accurately describing the EDL with cDFT for (a)
the RPM, (b) the PM, and (c) a multivalent fluid. In all
cases, confining walls located at _z=ff_ = ±7 _:_ 2 in a periodic cell
of _L=ff_ = 18 _:_ 1, and _Ez_ = 1 _:_ 7 _k_ B _T=eff_ . The resulting ion density
profiles from cDFT are in excellent agreement with molecular
simulations, and obey the contact theorem (Eq. 15).
fying the contact density theorem [72–74]
<u>s</u> _;_ (15)
<sup>_<u>ıf</u>_</sup> _›_ <sup>_f_</sup> <sup>2</sup>
and (c), we present results for a PM and multivalent system. For the PM, we have changed the sizes of the anion
and cation to _ff_ - = 4 _ff=_ 3 and _ff_ + = 2 _ff=_ 3, respectively. For
the multivalent system, we consider equal-sized anions and
cations of diameter _ff_, but increase the valency of the anion
such that _q_ - _=q_ + = 2. We use the same temperature as for
the RPM, _T_ <sup>∗</sup> = _›ffk_ B _T=_ | _q_ + _q_ −| = 0 _:_ 066. In both cases, we
observe excellent agreement between the neural cDFT and
simulations, both for inhomogeneous profiles and bulk equations of state, as further shown in the SM [49]). Future work
will pursue using neural functionals to understand EDL capacitance [83] and surface force balance measurements [13],
and to augment other cDFT approaches to understand solvation [84]. The framework we have outlined should also
find use in describing the dielectric response of polar fluids
such as water [57, 85, 86].
_Data availability._ Training data and code supporting the
findings of this study will be openly available [53, 103].
_Acknowledgements._ Via membership of the UK’s
HEC Materials Chemistry Consortium funded by EPSRC
(EP/X035859), this work used the ARCHER2 UK National Supercomputing Service. A.T.B. acknowledges funding from the Oppenheimer Fund and Peterhouse College,
University of Cambridge. S.J.C. is a Royal Society University Research Fellow (Grant No. URF\R1\211144) at
Durham University.
∗ stephen.j.cox@durham.ac.uk
[1] W. Kunz, J. Henle, and B. W. Ninham, ‘Zur Lehre von
der Wirkung der Salze’ (about the science of the effect of
salts): Franz Hofmeister’s historical papers, Curr. Opin.
Colloid Interface Sci 9, 19 (2004).
[2] S. Kondrat, G. Feng, F. Bresme, M. Urbakh, and A. A.
Kornyshev, Theory and simulations of ionic liquids in
nanoconfinement, Chem. Rev 123, 6668 (2023).
[3] R. M. Espinosa-Marzal, A. Arcifa, A. Rossi, and N. D.
Spencer, Microslips to “avalanches” in confined, molecular
layers of ionic liquids, J. Phys. Chem. Lett 5, 179 (2014).
[4] M. A. Gebbie, H. A. Dobbs, M. Valtiner, and J. N. Is
raelachvili, Long-range electrostatic screening in ionic liquids, Proc. Natl. Acad. Sci. U.S.A 112, 7432 (2015).
[5] A. M. Smith, A. A. Lee, and S. Perkin, The electrostatic
screening length in concentrated electrolytes increases with
concentration, J. Phys. Chem. Lett 7, 2157 (2016).
[6] A. A. Lee, C. S. Perez-Martinez, A. M. Smith, and
S. Perkin, Underscreening in concentrated electrolytes,
Faraday Discuss 199, 239 (2017).
[7] M. A. Gebbie, A. M. Smith, H. A. Dobbs, A. A. Lee, G. G.
Warr, X. Banquy, M. Valtiner, M. W. Rutland, J. N. Israelachvili, S. Perkin, and R. Atkin, Long range electrostatic forces in ionic liquids, Chem. Commun 53, 1214
(2017).
[8] G. M. Torrie and J. P. Valleau, Electrical double layers.
I. Monte Carlo study of a uniformly charged surface, J.
Chem. Phys 73, 5807 (1980).
[9] C. Merlet, D. T. Limmer, M. Salanne, R. van Roij, P. A.
Madden, D. Chandler, and B. Rotenberg, The electric dou
_P_ = −
__ Z
X
d _z ȷ_ ( _z_ ) <sup><u>d</u></sup> <sup>_<u>V</u>_</sup> <sup><u>(</u></sup> <sup>_<u>z</u>_</sup> <sup><u>)</u></sup>
<u>s</u>
<sup>_<u></u>_</sup> <sup><u>(</u></sup> <sup>_<u>z</u>_</sup> <sup><u>)</u></sup>
d _z_ - <sup><u>2</u></sup> <sup>_<u>ıf</u>_</sup> _›_ <sup>_f_</sup> <sup>2</sup>
which relates the bulk pressure to the surface charge density
_ff_ s = - _L_ <sup>d</sup> <sup>_z n_</sup> <sup>(</sup> <sup>_z_</sup> <sup>)</sup> <sup>[75]</sup> <sup>and</sup> <sup>ion</sup> <sup>densities</sup> <sup>at</sup> <sup>contact</sup> <sup>with</sup> <sup>the</sup>
R 0
R 0
_ff_ s = - _L_ <sup>d</sup> <sup>_z n_</sup> <sup>(</sup> <sup>_z_</sup> <sup>)</sup> <sup>[75]</sup> <sup>and</sup> <sup>ion</sup> <sup>densities</sup> <sup>at</sup> <sup>contact</sup> <sup>with</sup> <sup>the</sup>
walls. Obeying this contact theorem has proven a challenge
R 0
not only for integral equation methods [76–79], which tend
to violate key sum rules and are therefore generally thermodynamically inconsistent [48, 80], but also for most stateof-the-art cDFT functionals for ionic fluids [81, 82]. The
accurate description of EDL structure and thermodynamic
consistency displayed by our LMFT-based neural cDFT approach constitutes a significant advancement in the theoretical description of ionic fluids.
The main advantage of the neural functional approach
outlined in Ref. 36 is arguably that the local relationship
between _c_ <sup>(1)</sup>
and { _ȷ_ } permits application of the resulting
between _c_ <sup>(1)</sup>
and { _ȷ_ } permits application of the resulting
functional to system sizes far beyond those encountered during training of the ML. By using the framework of LMFT
and its relationship to cDFT, we have successfully extended
the neural functional approach to a case where the relationship between _c_ <sup>(1)</sup>
and { _ȷ_ } is nonlocal. To demonstrate that
ship between _c_ <sup>(1)</sup>
and { _ȷ_ } is nonlocal. To demonstrate that
this methodology is not limited to the RPM, in Figs. 3(b)
ble layer has a life of its own, J. Phys. Chem. C 118, 18291
(2014).
[10] M. Z. Bazant, B. D. Storey, and A. A. Kornyshev, Double
layer in ionic liquids: Overscreening versus crowding, Phys.
Rev. Lett. 106, 046102 (2011).
[11] F. Coupette, A. A. Lee, and A. H¨artel, Screening lengths
in ionic fluids, Phys. Rev. Lett. 121, 075501 (2018).
[12] J. P. de Souza, Z. A. H. Goodwin, M. McEldrew, A. A.
Kornyshev, and M. Z. Bazant, Interfacial layering in the
electric double layer of ionic liquids, Phys. Rev. Lett. 125,
116001 (2020).
[13] P. Cats, R. Evans, A. H¨artel, and R. van Roij, Primitive
model electrolytes in the near and far field: Decay lengths
from DFT and simulations, J. Chem. Phys 154, 124504
(2021).
[14] R. Evans, The nature of the liquid-vapour interface and
other topics in the statistical mechanics of non-uniform,
classical fluids, Adv. Phys 28, 143 (1979).
[15] R. Evans, _Fundamentals_ _of_ _inhomogeneous_ _fluids_, edited
by D. Henderson (Dekker, New York, 1992).
[16] J. F. Lutsko, _Recent_ _Developments_ _in_ _Classical_ _Density_
_Functional Theory_, Adv. Chem. Phys. (John Wiley & Sons,
2010) pp. 1–92.
[17] J. Hansen and I. McDonald, _Theory_ _of_ _Simple_ _Liquids:_
_with_ _Applications_ _to_ _Soft_ _Matter_ (Elsevier Science, 2013).
[18] Y. Rosenfeld, Free-energy model for the inhomogeneous
hard-sphere fluid mixture and density-functional theory of
freezing, Phys. Rev. Lett. 63, 980 (1989).
[19] R. Roth, R. Evans, A. Lang, and G. Kahl, Fundamen
tal measure theory for hard-sphere mixtures revisited: the
White Bear version, J. Phys. Condens. Matter 14, 12063
(2002).
[20] H. Hansen-Goos and R. Roth, Density functional theory
for hard-sphere mixtures: the White Bear version mark II,
J. Phys. Condens. Matter 18, 8413 (2006).
[21] R. Roth, Fundamental measure theory for hard-sphere mix
tures: a review, J. Phys. Condens. Matter 22, 063102
(2010).
[22] E. Kierlik and M. L. Rosinberg, Density-functional theory
for inhomogeneous fluids: Adsorption of binary mixtures,
Phys. Rev. A 44, 5025 (1991).
[23] M. C. Stewart and R. Evans, Wetting and drying at a
curved substrate: Long-ranged forces, Phys. Rev. E 71,
011602 (2005).
[24] A. J. Archer, B. Chacko, and R. Evans, The standard
mean-field treatment of inter-particle attraction in classical DFT is better than one might expect, J. Chem. Phys
147, 034501 (2017).
[25] A. H¨artel, M. Janssen, S. Samin, and R. v. Roij, Funda
mental measure theory for the electric double layer: implications for blue-energy harvesting and water desalination,
J. Phys. Condens. Matter 27, 194129 (2015).
[26] A. H¨artel, Structure of electric double layers in capacitive
systems and to what extent (classical) density functional
theory describes it, J. Phys. Condens. Matter 29, 423002
(2017).
[27] R. Roth and D. Gillespie, Shells of charge: a density func
tional theory for charged hard spheres, J. Phys. Condens.
Matter 28, 244006 (2016).
[28] M. B¨ultmann and A. H¨artel, The primitive model in classi
cal density functional theory: beyond the standard meanfield approximation, J. Phys. Condens. Matter 34, 235101
(2022).
[29] P. Cats, S. Kuipers, S. de Wind, R. van Damme, G. M.
Coli, M. Dijkstra, and R. van Roij, Machine-learning freeenergy functionals using density profiles from simulations,
APL Mater 9, 031109 (2021).
[30] J. Dijkman, M. Dijkstra, R. van Roij, M. Welling, J.
W. van de Meent, and B. Ensing, Learning neural freeenergy functionals with pair-correlation matching, Phys.
Rev. Lett. 134, 056103 (2025).
[31] A. Simon and M. Oettel, Machine learning approaches to classical density functional theory (2024),
arXiv:2406.07345 [cond-mat.stat-mech].
[32] S.-C. Lin, G. Martius, and M. Oettel, Analytical classical
density functionals from an equation learning network, J.
Chem. Phys 152, 021102 (2020).
[33] L. Shang-Chun and M. Oettel, A classical density func
tional from machine learning and a convolutional neural
network, SciPost Phys. 6, 025 (2019).
[34] A. Malpica-Morales, P. Yatsyshin, M. A. Dur´an-Olivencia,
and S. Kalliadasis, Physics-informed Bayesian inference of
external potentials in classical density-functional theory, J.
Chem. Phys 159, 104109 (2023).
[35] R. Pederson, B. Kalita, and K. Burke, Machine learn
ing and density functional theory, Nat. Rev. Phys 4, 357
(2022).
[36] F. Samm¨uller, S. Hermann, D. de las Heras, and
M. Schmidt, Neural functional theory for inhomogeneous
fluids: Fundamentals and applications, Proc. Natl. Acad.
Sci. U.S.A 120, e2312484120 (2023).
[37] F. Samm¨uller, M. Schmidt, and R. Evans, Neural density
functional theory of liquid-gas phase coexistence, Phys.
Rev. X 15, 011013 (2025).
[38] J. C. Shelley and G. N. Patey, A configuration bias Monte
Carlo method for ionic solutions, J. Chem. Phys 100, 8265
(1994).
[39] Q. Yan and J. J. de Pablo, Hyper-parallel tempering Monte
Carlo: Application to the Lennard-Jones fluid and the restricted primitive model, J. Chem. Phys 111, 9509 (1999).
[40] F. Mouˇcka, M. L´ısal, J. Skvor, <sup>ˇ</sup> J. Jirs´ak, I. Nezbeda, and
W. R. Smith, Molecular simulation of aqueous electrolyte
solubility. 2. Osmotic ensemble Monte Carlo methodology
for free energy and solubility calculations and application
to NaCl, J. Phys. Chem. B 115, 7849 (2011).
[41] F. Mouˇcka, D. Bratko, and A. Luzar, Electrolyte
pore/solution partitioning by expanded grand canonical
ensemble Monte Carlo simulation, J. Chem. Phys 142,
124705 (2015).
[42] J. Kim, L. Belloni, and B. Rotenberg, Grand-canonical
molecular dynamics simulations powered by a hybrid
4D nonequilibrium MD/MC method: Implementation in
LAMMPS and applications to electrolyte solutions, J.
Chem. Phys 159, 144802 (2023).
[43] J. M. Rodgers and J. D. Weeks, Local molecular field the
ory for the treatment of electrostatics, J. Phys. Condens.
Matter 20, 494206 (2008).
[44] J. D. Weeks, K. Katsov, and K. Vollmayr, Roles of repul
sive and attractive forces in determining the structure of
nonuniform liquids: Generalized mean field theory, Phys.
Rev. Lett. 81, 4400 (1998).
[45] J. M. Rodgers, C. Kaur, Y.-G. Chen, and J. D. Weeks,
Attraction between like-charged walls: Short-ranged simulations using local molecular field theory, Phys. Rev. Lett.
97, 097801 (2006).
[46] Y.-g. Chen, C. Kaur, and J. D. Weeks, Connecting systems
with short and long ranged interactions: Local molecular
field theory for ionic fluids, J. Phys. Chem. B 108, 19874
(2004).
[47] R. C. Remsing, S. Liu, and J. D. Weeks, Long-ranged con
tributions to solvation free energies from theory and shortranged models, Proc. Natl. Acad. Sci. U.S.A 113, 2819
(2016).
[48] A. J. Archer and R. Evans, Relationship between local
molecular field theory and density functional theory for
non-uniform liquids, J. Chem. Phys 138, 014502 (2013).
[49] See Supplemental Material at [url], which includes Refs.
[87-103], for additional information on simulation details,
training procedure, derivation of ∆ _—_, and additional results.
[50] The critical temperature of the RPM is _T_ c <sup>∗</sup> <sup>= 0</sup> <sup>_:_</sup> <sup>0492 (from</sup>
Ref. 39).
[51] D. Frenkel and B. Smit, _Understanding_ _Molecular_ _Simula-_
_tion:_ _From_ _Algorithms_ _to_ _Applications_ (Elsevier Science,
2023).
[52] F. Samm¨uller and M. Schmidt, Neural density functionals:
Local learning and pair-correlation matching, Phys. Rev. E
110, L032601 (2024).
[53] A. T. Bui and S. J. Cox, Research data supporting “Learn
ing classical density functionals for ionic fluids”. Zenodo.,
`https://doi.org/10.5281/zenodo.15085645` (2024).
[54] L. S. Ornstein and F. Zernike, Accidental deviations of
density and opalescence at the critical point of a single
substance, Proc. R. Neth. Acad. Arts Sci. 17, 793 (1914).
[55] R. J. Baxter, Ornstein–Zernike relation and Percus–Yevick
approximation for fluid mixtures, J. Chem. Phys 52, 4559
(2003).
[56] While GC simulations (i.e., known { _—_ }) are required to
train the neural networks (see Eq. 3), it is reasonable
to compare to average structures obtained with canonical
simulations at the same average density.
[57] S. J. Cox, Dielectric response with short-ranged electro
statics, Proc. Natl. Acad. Sci. U.S.A 117, 19746 (2020).
[58] F. H. Stillinger and R. Lovett, General restriction on the
distribution of ions in electrolytes, J. Chem. Phys 49, 1991
(1968).
[59] F. H. Stillinger and R. Lovett, Ion-pair theory of concen
trated electrolytes. I. Basic concepts, J. Chem. Phys 48,
3858 (1968).
[60] The number densities also have a functional dependence
on the non-electrostatic contribution to the external potential. As this is the same for both the full and mimic
systems, i.e { _V_ } = { _V;_ R}, we do not indicate this functional dependence explicitly in Eq. 7.
[61] J. M. Rodgers and J. D. Weeks, Accurate thermodynamics
for short-ranged truncations of Coulomb interactions in
site-site molecular models, J. Chem. Phys 131, 244108
(2009).
[62] N. F. Carnahan and K. E. Starling, Equation of state for
nonattracting rigid spheres, J. Chem. Phys 51, 635 (1969).
[63] J. L. Lebowitz and J. K. Percus, Mean spherical model
for lattice gases with extended hard cores and continuum
fluids, Phys. Rev. 144, 251 (1966).
[64] L. Blum, Mean spherical model for asymmetric elec
trolytes, Mol. Phys. 30, 1529 (1975).
[65] M. Stengel, N. A. Spaldin, and D. Vanderbilt, Electric
displacement as the fundamental variable in electronicstructure calculations, Nat. Phys. 5, 304 (2009).
[66] C. Zhang and M. Sprik, Computing the dielectric constant
of liquid water at constant dielectric displacement, Phys.
Rev. B 93, 144201 (2016).
[67] C. Zhang and M. Sprik, Finite field methods for the super
cell modeling of charged insulator/electrolyte interfaces,
Phys. Rev. B 94, 245309 (2016).
[68] M. Sprik, Finite Maxwell field and electric displace
ment Hamiltonians derived from a current dependent Lagrangian, Molecular Physics 116, 3114 (2018).
[69] S. J. Cox and M. Sprik, Finite field formalism for bulk
electrolyte solutions, J. Chem. Phys 151, 064506 (2019).
[70] T. Sayer and S. J. Cox, Macroscopic surface charges
from microscopic simulations, J. Chem. Phys 153, 164709
(2020).
[71] C. Zhang, T. Sayer, J. Hutter, and M. Sprik, Modelling
electrochemical systems with finite field molecular dynamics, J. Phys. Energy 2, 032005 (2020).
[72] D. Henderson and L. Blum, Some exact results and the
application of the mean spherical approximation to charged
hard spheres near a charged hard wall, J. Chem. Phys 69,
5441 (1978).
[73] D. Henderson, L. Blum, and J. L. Lebowitz, An exact for
mula for the contact value of the density profile of a system
of charged hard spheres near a charged wall, J. Electroanal.
Chem. 102, 315 (1979).
[74] P. A. Martin, Sum rules in charged fluids, Rev. Mod. Phys.
60, 1075 (1988).
[75] This equation for _ff_ s assumes that the electrolyte is cen
tered in a periodically replicated cell of length _L_ along the
_z_ direction.
[76] T. Ichiye and A. D. J. Haymet, Integral equation theory of
ionic solutions, J. Chem. Phys 93, 8954 (1990).
[77] K. Nyg˚ard, S. Sarman, and R. Kjellander, Local order vari
ations in confined hard-sphere fluids, J. Chem. Phys 139,
164701 (2013).
[78] Y. Jing, V. Jadhao, J. W. Zwanikken, and M. Olvera de la
Cruz, Ionic structure in liquids confined by dielectric interfaces, J. Chem. Phys 143, 194508 (2015).
[79] M. Dinpajooh, N. N. Intan, T. T. Duignan, E. Biasin, J. L.
Fulton, S. M. Kathmann, G. K. Schenter, and C. J. Mundy,
Beyond the Debye–H¨uckel limit: Toward a general theory
for concentrated electrolytes, J. Chem. Phys 161, 230901
(2024).
[80] J. R. Henderson, _Fundamentals_ _of_ _inhomogeneous_ _fluids_,
edited by D. Henderson (Dekker, New York, 1992).
[81] A. Voukadinova, M. Valisk´o, and D. Gillespie, Assessing
the accuracy of three classical density functional theories
of the electrical double layer, Phys. Rev. E 98, 012116
(2018).
[82] D. Gillespie, Restoring the consistency with the contact
density theorem of a classical density functional theory of
ions at a planar electrical double layer, Phys. Rev. E 90,
052134 (2014).
[83] P. Cats and R. van Roij, The differential capacitance as
a probe for the electric double layer structure and the
electrolyte bulk composition, J. Chem. Phys 155, 104702
(2021).
[84] A. T. Bui and S. J. Cox, A classical density functional
theory for solvation across length scales, J. Chem. Phys
161, 104103 (2024).
[85] A. Gao, R. C. Remsing, and J. D. Weeks, Local molecular
field theory for Coulomb interactions in aqueous solutions,
J. Phys. Chem. B 127, 809 (2023).
[86] J. M. Rodgers and J. D. Weeks, Interplay of local
hydrogen-bonding and long-ranged dipolar forces in simulations of confined water, Proc. Natl. Acad. Sci. U.S.A
105, 19136 (2008).
[87] A. Z. Panagiotopoulos, Molecular simulation of phase equi
libria: simple, ionic and polymeric fluids, Fluid Ph. Equilib
76, 97 (1992).
[88] A. P. Thompson, H. M. Aktulga, R. Berger, D. S. Bolin
tineanu, W. M. Brown, P. S. Crozier, P. J. in ’t Veld,
A. Kohlmeyer, S. G. Moore, T. D. Nguyen, R. Shan,
M. J. Stevens, J. Tranchida, C. Trott, and S. J. Plimpton, LAMMPS - a flexible simulation tool for particle-based
materials modeling at the atomic, meso, and continuum
scales, Comput. Phys. Commun 271, 108171 (2022).
[89] T. Schneider and E. Stoll, Molecular-dynamics study of
a three-dimensional one-component model for distortive
phase transitions, Phys. Rev. B 17, 1302 (1978).
[90] A. H¨artel, S. Samin, and R. van Roij, Dense ionic fluids
confined in planar capacitors: in- and out-of-plane structure from classical density functional theory, J. Phys. Condens. Matter 28, 244007 (2016).
[91] J. Jover, A. J. Haslam, A. Galindo, G. Jackson, and E. A.
M¨uller, Pseudo hard-sphere potential for use in continuous molecular-dynamics simulation of spherical and chain
molecules, J. Chem. Phys 137, 144505 (2012).
[92] A. V. Brukhno, J. Grant, T. L. Underwood, K. Strat
ford, S. C. Parker, J. A. Purton, and N. B. Wilding,
DL ~~M~~ ONTE: a multipurpose code for Monte Carlo simulation, Mol. Simul. 47, 131 (2021).
[93] S. W. de Leeuw, J. W. Perram, E. R. Smith, and J. S.
Rowlinson, Simulation of electrostatic systems in periodic
boundary conditions. I. Lattice sums and dielectric constants, Proc. R. Soc. A 373, 27 (1997).
[94] R. Hockney and J. Eastwood, _Computer_ _Simulation_ _Using_
_Particles_ (Adam-Hilger, 1988).
[95] J. Kolafa and J. W. Perram, Cutoff errors in the Ewald
summation formulae for point charge systems, Mol. Simul.
9, 351 (1992).
[96] F. Chollet, _Deep_ _Learning_ _with_ _Python_ (Manning Publica
tions, 2017).
[97] T. Sayer, C. Zhang, and M. Sprik, Charge compensation
at the interface between the polar nacl(111) surface and a
nacl aqueous solution, J. Chem. Phys 147, 104702 (2017).
[98] T. Sayer, M. Sprik, and C. Zhang, Finite electric displace
ment simulations of polar ionic solid-electrolyte interfaces:
Application to nacl(111)/aqueous nacl solution, J. Chem.
Phys 150, 041716 (2018).
[99] F. Sedlmeier, D. Horinek, and R. R. Netz, Spatial correla
tions of density and structural fluctuations in liquid water:
A comparative simulation study, J. Am. Chem. Soc 133,
1391 (2011).
[100] J. K. Johnson, J. A. Zollweg, and K. E. Gubbins, The
Lennard-Jones equation of state revisited, Mol. Phys. 78,
591 (1993).
[101] A. T. Bui, GCMC with Gaussian truncated potentials,
`https://github.com/annatbui/GCMC` (2024).
[102] S. J. Cox, Gaussian truncated potentials in LAMMPS,
`https://github.com/uccasco/LMFT` (2020).
[103] A. T. Bui and S. J. Cox, Learning cDFT for ionic fluids,
`https://github.com/annatbui/ion-cdft` (2024).
#### Supplemental material: Learning classical density functionals for ionic fluids
Anna T. Bui <sup>1</sup> and Stephen J. Cox <sup>2, a)</sup>
1) _Yusuf_ _Hamied_ _Department_ _of_ _Chemistry,_ _University_ _of_ _Cambridge,_ _Lensfield_ _Road,_ _Cambridge,_ _CB2_ _1EW,_
_United_ _Kingdom_
2) _Department_ _of_ _Chemistry,_ _Durham_ _University,_ _South_ _Road,_ _Durham,_ _DH1_ _3LE,_
_United_ _Kingdom_
(Dated: April 8, 2025)
CONTENTS
S1. Classical density functional theory S2
S2. Simulations of the short-ranged system S2
S2.1. GCMC simulations S3
S2.2. Bulk canonical MD simulations S3
S3. Simulations of the long-ranged system S4
S3.1. Bulk GCMC simulations S4
S3.2. Canonical MD simulations S4
S4. Connecting the short-ranged and long-ranged systems S4
S4.1. Structure S4
S4.2. Liquid–vapor coexistence S5
S4.3. Energy S5
S4.4. Chemical potential S6
S4.5. Pressure S6
S5. Finite field simulations S7
S6. Distribution functions S8
S7. Training one-body direct correlation neural functionals S10
S7.1. Training data S10
S7.2. Neural network S11
S7.3. Training procedure S11
S7.4. Bulk correlation matching S12
S8. Electric double layer S14
S9. Primitive model and multivalent system S16
References S16
a)Electronic mail: stephen.j.cox@durham.ac.uk
S2
S1. CLASSICAL DENSITY FUNCTIONAL THEORY
For an _n_ -component ionic fluid described by the singlet ion densities { _ȷ_ ( _r_ )} ( __ = 1 _;_ 2 _; :::; n_ ) with the
charge carried by ions of species __ being _q_, the grand potential functional is
_˙_ [{ _ȷ_ }] = Fintr[{ _ȷ_ }] −
__ Z
X
d _r_ [ _—_ - _V_ ( _r_ ) − _qffi_ ( _r_ )] _ȷ_ ( _r_ ) _;_ (S1)
where _—_ is the chemical potential of species __, _V_ contains all non-coulombic contributions to the external
potential on species __, and _ffi_ is the electrostatic potential. The intrinsic Helmholtz free energy functional
Fintr can be divided exactly into ideal and excess parts
ln
ˆ
ˆ
`
- 1
˜
´
_˛_ Fintr[{ _ȷ_ }] =
__
X
__
d _r ȷ_ ( _r_ )
Λ <sup>3</sup> __
<sup>3</sup> __ <sup>_ȷ_</sup> <sup>(</sup> <sup>_r_</sup> <sup>)</sup>
+ _˛_ Fintr <sup>(ex)[{</sup> <sup>_ȷ_</sup> <sup>}]</sup> <sup>_;_</sup> (S2)
Z
with _˛_ = ( _k_ B _T_ ) <sup>−1</sup>, where _k_ B is Boltzmann’s constant, _T_ is the temperature and Λ __ is the de Broglie thermal
wavelength of species __ . The intrinsic excess free energy functional Fintr <sup>(ex)</sup> <sup>acts</sup> <sup>as</sup> <sup>a</sup> <sup>generating</sup> <sup>functional</sup> <sup>for</sup>
the one-body direct correlation function of each species __ :
__ <sup>(1)(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}]) = −</sup> <sup>_<u>˛‹</u>_</sup> <sup><u>F</u></sup> _‹ȷ_ <u>intr</u> <sup>(ex)</sup> __
_c_ <sup>(1)</sup>
_‹ȷ_ <u>intr</u> <sup>(ex)</sup> __ ( <sup><u>[</u></sup> _r_ <sup><u>{</u></sup> ) <sup>_<u>ȷ</u>_</sup> <sup><u>}]</u></sup> _:_ (S3)
The variational principle states that the equilibrium ion densities minimise _˙_, so the Euler–Lagrange equation
for each species __ is given as
_ȷ_ ( _r_ ) = Λ <sup>−</sup> __ <sup>3</sup> exp
“
- _˛V_ ( _r_ ) − _˛qffi_ ( _r_ ) + _˛—_ + _c_ <sup>(1)(</sup>
__ <sup>(1)(</sup> <sup>_r_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}])</sup>
”
_:_ (S4)
Upon rearrangement, we can write the relationship for learning the one-body correlation functions
´
_c_ <sup>(1)(</sup> <sup>_r_</sup> <sup>) = ln</sup>
_c_ <sup>(1)</sup>
`
Λ <sup>3</sup> __
<sup>3</sup> __ <sup>_ȷ_</sup> <sup>(</sup> <sup>_r_</sup> <sup>)</sup>
+ _˛V_ ( _r_ ) + _˛qffi_ ( _r_ ) − _˛—:_ (S5)
S2. SIMULATIONS OF THE SHORT-RANGED SYSTEM
The full system we considered is the restricted primitive model (RPM) in which the solvent is treated as
a dielectric continuum with dielectric constant _›_, and the ions are modeled as hard spheres of two species
(cations and anions) that are characterized by equal diameter _ff_ and opposite charges _q_ + = - _q_ −. The pair
potentials of the RPM are defined by
_uij_ ( _r_ ) =
8
<
:
<
:
<u>∞</u> _r_ ≤ _ff_
_<u>qi</u>_ _<u>qj</u>_ <u>1</u>
(S6)
_›_
<u>1</u>
_r_ _> ff:_
_r_
Throughout, we adopt the Gaussian unit system for electrostatics in which 4 _ı›_ 0 = 1 where _›_ 0 is the permittivity
of free space. The short-ranged mimic system has pair potentials
_uij;_ R( _r_ ) =
8
>><
<
>>:
<u>∞</u> _r_ ≤ _ff_
_<u>qi</u>_ _<u>qj</u>_ <u>erfc(</u> _<u>»</u>_ <u>r)</u>
_›_
<u>erfc(</u> _<u>»</u>_ <u>r)</u>
(S7)
_r_ _ff_ _< r_ ≤ _r_ c
0 _r_ _> r_ c _;_
where _»_ <sup>−1</sup> = 1 _:_ 81 _ff_ and _r_ c = 3 _:_ 6 _ff_ . It is also convenient to introduce a reduced unit system, in which the
unit of energy is | _q_ ±| <sup>2</sup> _=›ff_ . Therefore, the reduced temperature is given as
(S8)
_T_ <sup>∗</sup> = <sup>_<u>›ffk</u>_</sup> <sup><u>B</u></sup> <sup>_<u>T</u>_</sup>
| _q_ + _q_ −| <sup>_:_</sup>
S3
In the article, we focus on the RPM at _T_ <sup>∗</sup> = 0 _:_ 066 under supercritical condition. In the main paper, we report
quantities in their reduced units. Here in the SM, to stay in line with how the simulations and calculations are
performed in practice, we will report quantities in “real” units and we employed _ff_ = 2 _:_ 76 <sup>˚</sup> A, _q_ - = − _q_ + = _e_
where _e_ is the elementary charge and _›_ = 1, which corresponds to molten NaCl <sup>1</sup> at _T_ = 4000 K.
S2.1. GCMC simulations
For the short-ranged systems, we performed GCMC simulations with our own code. <sup>2</sup> Insertion and deletion
moves were performed separately for each ionic species, i.e., _—_ R _;_ + and _—_ R _;_ - were controlled independently.
Cubic simulation boxes of length _L_ = 24 <sup>˚</sup> A with periodic boundary conditions were used. Each system was
equilibrated for at least 1 × 10 <sup>5</sup> MC steps. In each MC move, a choice of the species __ is made randomly,
followed by five possibilities with the following transition probabilities from state _i_ to state _j_, _pj_ _=pi_ :
(a) Displacement of an ion of species __
_<u>pj</u>_
_pi_
= exp(− _˛_ ∆ _Uji_ ) _;_ (S9)
(b) Insertion of an ion of species __
(c) Deletion of an ion of species __
_<u>pj</u>_
_pi_
_<u>V</u>_
=
( _N_ + 1)Λ <sup>3</sup> __
exp(− _˛_ ∆ _Uji_ + _˛—_ R _;_ ) _;_ (S10)
_<u>pj</u>_
_pi_
= <sup>_<u>N</u>_</sup> <sup><u>Λ</u></sup> _<u></u>_ <sup>3</sup> (S11)
_V_ exp(− _˛_ ∆ _Uji_ - _˛—_ R _;_ ) _;_
(d) Mutation of an ion of species __ to an ion of species _–_
_<u>pj</u>_
_pi_
= _<u>N</u>_ <u>Λ</u> <sup>3</sup> _<u></u>_
_<u></u>_
( _N–_ + 1)Λ <sup>3</sup> _–_
_–_
exp(− _˛_ ∆ _Uji_ - _˛—_ R _;_ + _˛—_ R _;–_ ) _;_ (S12)
(e) Swap position of an ion of species __ with an ion of species _–_
_<u>pj</u>_
_pi_
= exp(− _˛_ ∆ _Uji_ ) _;_ (S13)
where _N_ denotes the number of ions of species __, _V_ is the volume of the simulation box and ∆ _Uji_
is the change in potential energy between state _i_ and state _j_, including any contribution from external
potentials. In all cases, a trial move was accepted with probability min(1 _; pj_ _gj_ → _i_ _=pi_ _gi_ → _j_ ), where _g_ is
the generation probability by drawing a random number uniformly in the interval [0 _;_ 1).
For each simulation, around 1 × 10 <sup>9</sup> MC steps were attempted.
S2.2. Bulk canonical MD simulations
MD simulations of the short-ranged system were performed with the LAMMPS simulation package. <sup>3</sup> Source
code to implement the pair potential with short-ranged electrostatics is openly available. <sup>4,5</sup> Cubic simulation
boxes with periodic boundary conditions were used. The bulk systems contained 2000 ion pairs, with the
length of the box adjusted to yield the desired bulk densities. Dynamics were propagated using the velocity
Verlet algorithm with a time-step of 1 fs. The temperature was maintained using a Langevin thermostat. <sup>6</sup> The
system was equilibrated for 50 ps and production runs were performed for at least 2 ns in the NVT ensemble.
To describe the hard-core part of the pair interaction in MD simulations, as done in Refs. 7 and 8, we
replace the hard-sphere potential with the continuous pseudo hard-sphere potential
_r_
“ _<u>f</u>_
”49 <sup>–</sup>
49
` <u>50</u>
49
` <u>50</u>
49
<u>50</u> ´
49
<u>50</u> ´
_r_
»“ _<u>f</u>_
_r_
S4
(S14)
_u_ pHS( _r_ ) =
8
><
<
>:
50
49
„ <u>50</u>
«49
_"_
”50
_r_
+ _"_ _r_ ≤
_ff_
_ff;_
49
0 _r_ _>_
at _k_ B _T="_ = 1 _:_ 5, which was found to reproduce structural and thermodynamic data of hard-spheres. <sup>9</sup> The full
short-ranged potential becomes
<u>erfc(</u> _<u>»</u>_ <u>r)</u>
_r_ _r_ ≤ _r_ c
(S15)
_uij;_ R( _r_ ) =
8
<
:
<
:
_u_ pHS( _r_ ) + <sup>_<u>qi</u>_</sup> <sup>_<u>qj</u>_</sup>
_›_
0 _r_ _> r_ c _:_
S3. SIMULATIONS OF THE LONG-RANGED SYSTEM
S3.1. Bulk GCMC simulations
For the full long-ranged system, we performed GCMC simulations with `DL` `MONTE` . <sup>10</sup> Long-ranged electrostatics were treated with Ewald summation. <sup>11</sup> As insertion and deletion moves can only be done with pairs
of ions effectively, we controlled _—_ pair = _—_ + + _—_ −. Cubic simulation boxes with periodic boundary conditions
were used. The system was equilibrated for 1 × 10 <sup>4</sup> MC steps and 1 × 10 <sup>8</sup> MC steps were attempted in the
production run.
S3.2. Canonical MD simulations
MD simulations of the long-ranged system were performed with the LAMMPS simulation package. <sup>3</sup> Cubic
simulation boxes with periodic boundary conditions were used. The full pair potential employed in MD is
<u>1</u>
_r_ _r_ ≤ _r_ c
(S16)
_uij;_ R( _r_ ) =
8
<
:
<
:
_u_ pHS( _r_ ) + <sup>_<u>qi</u>_</sup> <sup>_<u>qj</u>_</sup>
0 _r_ _> r_ c _:_
_›_
The bulk systems contained 2000 ion pairs, with the length of the box adjusted to yield the desired bulk
densities. Dynamics were propagated using the velocity Verlet algorithm with a time-step of 1 fs. The temperature was maintained using a Langevin thermostat. <sup>6</sup> The system was equilibrated for 50 ps and production
runs were performed for at least 2 ns in the NVT ensemble.
Long-ranged electrostatic interactions were evaluated using particle–particle particle–mesh Ewald
summation <sup>12</sup> (using a 1 nm cut off in real space) such that the RMSE in the forces was a factor of 10 <sup>5</sup>
smaller than the force between two unit charges separated by a distance of 0 _:_ 1 nm. <sup>13</sup>
S4. CONNECTING THE SHORT-RANGED AND LONG-RANGED SYSTEMS
S4.1. Structure
The pair potentials for the long-ranged and mimic short-ranged systems are described in Eq. S6 and Eq. S7
and plotted in Fig. S1(a). With _»_ <sup>−1</sup> chosen to be large enough, the mimic system can faithfully capture
the short-ranged local structure of the full system in the bulk, reflected in the radial distribution functions
in Fig. S1(b). For the bulk structure, discrepancies between the mimic and full system would only appear at
longer wavelength, as shown in the structure factors in the main paper.
S5
Figure S1: Structure of the short-ranged and long-ranged RPM. (a) The pair potential and (b) radial distribution
function of a bulk fluid at the same density _ȷ_ + = _ȷ_ - = 0 _:_ 315 _ff_ <sup>−3</sup> obtained from GCMC simulations. The cation–cation
and anion–anion functions are shown in solid lines while cation–anion functions are in dotted lines.
S4.2. Liquid–vapor coexistence
For the long-ranged RPM, the liquid–vapor binodal curve has been determined <sup>14</sup> with the critical temperature _T_ c <sup>∗</sup> <sup>=</sup> <sup>0</sup> <sup>_:_</sup> <sup>0492.</sup> Short-ranged fluids are expected to have a lower critical temperature than their
long-ranged counterpart. <sup>15</sup> Indeed, we verified this by constructing the binodal curve for two short-ranged
mimic systems from GCMC simulations, as shown in Fig. S2(a). In this work, we focus on the isothermal
behavior at _T_ <sup>∗</sup> = 0 _:_ 066, which is supercritical for both the full RPM and the mimic system.
S4.3. Energy
In Ref. 16, an analytical correction for the Coulombic energy between the long-ranged and short-ranged
bulk systems based on the Stillinger–Lovett moment conditions is derived. For a binary salt, this long-range
correction reduces to
<u>1</u>
∆ _U_ ≡ _U_ - _U_ R = − _»_ <sup>−1</sup> <sup>~~√~~</sup> _<u>ı</u>_
`
_N_ + _q_ + <sup>2</sup>
+ <sup>2</sup> <sup>+</sup> <sup>_N_</sup> <sup>−</sup> <sup>_q_</sup> - <sup>2</sup>
- <sup>2</sup>
´
<u>1</u>
+ _»_ <sup>−3</sup> <sup>~~√~~</sup> _<u>ı</u>_
_<u>V</u>_
2 _ı˛_ <sup>_;_</sup> (S17)
where _N_ + is the number of cations, _N_ - is the number of anions and _V_ is the volume of the system. As seen
in Fig. S2, for mimic systems with _»_ <sup>−1</sup> _>_ _ff_, the total potential energy with this correction reproduces the
energy of the full system (calculated with Ewald summation) well.
S6
Figure S2: Phase diagram and potential energy long-range correction of the RPM. (a) The liquid–vapor coexistence curve of the long-ranged system is from Ref. 14, while those of the short-ranged mimic systems are determined
in this work. (b) The total potential energy of the mimic short-ranged system at various _»_ <sup>−1</sup> without (triangles) and
with the long-range correction (circles) for the bulk system at _ȷ_ R _;_ + = _ȷ_ R _;_ - = 0 _:_ 263 _ff_ <sup>−3</sup> . The energy determined from
Ewald summation is indicated by the horizontal dashed line.
S4.4. Chemical potential
The change in internal energy of the bulk system is given as
d _U_ = _T_ d _S_ + _—_ +d _N_ + + _—_ −d _N_ - - _P_ d _V;_ (S18)
where _S_ is the entropy and _P_ is the pressure. The chemical potentials of the anion _—_ - and cation _—_ + can be
expressed thermodynamically as
«
«
„ _@N@S_
_@N_ +
„ _<u>@S</u>_
_@N_ +
_—_ - =
_—_ + =
„ _@N@U_
_@N_ +
„ _<u>@U</u>_
_@N_ +
_@N_
_—_ + _;V;T_
_@N_
_—_ + _;V;T_
_;_
_:_
(S19)
«
«
_—_ - _;V;T_
_—_ - _;V;T_
- _T_
- _T_
Since the mimic system is constructed to capture the local order and structural variations that are expected
to dominate the entropy, we approximate _S_ ≈ _S_ R, giving:
_—_ - _;V;T_
∆ _—_ - ≡ _—_ - - _—_ R _;_ - =
∆ _—_ + ≡ _—_ + − _—_ R _;_ + =
„ _<u>@@N</u>_ <u>∆−</u> _<u>U</u>_
_@N_ +
„ _<u>@</u>_ <u>∆</u> _<u>U</u>_
_@N_
_—_ + _;V;T_
_<u>q</u>_ <sup>2</sup>
= − _»_ <sup>−1</sup> <u>−</u> <sup>~~√~~</sup> _<u>ı</u>_ <sup>_;_</sup>
(S20)
_@N_ +
«
«
= − _»_ <sup>−</sup> _<u>q</u>_ <sup>1</sup> <u>+</u> <sup>2</sup> <sup>~~√~~</sup> _<u>ı</u>_ <sup>_:_</sup>
For a range of _»_ <sup>−1</sup>, we find the chemical potentials that gives a bulk fluid of density _ȷ_ R _;_ + = _ȷ_ R _;_ - = 0 _:_ 263 _ff_ <sup>−3</sup>
by running GCMC simulations with various _—_ R _;_ - = _—_ R _;_ +. As shown in Fig. S3(a), for _»_ <sup>−1</sup> & _ff_, the corrected
chemical potentials of the mimic system agree well with that of the full system. The long-ranged GCMC
simulations of the RPM were done with insertions and deletions of cation-ion pairs so the chemical potential
is _—_ - = _—_ + = _—_ pair _=_ 2.
S4.5. Pressure
The pressure can be expressed thermodynamically as
« _N_ + _;N_ - _;T_
- _@V_
„ _<u>@U</u>_
« _N_ + _;N_ - _;T_
_P_ = _T_
_@V_
„ _<u>@S</u>_
_:_ (S21)
S7
Again, _S_ ≈ _S_ R, leaving the correction for the bulk pressure, consistent with Ref. 16, as
«
_N_ + _;N_ - _;T_
∆ _P_ ≡ _P_ - _P_ R = −
_@V_
„ _<u>@</u>_ <u>∆</u> _<u>U</u>_
_@V_
<u>1</u>
= − 2 _ı_ <sup>3</sup> <sup>_=_</sup> <sup>2</sup> _»_ <sup>−3</sup> _˛_ <sup>_:_</sup> (S22)
The pressure obtained from simulations of the mimic systems is shown in Fig. S3(b). The analytical pressure
correction brings the result closer to the pressure of the long-ranged system. For dense systems, its contribution
is relatively small.
Figure S3: Long-range corrections for the chemical potential and pressure for the RPM. (a) The chemical
potential for an ion and (b) the pressure of the mimic short-ranged system at at various _»_ <sup>−1</sup> without (triangles) and
with the long-range correction (circles) for the bulk system at _ȷ_ R _;_ + = _ȷ_ R _;_ - = 0 _:_ 263 _ff_ <sup>−3</sup> . The results for the full system
(determined with Ewald sums) are indicated by the horizontal dashed lines, with uncertainty in the pressure indicated
by the shaded region.
S5. FINITE FIELD SIMULATIONS
The Hamiltonian of the system under an imposed uniform _E_ field is given as
H _E_ ( _r_ <sup>_N_</sup> _; p_ <sup>_N_</sup> ) = HPBC( _r_ <sup>_N_</sup> _; p_ <sup>_N_</sup> ) − _V E_ - _P_ ( _r_ <sup>_N_</sup> ) _;_ (S23)
where HPBC denotes the Hamiltonian of the periodic system computed using standard Ewald summation
techniques and _P_ denotes the total polarization formally defined as the time integral of the current
_P_ ( _r_ <sup>_N_</sup> ) = <sup><u>1</u></sup>
_V_
_i_
X
_qi_ _r i_ _:_ (S24)
In our simulations, we use an “electrolyte centered cell” such that the above amounts to a straightforward
calculation of the total dipole moment of the simulation cell. <sup>17–19</sup> In MD simulations, this amounts to adding
a force _f_ _i_ = _qi_ _E_ to each ion _i_ in the simulation.
The finite field Hamiltonian for the system under constant displacement field _D_ is
(S25)
H _D_ ( _r_ <sup>_N_</sup> _; p_ <sup>_N_</sup> ) = HPBC( _r_ <sup>_N_</sup> _; p_ <sup>_N_</sup> ) + 8 <sup>_<u>V</u>_</sup> _ı_ <sup>[</sup> <sup>_D_</sup> <sup>−</sup> <sup>4</sup> <sup>_ıP_</sup> <sup>(</sup> <sup>_r N_</sup> <sup>)]2</sup> <sup>_:_</sup>
The displacement field is related to the electric field through
_D_ = _E_ + 4 _ıP:_ (S26)
In MD simulations, this amounts to adding a field-dependent force to each ion _f_ _i_ = _qi_ ( _D_ - 4 _ıP_ ).
S8
Figure S4: Finite field simulations of the RPM confined between two oppositely charged walls. (a) Ion density
profiles obtained are identical under a constant electric field _Ez_ = 0 _:_ 22 V <sup>˚</sup> A <sup>−1</sup> or under a constant displacement field
_Dz_ = 1 _:_ 13 V <sup>˚</sup> A <sup>−1</sup> . (b) The polarization _Pz_ in the two simulations are on average the same, with smaller fluctuations
under constant _Dz_ .
S6. DISTRIBUTION FUNCTIONS
We denote the 3D spatial Fourier transform of function _f_ ( _r_ ) as
_f_ ˆ ( _k_ ) =
and the inverse Fourier transform of _f_ <sup>ˆ</sup> ( _k_ ) as
Z
d _r f_ ( _r_ ) exp(− _ik_ - _r_ ) _;_ (S27)
<u>1</u>
_f_ ( _r_ ) =
(2 _ı_ ) <sup>3</sup>
Z
d _k_ _f_ <sup>ˆ</sup> ( _k_ ) exp( _ik_ - _r_ ) _:_ (S28)
For a radially symmetric function _f_ ( _r_ ), the corresponding expressions become
_f_ ˆ ( _k_ ) = <sup><u>4</u></sup> <sup>_<u>ı</u>_</sup>
_k_
d _r rf_ ( _r_ ) sin( _kr_ ) _;_ (S29)
0
Z ∞
d _k kf_ <sup>ˆ</sup> ( _k_ ) sin( _kr_ ) _:_ (S30)
0
Z ∞
and
<u>1</u>
_f_ ( _r_ ) =
2 _ı_ <sup>2</sup> _r_
The planar projection of a radially symmetric function _f_ ( _r_ ) is
d _r rf_ ( _r_ ) _;_ (S31)
_z_
Z ∞
_f_ ( _z_ ) =
Z
d _x_
Z
d _y f_ ( _r_ =
_x_ <sup>2</sup> + _y_ <sup>2</sup> + _z_ <sup>2</sup> ) = 2 _ı_
~~p~~
and the inverse transformation is
<u>1</u> _<u>@f</u>_ <u>(</u> _<u>z</u>_ <u>)</u>
_f_ ( _r_ ) = − 2 _ır_ _@z_
˛˛˛˛
_z_ = _r_
_:_ (S32)
For a bulk mixture containing _N_ of species __, we extracted the radial distribution functions
_N_
_i_
X
_N–_
_j_
X
_‹_ ( _r_ −| _r i_ - _r j_ |)+
_g–_ ( _r_ ) = <sup>_<u>ȷ</u>_</sup> <sup><u>tot</u></sup>
_ȷȷ–_
<u>1</u>
- _N_
_;_ (S33)
where _ȷ_ tot = <sup>P</sup>
__ <sup>_ȷ_</sup> <sup>=</sup> <sup>P</sup>
__ <sup>_N=V_</sup> <sup>,</sup> <sup>by</sup> <sup>generating</sup> <sup>a</sup> <sup>histogram</sup> <sup>of</sup> <sup>intermolecular</sup> <sup>distances</sup> <sup>and</sup> <sup>appropriate</sup>
S9
normalization. The corresponding total correlation functions are therefore
_h–_ ( _r_ ) = _g–_ ( _r_ ) − 1 _:_ (S34)
The high-wavevector part of the partial structure factors are computed from
_S–_ ( _k_ ) = <sup>_<u>ȷ</u>_</sup>
_ȷ_ tot
_‹–_ + <sup>_<u>ȷȷ–</u>_</sup>
_ȷ_ tot
ˆ _h–_ ( _k_ ) _:_ (S35)
In the low-wavevector limit, we also calculate the structure factor directly from the simulation trajectories
using <sup>20</sup>
#
_N_
_i_
X
_i_
_N–_
_j_
X
# " _Ni–_
X
_S–_ ( _k_ ) =
<u>1</u>
<u>*</u> _N_
exp[− _ik_ - ( _r i_ - _r j_ )]
_j_
+
# " _Ni–_
X
(S36)
= <sup><u>1</u></sup>
_N_
*" _Ni_
X
_i_
_i_
_i_
+
" _Ni_
X
cos( _k_ - _r i_ )
_:_
sin( _k_ - _r i_ )
sin( _k_ - _r i_ )
cos( _k_ - _r i_ )#+
The Ornstein–Zernike equation that relates the two-body direct correlation functions to the total correlation
function for a homogeneous mixture is
_h–_ ( _r_ ) = _c–_ <sup>(2)(</sup> <sup>_r_</sup> <sup>) +</sup>
_n_
_‚_
X
_ȷ‚_
Z
d _r_ <sup>′</sup> _c‚_ <sup>(2)(|</sup> <sup>_r_</sup> <sup>−</sup> <sup>_r_</sup> <sup>′|)</sup> <sup>_h‚–_</sup> <sup>(|</sup> <sup>_r_</sup> <sup>′|)</sup> <sup>_:_</sup> (S37)
It is convenient to define two matrices with components <sup>21</sup>
_H_ ˆ _–_ ( _k_ ) = ( _ȷȷ–_ ) <sup>1</sup> <sup>_=_</sup> <sup>2</sup> ˆ _h–_ ( _k_ ) _;_ (S38)
_C_ ˆ _–_ ( _k_ ) = ( _ȷȷ–_ ) <sup>1</sup> <sup>_=_</sup> <sup>2</sup> _c_ ˆ _–_ <sup>(2)(</sup> <sup>_k_</sup> <sup>)</sup> <sup>_;_</sup> (S39)
allowing the Ornstein–Zernike equation to be recast in a matrix form
_H_ ˆ ( _k_ ) = _C_ ˆ ( _k_ ) + _C_ ˆ ( _k_ ) ˆ _H_ ( _k_ ) _:_ (S40)
Upon rearrangement,
_C_ ˆ ( _k_ ) = _I_ - [ _I_ + _H_ ˆ ( _k_ )] <sup>−1</sup> _;_ (S41)
where _I_ is the identity matrix.
To obtain the planar bulk two-body direct correlation functions _~~c~~_ <sup>(2)</sup> R _;–_ <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}),</sup> <sup>where</sup> <sup>_ȷ_</sup> <sup>b</sup> <sup>=</sup> <sup>_ȷR;_</sup> <sup>±</sup> <sup>denotes</sup>
the bulk ionic density, from simulations for bulk correlation matching, we calculate in order:
- _S_ R _;–_ ( _k_ ; { _ȷ_ b}) at the low-wavevector end ( _kff_ _<_ 5) directly via Eq. S36,
- _g_ R _;–_ ( _r_ ; { _ȷ_ b}) by generating histograms of interatomic distances via Eq. S33,
- _h_ R _;–_ ( _r_ ; { _ȷ_ b}) via Eq. S34,
- <sup>ˆ</sup> _h_ R _;–_ ( _k_ ; { _ȷ_ b}) at the low-wavevector end through _S_ R _;–_ ( _k_ ; { _ȷ_ b}) via Eq. S35 and at the high-wavevector
end via the radial Fourier transform, Eq. S29, of _h_ R _;–_ ( _r_ ; { _ȷ_ b}),
- _H_ <sup>ˆ</sup> R _;–_ ( _k_ ; { _ȷ_ b}) via Eq. S38,
- _C_ <sup>ˆ</sup> R _;–_ ( _k_ ; { _ȷ_ b}) by solving the matrix equation Eq. S41,
- _c_ ˆR <sup>(2)</sup> _;–_ <sup>(</sup> <sup>_k_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b})</sup> <sup>via</sup> <sup>Eq.</sup> <sup>S39,</sup>
- _c_ R <sup>(2)</sup> _;–_ <sup>(</sup> <sup>_r_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b})</sup> <sup>via</sup> <sup>the</sup> <sup>inverse</sup> <sup>radial</sup> <sup>Fourier</sup> <sup>transform,</sup> <sup>Eq.</sup> <sup>S30,</sup> <sup>of</sup> <sup>_c_</sup> <sup>ˆ</sup> R <sup>(2)</sup> _;–_ <sup>(</sup> <sup>_k_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}),</sup>
- _~~c~~_ <sup>~~(~~</sup> R <sup>2)</sup> _;–_ <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b})</sup> <sup>via</sup> <sup>the</sup> <sup>planar</sup> <sup>projection,</sup> <sup>Eq.</sup> <sup>S31,</sup> <sup>of</sup> <sup>_c_</sup> R <sup>(2)</sup> _;–_ <sup>(</sup> <sup>_r_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}).</sup>
S10
Some of these functions are shown representatively in Fig. S5.
Figure S5: Distribution functions. For a short-ranged mimic bulk system at _ȷ_ R _;_ + = _ȷ_ R _;_ - = 0 _:_ 315 _ff_ <sup>−3</sup>, we show the
(a) radial distribution functions, (b) partial structure factors, (c) two-body direct correlation functions in reciprocal
space, (d) in real space and (e) their planar projections.
S7. TRAINING ONE-BODY DIRECT CORRELATION NEURAL FUNCTIONALS
S7.1. Training data
Following Ref. 22, we employ randomized simulation conditions by generating external potentials of the
form
+ _„n_
«
_n_
X
_Bn_ <sup>lin(</sup> <sup>_z_</sup> <sup>)</sup> <sup>_;_</sup> (S42)
_V_ ( _z_ ) =
4
_n_ =1
X
_An_ sin
_Lz_
„ <u>2</u> _<u>ınz</u>_
+
where _An_ and _„n_ are randomly selected Fourier coefficients and phases, respectively, and _Lz_ is the simulation
box length in the _z_ direction. The phases _„n_ are chosen uniformly in the interval [0, 2 _ı_ ), and values of _An_ are
drawn from a normal distribution with zero mean and a variance of 0 _:_ 06 (kB _T_ ) <sup>2</sup> . Cubic simulation boxes with
_Lz_ = 24 <sup>˚</sup> A with periodic boundary conditions were used. The second summation denotes up to four piecewise
linear functions
(S43)
_Bn_ <sup>lin(</sup> <sup>_z_</sup> <sup>) =</sup>
8
<
:
<
:
_V_ 1 + <sup>_<u>V</u>_</sup> <sup><u>2 −</u></sup> <sup>_<u>V</u>_</sup> <sup><u>1</u></sup>
0 otherwise _;_
( _z_ - _z_ 1) _z_ 1 _< z_ _< z_ 2
_z_ 2 − _z_ 1
with 0 _<_ _z_ 1 _<_ _z_ 2 _<_ _Lz_ . The locations _z_ 1 and _z_ 2 are distributed uniformly while _V_ 1 and _V_ 2 follow from an
unbiased normal distribution with variance of (kB _T_ ) <sup>2</sup> . Similarly, the external electrostatic potential used is
also randomized with an analogous form
_Lz_
„ <u>2</u> _<u>ınz</u>_
+ _„n_ <sup>_q_</sup>
«
_ffi_ ( _z_ ) =
4
_n_ =1
X
_A_ <sup>_q_</sup> _n_ <sup>sin</sup>
_A_ <sup>_q_</sup> _n_
+
_n_
X
_Bn_ <sup>lin</sup> <sup>_;q_</sup> ( _z_ ) _:_ (S44)
For a subset of simulations, we explicitly impose planar hard walls by setting _V_ ( _z_ ) = ∞ for _z_ _<_ _z_ w and
_z_ _> Lz_ - _z_ w with _z_ w = 2 <sup>˚</sup> A. The chemical potential is randomly chosen in the range _˛—R;_ ∈ [−10 _:_ 5 _;_ −4 _:_ 0].
The thermal wavelengths were set to Λ __ = 1 <sup>˚</sup> A.
In total, 2400 GCMC simulations were used including cases with only non-Coulombic external potentials
such that _ffi_ R( _z_ ) = 0, cases with only electrostatic external potentials such that _V_ R _;_ +( _z_ ) = _V_ R _;_ −( _z_ ) = 0,
symmetric cases where _V_ R _;_ +( _z_ ) = _V_ R _;_ −( _z_ ) and _—_ R _;_ + = _—_ R _;_ - and asymmetric cases.
For each simulation, the ion density profiles _ȷ_ R _;_ +( _z_ ) and _ȷ_ R _;_ −( _z_ ) were sampled with a grid-spacing ∆ _z_ =
0 _:_ 03 <sup>˚</sup> A. The one-body direct correlation profiles are calculated from
_c_ R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}]) = ln</sup>
_c_ R <sup>(1)</sup> _;_ + <sup>(</sup> <sup>_z_</sup> <sup>; [{</sup> <sup>_ȷ_</sup> <sup>}]) = ln</sup>
`
`
Λ <sup>3</sup>
Λ <sup>3</sup> +
´
´
S11
(S45)
<sup>3</sup> - <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>−(</sup> <sup>_z_</sup> <sup>)</sup>
<sup>3</sup> + <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>+(</sup> <sup>_z_</sup> <sup>)</sup>
+ _˛V_ R _;_ −( _z_ ) + _˛q_ - _ffi_ R( _z_ ) − _˛—_ R _;_ - _;_
+ _˛V_ R _;_ +( _z_ ) + _˛q_ + _ffi_ R( _z_ ) − _˛—_ R _;_ + _:_
S7.2. Neural network
We used two neural networks to represent the one-body direct correlation functionals, one for _c_ R <sup>(1)</sup> _;_
one for _c_ R <sup>(1)</sup> _;_
R <sup>(1)</sup> _;_ - <sup>and</sup>
one for _c_ R <sup>(1)</sup> _;_ + <sup>.</sup> <sup>The</sup> <sup>machine</sup> <sup>learning</sup> <sup>routine</sup> <sup>was</sup> <sup>implemented</sup> <sup>in</sup> <sup>Keras/Tensorflow</sup> <sup>with</sup> <sup>the</sup> <sup>standard</sup> <sup>Adam</sup>
optimizer. <sup>23</sup> The architecture of the models is shown in Fig. S6. The input layers take in both ion density
profiles, _ȷ_ R _;_ +( _z_ ) and _ȷ_ R _;_ −( _z_ ), in a window of size 10 <sup>˚</sup> A around the location of interest. Three fully-connected
hidden layers with 512 nodes and softplus activation functions then follow, finally resulting in a single scalar
value _c_ R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>)</sup> <sup>or</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_ + <sup>(</sup> <sup>_z_</sup> <sup>)</sup> <sup>at</sup> <sup>position</sup> <sup>_z_</sup> <sup>.</sup> <sup>We</sup> <sup>note</sup> <sup>that</sup> <sup>there</sup> <sup>are</sup> <sup>also</sup> <sup>other</sup> <sup>possible</sup> <sup>approaches</sup> <sup>proposed</sup> <sup>for</sup>
learning the short-ranged correlations. <sup>24,25</sup>
R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>)</sup> <sup>or</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_ +
the
Figure S6: Architecture of the neural networks. Two neural networks are trained to represent the one-body direction
correlation functionals one for the anion, _c_ R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>; [</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>+</sup> <sup>_; ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>−]),</sup> <sup>and</sup> <sup>one</sup> <sup>for</sup> <sup>the</sup> <sup>cation,</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_ + <sup>(</sup> <sup>_z_</sup> <sup>; [</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>+</sup> <sup>_; ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>−]).</sup> <sup>The</sup> <sup>output</sup>
R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>; [</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>+</sup> <sup>_; ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>−]),</sup> <sup>and</sup> <sup>one</sup> <sup>for</sup> <sup>the</sup> <sup>cation,</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_ +
functionals one for the anion, _c_ R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>; [</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>+</sup> <sup>_; ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>−]),</sup> <sup>and</sup> <sup>one</sup> <sup>for</sup> <sup>the</sup> <sup>cation,</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_ + <sup>(</sup> <sup>_z_</sup> <sup>; [</sup> <sup>_ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>+</sup> <sup>_; ȷ_</sup> <sup>R</sup> <sup>_;_</sup> <sup>−]).</sup> <sup>The</sup> <sup>output</sup>
shapes indicate the variable batch size (“None”) and the number of nodes for each layer.
S7.3. Training procedure
For the first generation of training, we separate the 2400 independent simulations into 480 for test set, 480
for validation set and 1440 for training set. Each model was trained for 200 epochs in batches of size 256 and
the learning rate was decreased exponentially by 5% per epoch from an initial value of 0.001. This results in
a best mean average error of 0.034 over the validation set for each model, which is of the same order as the
estimated average noise of the simulation data for the one-body direct correlation functions. Employing this
model in cDFT for the full LR system gives the results in Fig. S7(a).
S12
In addition to these GCMC simulations with randomized potentials, we further add to the data set 128
simulations in which the SR mimic system experiences the external potential describing the 9-3 Lennard Jones
soft walls at randomized values of the chemical potentials. With the updated dataset, we then separate the
independent simulations into 505 for test set, 505 for validation set and 1518 for training set. Following the
same training procedure as before, this results in a best mean average error of 0.038 and employing this model
in cDFT for the full LR system gives the results in Fig. S7(b).
For the last generation of training, we first perform cDFT for the LR full system under an electric field _Ez_
to generate 72 different data points. From cDFT, we also obtain to the corresponding one-body correlation
functions _c_ R <sup>(1)</sup> _;_ <sup>for</sup> <sup>the</sup> <sup>mimic</sup> <sup>system</sup> <sup>in</sup> <sup>the</sup> <sup>process.</sup> <sup>Using</sup> <sup>the</sup> <sup>resulting</sup> <sup>number</sup> <sup>density</sup> <sup>predicted</sup> <sup>from</sup> <sup>cDFT,</sup>
we perform 72 finite-field MD simulations (see Sec. S6) of the LR system and collect the density profiles
_ȷ_ = _ȷ_ R _;_ . These 72 combinations of { _ȷ_ R _;_ } and _c_ R <sup>(1)</sup> _;_ <sup>make up the final extra data to the total dataset, which</sup>
is split into 508 for test set, 508 for validation set and 1524 for training set. Following the same training
procedure as before, the final model results in a best mean average error of 0.032 and employing this model
in cDFT for the full LR system gives the results in Fig. S7(c).
The main computational cost lies in obtaining the training data. The training of the neural networks was
done on a GPU (NVIDIA GeForce RTX 3060) in a few hours. Once the neural network has been trained,
it can be used relatively inexpensively, with a typical minimization taking 1-2 minutes on a single CPU core
(and faster on a GPU).
S7.4. Bulk correlation matching
To reduce noise in the bulk structure predictions, we also obtained models regularized with bulk two-body
direct correlation functions as proposed in Ref. 25. With the bulk simulation of the short-ranged system,
we obtain the planar bulk two-body direct correlation functions as described in Section. S6. From the
neural network representation of the one-body direct correlation functions, these are the functional derivatives
obtainable via automatic differentiation
<sup>(2)</sup> <u>R</u> _<u>;</u>_ <u>−</u>
R _;_ −− <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}) =</sup> <sup>_‹c_</sup> <sup>(1)</sup>
<sup>~~(~~</sup> <sup>2)</sup> <u>R</u> _<u>;</u>_ <u>+</u>
R _;_ ++ <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}) =</sup> <sup>_‹c_</sup> <sup>(1)</sup>
<sup>(2)</sup> <u>R</u> _<u>;</u>_ <u>+</u>
R _;_ +− <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}) =</sup> <sup>_‹c_</sup> <sup>(1)</sup>
_~~c~~_ <sup>(2)</sup>
<u>R</u> <sup>(1)</sup> _<u>;</u>_ <u>−</u> <sup>(0; [{</sup> <sup>_ȷ_</sup> <sup><u>}])</u></sup>
_‹ȷ_ −( _z_ )
˛˛˛˛˛
{ _ȷ_ }={ _ȷ_ b}
_;_
_;_
= <sup>_‹c_</sup> <u>R</u> <sup>(1)</sup> _<u>;</u>_ <u>−</u>
<u>R</u> <sup>(1)</sup> _<u>;</u>_ <u>−</u> <sup>(0; [{</sup> <sup>_ȷ_</sup> <sup><u>}])</u></sup>
_~~c~~_ <sup>~~(~~</sup> <sup>2)</sup>
<u>R</u> <sup>(1)</sup> _<u>;</u>_ <u>+</u> <sup>(0; [{</sup> <sup>_ȷ_</sup> <sup><u>}])</u></sup>
_‹ȷ_ +( _z_ )
˛˛˛˛˛
_‹ȷ_ +( _z_ )
{ _ȷ_ }={ _ȷ_ b}
˛˛˛˛˛
_:_
_~~c~~_ <sup>(2)</sup>
<u>R</u> <sup>(1)</sup> _<u>;</u>_ <u>+</u> <sup>(0; [{</sup> <sup>_ȷ_</sup> <sup><u>}])</u></sup>
_‹ȷ_ −( _z_ )
˛˛˛˛˛
{ _ȷ_ }={ _ȷ_ b}
{ _ȷ_ }={ _ȷ_ b}
˛˛˛˛˛
To implement bulk correlation matching, we consider the loss functions
- <sup>inhom</sup> + _¸_ pcL− <sup>pc</sup>
+ <sup>inhom</sup> + _¸_ pcL+ <sup>pc</sup>
L− = _¸_ inhomL− <sup>inhom</sup>
+
L+ = _¸_ inhomL <sup>inhom</sup>
- <sup>pc</sup> <sup>_;_</sup>
+ <sup>pc</sup> <sup>_;_</sup>
in which the losses from local inhomogeneous one-body learning are given as
h
h
R <sup>(1)</sup> _;_ - _;_ sim <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>}</sup> <sup>_i_</sup> <sup>)</sup>
i2
i2
=
L− <sup>inhom</sup>
_i_
_c_ R <sup>(1)</sup> _;_
_;_
_;_
<sup>_c_</sup> R <sup>(1)</sup> _;_ + _;_ sim <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>}</sup> <sup>_i_</sup> <sup>)</sup>
+ =
L <sup>inhom</sup>
_i_
X
_i_
X
_i_
_c_ R <sup>(1)</sup> _;_
R <sup>(1)</sup> _;_ - <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>}</sup> <sup>_i_</sup> <sup>) −</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_
R <sup>(1)</sup> _;_ + <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>}</sup> <sup>_i_</sup> <sup>) −</sup> <sup>_c_</sup> R <sup>(1)</sup> _;_ +
and the losses from pair-correlation matching are
h
h
<sup>~~(~~</sup> R <sup>2)</sup> _;_ −− _;_ sim <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>)</sup>
i2
i2
<sup>~~(~~</sup> R <sup>2)</sup> _;_ +− _;_ sim <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>)</sup>
i2
i2
L− <sup>pc</sup> <sup>=</sup>
_i_
_~~c~~_ <sup>~~(~~</sup> R <sup>2)</sup> _;_
<u>h</u>
h
_~~c~~_ <sup>~~(~~</sup> R <sup>2)</sup> _;_
_~~c~~_ <sup>~~(~~</sup> R <sup>2)</sup> _;_
<sup>~~(~~</sup> R <sup>2)</sup> _;_ +− <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>) −</sup> <sup>_~~c~~_</sup> <sup>~~(~~</sup> R <sup>2)</sup> _;_
<sup>~~(~~</sup> R <sup>2)</sup> _;_ +− <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>) −</sup> <sup>_~~c~~_</sup> <sup>~~(~~</sup> R <sup>2)</sup> _;_ +
(S46)
(S47)
(S48)
(S49)
<sup>~~(~~</sup> R <sup>2)</sup> _;_ −− _;_ sim <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>)</sup>
<sup>~~(~~</sup> R <sup>2)</sup> _;_ +− _;_ sim <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>)</sup>
L+ <sup>pc</sup> <sup>=</sup>
_i_
X
_i_
X
_i_
_~~c~~_ <sup>~~(~~</sup> R <sup>2)</sup> _;_
+
+
_;_
_:_
<sup>~~(~~</sup> R <sup>2)</sup> _;_ −− <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>) −</sup> <sup>_~~c~~_</sup> <sup>~~(~~</sup> R <sup>2)</sup> _;_
<sup>~~(~~</sup> R <sup>2)</sup> _;_ ++ <sup>(</sup> <sup>_z_</sup> <sup>; {</sup> <sup>_ȷ_</sup> <sup>b}</sup> <sup>_i_</sup> <sup>) −</sup> <sup>_~~c~~_</sup> <sup>~~(~~</sup> R <sup>2)</sup> _;_
S13
Figure dashed S7: lines Performance are shown for of neural cDFT networks employing trained different with (a) generations randomized of potential, the neural (b) networks with additional for { _c_ slitR <sup>(1)}</sup> confinement <sup>.</sup> <sup>Results</sup> <sup>in</sup>
and (c) with additional electric fields. Overall, good agreement with simulation data (solid lines) is achieved for the
equation of state (first row), randomized inhomogeneous profiles (second row), slit confinement (third row) and the
electric double layer (final row). The addition of data with electric fields in the final model improves the contact
density predictions.
S14
The constant factors _¸_ inhom and _¸_ pc control the relative influence of inhomogeneous one-body matching
and pair-correlation matching by weighting the respective loss terms, for which we employ _¸_ inhom = 1 and
_¸_ pc = 0 _:_ 0001.
S8. ELECTRIC DOUBLE LAYER
The formula for the contact density sum rule for an ionic system at a charged wall is given as <sup>26–28</sup>
Z
<u>s</u> _;_ (S50)
<sup>_<u>ıf</u>_</sup> _›_ <sup>_f_</sup> <sup>2</sup>
_P_ = −
__
X
d _z ȷ_ ( _z_ ) <sup><u>d</u></sup> <sup>_<u>V</u>_</sup> <sup><u>(</u></sup> <sup>_<u>z</u>_</sup> <sup><u>)</u></sup>
<u>s</u>
<sup>_<u></u>_</sup> <sup><u>(</u></sup> <sup>_<u>z</u>_</sup> <sup><u>)</u></sup>
d _z_ - <sup><u>2</u></sup> <sup>_<u>ıf</u>_</sup> _›_ <sup>_f_</sup> <sup>2</sup>
where _ff_ s is the surface charge density of the wall. In this section, we will examine the extent to which the
cDFT presented in this work obeys Eq. S50. To this end, we focus on systems with the RPM confined in a
slit made by two walls with non-electrostatic potential
_z_ min
„ _<u>f</u>_ <u>LJ</u> _f_
_z_
“ _<u>f</u>_ <u>LJ</u> _f_ ”9
«9
«3 <sup>#</sup>
”3 <sup>–</sup>
_z_ min
„ _<u>f</u>_ <u>LJ</u> _f_
_z_
“ _<u>f</u>_ <u>LJ</u> _f_
_V_ ( _z_ ) = _"_ LJ
15
» <u>2</u>
+ _"_ LJ
<u>2</u>
" 15
_;_ (S51)
where _z_ min = 5
two oppositely charged walls are not represented explicitly. Instead, the surface charge is directly determined
` 2 ´1 _=_ 6 _ff_ LJ, _ff_ LJ = _ff_, _›_ LJ = _k_ B _T_ under an electric field _Ez_ . In the finite field simulations, the
by the displacement field _Dz_
where _z_ min =
5
` 2
s <sup>(sim)</sup> = <sup><u>⟨</u></sup> <sup>_<u>D</u>_</sup> 4 _ı_ <sup>_<u>z</u>_</sup> <sup><u>⟩</u></sup>
<sup>_<u>Ez</u>_</sup> (S52)
4 _ı_ <sup>+ ⟨</sup> <sup>_Pz_</sup> <sup>⟩</sup> <sup>_:_</sup>
_ff_ s <sup>(sim)</sup>
= <sup>_<u>Ez</u>_</sup>
<sup>_<u>D</u>_</sup> 4 _ı_ <sup>_<u>z</u>_</sup> <sup><u>⟩</u></sup> 4 _ı_
This approach assumes that the electrolyte screens perfectly, which is reasonable if the region occupied by
the electrolyte is thick enough. From the cDFT, we obtain the surface charge by integrating the equilibrium
charge densities:
__
X
_ff_ s <sup>(cDFT)</sup>
= −
d _z_
0
Z _Lz_ _=_ 2
_qȷ_ ( _z_ ) _:_ (S53)
We obtained the equilibrium density profiles from cDFT and simulations for the RPM at _˛—_ - = _˛—_ + ∈
[−13 _:_ 5 _;_ −8 _:_ 5] under _Ez_ ∈ [0 _:_ 0 _;_ 0 _:_ 26] V <sup>˚</sup> A−1, a subset of which are shown in Fig. S8(a). The cDFT performs
[−13 _:_ 5 _;_ −8 _:_ 5] under _Ez_ ∈ [0 _:_ 0 _;_ 0 _:_ 26] V <sup>˚</sup> A−1, a subset of which are shown in Fig. S8(a). The cDFT performs
R focuses on this density
the best for density range _ff_ <sup>3</sup> _ȷ_ ± ∈ [0 _:_ 1 _;_ 0 _:_ 4], as expected since the training data for _c_ <sup>(1)</sup>
region. Higher accuracy for lower and higher density would likely be achieved by extending the training data
R focuses on this density
the best for density range _ff_ <sup>3</sup> _ȷ_ ± ∈ [0 _:_ 1 _;_ 0 _:_ 4], as expected since the training data for _c_ <sup>(1)</sup>
region. Higher accuracy for lower and higher density would likely be achieved by extending the training data
further. In Fig. S8(b), we verified that _ff_ s <sup>(cDFT)</sup> is in agreement with _ff_ s <sup>(sim)</sup> . Then for each cDFT result, we
evaluate the bulk pressure in Eq. S50, _P_ <sup>(LHS)</sup>, by functional integration together with the pressure correction
as presented in the main paper. The right hand side of Eq. S50, _P_ <sup>(RHS)</sup>, is evaluated by numerical integration
with the equilibrium ionic profiles from cDFT, shown in Fig. S8(c).
s <sup>(cDFT)</sup> is in agreement with _ff_ s <sup>(sim)</sup>
S15
Figure S8: Electric double layer of the RPM electrolyte in contact with a charged wall. (a) The equilibrium
ion density profiles obtained from finite field simulations (solid lines) and from cDFT (dashed lines). (b) The surface
charge densities on the wall obtained from cDFT agree with that from simulation. (c) The cDFT obeys the contact
density theorem in Eq. S50, less strictly at high density due to the fixed discretization of the density profiles obtained
from cDFT.
S16
S9. PRIMITIVE MODEL AND MULTIVALENT SYSTEM
We illustrate the generalizability of our approach to all ionic fluids by considering the primitive model (PM)
and a multivalent system. For the PM, we have changed the sizes of the anion and cation to _ff_ - = 4 _ff=_ 3 and
_ff_ + = 2 _ff=_ 3, respectively. For the multivalent system, we consider equal-sized anions and cations of diameter
_ff_, but increase the valency of the anion such that | _q_ −| _=_ | _q_ +| = 2. We use the same temperature as for the
RPM, _T_ <sup>∗</sup> = _›ffk_ B _T=_ | _q_ + _q_ −| = 0 _:_ 066.
Analogous to the RPM, for each new ionic system, reference data is generated via GCMC simulations
of ∼ 2500 systems with randomized external conditions of which ∼ 1500 are used for training and ∼ 500
respectively for validation and testing. In addition to inhomogenous profiles of the electric double layers shown
in the main paper, in Fig. S9, we show the results for the equations of state.
Figure S9: The equations of state of additional ionic systems. Prediction from cDFT is in excellent agreement with
simulations both for the restricted primitive model (blue circles), the primitive model (pink triangles) and a multivalent
system (cyan pentagons).
REFERENCES
1A. Z. Panagiotopoulos, “Molecular simulation of phase equilibria: simple, ionic and polymeric fluids,” Fluid Ph. Equilib 76,
97–112 (1992).
2A. T. Bui, “GCMC with Gaussian truncated potentials,” `https://github.com/annatbui/GCMC` (2024).
3A. P. Thompson, H. M. Aktulga, R. Berger, D. S. Bolintineanu, W. M. Brown, P. S. Crozier, P. J. in ’t Veld, A. Kohlmeyer,
S. G. Moore, T. D. Nguyen, R. Shan, M. J. Stevens, J. Tranchida, C. Trott, and S. J. Plimpton, “LAMMPS - a flexible
simulation tool for particle-based materials modeling at the atomic, meso, and continuum scales,” Comput. Phys. Commun
271, 108171 (2022).
4S. J. Cox, “Gaussian truncated potentials in LAMMPS,” `https://github.com/uccasco/LMFT` (2020).
5S. J. Cox, “Dielectric response with short-ranged electrostatics,” Proc. Natl. Acad. Sci. U.S.A 117, 19746–19752 (2020).
6T. Schneider and E. Stoll, “Molecular-dynamics study of a three-dimensional one-component model for distortive phase transitions,” Phys. Rev. B 17, 1302–1322 (1978).
7A. H¨artel, M. Janssen, S. Samin, and R. v. Roij, “Fundamental measure theory for the electric double layer: implications for
blue-energy harvesting and water desalination,” J. Phys. Condens. Matter 27, 194129 (2015).
8A. H¨artel, S. Samin, and R. van Roij, “Dense ionic fluids confined in planar capacitors: in- and out-of-plane structure from
classical density functional theory,” J. Phys. Condens. Matter 28, 244007 (2016).
9J. Jover, A. J. Haslam, A. Galindo, G. Jackson, and E. A. M¨uller, “Pseudo hard-sphere potential for use in continuous
molecular-dynamics simulation of spherical and chain molecules,” J. Chem. Phys 137, 144505 (2012).
10A. V. Brukhno, J. Grant, T. L. Underwood, K. Stratford, S. C. Parker, J. A. Purton, and N. B. Wilding, “DL ~~M~~ ONTE: a
multipurpose code for Monte Carlo simulation,” Mol. Simul. 47, 131–151 (2021).
11S. W. de Leeuw, J. W. Perram, E. R. Smith, and J. S. Rowlinson, “Simulation of electrostatic systems in periodic boundary
conditions. I. Lattice sums and dielectric constants,” Proc. R. Soc. A 373, 27–56 (1997).
12R. Hockney and J. Eastwood, _Computer_ _Simulation_ _Using_ _Particles_ (Adam-Hilger, 1988).
13J. Kolafa and J. W. Perram, “Cutoff errors in the Ewald summation formulae for point charge systems,” Mol. Simul. 9, 351–368
(1992).
14Q. Yan and J. J. de Pablo, “Hyper-parallel tempering Monte Carlo: Application to the Lennard-Jones fluid and the restricted
primitive model,” J. Chem. Phys 111, 9509–9516 (1999).
15J. K. Johnson, J. A. Zollweg, and K. E. Gubbins, “The Lennard-Jones equation of state revisited,” Mol. Phys. 78, 591–618
(1993).
S17
16J. M. Rodgers and J. D. Weeks, “Accurate thermodynamics for short-ranged truncations of Coulomb interactions in site-site
molecular models,” J. Chem. Phys 131, 244108 (2009).
17C. Zhang and M. Sprik, “Finite field methods for the supercell modeling of charged insulator/electrolyte interfaces,” Phys.
Rev. B 94, 245309 (2016).
18T. Sayer, C. Zhang, and M. Sprik, “Charge compensation at the interface between the polar nacl(111) surface and a nacl
aqueous solution,” J. Chem. Phys 147, 104702 (2017).
19T. Sayer, M. Sprik, and C. Zhang, “Finite electric displacement simulations of polar ionic solid-electrolyte interfaces: Application
to nacl(111)/aqueous nacl solution,” J. Chem. Phys 150, 041716 (2018).
20F. Sedlmeier, D. Horinek, and R. R. Netz, “Spatial correlations of density and structural fluctuations in liquid water: A
comparative simulation study,” J. Am. Chem. Soc 133, 1391–1398 (2011).
21R. J. Baxter, “Ornstein–Zernike relation and Percus–Yevick approximation for fluid mixtures,” J. Chem. Phys 52, 4559–4562
(2003).
22F. Samm¨uller, S. Hermann, D. de las Heras, and M. Schmidt, “Neural functional theory for inhomogeneous fluids: Fundamentals
and applications,” Proc. Natl. Acad. Sci. U.S.A 120, e2312484120 (2023).
23F. Chollet, _Deep_ _Learning_ _with_ _Python_ (Manning Publications, 2017).
24J. Dijkman, M. Dijkstra, R. van Roij, M. Welling, J.-W. van de Meent, and B. Ensing, “Learning neural free-energy functionals
with pair-correlation matching,” Phys. Rev. Lett. 134, 056103 (2025).
25F. Samm¨uller and M. Schmidt, “Neural density functionals: Local learning and pair-correlation matching,” Phys. Rev. E 110,
L032601 (2024).
26D. Henderson and L. Blum, “Some exact results and the application of the mean spherical approximation to charged hard
spheres near a charged hard wall,” J. Chem. Phys 69, 5441–5449 (1978).
27D. Henderson, L. Blum, and J. L. Lebowitz, “An exact formula for the contact value of the density profile of a system of
charged hard spheres near a charged wall,” J. Electroanal. Chem. 102, 315–319 (1979).
28P. A. Martin, “Sum rules in charged fluids,” Rev. Mod. Phys. 60, 1075–1127 (1988).