Dissipation in hydrodynamics from micro- to macroscale: wisdom from Boltzmann and stochastic thermodynamics

We show that macroscopic irreversible thermodynamics for viscous fluids can be derived from exact information-theoretic thermodynamic identities valid at the microscale. Entropy production, in particular, is a measure of the loss of many-particle correlations in the same way in which it measures the loss of system-reservoirs correlations in stochastic thermodynamics (ST). More specifically, we first show that boundary conditions at the macroscopic level define a natural decomposition of the entropy production rate (EPR) in terms of thermodynamic forces multiplying their conjugate currents, as well as a change in suitable nonequilibrium potential that acts as a Lyapunov function in the absence of forces. Moving to the microscale, we identify the exact identities at the origin of these dissipative contributions for isolated Hamiltonian systems. We then show that the molecular chaos hypothesis, which gives rise to the Boltzmann equation at the mesoscale, leads to a positive rate of loss of many-particle correlations, which we identify with the Boltzmann EPR. By generalizing the Boltzmann equation to account for boundaries with nonuniform temperature and nonzero velocity, and resorting to the Chapman–Enskog expansion, we recover the macroscopic theory we started from. Finally, using a linearized Boltzmann equation we derive ST for dilute particles in a weakly out-of-equilibrium fluid and its corresponding macroscopic thermodynamics. Our work unambiguously demonstrates the information-theoretical origin of thermodynamic notions of entropy and dissipation in macroscale irreversible thermodynamics.


I. INTRODUCTION
Hydrodynamics is a theory of crucial importance across science.It provides tools to deal with systems spanning many orders of magnitude in terms of spatial scale, and thus it is fundamental for our understanding of phenomena ranging from chemical physics and biology to planetary science and astrophysics [1][2][3][4][5].One of its simplest formulations describes an isotropic fluid in terms of five dynamical fields, total energy (kinetic, potential and internal), the three components of momentum, and mass.These are conserved at the microscopic level and thus give rise to balance equations at the macroscopic level [6,7].These equations are however not closed from a dynamical standpoint.In irreversible thermodynamics, a complete thermodynamic description of a fluid assumes the existence of a local entropy which is solely a function of internal energy, volume and particle number, as in equilibrium.This so-called local equilibrium assumption defines temperature, pressure and chemical potential fields as partial derivatives of the entropy field and links them to the total energy, momentum and mass density fields.A second assumption, which defines linear irreversible thermodynamics, is that the fluxes featured in the balance equations (heat flux and pressure tensor) can be linearized in terms of the gradients of temperature and velocity.This linear regime assumption is essential to make the balance equations a closed dynamical system [1,2,8].
The microscopic underpinnings of irreversible thermodynamics have been the object of intense scrutiny for more than a century and a half [1,7,[9][10][11][12][13].The main problems, which remain still open today, are related to understanding the emergence of a macroscopic irreversible behavior, from microscopic reversible many-body dynamics.The first problem concerns how to go from the microscopic dynamics of a gas (formulated in terms of the many-body probability distribution of all the fluid particles) which is Hamiltonian and thus reversible, to a mesoscopic, irreversible closed evolution equation for the singleparticle probability distribution (for example, via the Boltzmann equation [7,9,11]).The second problem is the derivation of irreversible thermodynamics at the macroscopic level from the mesoscopic level (for example, using the Chapman-Enskog expansion [9,14,15]).Irreversibility (i.e., a nonnegative EPR) in this context is understood to arise from the molecular chaos hypothesis which neglects correlations amongst particles building after molecular collisions [12,13].
More recently, significant progress has been achieved in ST [16][17][18][19][20], which offers a different approach to deal with the mesoscopic level of description.Here the typical setup consists of a system in contact with one or multiple reservoirs.At the microscopic level of description, the full probability distribution contains both the system and reservoirs degrees of freedom [21,22].Exact identities corresponding to the first and second law of thermodynamics have been derived when considering a class of initial conditions where the system is prepared in an arbitrary state but is uncorrelated from the reservoirs that are at equilibrium.The entropy production is non-negative and takes the form of a relative entropy between the exact total probability distribution at a given time and the exact system probability distribution times the equilibrium reservoir distribution [23,24].It thus measures the information lost when both the system-reservoirs correlations and the displacement from equilibrium of the reservoirs are neglected [24,25].Various assumptions need to be made to derive a closed dynamics for the system probability distribution only (obtained by tracing out the reservoirs) [22].The most common approach relies on the Born-Markov approximation (assuming fast reservoirs and weak system-reservoir coupling [20,22]) which plays a role similar to the molecular chaos hypothesis in the context of fluids [1,11].It also makes it possible to express all the thermodynamic quantities entering the first and second law in terms of the system probability distribution only and to prove that the EPR is non-negative [20,26].The dynamics of the system only perceives the linear response properties of the reservoirs via transition rates -or drift and diffusion coefficients in a continuous description -which as a result satisfy the so-called local detailed balance property [27][28][29][30].This latter condition is known to be essential to build a consistent nonequilibrium thermodynamic description for a system described by a stochastic dynamics [30][31][32][33][34].These approaches hold for a large class of mesoscopic models such as Markov jump processes, overdamped and underdamped Fokker-Planck equations [33,[35][36][37].
Furthermore, the formulation of ST for Markov jump processes enables a decomposition of the EPR which provides a constructive identification of the nonequilibrium potential and of the global thermodynamic forces driving the system out of equilibrium [34].Close to equilibrium, it reproduces the classical results from linear irreversible thermodynamics, such as Onsager reciprocal relations and minimum entropy production principle [38][39][40].This decomposition of the EPR remains valid for macroscopic systems when assuming local equilibrium but without resorting to the linear regime assumption.This fact has been shown for chemical reaction networks with diffusion (but neglecting inertial or viscous effects), where deterministic field theories ensue [41,42].This construction reveals substantial differences between global and local thermodynamics because all global conservation laws can be broken at the local level [42].These macroscopic thermodynamic theories with local equilibrium can be explicitly constructed from an underlying ST by scaling up particle numbers (see Refs. [43][44][45], for chemical reaction networks, Potts models and electronic circuits, respectively, and Refs.[46,47] for the general arguments).These approaches correspond to overdamped dynamics where inertial effects are neglected, but generalization to underdamped dynamics seems possible and could be used to derive hydrodynamics.
In this paper, we revisit the derivation of hydrodynamics from the microscopic to the mesoscopic and macroscopic levels and establish the corresponding thermodynamics at each of these levels, in light of recent progress in ST.In particular, we give an information-theoretic interpretation to the entropy production and to the thermodynamic potentials of macroscopic hydrodynamics in the same fashion as it is done in ST [28,34].Furthermore, we clarify the role of the two distinct assumptions of local equilibrium and local detailed balance, which are of fundamental importance for hydrodynamics and ST, respectively, by constructing an example of mesoscopic evolution that allows us to discuss both.More specifically, in the first part of the paper we focus on macroscopic hydrodynamics, where we decompose the EPR in terms of the constraints imposed at the boundaries (e.g., a nonuniform temperature profile).This allows us to identify i) the global thermodynamic forces driving the system out of equilibrium and ii) the proper thermodynamic potential.When the thermodynamic forces are switched off and no time-dependent protocol is externally applied, the thermodynamic potential is maximized in the relaxation process to equilibrium, for which it acts as a Lyapunov function of the nonlinear dynamics.This shows how thermodynamic consistency (i.e., the requirement that the heat flux satisfies the second law) translates into a dynamical result for a fully nonlinear theory.In the second part of the paper, we focus on microscopic and mesoscopic descriptions behind macroscopic hydrodynamics to reveal the information-theoretic origin of the thermodynamic potential and EPR derived in the first part.To do so, we revisit the standard derivation of hydrodynamics which starts from the microscale (Hamiltonian dynamics for particles interacting via pairwise potentials) and goes to the macroscale via the mesoscale (Boltzmann equation) employing the Chapman-Enskog expansion [1,7,11,12].For an isolated system, when considering an initially factorized distribution in terms of (identical) oneparticle distributions, we show that the entropy production (identified with the change in Shannon entropy of the one-particle distribution) is always non-negative.Furthermore, in conceptual analogy with the system-reservoir setup, it takes the form of a relative entropy between the exact many-body probability distribution and the product of the one-particle distributions.Entropy production is thus a direct measure of the information lost when neglecting inter-particle correlations.When resorting to the molecular chaos hypothesis -used to derive a mesoscopic description in terms of the Boltzmann equation which ensures the relaxation of the one-particle distribution to equilibrium -the EPR becomes non-negative.Further resorting to the Chapman-Enskog expansion [1,11,48] and the relaxation-time approximation [49] used to derive macroscopic hydrodynamics, we identify the parts of the EPR which survive and give rise to the entropy production of irreversible thermodynamics.We then move to non-isolated systems which we model at the level of the Boltzmann equation by describing the collisions at nonisothermal and possibly moving boundary in a thermodynamically consistent way inspired by Refs.[7,11,50,51].We show that a first and second law ensue and that in the absence of thermodynamic forces, the nonequilibrium Massieu potential is maximized by the relaxation dynamics towards equilibrium.Finally, we derive a linear Boltzmann equation, similar to a master equation in the momentum space.This mesoscale theory provides a formulation of ST underlying macroscopic hydrodynam-ics in the regime where the Chapman-Enskog approach is justified.In fact, the system is shown to satisfy hydrodynamic equations at the macroscale while also obeying the local detailed balance at the mesoscopic level, providing, in addition, a systematic treatment of its ST in the presence of an extended and weakly out-of-equilibrium reservoir [29,52,53].The main outcome of our work is to unambiguously show how microscopic and mesoscopic formulations of nonequilibrium thermodynamics in terms of information-theoretic quantities are consistent with the macroscopic thermodynamics of non-isolated systems.

