supplement.pdf

††thanks: email<EMAIL_ADDRESS>email:
<EMAIL_ADDRESS>email<EMAIL_ADDRESS>
# Ultrafast Enhancement of Interfacial Exchange Coupling in Ferromagnetic
Bilayer

X. Liu  Department of Applied Science, The College of William and Mary,
Williamsburg, Virginia, 23187, USA  H. C. Yuan  Key Laboratory of Micro and
Nano Photonic Structures (Ministry of Education), Shanghai Ultra-precision
Optical Manufacturing Engineering Research Center, Department of Optical
Science and Engineering, Fudan University, Shanghai, 200433, China  P. Liu
Department of Applied Science, The College of William and Mary, Williamsburg,
Virginia, 23187, USA  J. Y. Shi  Key Laboratory of Micro and Nano Photonic
Structures (Ministry of Education), Shanghai Ultra-precision Optical
Manufacturing Engineering Research Center, Department of Optical Science and
Engineering, Fudan University, Shanghai, 200433, China  H. L. Wang  S. H. Nie
State Key Laboratory of Supperlattices and Microstructures, Institute of
Semiconductors, Chinese Academy of Sciences, Beijing, 100083, China  F. Jin
Z. Zheng  Key Laboratory of Micro and Nano Photonic Structures (Ministry of
Education), Shanghai Ultra-precision Optical Manufacturing Engineering
Research Center, Department of Optical Science and Engineering, Fudan
University, Shanghai, 200433, China  X. Z. Yu  J. H. Zhao  State Key
Laboratory of Supperlattices and Microstructures, Institute of Semiconductors,
Chinese Academy of Sciences, Beijing, 100083, China  H. B. Zhao  Key
Laboratory of Micro and Nano Photonic Structures (Ministry of Education),
Shanghai Ultra-precision Optical Manufacturing Engineering Research Center,
Department of Optical Science and Engineering, Fudan University, Shanghai,
200433, China  G. Lüpke  Department of Applied Science, The College of William
and Mary, Williamsburg, Virginia, 23187, USA

###### Abstract

Fast spin manipulation in magnetic heterostructures, where magnetic
interactions between different materials often define the functionality of
devices, is a key issue in the development of ultrafast spintronics. Although
recently developed optical approaches such as ultrafast spin-transfer and
spin-orbit torques open new pathways to fast spin manipulation, these
processes do not fully utilize the unique possibilities offered by interfacial
magnetic coupling effects in ferromagnetic multilayer systems. Here, we
experimentally demonstrate ultrafast photo-enhanced interfacial exchange
interactions in the ferromagnetic Co2FeAl/(Ga,Mn)As system at low laser
fluence levels. The excitation efficiency of Co2FeAl with the (Ga,Mn)As layer
is 30-40 times higher than the case with the GaAs layer at 5 K due to a photo-
enhanced exchange coupling interaction via photoexcited charge transfer
between the two ferromagnetic layers. In addition, the coherent spin
precessions persist to room temperature, excluding the drive of photo-enhanced
magnetization in the (Ga,Mn)As layer and indicating a proximity-effect-related
optical excitation mechanism. The results highlight the importance of
considering the range of interfacial exchange interactions in ferromagnetic
heterostructures and how these magnetic coupling effects can be utilized for
ultrafast, low-power spin manipulation.

##  I Introduction

Ultrafast optical control of coherent spin dynamics in ferromagnetic
heterostructures is currently of great interest because of its significance in
spintronic devices and magnetic recording 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 .
An overwhelming amount of research is devoted to discovering non-thermal, low-
power excitation processes to circumvent the disadvantages associate with
thermal mechanisms 10 ; 11 ; 12 ; 13 ; 14 ; 15 ; 16 . One promising approach
is to make use of the interaction between selectively photo-excited carriers
and magnetization since the photo-carrier recombination time is considerably
shorter than the thermal dissipation process. Accordingly, it is ideal to
utilize the exchange-coupled ferromagnetic systems, as their magnetic
properties may respond notably to a small alteration of the exchange-coupling
strength 17 ; 18 . Therefore, the combination of a ferromagnetic (FM) metal
and a FM semiconductor is specifically favorable for such a purpose of low-
power spin manipulation because the FM semiconductor may have pronounced
carrier effect on the magnetic properties 19 . Recent studies demonstrated
femtosecond optical control of coercivity 20  and complete reversal of
magnetic hysteresis loop 21 ; 22 ; 23  in (Ga,Mn)As. Nevertheless, the
question is still open whether it is possible to drive FM magnetization at low
laser fluence through exchange coupling across metal/semiconductor
heterostructure interface.

In this article, ultrafast optical excitation of coherent spin precession is
investigated in the exchange-coupled Co2FeAl/(Ga,Mn)As bilayer with time-
resolved magneto-optic Kerr effect (TRMOKE). Upon the photoexcitation of
electron carriers in (Ga,Mn)As, a nonequilibrium charge current is induced
through the heterojunction to the majority spin bands of Co2FeAl, which
enhances the interfacial exchange coupling. The photo-excited coherent spin
precession persist to room temperature, though the precession amplitude drops
significantly around the Curie temperature of (Ga,Mn)As, indicating that the
proximity effect plays an essential role in the optical excitation mechanism
of coherent spin precession in Co2FeAl/(Ga,Mn)As bilayer. Our results promote
the development of low-energy consumption magnetic device concepts for fast
spin manipulation.

##  II Results

###  II.1 Outline of the experiments

Figure 1: Schematic illustration of TRMOKE experiments, SQUID measurements,
and experimental observation of ultrafast enhanced interfacial exchange
interaction.(a) Schematic of TRMOKE measurement geometry, depicting the
structure of the sample and the magnetization M precessing around the
effective field Heff in Co2FeAl/(Ga,Mn)As bilayer in a canted magnetization
configuration with H applied along hard axis [1-10]. (b) SQUID measurement in
Co2FeAl/(Ga,Mn)As bilayer along the easy axis [110] direction. The inset shows
the close-up around zero magnetic field. (c) SQUID measurement in
Co2FeAl/(Ga,Mn)As bilayer along the hard axis [1-10] direction. (d) TRMOKE
data from Co2FeAl/(Ga,Mn)As bilayer at 5 K, exhibiting the initial
demagnetization (-0.41 mdeg) and the subsequent 100-ps magnetization rise
(0.46 mdeg) and uniform spin precession. The red and blue curves are fits of
LLG equation. The inset shows the FFT analysis of precession frequency. (e)
TRMOKE data from Co2FeAl layer without (Ga,Mn)As layer at 5 K. The FFT
analysis for precession frequency and the precession amplitude as a function
of pump-energy density are shown as insets.

Our experimental system is a FM exchange-coupled bilayer heterostructure,
composed of a near half-metallic Heusler alloy Co2FeAl and a FM semiconductor
(Ga,Mn)As (Fig. 1), epitaxially grown on GaAs (001) substrate by molecular
beam epitaxy (MBE) (see Methods) 24 . The 10-nm thick Co2FeAl layer shows an
in-plane uniaxial magnetic anisotropy with an easy axis along the [110]
direction (Fig. 1(b)], while the 150-nm thick (Ga,Mn)As film reveals an easy
axis along the [1-10] direction below the Curie temperature Tc = 50 K 24 , as
revealed by the minor loop in Fig. 1(c).

