Heterogeneous bubble nucleation dynamics

Abstract Heterogeneous nucleation is the most effective mechanism for the inception of phase transformation. Solid walls and impurities act as a catalyst for the formation of a new thermodynamic phase by reducing the activation energy required for a phase change, hence enhancing nucleation. The formation of vapour bubbles close to solid, ideally flat, walls is addressed here by exploiting a mesoscale description that couples diffuse interface modelling of the two-phase vapour–liquid system with fluctuating hydrodynamics, extending previous work by the authors on homogeneous nucleation. The technical focus of this work is to directly account for hydrophobic or hydrophilic walls through appropriate boundary conditions compliant with the fluctuation–dissipation balance, a crucial point in the context of fluctuating hydrodynamics theory. This methodology provides access to the complete dynamics of the nucleation process, from the inception of multiple bubbles up to their long-time macroscopic expansion, on time and spatial scales unaffordable by standard techniques for nucleation, such as molecular dynamics. The analysis mainly focuses on the effect of wall wettability on the nucleation rate, and, albeit qualitatively in agreement with classical nucleation theory predictions, it reveals several discrepancies to be ascribed to layering effects in the liquid close to the boundary and to bubble–bubble interactions. In particular, it is found that, close to moderately hydrophilic surfaces, the most probable nucleation events occur away from the wall through a homogeneous mechanism.