Outline
The paper is organized as follows.In § II, we consider the dynamics of continuous systems and their thermodynamics, we write the balance equations for energy and entropy and then identify the proper thermodynamic potentials and forces for isolated and non-isolated systems.In § III, we derive thermodynamic inequalities for the temporal change in informationtheoretic entropy and nonequilibrium Massieu potential at the microscopic scale following Hamiltonian dynamics by using a coarse-grained approach based on the one-particle distribution function.In § IV, we move to the mesoscopic scale and revisit the thermodynamic aspects of the microscopic derivation of the hydrodynamics of isolated systems using the Boltzmann equation.We use the Chapman-Enskog expansion to obtain the local equilibrium condition as the leading approximation in terms of the slowly varying variables describing macroscopic systems.We furthermore estimate the EPR during the initial stages of the relaxation to the local equilibrium.In § V, we generalize the Boltzmann equation to describe non-isolated systems in a thermodynamically consistent fashion.By writing explicitly the energy and entropy balance equations, we show how the nonequilibrium Massieu potential corresponds to the macroscopic thermodynamic potential identified in § II.Finally, in § VI, we formulate a linear version of the generalized Boltzmann equation that is consistent with both ST and macroscopic hydrodynamics.Future developments are discussed in § VII.

II. MACROSCOPIC SCALE: NAVIER-STOKES EQUATIONS
We revisit here the standard hydrodynamics of viscous fluids [1,48].We start by obtaining the local formulation of thermodynamics (i.e., the one valid in the interior of a domain ) and then systematically show how to determine the thermodynamic potential as well as the global thermodynamic forces keeping non-isolated fluids out of equilibrium (which require knowledge of the conditions imposed at the boundary ).

A. Dynamics
The dynamics of fluids is given by the Navier-Stokes equations [1], written in Lagrangian form using the material derivative for the spatio-temporal fields density of mass  (; ), velocity  (; ), external force (per unit mass)  (; ), and pressure tensor  (; ) (with (∇  •)  =        , and  and  labeling the three spatial components).The pressure tensor  describes the stress exerted by the fluid element on its surrounding and, in the case of isotropic, compressible fluids, can be written in terms of the scalar pressure  (; ) and the (symmetric) viscous tensor  (; ).In turn, for fluids sufficiently close to thermodynamic equilibrium,  (; ) is a function of the derivatives of the velocity [54]: This expression of  is obtained under a series of assumptions, valid in the linear regime.First,  is assumed to be invariant under global Galilean transformations, i.e.,  (; ) ↦ →  (; ) +  , implying that it depends on the velocity only through its derivatives.Second,  is assumed to depend only on the first derivatives      , which are supposed to be small enough to contribute only linearly to .Third, the pressure tensor  is assumed to be symmetric, which is justified when the molecules composing the fluid are spherical or when the fluid density is very low [1].Fourth, assuming isotropy, only two different scalar coefficients,  and , are needed to characterize viscous effects in the fluid (out of six possible ones).The coefficient , accounting for the shear, is called kinematic viscosity (while  is called dynamic viscosity) and the coefficient , accounting for dissipative compression or expansion, is called second viscosity.When it is not specified otherwise, we will not rely on the specific expression of    in (2) in the rest of the article.
The mass conservation (1a) can equivalently be written in Eulerian form as Since we will often switch between the Lagrangian and Eulerian description, we rely on this useful identity valid for any scalar quantity which is derived using the definition of   and Eq. ( 3).Note that throughout this manuscript, we use a compact notation in which any spatial and temporal dependence (of, for instance,  and ) is left implicit if no ambiguity can arise.

B. Local Energy Balance
The specific total energy, per unit mass, is given by three different contributions.The first,  (; ) = 1 2 ( (; )) 2 , is the specific kinetic energy associated to the motion of the fluid element.The second,  (; ), is the specific potential energy of the fluid element which can always be written as the sum of two terms:  (; ) =  int (; ) +  w (; ).The term  int (; ) accounts for the potential energy in the bulk of the fluid.An example of this contribution is the gravitational potential energy satisfying −∇   g () = − =  g with  g the gravitational force (per unit mass),  the modulus of the gravitational acceleration, and  the unit vector in the vertical direction.The term  w (; ) accounts instead for the confinement generated by the (moving) boundaries.We assume that all possible forces acting on a fluid element derive from a suitable potential energy, and therefore  = −∇   ( int = −∇   int and  w = −∇   w ) in the following.The last contribution in Eq. ( 5),  (; ), is the specific internal energy associated to all the other degrees of freedom.The corresponding global quantities are The balance equation for the total energy is    + ∇  •   = 0, as long as the potential energy is time-independent, while it becomes when the potential energy is time-dependent.Here,   (; ) is the flux of total energy which can be specified by considering how each single contribution to the total energy in Eq. ( 5) changes in time using the Navier-Stokes equations (1).First, we derive the balance equation for  (; ) from the momentum conservation equation (1b) and Eq. ( 2): where a term in the form of a divergence of fluxes has been isolated on the left-hand side.On the right-hand side, source terms appear, even though at this stage it is still not possible to tell apart dissipative contributions from those that modify the potential energy of the system.Moving to the Eulerian frame using the identity (4), Eq. ( 8) becomes Second, we consider the balance for the potential energy.By using Eq. ( 3), we find By adding Eqs. ( 9) and (10), we obtain the mechanical energy balance in the Eulerian frame: Notice that the first term on the right-hand side of Eq. ( 9), representing the nondissipative interconversion rate of kinetic energy into potential due to compression and advection with the velocity field , is entirely compensated by the corresponding term in the potential energy balance equation (10) and, therefore, does not enter the balance equation for the mechanical energy (11).
In Lagrangian form (obtained using ( 4)), Eq. ( 11) reads Having derived the balance equation for the total mechanical energy, we use Eq. ( 7) to obtain the balance equation for the internal energy  (; ): Notice that the first term on the right-hand side is due to a time-dependent change in potential energy.It does not directly contribute to the balance equation of the internal energy because it is compensated by the corresponding term in the mechanical energy balance (12).Nevertheless, it contributes to the internal energy indirectly since it enters the Navier-Stokes equations (via Eq. ( 1b)) and thus affects the state of the system.The expression of total energy flux   can now be given as the sum of the fluxes on the left-hand side of Eq. ( 12) and the heat flux   (for now unspecified) Indeed, this leads to a local balance equation for the internal energy (i.e., the first law), obtained using Eq. ( 12) and ( 14) in Eq. ( 13), where the divergence only acts on the heat flux, while a source term appears on the right-hand side.Here, we define Tr  ∇   ≡          .Notice that the last term in Eq. ( 15) can be equivalently written in terms of the strain-rate tensor  = Equation ( 15) and ( 16) constitute two equivalent (local) formulations of the first law of thermodynamics for fluids.Indeed, once they are integrated over a volume element to obtain their global counterparts, one can recognize that the internal energy changes because of the exchanged heat at the boundary, or the mechanical expansion of the system, (accounted on the lefthand side of Eq. ( 16)) or the viscous and other dissipative effects that take place inside the volume (accounted on the right-hand side of Eq. ( 16)).Finally, by substituting the expression of the total energy flux (14) in the balance equation (7) for the total energy, we obtain which will be used to prove the existence of a global Lyapunov function in systems with a well-defined equilibrium state ( § II E).

C. Local Equilibrium and Local Entropy Balance
The second balance equation that the system satisfies concerns the entropy.To derive it in the macroscopic theory, we resort to the following assumption: each fluid element  (macroscopic, but small compared to the domain ) becomes locally equilibrated with the surroundings after a very short time scale corresponding to microscopic collisions.This local equilibrium has well-defined values of local temperature  , pressure  and chemical potential , and the fluid element is thus characterized by the extensive quantities entropy   , internal energy   , volume   and number of particles   , which can all vary in time.Furthermore, the particle density inside the volume is uniform.Thus, the fundamental relation of equilibrium thermodynamics holds for the fluid element and can be written in the form also called local equilibrium condition.Note that here  is the molecular mass and we used the chemical potential per unit mass  = − (  /  )/.To formulate Eq. ( 18) in the same way as the balance equation ( 15) for the internal energy, we need to introduce the specific entropy , the specific internal energy  and the specific volume  −1 (that coincides with the inverse of the local mass density).This, together with Reynolds' theorem (see appendix A) and the identity (4), leads to where Eq. (19d) means that particles do not leave or enter the fluid element, which moves according to the velocity field .The local equilibrium condition (18) in terms of specific quantities becomes Since all variables are assumed to be uniform inside the fluid element , we can also write the specific variables as  =   /(  ),  =   /(  ),  −1 =   /(  ), with   being the total mass of the fluid element.Equation (20) thus becomes The extensivity of the entropy, i.e.,   (  ,   ,   ) =   (  ,   ,   ) for all positive values of , can be combined with Eq. ( 21) to provide a constraint on the intensive fields  , , , which are therefore not independent from each other.Indeed, by taking the derivative of   (  ,   ,   ) in  evaluated at  = 1 and dividing everything by the total mass   , we get the Euler relation Then, by subtracting Eq. ( 21) from the material derivative of  in Eq. ( 22), we obtain the Gibbs-Duhem equation, that constrains the evolution of intensive quantities Finally, the (local) entropy balance is obtained by using the first law (15) and the continuity equation (1a) in the local equilibrium (21): or, equivalently, In Eq. ( 25) we identify the entropy flux   ≡   / and the (macroscopic) EPR per unit volume The EPR is given by the sum of two different contributions corresponding to different local dissipative mechanisms: heat conduction (  hc ) and viscous friction (  vf ).In the macroscopic theory, the assumption that the two dissipative contributions in Eq. (26b) are decoupled and separately positive constitutes a formulation of the second law of thermodynamics, and it is related to the so-called Curie principle's [1].This assumption is the rationale behind the inequalities in Eq. (26b).In the microscopic and mesoscopic theory, one is instead interested in showing the positivity of the EPR combining hypotheses concerning the dynamics and the statistical behavior of a large number of particles (see § § III, IV and V).
Equations (1a), (1b) and ( 15) form a closed dynamical system for the spatio-temporal fields (, , ) when (i) the intensive fields ,  ,  are also expressed as functions of (, , ) from the knowledge of the entropy appearing in Eq. ( 22) and (ii) when an expression for the nonequilibrium fluxes   and  is available.The latter condition is achieved when confining the analysis to the linear regime, where   and  are linear functions of ∇   and ∇  , see e.g. the second equality in Eq. (2).In this case, the assumption that the distinct contributions to the entropy production are positive translates into the positivity of some coefficients characterizing the material (see § II F).
In the following, we will exploit the global conservation laws (i.e., those obtained upon integration over the whole volume) resulting from the boundary conditions to obtain stronger dynamical results valid beyond the linear regime.We will demonstrate how different boundary conditions (see Fig. 1) give rise to different global thermodynamic forces and thermodynamic potentials.The latter act as a Lyapunov function for systems in contact with an equilibrium environment.