Due to the strong coupling at the interface and the relatively strong cubic
anisotropy constant K1 of Co2FeAl, the interfacial spin alignment of the
(Ga,Mn)As layer should be very close to that in the Co2FeAl layer 24 . At low
temperature ($T<T_{c}$) a ferromagnetic alignment of Mn spins in the (Ga,Mn)As
layer is expected, whereas at high temperatures ($T>T_{c}$) Mn ions extending
a few nanometers in the (Ga,Mn)As layer remain spin-polarized due to the
ferromagnetic proximity effect 24 . Such a FM metal/semiconductor
heterostructure is ideal for examining the interfacial magnetic interactions,
due to their different magnetic anisotropy and strong interfacial exchange
coupling. Furthermore, one can envision an additional level of optoelectronic
control over the underlying exchange interaction due to the existence of spin
polarized carriers in the bilayer system.

###  II.2 Observation of ultrafast photo-enhanced exchange interactions

Coherent spin precessions in Co2FeAl/(Ga,Mn)As bilayer and a reference sample
of the Co2FeAl/GaAs bilayer are investigated by near-infrared ($\lambda=800$
nm), low-fluence ($I_{0}=5$ $\mu$J/cm2), pump-probe TRMOKE measurements (see
Methods) in a canted magnetization configuration where the magnetic field (H)
is applied along the hard axis [1-10], as depicted in Fig. 1(a). In
equilibrium, the magnetization M is along an effective field
H${}_{\textup{eff}}$, which is the sum of H, the demagnetizing field, the
anisotropy fields, and the exchange-coupling field (see Supplementary). The
s-polarized incident pump pulses create a short yet strong spin torque
$\mathbf{\tau}$(t) in the FM-coupled Co2FeAl/(Ga,Mn)As heterostructure. When
$\mathbf{\tau}$ vanishes, the magnetization M is away from its original
equilibrium orientation and starts to precess around H${}_{\textup{eff}}$, as
depicted in Fig. 1(a). The ultrafast spin precession excitation is described
by a modified Landau-Lifshitz-Gilbert (LLG) equation with the additional
torque term 17 :

$\frac{\partial\mathbf{M}}{\partial
t}=-\gamma\left(\mathbf{M}\times\mathbf{H_{eff}}\right)+\alpha\mathbf{M}\times\frac{\partial\mathbf{M}}{\partial
t}+\mathbf{\tau(t)}$ (1)

where $\gamma$ is gyromagnetic ratio and $\alpha$ is the Gilbert damping
constant.

Figure 1 (d) displays the TRMOKE result from the Co2FeAl/(Ga,Mn)As bilayer at
5 K with the pump pulse fluence $I_{0}=5$ $\mu$J/cm2 and magnetic field H =
227 Oe. Here, four mutually competing dynamic magnetization processes are
observed: (i) an initial $\sim$20 picosecond demagnetization (-0.2 mdeg), (ii)
followed by a distinct magnetization rise on a 100 ps time scale (0.2 mdeg),
(iii) the magnetization starts precessing in a damped circling way as
described by Eq. 1 and (iv) the demagnetization predominates again after the
decaying of magnetization enhancement.

The fast Fourier transform (FFT) of the TRMOKE signal is shown in the inset of
Fig. 1(d), indicating a precession frequency of around 11 GHz, which is
similar to that observed from the single Co2FeAl layer 25 . Besides, the
uniform magnetization precession exists up to the room temperature where
ferromagnetic order is absent in the (Ga,Mn)As layer. Moreover, since
(Ga,Mn)As has much smaller saturated magnetization and magnetic anisotropy,
its magnetization precession frequency is much smaller than the observed
frequency range.26 ; 27  Although the (Ga,Mn)As layer contributes to the
overall MOKE signal of the bilayer, this contribution does not affect the
amplitude of the oscillating component of the TRMOKE signal originating from
magnetization precession in the Co2FeAl layer (see Supplementary Note 6).
Therefore, we ascribe the precession signals observed in the Co2FeAl/(Ga,Mn)As
bilayer to the uniform magnetization precession of Co2FeAl, though the overall
TRMOKE signal encompasses the contribution of both layers.

Figure 1(e) shows TRMOKE results of Co2FeAl thin film directly grown on GaAs
(001) substrate (see Methods), which are remarkably different from those of
Co2FeAl/(Ga,Mn)As bilayer. First, very little picosecond demagnetization and
no magnetization rise on a 100-ps time scale are observed. Second, almost no
coherent spin precession signal can be observed with the same low excitation
fluence ($I_{0}=5$ $\mu$J/cm2) as the measurement on Co2FeAl/(Ga,Mn)As
bilayer, and small oscillations are noticeable only at higher pump energy
density, $I=15I_{0}$. Compared with the reference sample Co2FeAl/GaAs, it is
pronounced that the excitation efficiency is improved by 30-40 times in the
Co2FeAl/(Ga,Mn)As bilayer. In order to elucidate the enhanced optical
excitation mechanism, fluence-, field- and temperature-dependent TRMOKE
measurements are carried out.

###  II.3 Pump-fluence-, field-, and temperature-dependent TRMOKE studies

Figure 2: Fluence and field dependent TRMOKE studies. (a) TRMOKE results from
Co2FeAl/(Ga,Mn)As bilayer at 8 K with H applied along hard axis [1-10] for
different pump-energy densities. (b) Precession amplitude as a function of
pump-energy density for Co2FeAl/(Ga,Mn)As (red dots) and Co2FeAl/GaAs (blue
dots), respectively. The inset shows close-up of precession amplitude in
single Co2FeAl film. (c) Precession frequency as a function of applied field
along intermediate axis [100] and hard axis [1-10]. The black dots show the
experimental result. The blue and red curves are fits of LLG equation
(Supplementary). (d) Precession amplitude as a function of the applied
magnetic field for [100] (top) and [1-10] direction (bottom), respectively.
The black points show the experimental result. The blue and red lines
represent fits (Supplementary).

Figure 2(a) and 2(b) present TRMOKE results from Co2FeAl/(Ga,Mn)As bilayer as
a function of pump-pulse fluence with H = 227 Oe applied along the hard axis
[1-10]. The precession amplitude A increases with increasing pump-pulse
fluence and tends to saturate at higher pump fluences, due to thermal effect
with high laser power. Figure 2(c) and 2(d) display the extracted values of
precession frequency f and amplitude A, respectively, as a function of H
applied along the intermediate axis [100] and hard axis [1-10].

The frequency f is well fitted with Eq. 1 (red and blue curve) to derive the
magnetic anisotropies and the exchange-coupling energy $J_{\textup{ex}}$ (see
Supplementary Note 2). At $T$ = 7 K, The magnitude of $J_{\textup{ex}}$ =
326,056 erg/cm3 is comparable to the cubic anisotropy, $K_{\textup{1}}$ =
290,000 erg/cm3, indicating strong ferromagnetic exchange coupling in the
Co2FeAl/(Ga,Mn)As bilayer. The exchange-coupling term $J_{\textup{ex}}$
increases moderately from 300 K to around 50 K, and then increases
significantly afterwards (see Supplementary Note 4), which suggests a strong
exchange-coupling between Co2FeAl and (Ga,Mn)As.

The simulation of A versus H (red and blue curve), where A is assumed to be
proportional to the deviation of equilibrium magnetization $\Delta\varphi$,
also agrees well with the experimental data (black dots). At all temperatures,
only by considering the enhancement of exchange coupling energies can the
experimental data of A versus H satisfy the theoretical model (see
Supplementary Note 5). This evinces that such strong excitations of
magnetization precession originate from the photo-enhancement of interfacial
exchange coupling, where the enhancement ratio,, i.e., $\Delta
J_{\textup{ex}}$/$J_{\textup{ex}}$, is around 20% at $T$ = 7 K, 10% at $T$ =
50 K and 5% at $T$ = 300 K.