Introduction
Equilibrium systems exhibit thermal fluctuations. At the macroscopic level, in the so-called thermodynamic limit, such fluctuations are usually irrelevant. However, for small systems, below the micrometre scale, fluctuations are always crucial. Given the equilibrium configuration maximizing the system entropy under the relevant constraints, the probability density function (p.d.f.) of a fluctuation can be taken to be proportional to the exponential of the entropy decrease brought about by the fluctuation (Einstein 1956). The p.d.f. gives access to the equilibrium correlation function of the fluctuating field and provides information on the ensuing relaxation dynamics, which must obey the relevant fluctuation-dissipation balance (see e.g. De Groot & Mazur 2013). Within this general framework, under special circumstances, the effect of fluctuations emerges to the macroscale and determines the large-scale dynamics. In these most interesting cases, a (mesoscale) model able to bridge the gap between the macroscopic scale of interest and the microscopic level governed by fluctuations is urgently needed. After Landau & Lifshitz's seminal work (see the reprinted version in Landau & Lifshitz (1980)), several coarse-grained models have been proposed to include thermal fluctuations in hydrodynamic descriptions, at both continuum (Fox & Uhlenbeck 1970) and discrete (Español, Serrano & Öttinger 1999;Español, Anero & Zúñiga 2009) levels. These works contributed significantly to the growing field of 'fluctuating hydrodynamics', fostering interest in the numerical solution of the related stochastic partial differential equations (SPDEs) (Donev et al. 2010Balboa et al. 2012;Delong et al. 2013). Mesoscale approaches, besides playing an important role in the theory of fluids, have significant impact in cases where stochastic fluctuations are crucial, e.g. for microfluidic design, biological systems like lipid membranes (Naji, Atzberger & Brown 2009), Brownian engines and molecular motors (Peskin, Odell & Oster 1993;Detcheverry & Bocquet 2012).
Among the variety of fluctuation-induced effects, nucleation, the incipit of phase transitions in metastable fluids, is ubiquitous. It occurs, for instance, during bubble cavitation (Brennen 2013) and boiling (Carey 2018) as well as in freezing rain (Cao et al. 2009) and in crystal formation more generally (Lutsko 2019). Metastability implies that the transition is an activated process, i.e. an amount of energy is required to overcome the barriers separating different metastable basins. In particular, a liquid sustains a tensile condition reaching pressures well below the equilibrium vapour tension without forming a vapour phase. Equivalently, metastability is observed in superheated fluids, where bubble formation occurs far above the boiling temperature. In these conditions, bubble nucleation must be interpreted in statistical terms, with the probability of phase change related to the level of superheating or stretching of the liquid (Brennen 2013). However, notwithstanding the extremely large tensile strength of ultra-pure water, which is able to sustain up to 1 kbar tensions in specially designed experimental conditions (El Mekki Azouzi et al. 2013), bubbles are very common in real life. In fact, bubble nucleation is most often favoured by impurities or dissolved gas nuclei, which strongly lower the energy barrier and exponentially enhance the bubble formation rate. A similar effect is induced by solid boundaries. Close to the wall, the reduction of the energy barrier to nucleation depends on the wetting properties of the surface as measured by the contact angle. For instance, recent experimental works show how the wettability of ultra-smooth surfaces influences the onset temperature for pool boiling in superheated liquids (Bourdon et al. 2012Malavasi et al. 2015). In all the aforementioned cases, energy barrier crossing is due to stochastic fluctuations, which activate the phase transition (Jones, Evans & Galvin 1999;Kashchiev & Van Rosmalen 2003;Lohse & Prosperetti 2016). The accurate and thorough modelling of thermodynamics (i.e. metastability) and thermal fluctuations is then crucial to correctly reproduce nucleation dynamics.
With few exceptions (see e.g. Allen, Valeriani & ten Wolde 2009;Marchio et al. 2019), our current understanding of nucleation is built on quasi-static descriptions such as classical nucleation theory (CNT) (Blander & Katz 1975) or more recent extensions thereof (Lutsko & Durán-Olivencia 2015). CNT provides the basic interpretative framework in terms of simple energetic arguments and allows the estimation of energy barriers and nucleation rates in homogeneous conditions. Although introducing substantial simplifications, e.g. the shape of the embryo or the existence of a sharp interface between phases that retain their bulk thermodynamic properties despite their nanometric size, CNT is a powerful and predictive tool for the investigation of nucleation phenomena. It is easily extended to heterogeneous conditions, e.g. solid boundaries (Ward et al. 1983). From a thermodynamic standpoint, there are two major contributions to the work of vapour bubble formation: (i) the (positive) energy spent to form the liquid-vapour interface, the product of surface tension and interface area; and (ii) the (negative) work released in transforming liquid into vapour, proportional to bubble volume and vapour-liquid pressure difference. The (positive) surface energy prevails at small radii, whereas at larger radii the negative volume contribution is dominant. The maximum work is achieved at the critical radius, which, in the context of CNT, corresponds to the energy barrier to be overcome for activating the phase change. As intuitively expected on geometrical grounds (see § 2 for a more complete discussion), the surface contribution is lowered for wall-attached bubbles, since the surface of a spherical cap is smaller than the corresponding full sphere, entailing a larger probability of nucleating a bubble at the surface than in the bulk.
For vapour condensation and solidification from dilute solutions, the embryos grow by aggregation of mother-phase molecules into the cluster, a process described in terms of kinetic theory and attachment/detachment rates (Oxtoby 1992). Bubbles are more elusive (Shen & Debenedetti 2003) since the embryo, basically a region depleted of molecules, is more like a void than a molecular cluster. Since CNT describes microscopic objects in macroscopic terms and deals with embryos as if they had the same uniform thermodynamic properties as the stable phase (vapour for bubble nucleation), it cannot predict the energy barriers vanishing at spinodal conditions. Other more fundamental approaches like density functional theory (DFT) (Oxtoby & Evans 1988;Shen & Debenedetti 2001) and CNT extensions (Lutsko & Durán-Olivencia 2015;Lutsko 2018) have been proposed, addressing and correcting some CNT artifacts. Brute-force molecular dynamics (MD) simulations, although in principle representing a powerful tool (Novak, Maginn & McCready 2007;Diemand et al. 2014), can hardly cope with metastability, given the large disparity between atomistic and nucleation time scales. Specialized rare-event techniques (Bolhuis et al. 2002;Allen, Frenkel & ten Wolde 2006;Menzl et al. 2016) overcome the problem but are still limited to equilibrium, quasi-static conditions excluding dynamic effects. Forward flux methods may (Wang, Valeriani & Frenkel 2008) partially remove the limitation of quasi-static approaches but share the problem of being confined to extremely small spatial and time scales. Indeed, in general, atomistic approaches, given their extremely high computational cost, are confined to small systems of a few nanometres in extension, in many cases very far from the target technological application.
Recently, a novel approach in the context of continuum mechanics, based on a diffuse interface description of the two-phase vapour-liquid system endowed with thermal fluctuations in the spirit of fluctuating hydrodynamics (Landau & Lifshitz 1980), has been exploited to address the bubble nucleation process (Gallo, Magaletti & Casciola 2017, 2018Gallo et al. 2020) in homogeneous conditions and the boiling process close to neutrally wettable surfaces (Magaletti, Georgoulas & Marengo 2020). The model is robust from both the thermodynamic and the statistical points of view. For equilibrium systems, its deterministic ingredients can be traced back to the more fundamental DFT description with a squared-gradient approximation of the excess energy (Lutsko 2011) and, in general, can be framed in the context of non-equilibrium statistical mechanics, e.g. the GENERIC framework (Öttinger & Grmela 1997;Espanol 2001). The approach has been shown to be able to capture the rich hydrodynamics of a multiphase system, such as phase transformation, latent heat release, shock emission and topological changes (Magaletti, Marino & Casciola 2015;Magaletti et al. 2016). The square-gradient approximation was also used to address phase change and spreading of droplets (Teshigawara & Onuki 2010) or the thermodynamics of boiling (Laurila et al. 2012). The stochastic ingredients introduced to model thermal fluctuations obey the fluctuation-dissipation balance (Fox & Uhlenbeck 1970) and reproduce the statistics of the fluctuating fields (Chaudhri et al. 2014).
The aim of this work is to extend our previous studies to heterogeneous nucleation by focusing on spontaneous vapour bubble nucleation on a flat solid surface. A detailed derivation of the model and related boundary conditions is presented, and results of numerical simulations are produced to demonstrate the potential of the proposed approach. In doing so, some of the material discussed by the authors in previous papers -in particular, the diffuse interface model for non-isothermal fluids with a general equation of state (Magaletti et al. , 2016 and fluctuating hydrodynamics for homogeneous nucleation (Gallo et al. 2017(Gallo et al. , 2020 -is reviewed to present a comprehensive description of the model. The paper is structured as follows. In § 2 a brief review of CNT is provided, with a particular focus on heterogeneous conditions and nucleation in the microcanonical NVE ensemble (constrained number, volume and energy). In order to correctly take into account the solid-fluid interaction that determines the wetting properties of the surface in the diffuse interface modelling, an analytic form of the solid-wall free energy is derived in § 3. Its expression connects bulk-phase thermodynamics and contact angle with the fluid density at the wall. Next, § 4 is devoted to the Navier-Stokes equations with capillarity, with particular attention paid to the constitutive relations induced by the new boundary terms. The new energetic contribution associated with the solid-fluid interaction is found to modify the fluctuation statistics ( § 5), still preserving the fluctuation-dissipation balance in the general setting ( § 6). In ( § 7) explicit expressions are provided for a particular case. The whole model is assembled together in § 8, combining deterministic and stochastic contributions. In § 9 numerical validation against theoretical statistical properties of thermal fluctuations is provided and a detailed analysis of heterogeneous nucleation for changing surface wetting characteristics is presented. Conclusions and the future perspective are finally drawn in § 10.

Classical nucleation theory
Classical nucleation theory (CNT) (Ward et al. 1983;Kashchiev 2000;Brennen 2013) provides the fundamental understanding of bubble nucleation in a metastable liquid, for both homogeneous (bubble forming inside the bulk liquid) and heterogeneous conditions (bubble forming in contact with an extraneous phase, usually a solid with given geometry and chemical properties). Although classical, it is reviewed here to put the new material discussed in the paper in the proper perspective.
For a vapour bubble nucleating on a flat solid surface with prescribed contact angle φ (and neglecting gravity), CNT models the bubble as a spherical cap of radius R on top of the flat solid surface (figure 1a). The system is described in terms of free energy difference with respect to the pure liquid, Homogeneous where liquid (outside) and vapour (inside) are assumed to be in their respective bulk states and are separated by sharp interfaces from the neighbouring phases. In the above expression, the subscripts L, V and S refer to liquid, vapour and solid phases, respectively, Δp = p V − p L is the vapour-liquid pressure difference (the Laplace pressure), V V is the bubble volume, A LV , A SV and A LS are the liquid-vapour, solid-vapour and liquid-solid interface areas, respectively, with γ LV , γ SV and γ LS the corresponding surface energies. The other relevant parameter is the equilibrium (or Young) contact angle φ = cos −1 ((γ SV − γ LS )/γ LV ) sketched in figure 1(a), which, according to the standard convention, is measured from the liquid-solid interface, i.e. φ < π/2 means hydrophilic. The contact angle allows the relevant geometric quantities to be re-expressed as A SV = πR 2 sin 2 φ, where A w is the total area of the solid surface and Ψ (φ) = 1 4 (1 + cos φ) 2 (2 − cos φ), representing a geometric factor that accounts for the contact angle. As φ → 0 the free energy reduces to the homogeneous case where the work required to form a bubble with radius R is It should be noted that the energy required to form a spherical cap at the wall is the fraction Ψ (φ) of that required to nucleate a bubble with the same radius in the bulk, (2.2) Since the free energy consists of two contributions -a volume term scaling with R 3 and a surface term scaling with R 2 -a free energy maximum (critical state) is attained at the critical radius which is intrinsic to the fluid and independent of surface wettability. The corresponding free energy barrier, i.e. the free energy difference between the critical and pure liquid states, is At variance with the critical radius, which is the same under both homogeneous and heterogeneous conditions, irrespective of the contact angle, the energy barrier ΔΩ * is lowered by the contact-angle-dependent factor Ψ (φ) ≤ 1 with respect to nucleation in the bulk. The free energy profiles ΔΩ(R) are shown in figure 1(b) for two contact angles, hydrophilic and hydrophobic, respectively, and compared with the homogeneous case. The role of the surface in reducing the free energy barrier below ΔΩ * hom is apparent, and nucleation over a hydrophobic wall is favoured, as expected.
Together with the energy barrier, the other crucial quantity in nucleation processes is the nucleation rate, i.e. the normalized number of supercritical bubbles formed per unit time. In the heterogeneous context, the nucleation rate is normalized per unit surface (as opposed to unit volume, as used in homogeneous conditions). The classical expression for the nucleation rate is (Blander & Katz 1975;Debenedetti 1996) where n L is the number density of liquid molecules and m their mass.
2.1. Critical bubble in the grand canonical ensemble After retracing the main features of the classical theory of the nucleation of vapour bubbles in a liquid, the analysis is now specialized for the grand canonical μVθ ensemble (with parameters the chemical potential μ, system volume V and temperature θ ). Here, at fixed volume, the two different phases (liquid and vapour) exhibit the same chemical potential and the same temperature. The analysis is explicitly conducted for the homogeneous case, the extension to the heterogeneous case being simply obtained using the geometrical function ψ(φ) that rescales the energy barrier and the critical volume. The grand canonical ensemble is particularly suitable for addressing vapour bubble nucleation, since it imposes only mechanical and thermodynamical equilibrium between phases, without enforcing macroscopic constraints. Within this setting, the liquid and vapour densities, ρ L and ρ V , respectively, follow from the temperature and chemical potential, μ L (ρ L , θ) = μ and μ V (ρ V , θ) = μ, and the critical vapour bubble radius is determined by (2.4).

Critical bubble in the microcanonical ensemble
The microcanonical NVE ensemble requires, by definition, mass, M (or equivalently number of particles N), volume V and energy E to be constrained. Clearly, when the system is large in comparison with the typical bubble size, the μVθ and the NVE ensembles are equivalent. However, for confined and crowded systems with many bubbles, the nucleation processes can be different. In fact, this difference will turn out to be important to understand the numerical results in § 9, suggesting the need to review NVE nucleation explicitly.
In the NVE ensemble the equations to be solved to determine the critical bubble are more complicated than in the previous case: The unknowns here are the liquid and vapour densities, the temperature and the bubble radius. In the equation expressing the energy constraint, E c is the interfacial (capillary) energy, which in the case of a single nucleated bubble is given by γ LV 4πR * 2 . Here, it is left as an additional parameter for reasons to be discussed in § 9. The equations of state for the internal energy of the liquid and vapour U L/V and the corresponding chemical potentials μ L/V and pressures p L/V are assumed to be given. The 'free energy landscape', for different levels of confinement, is reported in figure 2. The thermodynamic potential of the NVE ensemble, i.e. the entropy, is plotted as a function of the bubble radius, taken as reaction coordinate for the process (stability corresponds to entropy maximum). The overall picture corresponds quite well to the phenomenology observed in the μVθ system: at extreme confinement the liquid remains stable, similar to what is found in Marti et al. (2012) and Vincent & Marmottant (2017). When the available volume is large enough, a barrier separates the metastable liquid from the equilibrium state featuring a bubble. The radius of the equilibrium bubble is also reported in figure 2 as a function of confinement. The equilibrium radius increases monotonically, consistently with the familiar result that full vapour is the equilibrium state in the μVθ ensemble. The critical radii in the NVE and μVθ ensembles are substantially identical as long as the confinement is not extreme, as in the simulations to be discussed in § 9.

Thermodynamics of liquid-vapour systems at solid walls
The purpose of the present section is modelling hydrophilic/hydrophobic walls in the context of a capillary fluid à la van der Waals. In particular, the surface free energy density at the wall is explicitly determined consistently with the thermodynamics of the bulk fluid and the prescribed equilibrium contact angle. To this end, the van der Waals square-gradient approximation of the (Helmholtz) free energy functional (van der Waals 1979) is extended as where f = f b + f c , with f b the free energy density (per unit volume) of the bulk fluid at mass density ρ and temperature θ and f c = (λ/2)∇ρ · ∇ρ the capillary contribution. As detailed below, in equilibrium, this free energy model describes a smooth density profile transitioning between liquid and vapour on a typical scale , the thickness of the interface. As discussed in Anderson, McFadden & Wheeler (1998) and Lutsko (2011), this corresponds to a gradient approximation of more general, non-local descriptions, like those exploited in DFT (Tarazona & Evans 1984). The free energy contribution f w arises from the fluid-wall interactions and accounts for the wetting properties of the surface. Its explicit expression, provided by Cahn (1977) in the context of the isothermal phase field model for immiscible liquids, is extended here to the non-isothermal van der Waals square-gradient model relevant for liquid-vapour phase transitions. The NVE CNT for homogeneous fluids, showing entropy profiles ΔS θ 0 /ΔΩ * (normalized with the μVθ free energy (grand potential) barrier ΔΩ * at θ = θ 0 ) versus bubble radius R (normalized with the μVθ critical radius R * ) at changing confinement V/V * , where V * = 4 3 πR * 3 is the critical bubble volume. For volumes below V/V * = 481 no critical bubble exists: confinement is strong enough to stabilize the liquid. Above this limiting confinement, a barrier separates the metastable liquid from the stable configuration featuring a finite size bubble (maximum in the entropy, explicitly appearing in the plot only for relatively small confinement volumes). Please note that with entropy as thermodynamic potential, the sign of stable and unstable extrema are reversed with respect to the more usual cases involving free energies. Inset: Radius of the equilibrium bubble versus confinement (log scale). As the confinement is reduced (available volume increased), the size of the equilibrium bubble grows larger, to eventually grow unbounded for infinite volume to meet the μVθ prediction. Note that the curve in the inset starts at a finite (small) V/V * .
It is instrumental to introduce the entropy functional S, obtained as the functional derivative of the free energy with respect to the temperature, where the third equality holds for a temperature-independent λ (assumed here for the only purpose of simplifying the exposition). The last identity follows from the definition of the bulk entropy density s b and after the introduction of the surface entropy density s w .
For a closed and isolated thermodynamic system of given energy E 0 and mass M 0 , the constrained entropy functional (S c ) reads where l 1 and l 2 are the Lagrange multipliers enforcing mass and energy constraints. The internal energy U is By maximizing the constrained entropy, the Lagrange multipliers are identified as l 1 = −(μ b c − λ∇ 2 ρ)/θ and l 2 = 1/θ , where μ b c = ∂f b /∂ρ is the bulk chemical potential. It follows that, at equilibrium, the temperature and the (generalized) chemical potential μ c must be constant: The boundary term produces the additional requirement wheren is the outward normal, to be read as a (nonlinear) boundary condition for the density.
The above equilibrium conditions provide the relationship between density distribution and system thermodynamics. It is first illustrated for a flat interface away from solid walls (and constant λ) to set the stage for the discussion of the boundary condition at the solid surface. For a flat interface the inhomogeneous direction isŝ (i.e. ρ = ρ(s)) and the equilibrium condition (3.7) reads After multiplying (3.9) by dρ/ds and integrating between ρ ∞ = ρ V (the saturation vapour density) and ρ, one has with w b = f b − μ eq ρ the bulk Landau free energy density (grand potential). The grand potential of this unbounded inhomogeneous system is defined, as usual, as the Legendre transform of the free energy, (3.11) where w = f b + (λ/2)∇ρ · ∇ρ − μ c ρ is the grand potential density (it is worth stressing that w b and w are different, unless the system is homogeneous, the latter including interfacial effects). The surface tension is the excess grand potential density is where s i denotes the position of the Gibbs dividing surface, and the equilibrium property has been used. The definition of w[ρ], (3.11) and the equilibrium condition (3.9) provide which, combined with (3.10), yields (3.14) It should be noted that, besides the capillary coefficient λ, the surface tension depends only on the bulk grand potential density in the coexistence mass density range The model is complete after determining the explicit expression for the fluid-surface interaction term f w . The resulting expression will generalize the one proposed by Cahn (1977) for two immiscible fluids of equal density that has been exploited in several phase-field-based numerical simulations (see e.g. Jacqmin 2000; Yue, Zhou & Feng 2010;Sartori et al. 2015). The starting point to derive the proper expression for f w is the geometrical relationŝ ·n = cos φ, involving the (contact) angle between the wall-normal and interface-normal directions (see figure 3), and (3.8), which is rearranged as At equilibrium the interface-normal density variation follows from (3.10), allowing one to integrate the above equation as (3.16) This form of f w is consistent with the surface free energy of a pure vapour with density ρ V in contact with the wall, given by the solid-vapour surface tension, . Sketch of the capillary forces originating at the triple contact line. The vector normal to the wall is indicated withn, whileŝ indicates the vector normal to the interface, in the direction of the density gradient. The geometrical relationŝ ·n = cos φ holds between the vectors and the contact angle φ.
Similarly, for a pure liquid with density ρ L , (3.16) yields (3.17) which is the well-known Young equation for the equilibrium contact angle.
The expression (3.16) for the surface energy differs from the usual recipes found in the literature. Seppecher (1996), for example, proposed a linear dependence on the density, while Sibley et al. (2013) considered a third-order polynomial (see also Shen et al. 2017). The cubic ansatz is particularly tricky, since it turns out to be consistent with the present equation (3.16) for the special case of a quartic, Ginzburg-Landau, which is the most common free energy model for the Cahn-Hilliard equation (Anderson et al. 1998;Jacqmin 2000;Carlson, Do-Quang & Amberg 2010;Magaletti et al. 2013), as also noted in Laurila et al. (2012), where the authors comment that for a van der Waals fluid the third-order polynomial is just an approximation. Equation (3.16) suggests that f w cannot in general be assigned independently of fluid bulk free energy f b (ρ), a prescription that is often ignored in applications. In figure 4 we show the equilibrium configurations of a two-dimensional vapour bubble laying on a flat wall with two different wettabilities. In both cases the contact angle φ has been imposed through the boundary condition for the density field, (3.8). The critical density isoline forms the prescribed contact angle with the solid wall, as expected.
The proposed fluid-solid free energy describes density layering at the solid surface for non-neutrally wettable surfaces (cos φ / = 0). Layering is a common feature for liquids in contact with solid walls. At nanoscale, oscillations of the density field close to the wall are known to occur, as observed through X-ray scattering experiments (Huisman et al. 1997;Yu et al. 2000) or MD simulations (Sikkenk et al. 1987). They are well captured by the intrinsically non-local DFT (Tarazona & Evans 1984;Tarazona, Marini Bettolo Marconi & Evans 1987;Evans, Stewart & Wilding 2017). The possible effect on nucleation of these near-wall density oscillations cannot be addressed in the present framework, FIGURE 4. (a) Adsorption/depletion of the density field occurring in the wall-normal direction, z, as a function of the contact angle. In the main panel the bulk liquid density is ρ b = 0.48. All the quantities are expressed in Lennard-Jones units, as will be explained in § 9. Hydrophobic walls, φ > 90 • , show a reduction of the density close to the wall; the opposite behaviour is provided by hydrophilic walls. The inset shows that this layering effect is amplified when the degree of metastability is increased. (b) Vapour-liquid contact angle for hydrophobic (top) and hydrophilic (bottom) solid surfaces.
which, due to the intrinsic limitations of purely local theories, should be understood as a coarse-grained description of the actual phenomenology, resulting in a monotonic density layering at the wall. A related approach is described in (Carey & Wemhoff 2005), where the fluid-solid interaction is accounted for through an interaction potential between solid and fluid particles, leading, through a mean-field theory, to a disjoining pressure, which induces a similar monotonic density stratification at the wall.
In the hydrophilic case, the liquid-solid interaction accumulates fluid at the wall, resulting in a local increase of density. Conversely, the lower affinity of hydrophobic walls produces a depletion region with layers of the order of a few nanometres -see figure 4 reporting the density profiles obtained by applying the boundary condition (3.8) for different wetting properties of the surface. This aspect is important for heterogeneous nucleation, since it facilitates the process at hydrophobic walls while discouraging it on hydrophilic surfaces (see the more detailed discussion in § 9).

The capillary Navier-Stokes model
Aim of the present section is deriving constitutive relations for stresses and energy fluxes consistent with the Clausius-Duhem formulation of thermodynamic irreversibility (De Groot & Mazur 2013) for non-homogeneous, wall-bounded capillary systems -see Magaletti et al. (2016) for the case of a homogeneous fluid.
The theory explicitly takes into account capillary effects occurring in the fluid, not only at the vapour-liquid interface but also in the stratified layer close to a substrate (typically, a solid wall). Stratification at a substrate is induced by the combination of capillarity (the λ|∇ρ| 2 contribution to the free energy (3.1)) and surface free energy f w (ρ, θ ) included in the boundary contribution. Associated with the surface free energy term there is a surface entropy with density s w = −∂f w /∂θ . In order to account for possible additional entropy production terms arising from the wall potential, the system can be thought of as comprising fluid, solid and a concentrated, zero-thickness layer separating fluid and solid. In total generality the layer may possess a (concentrated) mass density ρ w (units of mass per unit area) and a velocity v w , hence a kinetic energy density 1 2 ρ L |v w | 2 , and a total surface energy density, the sum of internal, u w = f w + θ∂f w /∂θ , and kinetic energy density. The surface free energy density is assumed to depend on the mass density of the fluid in contact with the layer ρ, on the concentrated mass density associated with the layer ρ w and on temperature. The equations for the layer establish mass, momentum and energy conservation, and will be used in the limit of vanishing layer mass density, ρ w , such that, in the limit, the surface potential recovers the form f w (ρ, θ ). In order not to burden the discussion, the governing equations inside the layer will be described in detail in appendix A. Here, only the results of the procedure are reported, consisting of a relaxation condition for the contact angle in the diffuse capillary context.
For a capillary fluid enclosed in a volume D, the conservation laws for mass M, momentum P and total energy E are (the inclusion of mass forces is straightforward) where n is the outward unit vector normal to the boundary, v is the fluid velocity, e = u + 1 2 ρ|v| 2 is the total energy density, with u = u b + u c the internal energy density defined in (3.4), and Σ and q the are stress tensor and heat flux, respectively, to be determined in the following. The local form of the conservation laws is obtained by applying Green's theorem, and take the classical form Under the assumption of local equilibrium, the above equations can be manipulated, as usual in the context of non-equilibrium thermodynamics (De Groot & Mazur 2013), to obtain an evolution equation for the entropy density. Namely, the internal energy evolution is first derived by subtracting the kinetic energy contribution from the total energy density, where D/Dt = ∂/∂t + v · ∇ is the material derivative andũ = u/ρ is the specific internal energy. By definitionũ =f + θs, withf = ( f b + (λ/2)|∇ρ| 2 )/ρ -see (3.1) and comments below -and hence its differential reads The partial derivatives of the specific free energy are derived from its definition, (3.1), providing with p the pressure. The material derivative of the density gradient (second term on the right-hand side of (4.5)) is evaluated from the mass conservation equation (Magaletti et al. 2016), After substitution of (4.5) and (4.6) into (4.3), a few more elementary steps isolate the entropy time derivative as where the divergence of the entropy flux (first term on the right-hand side) and two entropy production terms appear. By requiring a positive entropy production (Clausius-Duhem inequality) and by restricting the analysis to linear constitutive prescriptions for stress and energy flux capillary effects are explicitly included in the model. The irreversible part of the stress is the classical Newtonian viscous tensor, where η > 0 is the dynamic viscosity. Since viscosity is not expected to play a crucial role in nucleation (e.g. in CNT it is completely neglected), the simplest choice −2η/3 is made here for the second viscosity coefficient. A general value can be, however, straightforwardly included in the model as needed, e.g. to describe damping in nonlinear bubble oscillations (Scognamiglio et al. 2018). Similarly, the classical Fourier's heat flux, with k > 0 the thermal conductivity, provides the irreversible part of the energy flux. It is worth noting that the capillary (square density gradient) term in the free energy leads to capillary stresses included in the reversible part of the dynamics (no entropy production), as expected from the general thermodynamic definition of surface tension. The field equations for a capillary fluid, (4.2), (4.8) and (4.9), require an additional boundary condition for the density field. The equilibrium considerations of § 3 suggest the density normal derivative as the appropriate prescription, (3.8). This result can be extended to non-equilibrium conditions through a procedure strictly similar to that just reviewed for the bulk, applied in this case to the layer adjoining the fluid and solid surface. The layer is described in terms of suitable fields defined on the manifold supporting the layer that are energetically, mechanically and kinematically coupled with the neighbouring fluid. By prescribing that each entropy production term is non-negative (Clausius-Duhem inequality combined with Curie principle), linear constitutive laws for the layer stress tensor Q π and for the layer tangential heat flux q w are derived (see appendix A for derivation details).
The requirement that the entropy production associated with the layer should, in general, be non-negative leads to relaxing the equilibrium wetting condition. In this more general setting, the prescription of the equilibrium (Young) contact angle, (3.8), is replaced by the boundary equation where D w is a mobility coefficient determining the relaxation time scale. Notice that the surface free energy f w , as an equilibrium property of the system, keeps the form (3.16) obtained in § 3. This equation describes the relaxation of the contact angle towards equilibrium and can be understood as a generalization to the non-isothermal case and to general equations of state for the bulk fluid of the contact angle dynamics proposed in Jacqmin (2000), Carlson, Do-Quang & Amberg (2009, 2011 and Ren & E (2011). In what follows, the boundary term associated with (4.10) will be assumed to provide a negligible contribution to the entropy, implying the equilibrium Young's law (3.15).

Equilibrium thermal fluctuations of a wall-bounded capillary fluid
Fluids at a mesoscopic scale are subject to thermal fluctuations that need to be included in the hydrodynamic equations. The purpose of this section is discussing thermal fluctuations for a capillary fluid in contact with a solid surface. What follows falls within the theoretical framework of fluctuating hydrodynamics, first proposed by Landau & Lifshitz (1980 reprint) and systematically developed since then (Fox & Uhlenbeck 1970;Zubarev & Morozov 1983;Español et al. 2009). The theory was retraced and exploited in the context of liquid-vapour systems far from boundaries to address homogeneous bubble nucleation in a recent work . The extension of this theory to heterogeneous systems bounded by solid walls is presented here. The focus here is on a fluid enclosed between two fixed rigid solid walls to provide the static correlation functions of the fluid-phase fluctuations. In comparison with the unbounded cases, the interaction with the solid influences the fluctuating fluid field through the boundary conditions. Equilibrium thermal fluctuations were originally described by Einstein (1956), who provided the static correlation functions as a result of the entropy deviations ΔS from equilibrium, where the entropy S eq is a maximum. For the system described in § 4, the entropy consists of two contributions: the fluid, S f , and the layer entropy, S w , respectively. In § 3 the entropy deviation was expressed as a functional of mass density, δρ(x, t), velocity, δv(x, t), and temperature, δθ(x, t), fluctuations (see (3.3)).
Assuming small fluctuations with respect to the mean field, the entropy -a functional of the mass density, velocity and temperature fields -can be Taylor-expanded to second order around equilibrium (second order at least is required, since at equilibrium the first variation vanishes altogether). Explicitly, using the variables U = (ρ, ∇ρ, θ, v) T , where field derivatives higher than the density gradient will not be needed since the free energy (3.1) is quadratic in the density gradients, the entropy functional is Exploiting the well-known relations (the subscript b stands for homogeneous bulk conditions where capillary contributions do not appear) where c v is the constant-volume specific heat and c T is the isothermal speed of sound, (5.1) can be rearranged as 3) The first two rows are the volume contributions already discussed in Gallo et al. (2018). The new terms on the third line arise from the solid-liquid interaction due to the layer entropy. The first integral in the third row of (5.3) has two different contributions: the first one arises from the integration by parts of the square gradient, and the second comes from the solid-liquid energy f w . As a consequence of the static boundary condition, (3.8), the whole first integral vanishes (see the comments at the end of § 4 and appendix A): Fluctuating field correlations are most easily obtained after recasting the entropy in a form more appropriate to operational manipulations: In the above equation, δ(x −x) is the ordinary three-dimensional Dirac delta function and δ w (x w −x w ) denotes the Dirac delta function on the manifold, describing the boundary and δ 2D is the ordinary two-dimensional Dirac delta function. Integration by parts is used twice to move the Laplacian ∇ 2 from the density fluctuation δρ to the Dirac delta function. In a compact operator form, (5.5) reads with Δ = (δρ, δv, δθ) denoting the fluctuating fields, and H f and H w are diagonal, positive definite operators, defined as involves differential operators with I the 3 × 3 identity matrix and The probability distribution functional for the fluctuating fields Δ (Einstein 1956), can be approximated by exploiting the second-order approximation, (5.7), Owing to the exponential form of the probability distribution functional, the diagonal nature of the operatorĤ f together with the local dependence on temperature of the entropy, P eq can be factorized as (5.14) which implies that the fluctuations of temperature in the fluid and in the layer are statistically independent. Focusing on the fluid domain, the relevant property of the probability distribution functional is the correlation function where the integral over all the possible field fluctuations is understood on the right-hand side (path integral). It can be evaluated in closed form given the quadratic approximation for the entropy, which leads to Gaussian path integrals. The final expression is (see Gallo et al. (2018) for details) implying the following identity: From a practical standpoint, the correlation functions are obtained by solving the equivalent equationĤ are slightly different objects, (5.8)). The velocity and temperature correlations at equilibrium are straightforwardly obtained as respectively. The density correlation involves instead a differential operator, calling for the solution of the differential equation At variance with the unbounded system ), a closed-form solution of (5.21) is not readily available in the presence of the solid wall, because of the inhomogeneity of the coefficients (C T,eq = C T,eq (x)) in the linear equation for the Green's function, due to the stratification of the equilibrium density at the wall, ρ eq = ρ eq (x), which exists whenever the equilibrium contact angle differs from 90 • (neutral wettability).

Fluctuation-dissipation balance for wall-bounded capillary fluids: general theory
In a nutshell, fluctuating hydrodynamics amounts to including suitable stochastic forcing terms into the linearized version of the field equations. The noise is assumed to be generated by a linear operator (noise operator) acting on a zero-mean, delta-correlated-in-time Gaussian process (white noise). The equilibrium solution of the resulting system of SPDEs is a Gaussian field, completely determined by the correlations. After the noise operator is determined in such a way to generate the equilibrium correlations independently defined in terms of the entropy functional, the resulting SPDEs will sample the Gaussian equilibrium probability functional P f [Δ] discussed in the previous section. In other words, once the equilibrium correlation functions of the fluctuating fields are known, the fluctuation-dissipation balance (FDB) provides the explicit form of the stochastic forcing. Eventually, the capillary Navier-Stokes equations (4.2) and (4.8) completed with the additional stochastic contributions (4.9) result in a model that could be dubbed the capillary Landau-Lifshitz-Navier-Stokes (CLLNS) system. The purpose of the present section is to extend this model to the case of a wall-bounded capillary fluid. As will be shown in detail, the FDB can be satisfied keeping the noise in the form of a standard white noise. The noise terms act on momentum and energy and, also in the presence of walls, keeps the divergence form, consistently with the expected conservation properties. Special care is devoted to include the appropriate boundary conditions in the relevant operators, a crucial point in order to avoid the need to modify the structure of the noise.
The three-dimensional CLLNS system augmented with noise is where E is the total energy density, E = U + 1 2 ρ|v| 2 + 1 2 λ|∇ρ| 2 , with U the internal energy density. In the momentum and energy equations, respectively, Σ and q are the classical deterministic stress tensor and energy flux (derived in § 4), respectively. The boundary conditions consist of the no-slip/impermeability condition for velocity, zero heat flux and prescribed wall wettability at the solid surface: The stochastic forces, whose statistical properties are to be inferred from the fluctuation-dissipation theorem, are f Σ and f q . After introducing the equilibrium state U eq = (ρ eq (x), 0, θ eq ) and denoting the fluctuating fields by Δ = (δρ, δv, δθ), as previously, the state is described by U = Δ + U eq . With this notation, equations (6.1) written in a compact form are with B the operator that specifies the boundary conditions. Linearization around the equilibrium state U eq leads to ∂c v,eq ρ eq δθ ∂t = −θ eq ∂ θ p| eq ∇ · δv + k∇ 2 δθ + f q .
The linearized system can be rewritten in conservative (divergence) form with the change of variables Δ = (δρ, ρ eq δv, c v,eq ρ eq δθ) = (δρ, δπ, δι), where the (linearized) hydrodynamic operator L is and B is the (linearized) boundary conditions operator The stochastic contribution can be written through the linear operator K acting on independent white noise processes Ξ , as f = KΞ , where In three dimensions σ π is a 3 × 3 matrix whose components are scalar linear operators to be determined. The vector Ξ = (Ξ ρ , Ξ π , Ξ ι ) T collects the white noise processes for the fluctuating fields, with Ξ π = (Ξ π x , Ξ π y , Ξ π z ) T . The Gaussian process Ξ has zero mean and correlations given by with I now indicating a (5 × 5) identity matrix in Ξ space,ỹ andŷ denoting space points, and s and q time instants. It may be worth recalling that spatial and temporal Dirac delta functions carry dimensions of reciprocal space and time, respectively. Hence the noise Ξ has dimensions of reciprocal square root of time per volume. Introducing the operator L, which accounts for the differential operator (6.6) completed with the boundary conditions (6.7a,b), problem (6.5) is compactly rewritten as dΔ /dt = LΔ + f (in other words, the action of the operator L is restricted to the subspace of fluctuations that satisfy the boundary conditions). The solution can then be expressed in terms of the propagator P t = exp(Lt). (6.10) Considering that P t P −t = U, with U the relevant identity operator, and using the propagator as functional integrating factor, system (6.5) becomes where d(P −t )/dt = −LP −t and the obvious commutation LP −t = P −t L has been used. This equation can be now integrated in time, leading to the so-called mild solution (Da Prato 2012) where the last term retains memory of the initial conditions and vanishes for large times since L is a dissipative operator. Consistently, the equilibrium correlations take the explicit form where the stochastic force correlation is straightforwardly expressed in terms of the noise operator K and the stochastic process Ξ . Note that it should be stressed that the delta correlation in time for the stochastic forces is always adopted in fluctuating hydrodynamics based on the assumption of a clear scale separation between molecular and hydrodynamic time scales (Markovian dynamics) -see e.g. Duque-Zumajo et al. (2019) for additional comments.
In view of producing the explicit correlation (6.13), the Hermitian non-singular operator E −1 is assumed to exist and is able to factorize Q as ( 6.15) In this case the integrand in (6.13) would be the s derivative of P t−s E −1 P † t−s , implying that the exact integral Hence the operator E −1 does indeed exist and is the correlation matrix C f (5.16), resulting in By combining (6.15) and (6.16) the stochastic force correlation follows: where M = −LC f and O is the Onsager matrix. Relationship (6.18) is the form the celebrated FDB takes for the present system highlighting the connection between fluctuation intensity and dissipation mechanisms. The physical interpretation is that, in thermodynamic equilibrium, the response of a system to a perturbation is equivalent to the evolution of a spontaneous fluctuation. One is then enabled to infer non-equilibrium properties of a physical system from equilibrium properties.

Fluctuation-dissipation balance: explicit expression for neutrally wettable surfaces
The present section is devoted to obtain the explicit form of the stochastic forces following the general procedure outlined in the previous section. For the sake of simplicity, the contact angle φ = π/2 is assumed, in order to deal with homogeneous equilibrium fields. In this case the boundary conditions operator B, besides enforcing vanishing velocity (δπ = 0) and zero heat flux at the walls (∂δι/∂n = 0), also requires vanishing density normal derivative (∂δρ/∂n = 0) (see (6.7a,b)). These boundary conditions describe the evolution of a closed and isolated system, in the spirit of the NVE ensemble of statistical mechanics.
Compared with the general case, the above assumptions lead to homogeneous equilibrium fields (no stratification at the wall) with the advantage of facilitating the mathematical treatment. The extension to the case of generically wettable surfaces -albeit of greater complexity from the mathematical point of view -is not expected to alter the structure of stochastic forces. In fact, the wall wettability does not introduce an additional dissipation mechanism, and, as such, does not produce entropy. Hence a general solid-fluid energy is expected not to alter the fluctuation-dissipation balance.
Following the general procedure illustrated in § 6, the operators σ π and σ ι can be identified from the FBD (6.18), It should be stressed that the operator entering the definition of M is L. In practice, to solve the problem, one may start from the differential operator L, (6.6), and the correlation matrix C f , (5.16). Since the correlation matrix satisfies the boundary conditions, this leads to the same result that the actual operator L, i.e. L completed with boundary conditions, would imply. One finds 3) The entries of the matrix M are Thus, the sum of M and its hermitian conjugate M † provides the explicit expression for the square of the unknown matrix operator K, (6.8), i.e. the explicit form of the FDB, In deriving (7.10), one needs to take into account that the differential operators ∇ and ∇ 2 are effectively (and not purely formally) anti-and self-adjoint, respectively, thanks to the boundary conditions (∇ † = −∇· and (∇ 2 ) † = ∇ 2 ; appendix B). After recalling (6.8), determining K amounts to solving (7.10) component-wise, The explicit solution for the stochastic forces is f Σ = ∇ · δΣ, f q = ∇ · δq, (7.13a,b) where δΣ and δq are δΣ = 2ηk B θ eqΞ π − 1 3 2ηk B θ eq Tr(Ξ π )I, (7.14) δq = 2kk B θ 2 eq Ξ ι , (7.15) withΞ π = (Ξ π + Ξ π T )/ √ 2 a stochastic symmetric tensor field, and Ξ ι a stochastic vector, with correlations It is immediately shown that expressions (7.14) and (7.15) satisfy (7.11) and (7.12), namely The covariance of the stochastic process corresponding to the fluctuating stress is with Q Σ αβνη = 2k B θη(δ αν δ βη + δ αη δ βν − 2 3 δ αβ δ νη ). (7.21) Analogously, the covariance of the fluctuating heat flux is with Q q αβ = 2k B θ 2 eq kδ αβ . (7.23) Several comments are in order: (i) The stochastic forcing terms are in divergence form for momentum and energy (temperature) equations, and absent for mass, consistently with integral conservation principles. (ii) The correlation between the thermodynamic force of different tensor ranks is zero, consistently with the Curie-Prigogine principle, i.e. ( δq † (x,t) ⊗ δΣ(x,t) = 0). (iii) The formal expressions of the FDB, (6.18), and of the stochastic forces, (7.13a,b), are exactly the same as obtained in free space, Gallo et al. (2018), i.e. they are independent of the specific boundary conditions, as long as no additional entropy production mechanisms is implied. (iv) The presence of the wall is intrinsic to the functional representation of the operators, hence the statistical properties of the fluctuating fields will be affected by the boundary conditions, as already pointed out when commenting on the density correlation equation, (5.21).
As a final remark before closing the section, the reader should be aware that the FDB, as derived here, is strictly valid in the limit of small fluctuations about the equilibrium state, as follows from the original Landau-Lifshitz approach, which starts from the linearized Navier-Stokes equations. As common, the extension to the nonlinear case is based on the local equilibrium assumption (Bogoliubov 1946;De Zarate & Sengers 2006). The assumption consists in assuming that out-of-equilibrium fluctuation statistics can be obtained from an equilibrium state corresponding to the local hydrodynamic field. A more complete derivation of the nonlinear fluctuating hydrodynamics model for a simple fluid has been provided by Español (1998), obtaining the same noise terms as discussed here.