D. Entropy Balance and Thermodynamic Potential for Isolated Systems
We formulate the global entropy balance for an isolated fluid contained in a domain  and determine its thermodynamic potential.We label  and  the boundary and the outward pointing unit vector, respectively.On this boundary, the heat flow and the velocity field must satisfy namely, heat flux and velocity are orthogonal to the boundary which physically means that no energy or momentum can be exchanged with the boundaries.Note that Eq. (27b) is trivially satisfied if one imposes a no-slip condition at the boundary, i.e.,  (; )|  = 0. We now take the time derivative of the global entropy  ≡ ∫   d using the local entropy balance (25), Eq. ( 4) and the boundary conditions in Eq. ( 27): where we introduced the global EPR  macro .The inequality in Eq. ( 28) (resulting from Eq. (26b)) implies that entropy is the thermodynamic potential that is maximized when an isolated system reaches equilibrium [55].Prigogine introduced the notion of "evolution criterion" for an inequality of the type in Eq. (28), where the time derivative of a thermodynamic potential has a definite sign [56,57].If such a potential has an upper bound, then it plays the role of the (negative of the) Lyapunov function for the system.In § II E, we obtain analogous relations for non-isolated systems.

E. Entropy Balance and Thermodynamic Potential for Non-Isolated Systems
In non-isolated systems, the existence of a Lyapunov function satisfying the equivalent of Eq. ( 28) depends on the boundary conditions.We now show how the thermodynamic potential which is maximized at equilibrium is modified when different experimentally relevant boundary conditions are imposed.FIG. 1. Illustration of a fluid in contact with 6 different regions of the environment corresponding to different types of boundary conditions.Regions 1-3 correspond to movable pistons coupling the system to reservoirs at a fixed temperature and pressure.The corresponding EPR is given in Eq. ( 48).Regions 4-5 are characterized by an externally fixed velocity on the boundary, which results in volume changes (4) or shear (5).The corresponding EPR is given in Eq. ( 41).On region 6, the wall is not moving and a heat flux can be maintained using external thermal devices, e.g., resistors coupled to an electric circuit.Notice that the external temperature should be defined everywhere on the boundary to allow for equilibration, which occurs when all the regions of the boundary have the same temperature.
Consider a closed but non-isolated system in a rigid domain  with constant volume  , delimited by a boundary  satisfying namely, with fixed temperature and a no-slip condition.The system can exchange heat with the environment via a nonvanishing heat flux   at the boundary.If the potential  as well as the temperature   are constant in time, the system will relax to the equililbrium compatible with the external temperature.However, the global entropy  = ∫   d is not the thermodynamic potential anymore.Indeed, by using the local entropy balance equation (25), Eq. ( 4) and the boundary conditions in Eq. ( 29), we find where  ≡ − ∫  d •   is the exchanged heat at the boundary (positive when it flows from the environment to the system) which is related to the global total energy  ≡ ∫   d via using Eqs.( 17), ( 4) and (29).Hence, the thermodynamic potential that is maximized at equilibrium can be written as where the inequality follows from Eq. (26b).This means that for a closed, rigid system in contact with an external thermostat, the thermodynamic potential is the difference between the global entropy and the global total energy divided by the temperature of the boundary.Closed systems where the volume  () can change in time due to control on the pressure are exemplified by the idealized case of a fluid enclosed by a flexible membrane with negligible surface tension or put in a vessel with a movable, weightless piston which is in contact with a gas in equilibrium at a given temperature and pressure (see Fig. 1).Mathematically, the temperature on the boundary is externally fixed according to On the other hand, the pressure  (; ) of the fluid and that of the environment   () do not have to coincide on the boundary.
In fact, the imbalance between the two pressures generates the external force in the Navier-Stokes equation (1b), i.e., the force  w is different from zero only on the boundary  () and satisfies where  is the identity matrix).To analyze the dynamics of the boundary, we assume the no-slip condition on the boundary, such that it moves with a velocity   () that coincides with the velocity field  () of the fluid evaluated on the boundary Hence, the volume changes in time according to as prescribed by Reynolds' theorem (see Eq. (A6) in Appendix A).To compute the mechanical power note that the only contribution to the time derivative of the potential energy per unit mass is the one due to the moving wall, which is localized on the boundary, i.e.,    () =    w ( −   ()), the latter being proportional to  ( −   ()).Using the chain rule, since the wall is moving with velocity   , we have where we used that the force   is different from zero only on the boundary and results from the pressure unbalance.Using Eqs. ( 17), (25) and Eq. ( 36), we can write the balance equations for the total energy  = ∫   d and entropy  = ∫   d which read respectively.By combining now Eq.(37a) with Eq. (37b), we obtain the following expression for the global EPR where the inequality follows from Eq. (26b).
If the pressure on the boundary is constant, namely, )), Eq. ( 38) becomes which allows us to identify the proper thermodynamic potential of a closed systems in contact with an external thermostat and exposed to a constant pressure as the difference between the global entropy and the sum of the global energy plus    divided by the temperature of the boundary.For a reversible transformation, the EPR vanishes,  macro = 0, and Eq. ( 38) identifies the maximum mechanical work which can be extracted as [58]  max mech ≡    eq =    eq −  eq .
This maximum available work or available free energy is also known as "exergy" in engineering [59,60].
3. Closed system under velocity control.
The volume of closed systems can also change when the velocity profile on the boundary   is externally controlled according to Eq. ( 35).If we consider again a uniform temperature on the boundary as in Eq. ( 33), we can combine the balance equations for the global total energy  and entropy  in Eqs.(17), and (25), respectively, to express the global entropy production as where the inequality follows from Eq. (26b) and we used that the force  w is different from zero only on the boundary  ().
Here, as well as in § II E 2, the potential energy density is time-dependent because of the moving boundary.The last equality is obtained after noticing that the contribution of the time derivative    =    int +    w is localized on the boundary, as The thermodynamics behind Eq. ( 42) is transparent.If the velocity profile at the boundary is nonuniform, the system remains out of equilibrium and undergoes either expansion, or compression, or shearing.From a thermodynamic standpoint, this results from the environment continuously performing mechanical work.When shearing at constant volume far from the turbulent regime (i.e., when the nonlinear terms in (1b) are negligible), the system approaches a nonequilibrium steady state.Finally, if the boundary has uniform and constant speed   and the center of mass (CM) of the system moves at the same velocity as the boundary, i.e.,  CM =   , the mechanical power in Eq. ( 42) reduces to the rate of change of the energy of the center of mass, namely  = d   CM , (see Eq. (C3)), provided that the internal potential energy  int is linear in , namely  int () =  •  (as it is for the gravitational potential).Therefore the system relaxes towards equilibrium and the EPR reduces to the total derivative  macro = d  ( − ( −  CM )/  ), which coincides with Eq. ( 32) as the two situations are equivalent under a Galilean transformation.

Closed system with multiple heat baths and time-dependent driving.
We now consider a closed non-isolated system contained in a domain  of volume  whose boundary  is composed of  = 1, . . .,  distinct regions   called reservoirs, or baths, i.e.,  = ∪    .The temperature of each region   () and the (uniform) pressure each region is exposed to   () are externally controlled and may depend on time following arbitrary protocols (see Fig. 1).On each region , the fluid temperature is assumed to be equilibrated with the environment, namely, while its pressure differs in general from the external pressure, i.e.,  (; )|   ≠   ().As we already discussed in § II E 2, the mismatch of pressure at each region implies that i) the boundaries move according to Eq. ( 34) (which now holds at the level of each single region ), ii) the volume changes according to Eq. ( 35) (which can be split into the contribution of each single region) and iii) the potential energy density changes in time according to Eq. ( 36) (which now holds at the level of each single region ).
From a thermodynamic standpoint, by using Eqs.( 17), (25) and Eq. ( 36) together with  = ∪    , the balance equations for the total energy  = ∫   d and entropy  = respectively, with Without loss of generality, we choose the reservoir  =  as the reference for the equilibrium temperature and pressure.Thus, by combining now Eq.(44a) with Eq. (44b), the global EPR can be written as or, by summing and subtracting (  d   )/  (with d   =  d    ) together with collecting all the time derivatives in a single contribution, as where the inequality follows from Eq. (26b).Equation ( 46) is the general balance equation for the global EPR in terms of (from the right to the left) i) time-dependent driving of the reference pressure   and temperature   , ii) global thermodynamic forces (i.e., pressure and temperature differences between the boundaries), and iii) the time derivative of a thermodynamic potential, If the system is coupled to a single reservoir with no time-dependent driving of   and   , then the thermodynamic potential  () would be maximized at the (equilibrium) steady state.Note that, by using the thermodynamic potential (47), Equation (46) reads The systematic derivation of the decomposition of the EPR in terms of the global thermodynamic forces, the time-dependent driving and the derivative of a thermodynamic potential is a significant result of the present work.Indeed, as it is well known, the classic formulation of nonequilibrium thermodynamics [1,14] is unable to differentiate systems that relax toward equilibrium from those who are actively maintained away from it by just looking at the expression of the EPR, in which only local thermodynamic forces appear [8].The systematic procedure to obtain the decomposition of the EPR that we outlined here for the case of a single component fluid, but which can be easily extended to more complex situations, is strictly related to the one used in engineering thermodynamics [59,60] in the context of the so-called "exergy method" of analysis.However, the latter is introduced in a phenomenological way that may disregard some contributions, like those accounting for timedependent driving on the boundaries.Equation ( 48) may thus provide a useful point of view to interpret new numerical and laboratory experiments in fluid mechanics [61,62] in which time-dependent driving at the boundaries translates into nontrivial effects on macroscopic heat fluxes affecting the efficiency of heat transport.
Notice that an alternative formulation of Eq. ( 48) can be obtained by representing each reservoir  = 1, . . .,  as an ideal gas at equilibrium at temperature   .Indeed, this allows us to quantify the energy exchanges between the system and the  reservoir according to the equilibrium first law: where − d    is the energy variation of the  reservoir.Thus, by using Eq. ( 49) in Eq. ( 48) and treating 1/  and   /  as independent intensive variables of the thermodynamic potential  () in Eq. ( 47), Eq. ( 48) becomes Equation ( 50) gives the rationale for the expressions of the intensive fields used in ST, see e.g.[34].