Figure 3: Temperature dependent TRMOKE studies. (a) TRMOKE data from
Co2FeAl/(Ga,Mn)As bilayer at different temperatures: 5 K, 25 K, 80 K, 170 K
and 260 K. (b) Precession amplitude as a function of temperature at different
applied fields: 227 Oe (blue triangles), 374 Oe (red circles) and 411 Oe
(black squares). Inset: temperature dependence of static magnetization in
Co2FeAl/(Ga,Mn)As bilayer.

Figure 3 shows the temperature dependence of the magnetization precession in
Co2FeAl/(Ga,Mn)As bilayer with H applied along the hard axis [1-10]. The
TRMOKE results at T = 5 K and 25 K clearly exhibit the photo-induced transient
enhancement of magnetization precession amplitude, while at T = 80 K, 170 K
and 260 K the transient deviation of magnetization is almost absent (Fig.
3(a)). Figure 3(b) shows the temperature dependence of the precession
amplitude A for three applied fields: 227 Oe, 374 Oe and 411 Oe. It is
prominent that: (i) when the temperature T is below the Curie temperature of
(Ga,Mn)As $T_{c}$ = 50 K, the precession amplitude A rapidly decreases with
increasing temperature; and (ii) when T is above $T_{c}$, A almost remains
constant up to room temperature with a small magnitude. In addition, at T = 5
K, A strongly decreases with decreasing the external field (411 Oe to 227 Oe),
while such a reduction is much smaller when T $>$ 50 K. On the other hand, the
precession amplitude of the reference sample Co2FeAl/GaAs remains unchanged
for T = 5 K $-$ 300 K, and is 3 $-$ 4 times smaller than that
Co2FeAl/(Ga,Mn)As even when T $\geqslant$ 50 K. Therefore, these facts suggest
that the proximity effect in Co2FeAl/(Ga,Mn)As plays an essential role in the
excitation of magnetization precession that is due to the optical modulation
of the interfacial exchange coupling.

##  III Discussion

Three aspects are carefully considered to elucidate the pronounced
magnetization precession excitation mechanism. First, a comparison among
magnetization precessions of Co2FeAl/(Ga,Mn)As and Co2FeAl/GaAs
heterostructures indicates a photo-induced modulation on the interfacial
exchange coupling between the Co2FeAl and (Ga,Mn)As layer. If such a
modulation is a reduction, we should expect precession amplitudes increase
dramatically with temperature increasing near and above 50 K. Because the
interfacial exchange coupling will be modulated more significantly at higher
temperatures considering it should have a similar trend as frequency (see
Supplementary Note 3). However, the temperature dependency of precession
amplitude is inconsistent with our observations under such circumstances.
Second, the precession amplitudes A versus applied fields H at all
temperatures satisfy our theoretical model only when increments are included
in interfacial exchange coupling energies $J_{\textup{ex}}$, rather than
magnetic anisotropies or saturation magnetizations. Third, the pump fluence of
5 $\mu$J/cm2 is too small to induce heat on the lattice (see Supplementary
Note 7), making it impossible to modulate the magnetic anisotropies of Co2FeAl
with thermal effect. Last, since the temperature dependence of the precession
amplitude A [Fig. 3(b)] follows the same trend with the increase of
magnetization, one may think that the photo-enhanced ferromagnetism in the
(Ga,Mn)As layer could correlate with the high-efficient excitation of coherent
spin precession. However, such a correlation should be insignificant as the
photo-enhanced magnetization of (Ga,Mn)As is less than 0.2% with a similar
pump fluence and temperature.28  Therefore, we attribute the optical
excitation mechanism of the observed magnetization precession in the
Co2FeAl/(Ga,Mn)As heterostructure to a photo-enhanced interfacial exchange
interaction. The mechanism is discussed concretely in the following.

Figure 4: Schematic of the modulation of interfacial exchange coupling via
charge transfer to the majority spin states. Transfer and recombination
process of photoexcited carriers in the Co2FeAl/(Ga,Mn)As heterostrucutre in
(a) the density of state and energy diagram and (b) the corresponding band
lineup in real space along the normal to the surface z. Red and blue solid
circles in (a) corresponds to the majority- and minority-spin electrons,
respectively. White and black solid circles in (b) denotes the holes and
electrons, respectively.

A Schottky-barrier space charge layer forms at the heterojunction and the
valence band of (Ga,Mn)As is near the Fermi level due to its p-type
semiconductor nature, as depicted in Fig. 4(b). Under the low-fluence, near-
infrared pump-light excitation, a fast demagnetization process occurs in the
Ga,Mn)As layer during $\Delta t<20$ ps due to the rapid spin-flip scattering
of the optically generated hot hole carriers with the localized Mn moments,
which corresponds to the initial dip in Fig. 1(d). At extended time delays (20
ps $<\Delta t<$ 100 ps), the hole-mediated ferromagnetic ordering enhances as
the optically generated, thermalized holes populate the spin-split bands of
the (Ga,Mn)As layer. More pronouncedly, the photoexcited excess electrons, as
shown in Fig. 4b, transfer to the interfacial Co2FeAl layer and fill the
majority-spin bands, enhancing the magnetization of Co2FeAl layer at the
interface. This results in both a spin current and a charge current that
transfers spin angular momentum into the Co2FeAl layer, modulating the FM
order of Co2FeAl at the interface and thus enhancing the interfacial exchange
coupling. On the other hand, the spin injection to the Co2FeAl layer from the
(Ga, Mn)As layer may also produce a spin torque on the Co2FeAl magnetization
due to different spin-polarization of the two FM layers. The change of the
effective field direction in the Co2FeAl layer gives rise to a transient
torque on its magnetization and therefore prominently increases the amplitude
of the photo-excited FM spin precession.

At larger time delays, the magnetization enhancement decays as the excess
spin-up electrons in the Co2FeAl layer recombines with the spin-polarized
holes in the (Ga,Mn)As through spin-polarized hole tunneling through the
Schottky spacer, and the demagnetization in the (Ga,Mn)As layers predominates
in the TRMOKE signal as the corresponding recovery process can be as long as 5
ns due to laser-induced heat effect on lattice. 29

Lastly, although the ferromagnetic ordering in the (Ga,Mn)As layer is almost
broken when $T$ $>$ 50 K, the coherent spin precession can still be excited in
the Co2FeAl layer with amplitude being 3 $-$ 4 times larger than that of
Co2FeAl/GaAs. This consolidates our conclusion that the main contribution to
the salient FM precession in Co2FeAl is the modulation of $J_{\textup{ex}}$ by
a photo-excited spin current at the interface rather than the magnetization in
the (Ga,Mn)As layer. It is noted that the magnetization precession amplitude A
exhibits very little variation and remains considerable value with
temperatures up to 300 K (Fig. 3(b)). Therefore, the spin polarization of the
photogenerated holes should correspond to the FM order of (Ga,Mn)As at the
interface, which exchange-couple with the Co2FeAl layer via the magnetic
proximity effect. In fact, Nie and coworkers have shown that even above the
Curie temperature of (Ga,Mn)As, the Mn spins in a 2.11-nm thick interfacial
layer remain spin polarized up to 300 K 24 .

##  IV Conclusion

In summary, the efficiency of coherent spin precession excitation by laser
pulses is significantly improved in the Co2FeAl/(Ga,Mn)As bilayer, where a
large interfacial exchange-coupling establishes. The low-fluence, near-
infrared pump-light excitation generates carriers in the (Ga,Mn)As layer,
resulting in a charge/spin current to the Co2FeAl majority spin states,
alternating the FM order of Co2FeAl and thus dynamically enhancing the
exchange coupling at the interface. The photo-excited coherent spin precession
lives up to room temperature, with the amplitude dropping significantly around
the Curie temperature of (Ga,Mn)As, indicating that the proximity effect plays
an essential role in the optical excitation mechanism of coherent spin
precession. Our results highlight the importance of considering the range of
interfacial exchange interactions in ferromagnetic heterostructures and
promote the development of low-energy consumption magnetic device concepts for
fast spin manipulation.