The capillary Landau-Lifshitz-Navier-Stokes model
One of the central results of the previous section is that the stochastic terms keep the same form they have for a homogeneous capillary system (the interested reader is referred to Gallo et al. (2017) for further details). The solid wall imposing no-slip conditions and zero heat transfer and the solid-liquid free energy contribution f w do not affect the FDB (although they do affect the fluctuations). This result is deeply rooted in the van der Waals thermodynamics of non-homogeneous fluid systems, where capillary effects (both the square-gradient volume term and the wall contribution, (3.1)) are included as free energy contributions. As a result, the capillary stresses are generated by the reversible part of the dynamics, without any entropy production. On the other hand, the fluctuation-dissipation balance asserts that only the dissipative part of the dynamics (irreversible) contributes to stochastic fluxes, and thus there are no capillary contributions to the stochastic part of the equations. As a consequence, the form of the stochastic fluxes in both the bounded and unbounded CLLNS model is exactly the same of the simpler classical fluctuating Landau-Lifshitz-Navier-Stokes (LLNS) model (Fox & Uhlenbeck 1970).
The full CLLNS model reads ∂ρ ∂t where the deterministic stress tensor was defined in (4.8) and the deterministic energy flux in (4.9). The presence of the wall is reflected in the boundary conditions, here the no-slip condition for the fluid velocity at the solid surface and vanishing heat flux, i.e. ρv = 0 and q h ·n = 0. The wall wettability is controlled by the condition ∂ρ/∂n = g(θ, φ), where is positive for hydrophilic walls and negative for hydrophobic ones, (3.16).