F. Linear regime and minimum entropy production principle
We conclude the discussion on the macroscopic aspects of the thermodynamics of non-isolated systems by showing that systems close to equilibrium satisfy a minimum entropy production principle in a form similar to the one obtained in the framework of ST [40].In turn, the latter is akin to the adiabatic-nonadiabatic decomposition [37] specialized in the linear regime.For related work on decompositions of the EPR in macroscopic systems see also Ref. [63].To obtain the aforementioned minimum entropy production principle, we write the macroscopic EPR  macro obtained by integrating Eq. (26a) in the linear regime, namely, when  q = ∇  (1/ ) and  are evaluated at the equilibrium density  eq and temperature  eq : Here, we use a notation such that the vectors' entries are the three components of    (1/ ) and the nine components of the strain tensor    ≡ (     +      )/2.Furthermore, we introduce the 9 × 9 positive-definite matrix whose entries are  (  ),( ′  ′ ) ≡ (     ′  ′ + 2 eq   ′    ′ )/ eq which together with the 3 × 3 positive-definite matrix with entries    defines the positive-definite linear response matrix .By restricting ourselves to the case of an incompressible fluid (and thus neglecting phenomena like pressure waves or thermal expansion), in Appendix B we prove that Eq. ( 51) can be alternatively written in terms of the steady state EPR  ss macro according to the following decomposition Thus, since the response matrix  is positive-definite, the state that minimizes the total EPR coincides with the steady-state solution.In Appendix B we also prove that the EPR is a Lyapunov function of the dynamics close to equilibrium (without resorting to further assumptions).We remark that  ss macro can be computed in terms of quantities only defined at the boundaries using for example Eq. ( 48), which specializes, for systems without time-dependent driving, to We further stress that the formulation of the minimum entropy production principle given in Eq. ( 52) is different from the version proved in Ref. [57] (where no dynamics is directly involved).Equation ( 52) has the same form of the decomposition of the EPR proposed by Oono and Paniconi [64] on phenomenological grounds.In Appendix B we provide the conditions under which it can be expected to hold.Equation ( 52) is a remarkable property of close to equilibrium steady states, which has a direct analogue in ST and can be interpreted as a geometric formulation of Prigogine's minimum entropy production principle [1,56].However, notice that the positivity of the quadratic form in the local thermodynamic forces appearing on the right-hand side of Eq. ( 52) is only ensured by the equilibrium properties of the response coefficients, and thus cannot be generalized to situations in which the steady state is not close to equilibrium.

III. MICROSCOPIC SCALE: HAMILTONIAN DYNAMICS
In this Section, we derive thermodynamic identities (and the related inequalities) for isolated systems made of particles obeying Hamiltonian dynamics.We use the symbol   (resp.  ) for the spatial coordinates (resp.momentum) of the -th microscopic particle, while the symbol  (resp.) is reserved to indicate a generic value of position (resp.momentum).

A. Dynamics
We start from a system of  identical particles whose dynamics follows Hamilton's equations where we introduced the Poisson brackets {, By extending the definition of material derivative to the phase space, i.e., , and using the Hamilton equations ( 54), the Liouville equation becomes A coarse-grained description of the system in terms of a one-particle probability density  1 (, ; ) is obtained by marginalization over the  − 1 positions and momenta of the other particles.Since the  particles are identical and thus there are  identical ways to choose one particle, it is convenient to define the one-particle distribution function which is clearly normalized to  .Here and in the following, the volume element is d  =  = −+1 d  , where   = (  ,   ) and d  = (2ℏ) −3 d  d  are the vector of canonical coordinates of the -th particle and its associated volume element, respectively.
The evolution equation of the one-particle distribution function is obtained from marginalizing the Liouville equation (55).When  can be written as , with  the external single-particle potential per unit mass and  the interaction potential between pairs of particles, the time evolution of  1 is given by the first equation of the Bogoliubov-Born-Green-Kirkwood-Yvon (BBGKY) hierarchy [48]: In obtaining Eq. ( 58), we used that   vanishes at the boundary of the integration domain.Equation (58) shows that the evolution of  1 splits into i) the free evolution generated by a single-particle Hamiltonian  1 () = 1 2  2 +  () and ii) a collision integral depending on the two-particle distribution function This procedure can be iterated to obtain the BBGKY hierarchy of equations specifying the evolution of the -particles distribution function and the corresponding collision term [48].If the hierarchy is not truncated, all the information of the microscopic dynamics is retained and the system evolves according to the original Hamiltonian dynamics.Nevertheless, the one-particle distribution function, the corresponding Boltzmann entropy and the corresponding nonequilibrium free energy satisfy exact thermodynamic identities, as we proceed to show in § III B.

B. Thermodynamic identities
We derive exact thermodynamic identities for the Hamiltonian dynamics, and use them to discuss the emergence of macroscopic thermodynamics by means of coarse-graining and dynamical chaoticity.
We start by introducing two definitions of entropy.The Shannon entropy is defined using the probability density   (  ; ) over the whole phase-space, while the Boltzmann entropy [1] is defined using the one-particle distribution function (57).On the one hand, the Shannon entropy ( 60) is not a thermodynamic entropy: it has not the same properties of the macroscopic entropy introduced by the local equilibrium (18).For instance,  tot is a constant of motion, i.e., d   tot = − B ∫ d  {  ,  } = 0, because the Liouville equation ( 55) preserves the volume in phase space.On the other hand, the Boltzmann entropy (61) can be related to the macroscopic entropy under certain conditions that we now examine.
To do so, we first express the Shannon entropy (60) in terms of the Boltzmann entropy (61): where we used i) multiplication and division by the logarithm of the probability distribution  =1  1 () ≡  =1  1 (  ; ) that the system would have if there were no correlations between particles, ii) the fact that particles are identical and iii) the relative entropy (or Kullback-Leibler divergence)   ( |) between two probability distributions  and Equation ( 62), together with d   tot = 0, implies that if the system is initialized in a state of completely uncorrelated particles, i.e.,   (  ; 0) =  =1  1 (  ; 0).Hence, by combining Eqs. ( 64) and ( 62), we obtain that the change of Boltzmann entropy is given by the relative entropy between the  -particle description, in terms of the probability density   , and a factorized description of the  -particles, by means of products of one-particle distribution  1 (i.e., the mutual information with respect to the factorized state [65]): The thermodynamic identity (65) represents a (weaker) microscopic analog of the second law of thermodynamics predicting the increase of Boltzmann entropy in isolated systems (like for the macroscopic entropy in Eq. ( 28)).However, Eq. ( 65) is not equivalent to Eq. ( 28) as it does not imply the monotone increase of  B (i.e., a H-theorem) since recurrences may occur [24].This becomes evident when expressing the variation  B () during a very short time increment  via Eq.( 62) together with d   tot = 0: where we did not use any hypothesis on the initial state at time .Indeed, according to the thermodynamic identity in Eq. ( 66), a positive rate of change of the Boltzmann entropy, namely, d   B () ≥ 0 at all times, is granted if the contribution coming from the second relative entropy on the right-hand side of Eq. ( 66) is always negligible compared to the first one, in agreement with the intuition gained via different approaches [10,12].This can happen when the stronger requirement of molecular chaos is satisfied, that is when the second relative entropy on the right-hand side of Eq. ( 66) vanishes at all times.We can thus conclude that the coarse-grained description alone, in terms of the one-particle distribution function, is not enough to guarantee irreversible thermodynamic behavior and should be complemented with hypotheses on the dynamics, e.g., molecular chaos.
For isolated systems, the entropy is the thermodynamic potential that is maximized at equilibrium and links the microscopic and macroscopic scales via its information-theoretic interpretation (see, for instance, Eq. ( 65)).On the other hand, non-isolated and non-isothermal systems feature a different thermodynamic potential liking the microscopic and macroscopic scales via its information-theoretic interpretation.Hence, we define the nonequilibrium Massieu potential [24,34] at the microscopic scale as where the average ⟪...⟫ stands for ⟪...⟫ = ∫ d 1  1 ( 1 ) (...), in such a way that it gives an extensive contribution, with  an arbitrary temperature.Its equilibrium counterpart  eq is obtained via Eq.( 67) by using the equilibrium one-particle distribution which reads, in the limit of impulsive interactions (i.e., short-range interaction not contributing to the total energy on average), where  eq is the equilibrium chemical potential which gives the correct normalization.Note that i) at equilibrium  eq  (  ; ) =   eq 1 (  ; ) and ii) the limit of impulsive interactions allows us to express the equilibrium one-particle distribution in terms of the  1 only [66].
In the following, we show that i)  () is upper bounded by its equilibrium value  eq and ii)  () − (0) ≥ 0 when the initial state satisfies   (  ; 0) =  =1  1 (  ; 0).First, by using Eq. ( 68) in Eq. ( 67) and summing and subtracting  eq  , we obtain the following thermodynamic identity for the nonequilibrium Massieu potential: where is the generalization of the relative entropy for non-normalized, positive functions  and  (also called Shear Lyapunov function in the context of chemical reaction networks [67,68]).Notice that the same result (69) applies also in the case of a timedependent Hamiltonian of the type  1 =  2 /2 +  (, ), which we will use in § V. Second, by using Eqs.( 67) and ( 65) together with the conservation of the single-particle energy, which holds for systems where the resulting force acting on the single particle due to impulsive interactions vanishes in average, i.e., ∫  =1 d    ∇   (| 1 −   |)) = 0, we obtain that the nonequilibrium Massieu potential increases in time: Note that Eq. ( 72), as well as Eq. ( 65), holds when the system is initialized in a state of completely uncorrelated particles, i.e.,   (  ; 0) =  =1  1 (  ; 0).Finally, we notice that similar thermodynamic identities have been already observed in different contexts.A similar thermodynamic identity to Eq. ( 65) has been already obtained using integral fluctuation relations [7,69].The difference is that we compare the  -particles distribution with a (completely decorrelated) product of one-particle distributions, while they introduce the backward Hamiltonian evolution which enters the integral fluctuation relations.The thermodynamic identities ( 65), (66), (69) are also similar to results obtained for systems coupled to equilibrium baths [24], but here there is no distinction between degrees of freedom of the system and of the baths.The identities presented in this Section rely on coarse-graining the many degrees of freedom in favor of a description in terms of the one-particle distribution and the factorization of the initial distribution.They are exact results which are consistent with the thermodynamic intuition, but do not lead to a full irreversible thermodynamics with a positive EPR.In fact, the microscopic dynamics may not be chaotic enough or may involve too few particles to obtain thermodynamic behavior [13,70].A fully consistent thermodynamic description can be obtained at the mesoscopic level by using the assumption of molecular chaos, as we proceed to do in § IV.