##  V Methods

Sample fabrication. Co2FeAl/(Ga,Mn)As bilayers are grown on GaAs (001)
substrates by molecular-beam epitaxy (MBE) 24 . The thickness of Co2FeAl and
Ga1-xMnxAs ($x=0.07$) layers are 10 nm and 150 nm, respectively. The bilayers
are capped with 2-nm thick Al layer to avoid oxidation. For the reference, a
single 10-nm thick Co2FeAl layer is grown on GaAs (001) substrate by MBE.
Reflection high-energy electron diffraction (RHEED) patterns, high-resolution
double-crystal x-ray diffraction (DCXRD) measurements, and high-resolution
cross-sectional transmission electron microscopy (HRTEM) reveal high-quality,
single-crystalline, epitaxial growth of the Co2FeAl and (Ga,Mn)As films 24 .

Magnetic characterization. Magnetic measurements are conducted from 300 to 5 K
in a magnetic field of 1 T using a SQUID magnetometer 24 . The magnetic
coupling at the interface between Co2FeAl and (Ga,Mn)As layers is probed with
element-resolved XMCD measurements 24 . Ab-initio density functional
calculations are performed to support the experimental results 24 .

MOKE experiments. The ferromagnetic magnetization of the exchange-coupled
Co2FeAl/(Ga,Mn)As bilayer is measured using the longitudinal MOKE setup. The
sample is illuminated with p-polarized light and the reflected s-polarized
light is detected with a photodiode. The magnetic field is applied along the
in-plane [110] or [-110] crystallographic directions. The measurements are
conducted from 5 K to above room temperature.

TRMOKE experiments. For the pump-probe TRMOKE measurements, a Ti:sapphire
oscillator laser system is employed, which produces 150-fs pulses at 800-nm
wavelength with a repetition rate of 80 MHz. The probe fluence is fixed at
$\sim$0.5 $\mu$J/cm2 and the pump fluence varies from 0.5 - 100 $\mu$J/cm2.
The probe pulses ($\lambda=800$ nm) utilize the balanced detection technique
with a half-wave plate and Wollaston prism to investigate the transient
magnetic state change along longitudinal and polar directions. The
measurements are conducted from 5 K to above room temperature.

Data analysis and simulations. The Origin 8.5 software is employed to fit the
raw TRMOKE data utilizing the build-in non-linear-fit function. The software
provides the uncertainties of precession amplitude A and precession frequency
f from least-square fitting. The Matlab software is utilized to fit the change
of f and A as functions of H with least-square methods (see Supplementary).
The error-propagation method is used to estimate the uncertainties of
interfacial exchange-coupling strength and magnetic anisotropy fields.

##  VI Data Availability

The data that support the findings of this study are available from the
corresponding author upon reasonable request.

##  VII Acknowledgments

The work at the College of William and Mary was sponsored by the DOE through
Grant No. DEFG02-04ER46127. The work at the Department of Optical Science and
Engineering, Fudan University, was supported by the National Natural Science
Foundation of China with Grant No. 11774064, National Key Research and
Development Program of China (Grant No. 2016YFA0300703), and National Key
Basic Research Program (No. 2015CB921403). The work at the State Key
Laboratory of Superlattices and Microstructures, Institute of Semiconductors,
Chinese Academy of Sciences, was supported by National Natural Science
Foundation of China with Grant No. U1632264.

##  VIII Author Contributions

X. L., P. L., H. C. Y, J. H. Z., H. B. Z., and G. L. designed and analyzed the
experiments. H. L. W., S. H. N., J. Y. S., and X. Z. Y. prepared the samples
and carried out characterizations using MOKE, RHEED, and SQUID measurements.
H. C. Y., J. Y. S., X. L., P. L., and F. J. performed the TRMOKE experiments.
X. L., P. L., H. C. Y. and J. Y. S. conducted the data analysis and
simulations. All authors discussed the results. X. L., P. L., J. H. Z., H. B.
Z., and G. L. wrote the manuscript with contributions from all authors.

##  IX Competing Interests

The authors declare no competing financial interests.

## References

  * (1) Lambert, C.-H. _et al._ All-optical control of ferromagnetic thin films and nanostructures.  _Science_ 345, 1337–1340 (2014).
  * (2) Guyader, L. L. _et al._ Nanoscale sub-100 picosecond all-optical magnetization switching in GdFeCo microstructures.  _Nat. Commun._ 6, 5839 (2015).
  * (3) Rudolf, D. _et al._ Ultrafast magnetization enhancement in metallic multilayers driven by superdiffusive spin current.  _Nat. Commun._ 3, 1037 (2012).
  * (4) hoi, G.-M. _et al._ Spin current generated by thermally driven ultrafast demagnetization.  _Nat. Commun._ 5, 4334 (2014).
  * (5) Němec, P. _et al._ Experimental observation of the optical spin transfer torque.  _Nat. Phys_ 8, 411–415 (2012).
  * (6) Tesařová, N. _et al._ Experimental observation of the optical spin–orbit torque.  _Nat. Photon._ 7, 492–498 (2013).
  * (7) Chen, J.-Y. _et al._ Time-resolved magneto-optical kerr effect of magnetic thin films for ultrafast thermal characterization.  _J. Phys. Chem. Lett._ 7, 2328–2332 (2016).
  * (8) El Hadri, M. S. _et al._ Electrical characterization of all-optical helicity-dependent switching in ferromagnetic hall crosses.  _Appl. Phys. Lett._ 108, 092405 (2016).
  * (9) Chen, J.-Y. _et al._ All-optical switching of magnetic tunnel junctions with single subpicosecond laser pulses.  _Phys. Rev. Applied_ 7, 021001 (2017).
  * (10) Mentink, J. H.  Manipulating magnetism by ultrafast control of the exchange interaction.  _J. Condens. Matter Phys._ 29, 453001 (2017).
  * (11) Kirilyuk, A., Kimel, A. V. & Rasing, T.  Ultrafast optical manipulation of magnetic order.  _Rev. Mod. Phys._ 82, 2731–2784 (2010).
  * (12) Hashimoto, Y., Kobayashi, S. & Munekata, H.  Photoinduced precession of magnetization in ferromagnetic (Ga,Mn)As.  _Phys. Rev. Lett._ 100, 067202 (2008).
  * (13) Radu, I. _et al._ Transient ferromagnetic-like state mediating ultrafast reversal of antiferromagnetically coupled spins.  _Nature_ 472, 205–208 (2011).
  * (14) Mathias, S. _et al._ Probing the timescale of the exchange interaction in a ferromagnetic alloy.  _Proc. Natl. Acad. Sci._ 109, 4792–4797 (2012).
  * (15) Stupakiewicz, A. _et al._ Ultrafast nonthermal photo-magnetic recording in a transparent medium.  _Nature_ 542, 71–74 (2017).
  * (16) Mikhaylovskiy, R. _et al._ Ultrafast optical modification of exchange interactions in iron oxides.  _Nat. Commun._ 6, 8190 (2015).
  * (17) Ma, X. _et al._ Ultrafast spin exchange-coupling torque via photo-excited charge-transfer processes.  _Nat. Commun._ 6, 8800 (2015).
  * (18) Fan, Y. _et al._ Photoinduced spin angular momentum transfer into an antiferromagnetic insulator.  _Phys. Rev. B_ 89, 094428 (2014).
  * (19) Matsubara, M. _et al._ Ultrafast optical tuning of ferromagnetism via the carrier density.  _Nat. Commun._ 6, 6724 (2015).
  * (20) Hall, K. C. _et al._ Ultrafast optical control of coercivity in GaMnAs.  _Appl. Phys. Lett._ 93, 032504 (2008).
  * (21) Astakhov, G. V. _et al._ Magnetization manipulation in (Ga,Mn)As by subpicosecond optical excitation.  _Appl. Phys. Lett._ 86, 152506 (2005).
  * (22) Wang, J. _et al._ Memory effects in photoinduced femtosecond magnetization rotation in ferromagnetic GaMnAs.  _Appl. Phys. Lett._ 94, 021101 (2009).
  * (23) Zhu, Y. _et al._ Ultrafast dynamics of four-state magnetization reversal in (Ga,Mn)As.  _Appl. Phys. Lett._ 95, 052108 (2009).
  * (24) Nie, S. H. _et al._ Ferromagnetic interfacial interaction and the proximity effect in a ${\mathrm{Co}}_{2}\mathrm{FeAl}/(\mathrm{Ga},\mathrm{Mn})\mathrm{As}$ bilayer.  _Phys. Rev. Lett._ 111, 027203 (2013).
  * (25) Yuan, H. C. _et al._ Different temperature scaling of strain-induced magneto-crystalline anisotropy and Gilbert damping in Co2FeAl film epitaxied on GaAs.  _Appl. Phys. Lett._ 105, 072413 (2014).
  * (26) Rozkotová, E. _et al._ Light-induced magnetization precession in GaMnAs.  _Applied Physics Letters_ 92, 122507 (2008).
  * (27) Qi, J. _et al._ Coherent magnetization precession in GaMnAs induced by ultrafast optical excitation.  _Appl. Phys. Lett._ 91, 112506 (2007).
  * (28) Wang, J. _et al._ Ultrafast Enhancement of Ferromagnetism via Photoexcited Holes in GaMnAs.  _Phys. Rev. Lett._ 98, 217401 (2007).
  * (29) Zahn, J. P. _et al._ Ultrafast studies of carrier and magnetization dynamics in GaMnAs.  _J. Appl. Phys._ 107, 033908 (2010).