Equation of state
Two additional relations are still needed to close the system of equations (8.1). They are the two equations of state relating thermodynamic pressure and internal energy to density and temperature, p = p(ρ, θ ) and u b = u b (ρ, θ ). Both follow from the (bulk) free energy density f b = f b (ρ, θ ) specified in (3.1). Here the free energy of a Lennard-Jones fluid (Johnson et al. 1993) will be assumed in order to be able to compare the present results with classical techniques, such as molecular dynamics simulations. Once the appropriate thermodynamic potential is selected, the other thermodynamic properties follow straightforwardly, e.g. the pressure p = −ρ 2 ∂( f b /ρ)/∂ρ.
For a Lennard-Jones fluid, the relevant expressions are too cumbersome to be repeated here, but it may still be interesting to recall the general aspects of a two-phase,   (Johnson, Zollweg & Gubbins 1993). In the main panel, the isotherm θ = 1.25 and the iso-chemical potential μ = μ sat with the saturation value are reported with dashed and dash-dotted lines, respectively. The saturation densities are identified as the two points with equal temperature, chemical potential and pressure; the red circle represents the vapour saturation point and the orange circle the liquid one. The other two circles, dark blue and light blue, represent the spinodal points, vapour and liquid, respectively, identified on the isotherm where ∂p/∂ρ = 0. In the inset, the loci of all the saturation and spinodal points at different temperatures are reported in the ρ-θ plane.
vapour-liquid, system. The phase diagram is reported in figure 5 with binodal and spinodal lines shown in the inset. The binodal, as locus of saturation densities at changing temperature, is obtained from the classical equilibrium conditions stating that identical pressures p and chemical potential μ c characterize bulk vapour and liquid. The saturation densities ρ V sat and ρ L sat are evaluated by (numerically) solving, at given temperature, the nonlinear system of equations The two spinodals, as locus of the densities (ρ V spin and ρ L spin , respectively) where ∂p/∂ρ| θ = 0, represent the thermodynamic limit of metastability. All the thermodynamic states placed between the binodal and the spinodal lines are metastable. In these states, nucleation is a thermally activated process requiring an activation energy, as discussed in § 2. The closer the metastable state is to the spinodal, the smaller the activation barrier and the higher the nucleation probability.