IV. MESOSCOPIC SCALE: BOLTZMANN EQUATION
The standard approach to introduce irreversibility in the evolution of the one-particle distribution function relies on the crucial assumption of molecular chaos [48], which means that particles are assumed to be uncorrelated before they collide [12].The resulting mesoscopic evolution is the Boltzmann equation.We now review the dynamics and thermodynamics of the Boltzmann equation both in general and after applying the Chapman-Enskog expansion to obtain the hydrodynamic equations.

A. Dynamics
The Boltzmann equation is a closed dynamical equation for the one-particle distribution function  1 resulting from truncating the BBGKY hierarchy [1,7,48] at the first equation ( 58) and approximating the collision integral involving the two-particles distribution function  2 in terms of the product of two one-particle distribution functions times a scattering rate  : Because of the underlying Hamiltonian dynamics [21], the scattering rate  must satisfy the time-reversal symmetry and be invariant under a generic rotation which implies invariance under inversion of the coordinate reference frame (, ) ↦ → (−, −) Combining Eqs. ( 75) and ( 76) leads to the microscopic reversibility condition: In this framework, the so-called summational invariant functions (, ) represent quantities satisfying the conservation law when two particles collide in  and the momenta  1 ,  2 ,  ′ 1 and  ′ 2 satisfy the equation of motion, i.e.,  ( ′ 1 ,  ′ 2 | 1 ,  2 ) ≠ 0. Their integral over the momentum is zero when multiplied by the collision integral [1]: This can be proved by multiplying the conservation law (78) by the integrand of  ( 1 ,  1 ), integrating over all the momenta and using the symmetry (77) and indistinguishability of particles to obtain four times the integral in Eq. ( 79).Functions () of the position only and constant functions are always summational invariants.Moreover, since the scattering rate  derives from an underlying Hamiltonian dynamics, also the kinetic energy and the momentum are summational invariants: Note that Eq. ( 79) implies that ∫ d  ( 1 ,  1 ) = 0 and, therefore, that the Boltzmann equation ( 73) conserves the total number of particles.
To describe the behavior of the system in the configuration space, we introduce the (mesoscopic) spatio-temporal fields mass density and velocity as Their balance equations are obtained by applying the the material derivative   =   + ⟨⟩ • ∇  and using the Boltzmann equation ( 73) when evaluating    1 in Eqs.(80).The balance equation for mass density reads while the balance equation for the average velocity reads where the pressure tensor can be expressed as with ( −  ⟨⟩) ( −  ⟨⟩) being the matrix whose entries are (  −  ⟨  ⟩) (  −    ) ( and  labeling here the three spatial components) and  = −∇   being the external force per unit mass at point .Note that these mesoscopically-derived balance equations ( 81) and ( 82) are in one-to-one correspondence to the macroscopic Navier-Stokes equations (1).

B. Thermodynamics
We now introduce the mesoscopic definitions, as well as their respective balance equations, of the specific thermodynamic quantities examined at the macroscopic level in § II.The (specific) internal energy is given by and its balance equation, obtained using again the Boltzmann equation ( 73), reads where the heat flux is given by The specific entropy per unit mass defined, for consistency with Eq. ( 61), as satisfies the balance equation Here, the entropy flux is defined as It is worth noting that, unlike the corresponding macroscopic fluxes in Eq. ( 25), the mesoscopic entropy flux (89) is not proportional to the mesoscopic heat flux (86).This difference emerges from the absence, in general, of the local equilibrium condition.We will verify in § IV D that if  1 satisfies the local equilibrium, the proportionality between ⟨  ⟩ and   is recovered.By omitting the spatial dependence for shortness and with the notation d 4  = (2ℏ) −3 =1,2 d  d ′  , the (local) EPR ⟨  B ⟩ reads where the inequality follows from microscopic reversibility (77).Note that the balance equation ( 88) implies that for an isolated system namely, the (global) Boltzmann's entropy  B defined in Eq. ( 61) monotonously increases in time according to the Boltzmann equation, in contrast to what we obtained in the microscopic theory (see Eq. ( 65)).This is an alternative statement of Boltzmann's H-theorem [1].
The theory developed here is the mesoscopic analog of the macroscopic thermodynamics discussed in § II, but they are still not equivalent: the crucial local equilibrium condition (21), or equivalently, the Euler relation (22), has not been derived yet.
To recover them, we need to introduce perturbative solutions of the Boltzmann equation as we now do in § IV C.

C. Linking the Mesoscopic and Macroscopic Description via the Chapman-Enskog Expansion
Many perturbative solutions of the Boltzmann equation have been derived [1,11].Since we are interested in the dynamics of the spatio-temporal fields accounted by the balance equations ( 81), ( 82), (85), (88), we apply the Chapman-Enskog scheme, i.e., a type of multiple-scales perturbation theory [15].