in 1,…,0 See pages \x, of supplement.pdf


# Learning Neural Free-Energy Functionals with Pair-Correlation Matching

Jacobus Dijkman  Computational Chemistry group, Van ’t Hoff Institute for
Molecular Sciences, University of Amsterdam, Science Park 900, 1098 XH
Amsterdam, The Netherlands  Amsterdam Machine Learning Lab, Informatics
Institute, University of Amsterdam, Science Park 900, 1098 XH Amsterdam, The
Netherlands  AI4Science Lab, University of Amsterdam, Science Park 900, 1098
XH Amsterdam, The Netherlands  Marjolein Dijkstra  Soft Condensed Matter &
Biophysics group, Debye Institute for Nanomaterials Science, Utrecht
University, Princetonplein 5, 3584 CC Utrecht, The Netherlands  René van Roij
Institute for Theoretical Physics, Utrecht University, Princetonplein 5, 3584
CC Utrecht, The Netherlands  Max Welling  Amsterdam Machine Learning Lab,
Informatics Institute, University of Amsterdam, Science Park 900, 1098 XH
Amsterdam, The Netherlands  Jan-Willem van de Meent  Amsterdam Machine
Learning Lab, Informatics Institute, University of Amsterdam, Science Park
900, 1098 XH Amsterdam, The Netherlands  Bernd Ensing  Computational Chemistry
group, Van ’t Hoff Institute for Molecular Sciences, University of Amsterdam,
Science Park 900, 1098 XH Amsterdam, The Netherlands  AI4Science Lab,
University of Amsterdam, Science Park 900, 1098 XH Amsterdam, The Netherlands

###### Abstract

The intrinsic Helmholtz free-energy functional, the centerpiece of classical
density functional theory (cDFT), is at best only known approximately for 3D
systems, which hampers the use of cDFT as a powerful tool for describing the
intricate thermodynamic equilibrium properties and structural aspects of
classical many-body systems. Here we introduce a method for learning a quasi-
exact neural-network approximation of this functional by exclusively training
on a dataset of radial distribution functions. This method based on pair-
correlation matching circumvents the need to sample costly heterogeneous
density profiles in a wide variety of external potentials and hence offers a
pathway to significantly ease the computational demands for future approaches
to extend machine learning for cDFT to arbitrary three-dimensional systems.
For a supercritical 3D Lennard-Jones system we demonstrate that the learned
neural free-energy functional accurately predicts planar inhomogeneous density
profiles under various complex external potentials obtained from simulations,
while simultaneously offering precise thermodynamic predictions far outside
the training regime.

††preprint: APS/123-QED Figure 1: 1. Bulk densities in planar geometry
$\rho(z_{i})=\rho_{b}$ and radial distribution functions $g(r)$ are sampled
from Monte Carlo simulations of homogeneous bulk systems of Lennard-Jones
particles. Each $g(r)$ is converted to the laterally integrated bulk direct
correlation function $\bar{c}_{b}^{(2)}(|z_{i}-z_{j}|)$ by employing the
Ornstein-Zernike equation. 2. Through automatic differentiation (autodiff2)
[1, 2], the neural functional $F_{\theta}^{(2)}$ is optimized to fit the
Hessian of the model output with respect to input density profiles to
$\bar{c}_{b}^{(2)}(|z_{i}-z_{j}|)$. 3. The optimized model can then be applied
in cDFT to obtain non-uniform equilibrium density profiles through automatic
differentiation (autodiff) and the free energy $F_{\theta}^{(2)}$ for a system
of Lennard-Jones particles subjected to arbitrary external potentials.

Inhomogeneous many-body systems play a profound role in both science and
technology, with examples spanning from p-n junctions in semiconducting solid-
state devices to phenomena like hydrogen bubbles in electrolysers, or gas
adsorption in porous materials [3, 4, 5, 6, 7, 8]. Density functional theory
(DFT) is a powerful theoretical framework to describe the thermodynamic
equilibrium properties and the structure of such systems, relying solely on
the one-body density profile $\rho({\bf r})$. Classical DFT (cDFT) relies on
the existence of an excess free-energy functional
$\mathscr{F}_{\text{exc}}[\rho]$, which describes the non-ideal contribution
to the total intrinsic free-energy functional $\mathscr{F}[\rho]$ and
encompasses the inter-particle interactions. However, the main bottleneck of
cDFT is that this functional is in general unknown, and hence, one has to rely
on developing accurate approximations for the excess free-energy functionals.

Historically, the field of cDFT has emphasized development of analytical
approximations for $\mathscr{F}_{\text{exc}}[\rho]$, often based on
thermodynamics and (direct) pair correlations derived from approximate
closures of the Ornstein-Zernike equation of bulk systems [9]. For instance,
the highly successful Fundamental Measure Theory (FMT) for hard spheres is
deeply connected to the Percus-Yevick closure [10], and many functionals for
systems with soft Van der Waals or Coulombic interactions build on mean-field
and mean-spherical approximations [11, 9].

In recent years, there has been a resurgence of cDFT developments facilitated
by machine learning (ML) methods, which employ virtually exact thermodynamic
and structural data obtained from explicit many-body simulations to learn
data-driven representations of the excess free-energy functional
$\mathscr{F}_{\text{exc}}[\rho]$. In the classical regime, the first machine-
learned cDFTs focused on supercritical Lennard-Jones fluids, for which
explicit approximate functional forms for $\mathscr{F}_{\text{exc}}[\rho]$
were fitted to density profiles in external fields obtained from simulations,
both for 1D [12] and 3D systems in planar geometry [13]. Recent work, once
again leveraging simulations of density profiles in a variety of external
potentials, has shown that a neural approximation of the functional derivative
$\delta\mathscr{F}_{\text{exc}}/\delta\rho$ for hard-sphere systems
outperforms FMT [14] in accurately estimating inhomogeneous density profiles.