Numerical results
Heterogeneous vapour bubble nucleation is here simulated by numerically solving the CLLNS system of equations presented in § 8. The configuration consists of a metastable L x = 750 Solid wall Solid wall
liquid described by the equation of state of a Lennard-Jones fluid (Johnson et al. 1993) which is enclosed in a box with two flat solid surfaces perpendicular to the z direction where no slip, zero heat flux and given wettability are assigned, using periodicity in the x-y plane. These boundary conditions globally enforce volume, mass and total energy conservation.
In figure 6 a sketch of the simulation set-up is reported for the reader's convenience. The equations are made dimensionless using the following reference quantities: σ = 3.4 × 10 −10 m as length, = 1.65 × 10 −21 J as energy, m = 6.63 × 10 −26 kg as mass, V r = ( /m) 1/2 as velocity, T r = σ/V r as time, θ r = /k B as temperature, η r = √ m /σ 2 as shear viscosity, c vr = mk B as specific heat at constant volume and k r = η r c vr as thermal conductivity. The dimensionless fields are defined as ρ * = ρ/ρ r , θ * = θ/θ r and v * = v/V r . The dimensionless fluxes, (4.8), (4.9), (7.14) and (7.15), read (9.4) where C = λρ r /σ 2 V 2 r is a capillary number. All throughout, the capillary number is fixed at C = 5.244, in order to reproduce the surface tension expected of a Lennard-Jones fluid . Hereafter the symbol * indicating dimensionless quantities is omitted, for the ease of notation. The system volume V = 750 × 750 × 500 has been discretized on a uniform grid, containing 50 cells in the z direction and 75 × 75 in the x-y plane. The dimensionless viscosity and thermal conductivity of a Lennard-Jones fluid (Rowley & Painter 1997) have been used to account for the variability of transport coefficients due to the vapour-liquid density contrast.
The system of equations (8.1) has been discretized in the spirit of the method of lines with the numerical scheme proposed by Balboa et al. (2012) and recently adopted and validated by these authors in Gallo et al. (2018). When dealing with stochastic equations, particular attention must be paid to the discrete version of the fluctuation-dissipation balance. In particular, the numerical scheme must reproduce the field statistics as predicted by Einstein-Boltzmann theory. In order to cope with this particular requirement, Balboa et al. (2012) proposed to exploit a staggered grid to spatially discretize the equations. Special attention is here dedicated to the numerical treatment of the boundary conditions at the wall -see details illustrated in appendix C. The time evolution has been performed by means of a second-order Runge-Kutta scheme (Delong et al. 2013), with a constant time step Δt = 0.1, which is small enough to accurately solve acoustic and viscous time scales.
Several metastable conditions have been investigated: this section reports on four different sets of simulations at initial temperature θ = 1.25 and five different initial bulk densities, ρ L = 0.47, 0.475, 0.48, 0.485, 0.4875, corresponding to a decreasing degree of metastability, and μ spin c the saturation and spinodal chemical potential, respectively (Shen & Debenedetti 2001). The simulations explore the metastable range of density at the selected temperature, ρ L ∈ [ρ L spin , ρ L sat ] = [0.44, 0.51]. It may be worth stressing that on decreasing the metastability parameter the barrier height for nucleating vapour bubbles increases (e.g. the saturation line is approached). As a main goal, the effect of changing the wall wettability is discussed and the potential effect of liquid stratification (depletion/accumulation) at the wall is investigated.
In order to correctly identify bubbles and evaluate the nucleation rate in the different conditions, it is crucial to properly distinguish vapour bubbles from subcritical embryos. Here the same technique (the string method; E, Ren & Vanden-Eijnden 2002;Bonella, Meloni & Ciccotti 2012) adopted by Gallo et al. (2018) is exploited, with a slight modification to take the wall into account. In a first step, the critical bubble is evaluated at given metastable conditions (ρ L and θ ). A spherical vapour bubble, with the corresponding density profile ρ crit (r) in the radial direction, is found. Then, the critical volume V c is rescaled to account for the contact angle using the geometrical function ψ(φ) described in § 2. This procedure provides the estimate of the critical volume to be used as reference size discriminating bubbles from embryos. A few dedicated computations to determine the critical bubble in the presence of the wall, adapting the string method approach to the case of heterogeneous nucleation, showed that the use of the geometric factor is in excellent agreement with the actual critical volume.
In the second step, a clustering algorithm detects the number of critical bubbles in the domain, as follows: (1) A cell flagging procedure selects the vapour cells based on density (ρ < ρ cut identifies vapour). The threshold density, ρ cut , is chosen as the density where the critical profile ρ crit (r) exhibits the maximum slope, corresponding to the interface centre. It turned out that, in the range of metastable states analysed here, ρ cut is in the range 0.35-0.36. A sensitivity analysis showed small effects of this threshold value on the results. (2) A region growing procedure clusters vapour cells by examining the neighbourhood of flagged cells. The procedure is iterated until all flagged cells are processed. (3) The volume V k of the kth cell aggregate (cluster), the sum of cell volumes belonging to the cluster, is used as order parameter identifying supercritical bubbles when V k ≥ V c . Before discussing the nucleation rate, snapshots at two different conditions are shown in figures 7 and 8, at ρ L = 0.475 and ρ L = 0.485, respectively, to illustrate the evolution at different degree of metastability. Starting from a homogeneous liquid mother phase, thermal fluctuations produce regions of low density with a complex shape. Although energy considerations may suggest that vapour bubbles should preferentially form close to the walls, in both cases vapour embryos are observed all over the domain. After reaching the critical size, a complex dynamics is initiated during which collapses and/or coalescence events take place. In the long run, the bubbles surviving in the condition with smaller metastability, figure 8, are all found attached to the wall. At large degree of metastability (small nucleation barrier) several bubbles persist instead in the bulk liquid.
In general, bubble number and dimensions depend on the initial metastability, as shown in figure 9, reporting the number of bubbles formed at the wall for the two previously mentioned thermodynamic conditions. The time instants singled out in the panels of figures 7 and 8 are indicated with circles and identified by the letters a, b, c, d in figure 9. The evolution shows three main stages.
Initially the bubble number increases almost linearly with time (constant production rate). At the lower degree of metastability (ρ L = 0.485) the constant rate regime follows after a relatively long incubation period with almost no bubble. This waiting time is related to the mean first passage time (Kramers 1940) of classical theory, where nucleation is described as Brownian wandering on a free energy landscape, until the walker escapes the barrier to nucleate the bubble. The constant rate stage persists until a maximum number of bubbles accumulates in the domain (configurations denoted by the letter b). The higher the degree of metastability, the lower is the energy barrier and, as a consequence, the larger is the maximum number of bubbles in the domain. The second stage consists of the expansion-coalescence dynamics where bubbles increase their size evolving towards equilibrium while partially coalescing with neighbouring ones. During this phase, the newly formed embryos typically collapse, since the liquid gets compressed by the enlarging vapour phase, given the constraints of constant mass and volume. This kind of event occurs more frequently for the more populated condition at larger degree of metastability.
Finally, during the third stage, the evolution slows down while reaching a more stable condition, where a small number of large vapour bubbles are in equilibrium with the surrounding compressed liquid (see configurations d in the figures. In the present numerical experiments, the nucleation rate J is accessed during the first stage. The nucleation rate expresses the frequency of bubble formation normalized by the system volume (in the context of homogeneous nucleation) or by the solid surface area (in heterogeneous conditions). From an operative standpoint, there are two main procedures to evaluate the bubble formation frequency: (i) When the simulated system is small and only a single nucleation event occurs, as often happens in MD simulations, the waiting time In both panels, the insets report a zoom in the time interval where a linear fitting was applied for calculating the nucleation rate.
for the appearance of the bubble is measured. A large number of independent simulations are used to properly sample the statistics of the phenomenon, and the inverse of the mean waiting time is used as bubble nucleation frequency (Menzl et al. 2016). (ii) When the simulated system is large and the nucleation of a multitude of bubbles can be sampled within a single simulation, the frequency is evaluated as the slope of the curve expressing the time evolution of the number of bubbles in the system (Yasuoka & Matsumoto 1998;Diemand et al. 2014). This linear fitting, expressing the number of bubbles formed per unit time, is performed at the beginning of the nucleation process, and the so-called steady-state rate is measured.
Here the second strategy has been exploited, and the slopes have been evaluated as in the inset of figure 9. The calculated nucleation rates are shown in figure 10(a) in comparison with CNT predictions. It might be worth noting that CNT in the μVθ ensemble ( § 2.1) is here used as a reference theory in the entire range of metastability conditions. The difference between the unknown actual rate and the CNT prediction is expected to vanish asymptotically at larger density, close to saturation. The present results are in line with this expectation, with the convergent trend apparent in the figure. Far from saturation, only homogeneous nucleation has been plentifully analysed, finding that the results spread over approximately eight orders of magnitude, at high temperature, and differ by up to 20 orders from CNT (see Diemand et al. (2014) for a summary of the literature data). To the best of our knowledge, quantitative simulations of heterogeneous bubble nucleation rates are not available for a direct comparison. Only few qualitative attempts can be found in Nagayama, Tsuruta & Cheng (2006). The available MD simulations by Novak et al. (2007) have instead been performed in an isothermal-isostress ensemble (NP zz θ ).
The standard application of CNT refers to the grand canonical (μVθ ) context, where the liquid bulk density remains unaltered along the nucleation process in macroscopic systems. The total mass and energy constraints (NVE ensemble) used in the present simulations might lead to crucial differences, particularly when the system is small or extremely crowded with several bubbles. As shown below, this explains the discrepancy between simulation results and predictions found in figure 10.
By elaborating on the NVE model recalled in § 2.2, a system partially filled with a given quantity of vapour to account for nucleation in the presence of multiple bubbles can be considered. In this case, the critical bubble radius and corresponding energy barrier are found by solving equations (2.6) specialized as In the above equations, R * , A * and V * are the bubble critical radius, area and volume, respectively. In the case of a neutrally wettable solid wall (90 • contact angle), for example, A * = 2πR * 2 and V * = 2 3 πR * 3 . Moreover, U bubble is the internal energy of the critical vapour bubble, evaluated through the equation of state, as u b (ρ V , θ)V * . All terms highlighted with a tilde are free parameters that allow one to take into account the vapour already formed in the system. Specifically,Ũ V is the total internal energy of the vapour phase,Ẽ c is the (total) surface energy,M V is the total mass of vapour andṼ V its total volume. In comparing numerical results with the predictions of this extended NVE model, the free parameters are measured from the simulation along the evolution. The time-dependent nucleation rate J NVE (t) is evaluated by solving system (9.5) at each instant. Finally, the number of bubbles is obtained by integrating the nucleation rate, where 2S is the area of the solid walls and t 0 the nucleation waiting time, also extracted from the simulation. The remarkable agreement shown in figure 11 confirms that the constraints on mass and energy strongly affect the nucleation rate, and fully justifies the order-of-magnitude difference in the rate when fluctuating hydrodynamics results are compared with standard CNT in the μVθ setting. The modified NVE description envisaged here hinges on input data from the simulation. As such, it is not a closed model of nucleation. Nevertheless, it enlightens the physical mechanisms operating in the system, also capturing the progressive reduction of nucleation rate, due to the progressive filling of the system with nucleated vapour. On the contrary, the constant rate predicted by the CNT μVθ leads to a linearly increasing number of bubbles (blue dashed line in figure 11), out of scale with respect to the simulation results.
Wall wettability in the specific thermodynamic condition ρ L = 0.48 is investigated by changing the contact angle φ, (3.8). The numerical simulations span a range of hydrophobic (φ > 90 • ) and hydrophilic (φ < 90 • ) conditions. The results shown in figure 10(b) are consistent with the expected behaviour, based on energy barrier considerations: the nucleation rate increases when the contact angle is increased, i.e. the more hydrophobic the surface, the more likely is vapour formation close to the wall. Quantitatively, the CNT prediction shows a more pronounced effect with respect to those observed in the numerical simulations.
For a qualitative illustration, snapshots during nucleation at weakly hydrophilic and weakly hydrophobic walls are reported in figure 12. It is clear that the number of embryos formed at the wall is larger for hydrophobic surfaces. Eventually, figure 13, at moderate and strong hydrophilicity, nucleation is mostly observed in the bulk in the same manner as described for homogeneous nucleation.
In quantitative terms, figure 14 reports the number of vapour bubbles detected in the domain for several hydrophilic wettability levels. Figure 14   The sensitivity of bulk nucleation to contact angle observed in the data can be explained by the enforced mass and volume constraints, which makes pressure and density responsive to the overall volume of vapour phase, which is influenced by the number and size of wall bubbles. Separating surface from bulk nucleation events allows the surface and bulk nucleation rates to be compared. By comparing the slope in the constant-rate regime, the homogeneous nucleation rate is found to be constant within the present statistical accuracy, independently of wall wettability. The heterogeneous (surface) nucleation rate reduces at increasing hydrophilicity and, when φ < φ crit with φ crit ≈ 60 • , almost all nucleation events take place in the bulk. This behaviour can be explained by the following considerations.
(1) From a thermodynamic point of view, the hydrophilic nature of the surfaces involves accumulation of liquid to the wall, strongly preventing the formation of vapour nuclei in these zones.
(2) The homogeneous nucleation barriers are comparable to the heterogeneous one close to moderately and strong hydrophilic surfaces, but the number of nucleation sites in the bulk volume is clearly larger than those on the walls. As a consequence, the homogeneous nucleation probability is higher. A similar behaviour was also observed in several MD simulations of heterogeneous nucleation, both on flat solid walls (Nagayama et al. 2006;Chen et al. 2018;Marchio et al. 2018) and close to structured surfaces (She et al. 2016). It may be worth stressing that these results contradict the widespread opinion based on CNT (see § 2) that solid surfaces should always act as bubble catalysts. One of the major advantages of the mesoscale approach considered here consists in the possibility to follow the complete bubble dynamics, from the inception of phase transition to the late stage of macroscopic bubble evolution. The latter is analysed in the following. The cluster analysis described at the beginning of this section enables tracking of individual bubbles. Figure 15 concerns the volume histories of bubbles that survive for the entire simulations. There, several curves (red and blue lines) feature sudden volume jumps that correspond to coalescence events. One of those, see the event labelled b captured in the snapshots of figure 16, involves the coalescence of two wall-attached bubbles. The growth rate of the resulting bubble increases after coalescence, probably due to the fusion process, which, by decreasing the interfacial curvature, tends to favour the expansion.
The analysis is completed by the time evolution of mean temperature and pressure inside the bubbles (figure 17). The saturation pressure and initial temperature are indicated as references. Initially, both temperature and pressures are quite noisy, with a large variance due to the small bubble dimensions. The temperature, which initially fluctuates around the liquid temperature, starts decreasing during the expansion stage. Similarly the pressure, which initially fluctuates around the saturation value, decreases together with the temperature. All the bubbles experience a similar trend, with pressure that differs from the saturation pressure up to 10 %.

Conclusions
This paper deals with the long-standing issue of heterogeneous nucleation in metastable liquids. Common approaches deal with the problem using heuristic models in the context of classical fluid mechanics or, more rigorously, simplified approaches like the classical nucleation theory (CNT) or different kinds of more or less sophisticated simulations based   figure 16 (letters a, b, c, d respectively). (b) Time evolution of the mean pressure inside the same bubbles. Both the initial temperature and the saturation pressure are reported as a reference. on atomistic descriptions of the fluid. Here a different path is followed, addressing the nucleation process in the context of a formulation where thermal fluctuations are included in the diffuse interface model in a physically consistent way. This leads to a system of SPDEs that extends the capillary Navier-Stokes equations and includes a suitable random forcing to model thermal noise. The diffuse interface model may be seen as originating from the gradient expansion of more general non-local functionals in the context of density functional theory (DFT). The result is an extension to heterogeneous nucleation of a previous proposal based on fluctuating hydrodynamics that was originally used to deal with nucleation in homogeneous conditions. Technically, the issue was developing a theory of fluctuations in the presence of walls. In this approach, the appropriate boundary condition describing the hydrophobic or hydrophilic walls enters the Onsager operator that determines the noise intensity. Although the theory is in several respects basically formal, specific examples allowed the noise intensity operator to be explicitly determined. As a consequence, it is shown that there is no need to modify the structure of the white noise when boundary conditions are suitably included in the relevant operators. The issue is discussed also for the discrete system, showing how the discrete model can be consistently derived from the original system of SPDEs. The equivalence of the discrete model so derived with previous works that addressed the problem in purely numerical terms by modifying the noise structure at the wall is illustrated.
The proposed model is exploited to produce numerical simulations of bubble nucleation at a solid wall with various degrees of wettability. By inducing layering effects in the liquid close to the boundary, the wettability affects the heterogeneous nucleation rate. At a qualitative level, the numerical data reproduce the predictions of CNT. There are, however, significant differences with respect to the predictions of classical CNT extended to heterogeneous conditions. The usual theory deals with the μVθ ensemble and provides an estimate for the mean nucleation rate by considering a single bubble developing in the metastable liquid. Direct comparison with this approach produces a small but significant discrepancy in the rate, which decreases as the metastability level is reduced. In order to better validate the present model, it was found crucial to take into account two basic differences with the assumptions of the classical theory: (i) the simulations were performed keeping the total system energy constant, making the NVE ensemble more appropriate; and (ii) the system evolves in time, due to the accumulation of vapour in the closed system. For this reason we adapted the NVE CNT to make it able to predict the nucleation rate in a time-dependent state. The comparison of this extended model turns out to be excellent. Although care must be exerted when comparing heterogeneous and homogeneous nucleation rates, since the former is a surface process and the latter a volume process, the present results suggest that, already for moderately hydrophilic walls, homogeneous nucleation may still result in the most effective mechanism, due to the liquid layering at the wall.
The favourable computational cost of this methodology encourages its exploitation for more complex conditions of nucleation in the presence of complex geometries, mean flow and dissolved gas, all aspects left for future works.
One of the potentially interesting novelties obtained as a byproduct of the present analysis concerns a systematic description of the interaction between a capillary fluid and a solid wall in the context of a diffuse interface approach. The equation introduced to model the wall wettability is related to the boundary condition introduced by Cahn in the context of the Cahn-Hilliard model. Here such a relationship is extended to take into account the thermodynamics of a non-isothermal liquid-vapour system showing how to determine the wall contribution to the free energy consistently with the specific equation of state used to describe the bulk fluid. Based on the resulting expression of the wall free energy, it is also shown how to include non-equilibrium effects in the contact angle relaxation dynamics.
Although the present contribution may constitute a basic step to develop mesoscopic numerical models of nucleation for complex systems able to bridge the gap between nucleation and macroscopic bubble dynamics, several important ingredients still need to be considered. Among the most important in view of practical applications is the extension of the numerics to complex geometries in order to take into account wall roughness effects, which are known to be crucial in most cases. The presence of dissolved gas is almost unavoidable in experiments and very important for applications. Both effects are in principle easily included in the model, although at the price of some additional work.
At the microscopic level, slippage is known to occur at liquid-solid interfaces. At mesoscopic scale, this effect is described by introducing a phenomenological slip length in the Navier equation that replaces the no-slip condition at the wall. It turns out that, apart from special systems, such as flow in carbon nanotubes, the slip length is of the order of less than one nanometre. Its effect on nucleation may, however, need to be included in the model. In principle, this can be easily considered, including also non-equilibrium effects on the contact angle dynamics. This will, however, require dedicated consideration, since any new dissipative effect is expected to alter the explicit form of the fluctuation-dissipation balance that determines the noise intensity.
At a more fundamental level, the limit of the model is the very assumption of the square-gradient form for the free energy functional. The consequence is a monotonic density profile, which, although describing the correct trend in a coarse-grained sense, does not capture the details of the density oscillations that are known to occur in liquids both experimentally, via X-ray scattering, and numerically, via MD simulations. More complex functionals derived in the context of DFT can capture these effects, which could, in principle, affect the nucleation rate. A common characteristic of DFT is, however, the non-local nature of the functionals. If included in the model in the spirit of a generalized dynamic DFT, non-locality would make the computations much more demanding, spoiling the the ability of the model to reach macroscopic scales. In this respect, the opinion of the authors is that the square-gradient approximation could be considered as a very good compromise between the ability to account for even the finest details and computational feasibility.

Declaration of interests
The authors report no conflict of interest.

Appendix A. Boundary condition for the density field
In order to account for the interaction of the capillary fluid with the wall, the surface contribution f w (ρ w , θ) was added to the free energy, (3.1).
The relevant conservation laws for the mass, momentum and energy of the layer are (Slattery, Sagis & Oh 2007) where ∇ π is the gradient operator in the directions tangent to the layer, Q π is the (surface) stress tensor in the layer, and q w is the (tangent) energy flux within the layer. The symbol [[·]] indicates the jump of a quantity throughout the layer. Thus [[t]] = t fluid − t sub = Σ · n − t sub is the stress exerted on the layer by the bulk fluid and the substrate. Analogously, [[h]] = h fluid − h sub = q · n − h sub is the energy flux in the layer from bulk fluid and substrate. In the above equations, the subscript w is used to specify the fields defined on the layer, in general. Notice that ρ w has the dimensions of mass per unit surface (i.e. it is inherently different from a bulk mass density) and, in principle, v w may differ from the velocity of the fluid in contact with the layer. In fact, the no-slip condition v| ∂D = v w will be explicitly assumed in the following, as natural.
The time derivative of a generic extensive variable Φ defined on the surface reads where the so-called displacement derivative, δ/δt = ∂/∂t + v n ∂/∂n, has been introduced in the last equality, with v n the normal velocity component. Notice that for a generic moving surface the normal spatial derivative and the time derivative of fields defined on the manifold happen to be singular when taken separated. The displacement derivative, instead, is well defined for smooth fields (Trusdell & Toupin 1960). After the application of the time derivative, (A 2), the layer conservation laws can be rewritten in local form as where energy conservation is re-expressed in terms of internal energy by subtracting the kinetic energy balance from the total energy equation, as standard -see e.g. (4.3) for the bulk fluid. Following the definition of surface internal energy, u w = f w + θ s w with s w the entropy density per unit surface of the layer, its differential is given in terms of the differential of the layer free energy. In general, f w may be taken to depend on the layer mass density ρ w , the temperature θ and the thermodynamic properties of the adjoining fluid, e.g. the density ρ of the fluid locally in contact with the layer.
In the limit as the concentrated layer mass density vanishes, the mass conservation equation becomes irrelevant, while momentum conservation turns into a local force balance, i.e. the tension on the fluid may differ from that acting on the solid due to a surface-tension-like contribution in the concentrated layer. In the same limit, the free energy of the layer becomes f w = f w (ρ, θ ) and the differential of the related internal energy becomes which implies that the left-hand side of the third equation in (A 4) is rewritten as It follows that the equation for the layer entropy density is Since v · ∇ π = v π · ∇ π , the terms in round brackets on the right-hand side of (A 8) correspond to the material derivative of the density, Dρ/Dt. By applying the definition of [[h]] = q · n − h sub = −λ(Dρ/Dt)(∂ρ/∂n) − h sub (please refer to (4.9) for the expression of the energy flux q), the entropy equation reduces to The right-hand side of this equation consists of the sum of a source term s source = −(h sub + k ∂θ/∂n)/θ, a flux term s flux = −∇ π · (q w /θ ) and an entropy production term consisting of three contributions, Considering linear constitutive laws, the Clausius-Duhem inequality combined with the Curie principle allows one to express the layer stress tensor Q π as a function of the layer velocity surface gradient, and the layer tangential heat flux q w as a function of the temperature surface gradient. Although, in principle, a Newtonian viscous surface stress and Fourier-type heat conduction can be included, the continuity of velocity between the solid (assumed as rigid), concentrated layer and fluid, and a vanishing surface conductivity, lead to Q π = f w I π and q w = 0. The remaining production process associated with capillarity, s prod = −(1/θ )(Dρ/Dt)(∂f w /∂ρ + λ ∂ρ/∂n), suggests the simplest contact angle dynamics relaxing to equilibrium, (3.8), consistent with positive entropy production, with M w ≥ 0. When the entropy generated by the relaxation process is negligible, Young's law (3.8) directly applies.

Appendix C. Numerical scheme
When dealing with stochastic equations, the numerical integration must reproduce the correct statistics of the fluctuating fields, i.e. the discrete scheme needs to be consistent with the fluctuation-dissipation balance. A necessary condition is that the scheme should map operators that are mutually adjoint into mutually adjoint matrices (the discrete operators); namely, if, for two operators A and B, B = A † , the matrix representing their discrete form, A N and B N , should satisfy B N = A † N (Atzberger 2010). Entering in detail, equations (8.1) were discretized with the method of lines on a uniform, staggered grid with differential operators approximated through central, second-order, finite differences (Donev et al. 2010;Balboa et al. 2012). The simulation domain is partitioned into N disjoint cubic cells V n of volume ΔV = Δx 3 , i.e. V = N n=1 V n and V n ∩ V m = ∅ if m / = n. All the scalar fields are located at cell centres while cell face centres allocate the normal-to-face component of vectors.
terms do not contribute to the correlation in the fluid domain. The factorized p.d.f. reads P eq (Δ 1 , . . . , The covariance matrix of the discrete density fields reads where, from (C 5), The p.d.f. in (C 7) is a multivariate Gaussian with covariance matrix C ν 1 ν 2 = k B h −1 ν 1 ν 2 /ΔV, hence δρ n 1 δρ n 2 = k B ΔV h −1 n 1 n 2 . (C 9) Using the same procedure one finds δv n 1 ⊗ δv n 2 = k B ΔV θ eq ρ eq n 1 Iδ n 1 n 2 , (C 10) δθ n 1 δθ n 2 = k B ΔV c v,eq θ 2 eq ρ eq n 1 δ n 1 n 2 . (C 11) At discrete level, the fluctuating fields are zero-mean Gaussian processes, with covariance matrix given by (C 9), (C 10) and (C 11). The fields are statistically independent of each other (i.e. the cross-correlation of density and temperature is zero), velocity and temperature are uncorrelated across cells, while the density field has a finite correlation due to capillarity. Given all the correlations, the overall correlation matrix Δ ⊗Δ is easily built and the discrete noise intensity operator is found by solving (C 4). In order to provide the flavour of this approach, it may be instrumental to describe a simple but illustrative one-dimensional problem, given by the heat equation for a scalar field c on the interval [0, L]. The interval is partitioned into N cells, from cell 0 to cell N − 1 with a ghost cell added to the right and the left of the interval, to enforce boundary conditions; see figure 18 for a sketch. The scalar is located at cell centres while fluxes are located at cell boundaries.
of stochastic fluxesΞ (x, t); andL is the one-dimensional Laplacian, where α = −1 and 1 for homogeneous Dirichlet (field value assigned) and for Neumann (normal derivative) boundary conditions, respectively. For the present system the field correlation reduces to the identity matrix, ĉ n 1ĉ n 2 = δ n 1 n 2 . As one may guess from the continuum theory illustrated in § 6, the noise intensity operator is, basically, the discrete version of the divergence operator. However, it must be properly modified at the first (−1/2) and last (N + 1/2) cell interface to account for the effect of the boundary conditions. The ansatz for the discrete noise operator iŝ where β is a free parameter needed to adapt the divergence operator to the boundary conditions and the factor √ 2 has been added for convenience. For the present system, since the correlation matrix is the identity, (C 4) is simply − 2L =KK T , (C 15) which is solved by the ansatz provided β = √ 1 − α with α = −1, 1 (Dirichlet, Neumann), respectively. This result reproduces, using a different philosophy, the prescription suggested by Donev et al. (2010) and Balboa et al. (2012). In their case the noise operator was postulated to be given by the present ansatz with β = −1 (i.e. the noise operator was kept identical to that for an unbound domain) and the noise correlation was modified at end points, Ξ 2 −1/2 = Ξ 2 N−1/2 = 2 and 0 for Dirichlet and Neumann boundary conditions, respectively. The present choice is to leave the noise correlations unaffected (specifically,  FIGURE 20. Probability distribution functions of kinetic energyK n = 1 2 ρ eq ΔV( v n ·v n ) normalized with k B θ eq /2 (a) and pressure (b). Theoretical predictions are shown by the solid lines.
Ξ 2 −1/2 = Ξ 2 N−1/2 = 1) and suitably modify the noise intensity operator as explained above. At the practical level, the two approaches are identical, but the present proposal sticks more directly to the continuum formulation described in § 6.
Several equilibrium simulations have been performed in order to compare the numerical results with the theoretical predictions. As an example, the fluctuations of a stable liquid at ρ eq = 0.75 and θ eq = 1 (non-dimensional Lennard-Jones units) have been simulated in a channel with two parallel plates as bottom and top boundaries. The contact angle was φ = π/2, which implies ∂ρ/∂n = 0 at the solid boundaries. The variances of the fluctuating fields were evaluated by averaging over time, Δ 2 n = (1/T) T 0Δ 2 n dt (hereΔ n denotes one of the components of the fluctuating field at cell n), with a time window of T = 100 (for the specific case of φ = π/2, the equilibrium field is homogeneous, hence additional averaging over cells can be exploited to increase the statistics).