Zeroth-order of the Chapman-Enskog expansion.
We start by identifying two (temporal and spatial) scales of the Boltzmann dynamics.We introduce a macroscopic length scale  on which the external potential  varies, and the associated macroscopic timescale  = /  , with   the typical molecular velocity.The second timescale corresponds to the mean free time between collisions   and is related to the mean free path  =     .The Knudsen number is defined as the ratio between these two scales, and plays the role of the small parameter in the Chapman-Enskog perturbative scheme.Indeed, by using these length and time scales to define adimensional variables (marked by the primes), the Boltzmann equation ( 73) becomes (removing the primes for compactness) We are interested in the limit  → 0, in which the collision term dominates the evolution of the one-particle distribution.We thus consider the expansion and substitute it in Eq. ( 94).The zeroth-order solution is given by any one-particle distribution function for which the collision integral of the Boltzmann equation vanishes: To identify  (0) , we notice that a solution for which the EPR in Eq. (90) vanishes must also satisfy Eq. ( 96).Thus, we look for solutions of ⟨  B ⟩ = 0 which can be rewritten in the form (79) for the quantity  = ln  (0) by using the symmetry in Eq. ( 77) and the indistinguishability of the particles.This implies that ln  (0) must be a function of summational invariants, like mass, momentum and kinetic energy.We can thus verify that the local Maxwell-Boltzmann distribution with, in general, -dependent and -dependent temperature  (), velocity  (), chemical potential of the ideal gas and density  () (satisfying ∫ d  () =  ), solves Eq. ( 96), namely,  (0) =  MB .Here all the quantities in Eqs. ( 97) and (98) are written using the scaling defined in Eq. (93) (in particular, energy, temperature and ℏ are expressed in  2  ,  2  / B and   units, respectively).At this stage, the temperature  (), the velocity  () and the density  () in Eq. ( 97) are arbitrary parameters of the Maxwell-Boltzmann distribution, but they will be determined in the following using the balance equations.For convenience, we recast the expansion in Eq. ( 95) truncated at the first order using the Maxwell-Boltzmann distribution as namely, defining  (, ) ≡  (1) (, )/ MB (, ).Now we examine how the parameters of the Maxwell-Boltzmann distribution (97), that is the zeroth-order solution of (94), are related to the (mesoscopic) spatio-temporal fields mass density ⟨⟩() and velocity ⟨⟩() introduced in § IV A. By using Eq.(97) in Eqs.(80a) and (80b), we obtain and, consequently, the density  () and velocity  () are determined by the balance equations ( 81) and ( 82) which can be rewritten now as by solving the integral in Eq. ( 83) using Eq. ( 97) which leads to a diagonal pressure tensor, On the one hand, the zeroth-order Chapman-Enskog expansion recovers the macroscopic mass balance equation (namely, Eq. (101a) coincides with Eq. ( 1a)).On the other hand, it describes only fluids without viscous friction since a diagonal pressure tensor enters the zeroth order momentum balance equation (101b) unlike in Eq. (1b).Second, we focus on the thermodynamic quantities introduced in § IV B, as well as their balance equations.By using the Maxwell-Boltzmann distribution (97), the (specific) internal energy (84) becomes while its balance equation (85) reads since the heat flux vanishes, i.e.,   () = 0.The balance equation (104) implies that the temperature  () changes only due to the transport caused by the velocity field.Analogously, the balance equation (88) for the local entropy becomes since the Maxwell-Boltzmann distribution leads to a vanishing entropy flux ⟨  ⟩() = 0 and entropy producation rate ⟨  B ⟩ = 0.This physically means that, at the zeroth-order of Chapman-Enskog expansion, the evolution of a fluid is isentropic along the flow lines.Finally, by using the using the Maxwell-Boltzmann distribution (97) in Eq. ( 87) together with Eq. ( 103) and  () =  () (), we can write the specific entropy as which represents the mesoscopic formulation of the Euler relation (22).Note that, even if the zeroth-order of Chapman-Enskog expansion is consistent with the Euler relation (22), or equivalently with the local equilibrium condition (21), this consistency is a trivial one.In fact, the dissipative effects characterizing the macroscopic thermodynamics and responsible for the variation of the local entropy are not recovered (see Eq. ( 105)).We thus move to the next order of the Chapman-Enskog expansion.
The first-order equation of the Chapman-Enskog expansion of the (adimensional) Boltzmann equation ( 94) can be written as by using Eq. ( 99), the material derivative because of the conservation of the kinetic energy and momentum.The first order correction  must not contribute to the value of the spatio-temporal fields mass ⟨⟩(), momentum ⟨⟩() and internal energy ⟨⟩() since they are already recovered from the the parameters  (),  () and  () of the zeroth-order solution (97) according to Eqs. (100a), (100b) and (103), respectively.This implies that ∫ d (2ℏ) 3  (, ) MB (, ) = 0 , (108a) However, the correction  should affect the balance equations of momentum, internal energy and entropy via the non-diagonal elements of the pressure tensor and the heat flux and, furthermore, lead to a nonvanishing entropy flux and EPR.
To determine , we start by expressing the terms on left-hand side of Eq. (107) using Eq. ( 97) together with Eqs.(101a), (101b) and (104).We obtain with  and  labeling the three spatial components.By using the strain tensor    = 1 2 (     +      ), the left-hand side of Eq. (107) becomes Comparing this expression with Eq. ( 107) suggests that  is a linear function of the temperature ∇   and velocity {     } gradients [1].To determine its expression, one could introduce an expansion in appropriate orthogonal polynomials [9].However, for the sake of simplicity, we will employ the relaxation-time approximation or single-collision-time approximation [48,49].This approximation corresponds to use the properties of the Maxwell-Boltzmann distribution  MB to obtain the following estimate of the collision operator on the right-hand side of Eq. ( 107), Here, we assumed that before a collision takes place the distribution is the equilibrium one, i.e.,  ( ′ 1 ) =  ( ′ 2 ) ≈ 0. Furthermore, we assumed that the factor  MB ( 2 ) (,  2 | ′ 1 ,  ′ 2 ) decays fast enough as a function of the difference  2 −  that only the zeroth-order contribution in the expansion around , namely  ( 2 ) ≃  (), can be retained.Therefore, the resulting scattering timescale   does not depend on  or on the gradients of temperature or velocity.
Thus, by using the relaxation time approximation (111) together with Eq. ( 110) in Eq. ( 107), we conclude that The relaxation time approximation is only appropriate for modeling near-equilibrium systems [49].A more rigorous treatment leads to the emergence of two different scattering timescales associated to viscous forces, accounted by the first term on the right-hand side of Eq. ( 112), and thermal diffusion, accounted by the second term on the right-hand side of Eq. ( 112).This discrepancy becomes important in determining the quantitative values of the pressure tensor ( 83) and the heat flux ( 86), but it is not fundamental for our qualitative discussion of thermodynamics.For this reason, we will further simplify the expressions assuming   = 1 in the following.Notice that  given in Eq. ( 112) satisfies the constraints in Eqs.(108a), ( 108b) and (108c) as one can verify using the properties of the Gaussian distribution: In particular, Eq. ( 108b) is equivalent to ∫ d ( − )  (, )  MB (, ) = 0 (by using Eq.(108a)), which is verified by  given in Eq. (112) because i) the terms multiplied by the strain tensor    independently vanish by symmetry, while ii) the terms multiplied by the temperature gradient ∇   sum up to zero after integration.
We have now all the elements to assess the consistency of the first order solution (99) (with  given in Eq. ( 112)) with the macroscopic theory, as originally done by Prigogine [14].
First, we consider the balance equations for the (mesoscopic) spatio-temporal fields mass ⟨⟩(), momentum ⟨⟩() and internal energy ⟨⟩() given in Eqs. ( 81), ( 82) and (85).These equations have the same form as the macroscopic balance equations (1a), (1b) and ( 15) using the zeroth-order solution.Therefore, we only need to use the correction  to evaluate the changes in the pressure tensor ⟨⟩ in Eq. ( 83) and the heat flux   in Eq. ( 86) which become equal to Unlike the zeroth-order expression (102), Eqs.(114a) and (114b) account for the additional viscous part of the tensor pressure as well as a nonzero thermal conductivity.Furthermore, Eqs.(114a) and (114b) show a linear relation between ⟨⟩ and   , on the one hand, and their conjugate thermodynamic forces {   } and ∇   , on the other hand.This means that the first-order of the Chapman-Enskog expansion describes fluids in the linear regime, namely, close to equilibrium.Second, the local thermodynamic equilibrium is left unaffected by the inclusion of the first Chapman-Enskog correction: substituting the first order solution (99) (with  in Eq. ( 112)) in Eq. ( 87), we obtain again Eq. ( 106), as a consequence of the constraints in Eqs.(108a), (108b) and (108c).On the other hand, the first order solution leads to a nonvanishing EPR which reads where the  macro is the one computed in the linear regime of irreversible thermodynamics, i.e., after linearization of ⟨⟩ and   in terms of (   ) and ∇   as given in Eq. ( 51).Third, we verify that in the presence of local equilibrium the entropy and heat flux are proportional to each other.By substitutiong the Chapman-Enskog solution (99) in Eq. ( 89) and using the expression of the Maxwell-Boltzmann and the property (108b), we find The Chapman-Enskog procedure can in principle be continued to obtain higher order corrections in the Knudsen number.However, the resulting Burnett and super-Burnett equations display unphysical oscillations or other artificial behavior near the boundary [11,71].Furthermore, by considering the higher perturbative orders one looses the crucial property of local equilibrium [1,14].Therefore, the higher orders of this approximation have little significance for thermodynamics and will not be considered in the following.

D. Thermodynamics of the Transient Relaxation to Local Equilibrium
The Chapman-Enskog solution (99) describes only a restricted class of solutions of the Boltzmann equation ( 94) close to the equilibrium for which the EPR (90) coincides with the macroscopic one in the linear regime according to Eq. ( 115).However, the Chapman-Enskog perturbation series does not describe the relaxation of an arbitrary initial condition towards the distribution (99).The study of the relaxation process of an arbitrary initial condition to the Chapman-Enskog solution is as difficult as the original Boltzmann equation.Therefore, we employ a perturbative treatment following Grad's method [11,72].In this way, we are able to identify the contribution of this relaxation process to the EPR in Eq. (90).
We consider an initial condition  1 (0) for the one-particle distribution close to the near-equilibrium solution (99).Then, we introduce two separate timescales.One timescale is associated with the (slow) dynamics of the Chapman-Enskog solution (99).The other one,  =  −1 , is related to a fast relaxation process, and is relevant only over times comparable to the Knudsen number (92).To account for both timescales, we add a correction term to the Chapman-Enskog solution (99) and write with the condition that  rel 1 () decays to zero exponentially fast for  ≫ 1.By substituting Eq. (117) in the Boltzmann equation (94), we obtain By introducing   =   , keeping only terms linear in , and using the fact that  CE 1 makes the left-hand side of Eq. ( 118) vanish, being a solution of Eq. (94) up to order  (), we obtain where we introduced the linearized collision operator (acting on a generic distribution function ) with  MB the Maxwell-Boltzmann distribution (97) satisfying  MB ( ′ 1 )  MB ( ′ 2 ) =  MB ( 1 )  MB ( 2 ) because of the conservation of the kinetic energy.The dynamics of  rel 1 () is obtained by solving Eq. ( 119), and we refer to the original article [72] for the quantitative theory.Here, we focus on the entropy production (90) for distributions of the type in Eq. ( 117).The result in the dominant order in  is given by where  macro is given in Eq. ( 115), is the EPR of the relaxation to the Chapman-Enskog distribution (the local equilibrium distribution) and becomes negligible for long times  ≫ 1.It is important to note, however, that for short times  ≲ 1, the two contributions are of the same order in .The third term in Eq. (121), does not have, in general, a definite sign.This means that while the total EPR in Eq. ( 121) is positive definite, it is not necessarily larger than the one due to the macroscopic processes, i.e.,  macro .

V. MESOSCOPIC SCALE: GENERALIZED BOLTZMANN EQUATION WITH EXTERNAL RESERVOIRS
The microscopic and mesoscopic theory discussed in § § III and IV, respectively, are derived starting from an isolated system setup.Therefore, they do not explicitly account for what happens at the system's boundary which is crucial in open systems, as it can lead to thermodynamic inconsistencies when arbitrary conditions are fixed at the boundary [7,8,11].By taking inspiration from both old and recent works in nonequilibrium thermodynamics and ST [50][51][52][53], we develop here a model that includes the boundary directly in the Boltzmann equation and examine the corresponding thermodynamics.Note that throughout this Section we will use the adimensional variables introduced in Eq. (93).