In this Letter, we introduce a neural free-energy functional that we train
using pair-correlation matching, a novel optimization objective that matches
the Hessian of the neural approximation to pair correlations of particles. We
show that pair-correlation matching yields a neural functional that accurately
predicts the complete excess free energy for a one-component system of
interacting particles. The differentiable nature of this neural functional
allows access to, and learning from, various structural and thermodynamic
properties by utilizing the first and second functional derivatives of
$\mathscr{F}_{\text{exc}}[\rho]$. Unlike previous ML approaches to cDFT [12,
13, 14], our neural functional is trained by directly learning pair
correlations from radial distribution functions sampled from short simulations
of homogeneous bulk systems (illustrated in Fig. 1), rather than inferring
from a costly dataset of inhomogeneous densities. We demonstrate that this
neural free-energy functional can be applied in the cDFT framework to achieve
accurate estimates for inhomogeneous density profiles in external fields
without ever having seen any inhomogeneous densities during training.
Simultaneously, the neural free-energy functional provides accurate estimates
of the excess free energy.

Classical DFT is a grand-canonical framework that relies on the fact that the
variational grand potential $\Omega[\rho]$ is uniquely determined by the
particle density via

$\Omega[\rho]=\mathscr{F}[\rho]+\int\mathrm{d}r\rho(\mathbf{r})\left(V_{\text{ext
}}(\mathbf{r})-\mu\right),$ (1)

with $\mathscr{F}[\rho]$ representing the intrinsic Helmholtz free energy,
$V_{\text{ext}}(\mathbf{r})$ the external potential, and $\mu$ the chemical
potential. For a given particle-particle interaction and temperature, the
unique density functional $\mathscr{F}[\rho]$ determines the thermodynamic and
structural equilibrium properties for any chemical potential and external
potential. Within cDFT, it is conventional to split the intrinsic free-energy
functional into an ideal and excess contribution,
$\mathscr{F}[\rho]=\mathscr{F}_{\text{id}}[\rho]+\mathscr{F}_{\text{exc}}[\rho]$.
The ideal-gas contribution is exactly known as

$\mathscr{F}_{\text{id}}[\rho]=\frac{1}{\beta}\int\operatorname{dr}\rho(\mathbf{r})\big{(}\ln\rho(\mathbf{r})\Lambda^{3}-1\big{)},$
(2)

with $\beta=1/k_{B}T$ and $\Lambda$ the thermal wavelength.

Mathematical proofs exist [15] stating that (i) the equilibrium density
profile, denoted here as $\rho_{0}({\bf r})$, minimizes $\Omega[\rho]$, and
(ii) the equilibrium grand potential equals $\Omega[\rho_{0}]$. Clearly, once
$\mathscr{F}[\rho]$ for the system of interest is known, the Euler-Lagrange
equation $\delta\Omega[\rho]/\delta\rho({\bf r})|_{\rho_{0}}=0$ can be solved
to find $\rho_{0}({\bf r})$ and $\Omega[\rho_{0}]$. The Euler-Lagrange
equation takes the form

$\rho_{0}(\mathbf{r})=\frac{1}{\Lambda^{3}}\exp\left(\beta\mu-\left.\beta\frac{\delta\mathscr{F}_{\text{exc}}[\rho]}{\delta\rho(\mathbf{r})}\right|_{\rho=\rho_{0}}-\beta
V_{\text{ext }}(\mathbf{r})\right).$ (3)

This self-consistency relation can be leveraged to find $\rho_{0}(\mathbf{r})$
through recursive iteration. Since $\rho_{0}(\mathbf{r})$ is dependent on
$\mathscr{F}_{\text{exc}}[\rho]$ through the first functional derivative
$\delta\mathscr{F}_{\text{exc}}[\rho]/\delta\rho(\mathbf{r})$, previous
approaches to leveraging machine learning for cDFT [12, 13, 14] involve
training a model to capture
$\delta\mathscr{F}_{\text{exc}}/\delta\rho(\mathbf{r})$, which can be derived
from sampled inhomogeneous equilibrium density profiles and employing Eq.(3).

Figure 2: Evaluation of neural free-energy functionals $F_{\theta}^{(1)}$ and
$F_{\theta}^{(2)}$, where $F_{\theta}^{(1)}$ is optimized by matching
inhomogeneous one-body densities and $F_{\theta}^{(2)}$ by pair-correlation
matching in the homogeneous bulk. a) Density profiles of a Lennard-Jones
system in a planar geometry characterized by an external potential (shown in
gray) at a chemical potential of $\beta\mu=0$ obtained from DFT using
$F_{\theta}^{(1)}$ and $F_{\theta}^{(2)}$ and the mean-field approximation
$F_{\text{exc}}^{\text{MF}}$, along with the simulated density profile. b)
Comparison of the free-energy estimates using $F_{\theta}^{(1)}$,
$F_{\theta}^{(2)}$, and $F_{\text{exc}}^{\text{MF}}$ for the specific external
potential shown in a), for the same chemical potential of $\beta\mu=0$. c)
Integrated absolute error (IAE) between density profiles obtained from DFT
using $F_{\theta}^{(1)}$, $F_{\theta}^{(2)}$, and
$F_{\text{exc}}^{\text{MF}}$, along with the densities sampled from
simulation. d) Absolute error of the excess free energy from DFT and
simulations. c)/d) Data is shown for 150 distinct external potentials,
evaluated across the range $-4<\beta\mu<6$, with steps of
$\Delta\beta\mu=0.1$. The area of the mean $\pm$ standard deviation is
colored. The error is shown up to the point where the DFT iterations stop to
converge to a solution within 1000 iterations. e) The pressure and the
chemical potential obtained from DFT and simulations. f) The laterally
integrated direct correlation function $\bar{c}_{b}^{(2)}(z)$ at
$\rho_{b}\sigma^{3}=0.5$ and the radial distribution function $g(r)$ obtained
from simulation and DFT.

In this work, we train a convolutional neural network to directly learn the
excess free energy $\mathscr{F}_{\text{exc}}[\rho]$, enabling the
straightforward calculation of functional derivatives by
(auto-)differentiating the neural functional with respect to its inputs. We
focus on 3D systems in a planar geometry, where the excess free energy of a
system of area $A$ is a functional of the density $\rho(z)$, which is constant
across any plane parallel to the $xy$-plane, i.e., $\rho(z)=\rho(x,y,z)$ with
$\rho(x,y,z)=\rho(x^{\prime},y^{\prime},z)$ for all
$(x,y),(x^{\prime},y^{\prime})$ within the confines of $A$. We represent the
excess free-energy functional $\mathscr{F}_{\text{exc}}[\rho]$ as a neural
network $F_{\theta}^{(2)}(\rho_{1},\cdots\rho_{n})$, with $\rho_{i}$ the
density at grid point $z_{i}$ for $i\in\\{1,\ldots,n\\}$, network parameters
$\theta$, and where the upper index ‘$(2)$’ indicates that the neural network
is optimized for pair correlations of bulk systems as obtained from
simulations.

The functional derivative $\delta\mathscr{F}_{\text{exc}}/\delta\rho(z_{i})$
is defined as the limit of the partial derivative $\lim_{\Delta z\rightarrow
0}(1/\Delta z)\partial F_{\theta}^{(2)}/\partial\rho_{i}$ with
$\rho_{i}=\rho(z_{i})$ and $\Delta z$ the (uniform) grid spacing. We leverage
this relationship by employing automatic differentiation (autodiff) to
approximate the first and second functional derivatives of
$\mathscr{F}_{\text{exc}}[\rho]$ on a finite grid by $(1/\Delta z)\partial
F_{\theta}^{(2)}/\partial\rho_{i}$ and $(1/\Delta
z)^{2}\partial^{2}F_{\theta}^{(2)}/\partial\rho_{i}\partial\rho_{j}$,
respectively. Here we note that the latter is related to the laterally
integrated direct correlation function $\bar{c}_{b}^{(2)}(|z_{i}-z_{j}|)$
through

$\frac{-\beta}{A(\Delta
z)^{2}}\frac{\partial^{2}F_{\theta}^{(2)}}{\partial\rho_{i}\partial\rho_{j}}=\bar{c}_{b}^{(2)}(|z_{i}-z_{j}|)\equiv\int_{|z_{i}-z_{j}|}^{\infty}dr\>2\pi
r\>c_{b}^{(2)}(r),$ (4)

where the direct correlation function $c^{(2)}_{b}(r)$ of homogeneous bulk
fluids at density $\rho_{b}$ are obtained from simulated radial distribution
functions $g(r)$ through the bulk Ornstein-Zernike equation

$c^{(2)}_{b}(r)=\frac{1}{2\pi^{2}}\int_{0}^{\infty}\frac{\sin(kr)}{kr}\left(\frac{\hat{h}(k)}{1+\rho_{b}\hat{h}(k)}\right)k^{2}dk,$
(5)

with $\hat{h}(k)$ the Fourier transform of the total correlation function
$h(r)=g(r)-1$ [9, 16]. Thus we train our neural network such that its Hessian
$\partial^{2}F_{\theta}^{(2)}/\partial\rho_{i}\partial\rho_{j}$ represents
well the laterally integrated direct correlation function obtained from
homogeneous bulk simulations [16]. We will refer to this approach as pair-
correlation matching.

We illustrate the power of this methodology for systems interacting with a
Lennard-Jones potential truncated at $r_{\text{cut}}=4\sigma$ with $\sigma$
the particle diameter, shifted upwards by $\epsilon_{\text{cut}}=0.98\cdot
10^{-3}\epsilon$ with $\epsilon$ the well depth, at a temperature
$k_{B}T/\epsilon=2$, i.e. above the critical point. Setting $\Lambda=\sigma$
throughout, we perform grand-canonical Monte Carlo (GCMC) simulations of
homogeneous bulk systems at a variety of chemical potentials
$\beta\mu\in[-4,0.5]$, resulting in bulk densities
$\rho_{b}\sigma^{3}\in[0.02,0.67]$. We employ $10^{9}$ trial moves in a cubic
box with an edge length $L=10\sigma$ (hence with area $A=L^{2}$ and volume
$V=L^{3}$) and apply periodic boundary conditions. We sample $g(r)$ and
$\rho_{b}$ and convert each $g(r)$ to $\bar{c}_{b}^{(2)}(z)$ using Eqs. (4)
and (5) with a grid-spacing $\Delta z=\sigma/32$. We create a data set of 800
combinations of $\bar{c}_{b}^{(2)}(z)$ and $\rho_{b}$, from which we learn the
parameters $\theta$ of $F_{\theta}^{(2)}$. The neural network architecture of
$F_{\theta}^{(2)}$ is a six-layer convolutional neural network with periodic
padding [17] to match the system’s periodic boundary conditions. Each
convolution uses a kernel size of 3 with a dilation rate of 3. The number of
channels per hidden layer is configured as follows: $[16,16,32,32,64,64]$,
such that $\theta$ consists of 24.4K parameters [16].

To evaluate the accuracy of our neural excess free-energy functional
$F_{\theta}^{(2)}$, we compare it to the Van der Waals-like mean-field
approximation $F_{\text{exc}}^{\text{MF}}$, which treats the attractions of
Lennard-Jones particles as a perturbation on the hard-sphere system, as
implemented in PyDFTlj [3]. We use the White-Bear mark II version of FMT for
the excess free energy of the hard-sphere system [18]. Additionally, we
compare to $F_{\theta}^{(1)}$, which is a neural functional trained by
minimization of the error between $(1/\Delta z)\partial
F^{(1)}_{\theta}/\partial\rho_{i}$ and
$\delta\mathscr{F}_{\text{exc}}/\delta\rho(z_{i})$ rather than by pair-
correlation matching. This neural functional is trained on a dataset of 800
non-uniform densities, subjected to the same set of chemical potentials as
before. By approximating $\delta\mathscr{F}_{\text{exc}}/\delta\rho(z_{i})$ by
the gradient $(1/\Delta z)\partial F^{(n)}_{\theta}/\partial\rho_{i}$ for
$n=1$ and 2, both neural functionals are applied in Picard iterations [19, 20,
21] to obtain DFT estimates for the equilibrium density profiles of
inhomogeneous systems according to Eq. (3) [16].

The DFT results for an exemplary external potential at $\beta\mu=0$ are shown
in Fig. 2a, where we observe that the neural functionals $F_{\theta}^{(1)}$
and $F_{\theta}^{(2)}$ provide similar estimates, both outperforming
$F_{\text{exc}}^{\text{MF}}$. For the same external potential, we evaluate the
accuracy of DFT estimates for the free energy for a range of chemical
potentials $-4<\beta\mu<6$ (Fig. 2b). We compare with the excess free energy
obtained from GCMC simulations through thermodynamic integration [16]. We
observe that both neural functionals outperform $F_{\text{exc}}^{\text{MF}}$
within the range of $\mu$ values in the training set, exhibiting good
agreement with the simulations. The DFT estimates are shown until the DFT
iterations diverge and errors become unmanageable. This reveals that
$F_{\theta}^{(1)}$ diverges rapidly when extrapolating beyond the training
set, even earlier than $F^{\text{exc}}_{\text{MF}}$. In contrast,
$F_{\theta}^{(2)}$ is capable of converging to a solution far beyond the
trained $\mu$ range.

For a more detailed comparison of the performance of the free-energy
functionals for various inhomogeneous systems, we performed separate DFT
calculations for 150 distinct external potentials, evaluated across the range
$-4<\beta\mu<6$. For both the density estimates (Fig. 2c) and the free energy
estimates (Fig. 2d), we observe excellent agreement between the
$F_{\theta}^{(1)}$ and $F_{\theta}^{(2)}$ functionals and simulated data. They
demonstrate similar performance for $\mu$ values within the training set
range, and outperform the $F_{\text{exc}}^{\text{MF}}$ functional for all
evaluated external potentials (Fig. 2). Again, we observe that
$F_{\theta}^{(2)}$ surpasses $F_{\theta}^{(1)}$ when extrapolating beyond the
$\mu$ range encountered during training.

Additionally, the free-energy functionals can be applied in a uniform density
setting to obtain access to the bulk pressure

$P(\rho_{b})=\left(\frac{\delta\mathscr{F}_{\text{exc}}}{\delta\rho}\Big{|}_{\rho_{b}}+k_{B}T\right)\rho_{b}-\mathscr{F}_{\text{exc}}[\rho_{b}]/V,$
(6)