A. Dynamics
The boundary  is split into different reservoirs, or baths,  = ∪    like in § II E 4. We assume that each reservoir  is composed of non-interacting particles always in equilibrium at the temperature   and its one-particle distribution function is given by Here,  (  ) is the partition function,   is the total number of particles,   is the (externally controlled) velocity of the reservoir, U  ( ) is a (arbitrary) potential that confines the reservoir's particles to   , i.e.,   = ∫ 3 .For simplicity, we further assume that the particles of the reservoir have the same mass of those of the system:   = .
In the limit of dilute fluids, collisions are rare and can only take place either between pairs of particles of the system or between one particle of the system and one particle of a single bath.Thus, we modify the Boltzmann equation (94) by adding collision terms corresponding to each reservoir: where  ( 1 ,  1 ) is given in Eq. ( 74), while the linear collision term due to the reservoirs reads with the scattering rate   satisfying Eq. ( 77) like  .Note that Eq. ( 125) generalizes previous formulations of linear Boltzmann equations discussed in the framework of ST [52,53] by including the nonlinear collision integral  ( 1 ,  1 ).
The balance equations for the (mesoscopic) mass density and velocity defined in Eqs.(80) according to the generalized Boltzmann equation (125) (which are analogous to Eqs. ( 81) and ( 82)) read: where the pressure tensor ⟨⟩ () is defined in Eq. ( 83), the force can be written as  =  int +  w (see § II B), and we used Eq. ( 125) together with the property of summational invariance Eq. ( 79).Notice that i) ⟨⟩ must satisfy the boundary conditions ⟨⟩ |   =   , and ii)  w as well as   ( 1 ) are nonvanishing only on the boundary .

B. Thermodynamics
We now derive the thermodynamic description corresponding to the generalized Boltzmann equation (125).
1. First and Second Law.
The global momentum, the kinetic and potential energy balances corresponding to Eqs. (127) are respectively.In Eq. (128c), we used that boundary is split in different reservoirs moving at different velocities changing the confining potential  w in such a way that ( ) d  w .We now use Eqs.( 127) and (128b) to express the balance for the (global) internal energy  = ⟪( − ⟨⟩) 2 ⟫ /2 in terms of the power  and the heat flows at the boundaries   with each reservoir : Equation ( 129b) is the global formulation of the first law for the generalized Boltzmann equation (125).Before turning to the entropy balance, we consider the equilibrium distribution corresponding to the -th reservoir, with a time-dependent chemical potential   eq , that becomes the equilibrium solution  eq  of the generalized Boltzmann equation (125) when all reservoirs have the same temperature   =   and velocity   =   .Indeed,  eq  satisfies where   = (  +   • ∇  ), and the equilibrium chemical potential  eq satisfies ∇   eq () =  () and therefore reads at every time  and with  eq a constant.This can be easily proven by direct substitution and using momentum conservation in the form  eq  () eq  ( 2 ) =  eq  ( ′ )  eq  ( ′ 2 ) as well as   1 ( )  eq  () =   1 ( ′ )  eq  ( ′ ) when   =   and   =   for every reservoir.Equation ( 130), together with ∫ d   ( 1 ) = 0, and the fact that the bath distribution   1 ( ) is nonvanishing only on the region   where ⟨⟩ =   , allows us to write the heat flux (defined in Eq. (129b)) as Therefore, we obtain the second law (the global entropy balance) in the form of Equation (134c) follows from Eq. (A6), the summational invariance (79), summing and subtracting    1 ln  eq  , and identifying the EPR inside the system and on the boundary which are separately nonnegative as we now show.Indeed, by using the indistinguishability of the particles and the symmetry (77), Eq. ( 135) can be rewritten as This approach cannot be applied to Eq. ( 136) since the particles of the system and the particles of the reservoirs are not indistinguishable.However, by using i) the explicit expression of   1 and  eq  in Eqs. ( 124) and (130), respectively, together with ii) the conservation of the kinetic energy in the form, i.e., ( −   ) 2 − ( ′ −   ) 2 = ( ′ −   ) 2 − ( −   ) 2 , we obtain 2. Global thermodynamic potential.
We now show that, when the system is i) closed in a domain  () with the boundary moving at constant and uniform velocity   , and ii) in contact with a single external reservoir (identified by  = ) with temperature   , the dynamical equation (125) satisfies the analogous of a H-theorem (i.e., it admits a Lyapunov function) ruling the relaxation to equilibrium.To do so, we rely on the nonequilibrium Massieu potential  =  B () − ⟪((−  ) 2 /2 + )⟫ /  (defined in general in Eq. ( 67)), and we proceed in three steps.
First, as proven in Eq. ( 69),  is upper bounded by its equilibrium value  eq when the time-dependent Hamiltonian  1 = (−  ) 2 /2 +  (, ) results from all reservoirs moving with the same uniform velocity   and all reservoirs having the same temperature   .
Second, for the general case of multiple reservoirs  = 1, ...,  with different velocities and temperatures, the time-derivative d   reads and, consequently, (minus) the nonequilibrium Massieu potential  plays the role of a Lyapunov function for the relaxation to equilibrium of the dynamics (125).Note that the system relaxes to equilibrium also when the boundaries move with a single velocity   =   ∀ and the center of mass (CM) of the system moves at the same velocity, i.e.,  CM =   .Indeed, in this case the the mechanical power  mech in Eq. (139b) reduces to the rate of change of the potential energy of the center of mass, namely )), provided that the internal potential energy  int is linear in , namely  int (() =  • (as it is for the gravitational potential), and the thermodynamic potential becomes Finally, we recast Eq. (139c) in the form of a decomposition of the EPR.By isolating the total EPR, we obtain that is the mesoscopic analogue of Eq. ( 48) (see also Eq. ( 42)).Indeed, it features the time derivative of a thermodynamic potential d  ; a mechanical power contribution  mech due to the velocity externally imposed on the boundary; a flux-force contribution due to the presence of heat fluxes   exchanged with the environment and triggered by the presence of global differences in temperature.For clarity of presentation, we did not consider the possible time-dependence in externally controlled parameters   or   , and therefore the corresponding terms in Eq. ( 48) do not appear here.Therefore, we can identify the nonequilibrium Massieu potential defined at the mesoscopic scale with the one featuring in Eq. ( 48), i.e.,  =  , if the one-particle distribution  1 satisfies the local equilibrium.This point is further examined in the following Section.

Local thermodynamic potential.
We now identify the local thermodynamic potential ⟨⟩ (i.e., the local version of the global potential ), upper bounded by its equilibrium value ⟨⟩ eq , corresponding to the global macroscopic thermodynamic potential  given in Eq. ( 47), and which governs the relaxation to equilibrium when all the reservoirs have the same velocity   =   and temperature   =   .We start by observing that by using Eqs.( 80), ( 84), ( 87), ( 130), ( 132) and We then identify the local total energy in the frame comoving with   as and recall that the pressure tensor satisfies Eq. ( 102) when  1 is a Maxwell-Boltzmann distribution like  eq  in Eq. ( 130) yielding where   is the pressure that the system would reach at equilibrium.This allows us to write the mescoscopic thermodynamic potential as (minus) the right-hand side of Eq. ( 142) divided by the local density ⟨⟩: with ⟨⟩ −1 being the specific volume as in § II C. Note that ⟨⟩ eq = 0 because of the local equilibrium (106) and that ⟨⟩−⟨⟩ eq ≤ 0 because of Eq. (142).Furthermore, ⟨⟩ is the local, mesoscopic analog of the global, macroscopic potential  , and the exact identity ∫  d ⟨⟩ ⟨⟩ =  is recovered when (i)   = 0 and (ii)  1 satisfies the local equilibrium, as it is the case for the Chapman-Enskog solution (99) that turns the mesoscopic specific entropy ⟨ B ⟩ into the macroscopic specific entropy.Notice that the local thermodynamic potential (145) has the same form as the macroscopic one (47), the only difference being the term  eq /  , which emerges because the system is locally open (i.e., it exchanges matter with its surroundings) as already observed in Ref. [42].This same fact also prevents the existence of a local version of a H-theorem for ⟨⟩.

VI. STOCHASTIC THERMODYNAMICS FOR VISCOUS FLUIDS
By building on Eq. ( 125), we now develop a linear theory for the one-particle distribution function, endowed with the property of local detailed balance featuring an explicit non-conservative contribution, which is the form usually assumed in Stochastic Thermodynamics [17,34,73].This theory further admits a Chapman-Enskog solution identical to the one obtained in § IV C and therefore gives rise to the hydrodynamic equations presented in § II.
A. Dynamics and Local Detailed Balance.
We consider a diluted suspension of   particles  in a weakly out-of-equilibrium fluid made up of   particles , with respective molecular masses are   and   .Since   ≫   , the fluid of particles  is not affected by the presence of particles .The one-particle distribution,  1 , is thus well described by the Chapman-Enskog form  1 =  MB  (1 +    ) with  MB  given in Eq. (97) and   given in Eq. ( 112), except for a trivial change in normalization from  to   .Also, ⟨  ⟩ = , where  is the velocity of the fluid solving the macroscopic Navier-Stokes equations.Since the particles  are diluted, the collisions among them are neglected, while their collisions with the fluid of particles  and with the reservoirs constituting the boundaries are retained.Therefore, dynamics of the one-particle distribution  1 is given by (125), where the collision integral  ( 1 ,  1 ) is neglected, a collision integral  ( 1 ,  1 ) is added and the collision integral   ( 1 ) is retained.
First, we consider the interaction with the boundary   and we rewrite the collision integral (126) as where we introduced the transition rates By using the one-particle distribution function (124), we prove that the transition rates satisfy the local detailed balance condition [29,30,50,52,53,73] with the variation of the kinetic energy of the system (measured with respect to the wall velocity   ) due to the transition  ′  ↦ →   satisfying   (  | ′  ) = (( ′ −  ) 2 − ( −  ) 2 )/2 because of the conservation of the kinetic energy.Note that Eq. ( 148) means that the local detailed balance condition holds for each reservoir individually.Furthermore, the change in kinetic energy in Eq. ( 149) is expressed as the sum of two terms of the same order in the Knudsen number  but with different thermodynamic meaning.The first term after the second equality in Eq. ( 149) plays the role of the change in a thermodynamic potential.The second term after the second equality in Eq. ( 149) is a nonconservative term that emerges from the collisions with the reservoir moving at the velocity   .Indeed, it is the same as in the local detailed balance condition obtained in Ref. [53].Second, we consider the dynamics far from the boundary and we write the the collision integral  ( 1 ,  1 ) as with rates since we assumed that  1 =  MB  (1 +    ).Note that Eqs. ( 146), ( 147), ( 150) and (151) define a linear evolution equation for  1 .To verify whether the rates (151) satisfy the local detailed balance condition or not, we expand the ratio   (  | ′  )/  ( ′  |  ) to first order in  and we obtain where we used the notations Equation ( 152) does not correspond to the local detailed balance condition.Indeed, on the one hand, the most general formulation of the local detailed balance [34] for a transition  reads ()/(−) = exp{−(   −  () ())/  }, where () (resp.(−)) is the forward (resp.backward) rate,    is the change of the thermodynamic potential, as in the local detailed balance (148) for collisions at the boundary, while  () () is the nonconservative work that depends only on the transition and is given by the product between a thermodynamic force  () and the conjugate quantity  ().On the other hand, the term of order  in Eq. ( 152) does not depend only on the change in momentum, which identifies a transition in our case.However, Eq. (152) becomes equivalent to the local detailed balance condition in the small variance limit    2 ≫  B  where the Maxwell-Boltzmann distribution  MB  ( ′  ) becomes sharply peaked around  (see Eq. ( 97)).This, together with the momentum conservation  ′  =   +   (with   =   −  ′  ), leads to using   ≃ 1 + .Equation ( 154) is the local detailed balance for the collisions between particles of type  and , and features two contributions with a different scaling in the Knudsen number .The zeroth order contribution,  (  | ′  ), can be split into two terms (see Eq. (153a)) with different thermodynamic meanings, as for   (  | ′  ) in Eq. ( 149).The first term after the second equality in Eq. (153a) plays the role of the change in a thermodynamic potential.The second term after the second equality in Eq. (153a) is a nonconservative term that emerges from the collisions with the particles  moving at the average velocity .It generalizes Eq. (149) to reservoirs with spatially nonuniform temperature and velocity.The first order contribution,  (,  −  ), is an additional nonconservative term due to temperature and velocity gradients.Indeed, by using Eqs.(153b) and (112),  (,  −   ) becomes The thermodynamic forces are the local strain tensor    and the local temperature gradient ∇   , while the conjugate quantities are { , }, which are conserved in the corresponding thermodynamically isolated system.The thermodynamic forces can be determined by solving the macroscopic equations for  and  and vanish when temperature and velocity become uniform in space.The necessity of a small noise approximation (like the small variance limit leading to Eq. ( 154)) when deriving the local detailed balance condition as a coarse-graining of an underlying nonconservative dynamics has been already observed in the context of overdamped diffusion in a potential landscape plus a small nonconservative force [29].Therefore, by using the rates in Eqs. ( 147) and (151) satisfying the local detailed balance conditions in Eqs. ( 148) and (154), the generalized Boltzmann equation (125) for the type  particles becomes the following linear equation (dropping the  subscript when redundant from now on):

B. Chapman-Enskog Expansion
We now show that Eq. ( 156) admits a Chapman-Enskog solution and, consequently, it has a macroscopic hydrodynamic limit.To do so, we apply the Chapman-Enskog procedure of § IV C to Eq. (156) in the small variance limit in which the local detailed balance (154) holds.By inserting  1 =  (0) 1 +   (1)  1 +  ( 2 ) into Eq.( 156), zeroth-order in  reads We now assume that the two terms in Eq. ( 157) vanish separately and then check the consistency of the result.Note that the first term must vanish in every point of the domain , while the second only on the boundary  because of the definition of   .By using the local detailed balance (154) with  = 0, we find that the first term is zero if  (0) 1 is a Maxwell-Boltzmann distribution (97) with the temperature and mesoscopic velocity field  solving the macroscopic Navier-Stokes equations determined by the type  particles.By using the local detailed balance (148), we find that the Maxwell-Boltzmann distribution makes also the second term in Eq. ( 157) vanish when the temperature and mesoscopic velocity field assume the values imposed by the reservoirs on the boundary, i.e.,   and   .
We now examine the first-order correction in  of Eq. ( 156).The first-order correction of the left-hand side of Eq. ( 156) is the same as the one obtained in Eq. ( 110) when applying the Chapman-Enskog procedure to the original Boltzmann equation (94).To determine the first-order correction of the right-hand side of Eq. ( 156 We now apply again the relaxation time approximation (111).By assuming that i) the perturbation is negligible before a collision, i.e.,   ( ′ 1 ) ≈ 0 and ii)  0 ( ′ |) decays fast enough with  implying  (,  − ) =  (|| 2 ), Eq. (158a) leads to where ( ′  ) −1 ≡ ∫ d ′  0 ( ′ |) is -independent for the same reasons as in Eq. (111).By applying the same reasoning to Eq. (158b), we obtain with (  ) −1 ≡ ∫ d ′   ( ′ |).By combining the left-hand side of Eq. (110) with Eqs.(159), and (160), we verify that the expression in Eq. (112), with the relaxation time  −1  = (( ′  ) −1 +   −1  ), is the first-order correction in the Chapman-Enskog solution of Eq. (156).Notice that by following the same approach, one can also show that  1 is the Chapman-Enskog solution of Eq. (125) corresponding to the values of temperature and velocity imposed at the boundaries.
The corresponding dynamical equations for   and ⟨  ⟩ =  are, therefore, obtained substituting the Chapman-Enskog expansion of  1 into the balance equations for mass and momentum, Eqs.(80), and result in the macroscopic Eqs.(1) (with  =   ).Notice that the pressure tensor  and heat flux   coincide with those in Eqs.(114), except for a different relaxation time taking into account the effect of the boundary.

C. Thermodynamics
We now formulate the thermodynamics, namely, the first and second law, corresponding to the Chapman-Enskog solution of Eq. (156) (ensuring in particular that ⟨  ⟩ = ) by following the same steps as in § V B 1. We start by writing the balance equations for the velocity and the kinetic energy respectively.The difference between Eqs. (161a) and (161b), on the one hand, and Eqs.(127b) and (128b), on the other, results from  2 and  not being summational invariants under the collision operator   ( 1 ) in Eq. ( 150).Hence, Eqs.(161) lead to the following first law where the   and  are defined like in Eq. (129b), while   reads where   is the EPR on the boundary in Eqs. ( 136) and (138).We split the integral in Eq. (164b) into Note that Eq. (167) together with Eq. (158a) implies that   () is given by the sum of two contributions with a different scaling in the Knudsen number.The zeroth order contribution accounts for the local heat flow   ().At this order, the local equilibrium relation   () =   ()/ () holds.The first order contribution emerges instead from the nonconservative work (resulting from the irreversible momentum exchanges between  and  particles) and breaks the local equilibrium even if, at the same time, local detailed balance is obeyed at the mesoscopic scale and the macroscopic dynamics is the solution to the hydrodynamic equations.The local equilibrium is broken also in the framework of the so-called Extended Irreversible Thermodynamics where the nonconservative contributions to the balance equation for the entropy are included on phenomenological grounds or derived from Grad's thirteen-moment approximation [74].We conclude by expressing the entropy production (165) in the first order in  by using Eq.(158a), the local detailed balance condition (154) and  0 (| ′ )  MB  ( ′ ) =  0 ( ′ |)  MB  ().This leads to which emphasizes the analogy with the expression obtained in ST (in the corresponding linear regime [40]).This expression confirms that the physical meaning of  (,  − ) is that of a nonconservative work rate done by the local thermodynamic forces ∇   and (   ).On the other hand,  (   ( ′ ) −   ()) ≃ ln  1 () MB 1 ()/ 1 ( ′ )  MB 1 ( ′ ) is the information-theoretic contribution to the EPR due to the fact that the transition  ↦ →  ′ occurs out-of-equilibrium.

VII. CONCLUSIONS AND PERSPECTIVES
Our work systematically analyzed how to construct nonequilibrium thermodynamics for systems described by hydrodynamics at the macroscopic level, starting from the microscopic scale.Emphasis has been placed on the boundary conditions which play a crucial role in determining the right thermodynamic potentials and the thermodynamic forces.
Several further developments can be envisioned.The description we provide here is based on the Boltzmann equation and allows for relatively explicit calculations, but the argument used to truncate the BBGKY hierarchy holds only for very rarefied gases.An alternative approach based on an integral fluctuation theorem has recently been developed [7,[75][76][77].It would be interesting to systematically investigate the thermodynamic implications of this approach employing techniques from large deviations theory [78], which recover irreversibility at the mesoscopic level by focusing on the typical microscopic evolution [70].
Our microscopic approach can be extended to include the effect of chemical reactions, where macroscopic nonequilibrium thermodynamics is well established [1,58,79,80] and continues to receive attention [42,[81][82][83].Recent formulations of nonequilibrium thermodynamics for systems undergoing chemical reactions [41,42] are currently assuming the absence of macroscopic motion of the fluid and isothermal conditions.The effects of viscous flows and heat exchanges are thus neglected but could be accounted by such extensions.

2 .
Closed system under pressure control.