and the chemical potential $\mu$ following Eq. (3). Again, we find excellent
agreement of both neural functionals with simulations within the train set,
and superior agreement of $F_{\theta}^{(2)}$ at higher densities, as shown in
Fig. 2e. Lastly, we demonstrate that $F_{\theta}^{(2)}$ compared to both
$F_{\theta}^{(1)}$ and $F^{\text{exc}}_{\text{MF}}$ provides accurate
estimates for the laterally integrated direct correlation function
$\bar{c}_{b}^{(2)}(z)$ and the radial distribution function $g(r)$ as shown in
Fig. 2f for $\rho_{b}\sigma^{3}=0.5$. Here, we approximate
$\bar{c}_{b}^{(2)}(z)$ by $(-\beta/A(\Delta
z)^{2})\partial^{2}F_{\theta}/\partial\rho_{i}\partial\rho_{j}$ with
$z=|z_{i}-z_{j}|$. To derive the radial distribution function, we first
numerically calculate $c_{b}^{(2)}(r)$ from $\bar{c}_{b}^{(2)}(z)$ using

$-\left.\frac{1}{2\pi}\left(\frac{1}{z}\frac{d\bar{c}_{b}^{(2)}(z)}{dz}\right)\right|_{z=r}=c_{b}^{(2)}(r).$
(7)

We then obtain $g(r)$ using the Ornstein-Zernike equation. To suppress
artefacts stemming from numerical transformations in the region for
$g(r)\rightarrow 0$, we apply a noise-reducing filter [16].

Summarizing, our results lead to the remarkable observation that our neural
free-energy functional $F_{\theta}^{(2)}$ is robust and accurate for non-
uniform density systems, even far beyond its training range, solely by
training on pair correlation functions in homogeneous bulk systems. These
observations show that generating a large dataset of density profiles across a
wide range of external potentials is not necessary to train an accurate neural
free-energy functional. Instead, only a dataset of radial distribution
functions from bulk systems is needed. This work thus represents a significant
advancement in the field of cDFT, enabling applications to systems in
arbitrary three-dimensional geometries, as accurate sampling of three-
dimensional density profiles is considerably more expensive than sampling the
one-dimensional radial distribution function. We expect that extensions of
this method to mixtures of simple fluids and to particles with orientation
degrees of freedom should also be possible.

Unlike the density profile, the radial distribution function is experimentally
available through X-ray diffraction. This suggests the potential to use pair-
correlation matching to directly construct the excess free energy of a
molecular system from the true radial distribution function obtained from
experiments, bypassing the dependence on simulations with model interaction
approximations such as the Lennard-Jones potential.

In conclusion, this work introduces a generic machine learning approach to
obtain classical free-energy functionals through pair-correlation matching. We
showed how to learn a neural-network representation of the excess free-energy
functional of a generic simple fluid by solely learning the direct
correlations from the radial distribution function obtained from uniform
density simulations. Through pair-correlation matching, we attain a neural
free-energy functional that enables simultaneous and direct access to both the
excess free energy and the density of a system of interacting particles in any
external environment.

## Acknowledgements

The authors acknowledge the University of Amsterdam Data Science Centre for
financial support. M.D. acknowledges funding from the European Research
Council (ERC) under the European Union’s Horizon 2020 Research and Innovation
Program (Grant Agreement No. ERC-2019-ADG 884902 SoftML). J.W.M. acknowledges
funding from the European Union’s Horizon Framework Programme (Grant agreement
ID: 101120237).

## References

  * Baydin  _et al._ [2018] A. G. Baydin, B. A. Pearlmutter, A. A. Radul, and J. M. Siskind, Automatic differentiation in machine learning: a survey, J. Machine Learn. Res. 18, 1 (2018).
  * Paszke  _et al._ [2017] A. Paszke, S. Gross, S. Chintala, G. Chanan, E. Yang, Z. DeVito, Z. Lin, A. Desmaison, L. Antiga, and A. Lerer, Automatic differentiation in PyTorch, NIPS Autodiff Workshop (2017).
  * Soares  _et al._ [2023] E. d. A. Soares, A. G. Barreto Jr., and F. W. Tavares, Classical Density Functional Theory Reveals Structural Information of H2 and CH4 Fluids Adsorbed in MOF-5 (2023), arxiv:2303.11384 [cond-mat, physics:physics] .
  * Guo  _et al._ [2016] F. Guo, Y. Liu, J. Hu, H. Liu, and Y. Hu, Classical density functional theory for gas separation in nanoporous materials and its application to CH4/H2 separation, Chem. Eng. Sci. 149, 14 (2016).
  * Guo  _et al._ [2018] F. Guo, Y. Liu, J. Hu, H. Liu, and Y. Hu, Fast screening of porous materials for noble gas adsorption and separation: A classical density functional approach, Phys. Chem. Chem. Phys. 20, 28193 (2018).
  * Guo  _et al._ [2020] F. Guo, Y. Liu, J. Hu, H. Liu, and Y. Hu, Screening of Porous Materials for Toxic Gas Adsorption: Classical Density Functional Approach, Ind. Eng. Chem. Res. 59, 14364 (2020).
  * Fu  _et al._ [2015] J. Fu, Y. Tian, and J. Wu, Classical density functional theory for methane adsorption in metal-organic framework materials, AIChE J. 61, 3012 (2015).
  * Liu and Liu [2016] Y. Liu and H. Liu, Classical Density Functional Theory for Fluids Adsorption in MOFs, in  _Metal-Organic Frameworks_, edited by F. Zafar and E. Sharmin (InTech, 2016).
  * Hansen and McDonald [2013] J.-P. Hansen and I. R. McDonald, Theory of Simple Liquids, in  _Theory of Simple Liquids_ (Elsevier, 2013).
  * Roth [2010] R. Roth, Fundamental measure theory for hard-sphere mixtures: A review, J. Phys. Condens. Matter 22, 10.1088/0953-8984/22/6/063102 (2010).
  * Cats  _et al._ [2021a] P. Cats, R. Evans, A. Härtel, and R. Van Roij, Primitive model electrolytes in the near and far field: Decay lengths from DFT and simulations, J. Chem. Phys. 154, 10.1063/5.0039619 (2021a), arxiv:2012.02713 .
  * Lin and Oettel [2019] S. C. Lin and M. Oettel, A classical density functional from machine learning and a convolutional neural network, SciPost Phys. 6, 1 (2019), arxiv:1811.05728 .
  * Cats  _et al._ [2021b] P. Cats, S. Kuipers, S. De Wind, R. Van Damme, G. M. Coli, M. Dijkstra, and R. Van Roij, Machine-learning free-energy functionals using density profiles from simulations, APL Mater. 9, 10.1063/5.0042558 (2021b), arxiv:2101.01942 .
  * Sammüller  _et al._ [2023] F. Sammüller, S. Hermann, D. De Las Heras, and M. Schmidt, Neural functional theory for inhomogeneous fluids: Fundamentals and applications, Proc. Natl. Acad. Sci. USA 120, e2312484120 (2023).
  * Evans [1979] 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).
  * Dijkman  _et al._ [2024] J. Dijkman, M. Dijkstra, R. Van Roij, M. Welling, J.-W. Van de Meent, and B. Ensing, Supplementary materials of ”learning neural free-energy functionals with pair-correlation matching”, (2024).
  * Alguacil  _et al._ [2021] A. Alguacil, W. G. Pinto, M. Bauerheim, M. C. Jacob, and S. Moreau, Effects of boundary conditions in fully convolutional networks for learning spatio-temporal dynamics (2021), arxiv:2106.11160 [physics] .
  * Hansen-Goos and Roth [2006] 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).
  * Roth [2006] R. Roth, Introduction to Density Functional Theory of Classical Systems: Theory and Applications, Lecture Notes (2006).
  * Edelmann and Roth [2016] M. Edelmann and R. Roth, A numerical efficient way to minimize classical density functional theory, J. Chem. Phys. 144, 074105 (2016).
  * Mairhofer and Gross [2017] J. Mairhofer and J. Gross, Numerical aspects of classical density functional theory for one-dimensional vapor-liquid interfaces, Fluid Phase Equilibria 444, 1 (2017).