From Lagrangian Mechanics to Nonequilibrium Thermodynamics: A Variational Perspective

In this paper, we survey our recent results on the variational formulation of nonequilibrium thermodynamics for the finite-dimensional case of discrete systems, as well as for the infinite-dimensional case of continuum systems. Starting with the fundamental variational principle of classical mechanics, namely, Hamilton’s principle, we show, with the help of thermodynamic systems with gradually increasing complexity, how to systematically extend it to include irreversible processes. In the finite dimensional cases, we treat systems experiencing the irreversible processes of mechanical friction, heat, and mass transfer in both the adiabatically closed cases and open cases. On the continuum side, we illustrate our theory using the example of multicomponent Navier–Stokes–Fourier systems.


Introduction
This paper reviews our recent work on the development of a variational formulation of nonequilibrium thermodynamics, as established in [1][2][3][4]. This formulation extends to nonequilibrium thermodynamics of the Lagrangian formulation of classical and continuum mechanics that include irreversible processes, such as friction, heat, and mass transfer, chemical reactions, and viscosity.

Some History of the Variational Approaches to Thermodynamics
Thermodynamics was first developed to treat exclusively equilibrium states and the transition from one equilibrium state to another in which a change in temperature plays an important role. In this context, thermodynamics appeared mainly as a theory of heat, and it is viewed today as a branch of equilibrium thermodynamics. Such a classical theory, which does not aim to describe the time evolution of the system, can be developed in a well-established setting [5] governed by the well-known first and second laws, e.g., [6,7]. It is worth noting that classical mechanics, fluid dynamics, and electromagnetism, being essentially dynamical theories, cannot be treated in the context of equilibrium thermodynamics. Although much effort has been applied to the theoretical investigation of nonequilibrium thermodynamics in relation to physics, chemistry, biology, and engineering, the theory of nonequilibrium thermodynamics has not reached the level of completeness. This is in part due to the lack of a general variational formulation for nonequilibrium thermodynamics that would reduce to the classical Lagrangian variational formulation of mechanics in absence of irreversible processes. So far, various variational approaches have been proposed in relation to nonequilibrium thermodynamics. For example, the principle of least dissipation of energy, introduced in [8] and later

Organization of the Paper
In Section 2, we start with a very elementary review of Hamilton's variational principle in classical mechanics and its extension to the case of mechanical systems with external forces. We also briefly review the variational formulation of mechanical systems with linear nonholonomic constraints by using the Lagrange-d'Alembert principle. Furthermore, we review the extension of Hamilton's principle to continuum systems and illustrate it with the example of compressible fluids in the Lagrangian description. The variational principle in the Eulerian description is then deduced in the context of symmetry reduction. In Section 3, we recall the two laws of thermodynamics as formulated by [38], and we present the variational formulation of nonequilibrium thermodynamics for the finite-dimensional case of discrete systems. We first consider adiabatically closed simple systems and illustrate the variational formulation using the case of a movable piston containing an ideal gas and the case of a system consisting of a chemical species experiencing diffusion between several compartments. We then consider adiabatically closed non-simple systems, such as the adiabatic piston with two cylinders and a system with a chemical species experiencing both diffusion and heat conduction between two compartments. Further, we consider the variational formulation for open systems and illustrate it with the example of a piston device with ports and heat sources. In Section 4, we extend the variational formulation of nonequilibrium thermodynamics to the infinite-dimensional case of continuum systems and consider a multicomponent compressible fluid subject to irreversible processes due to viscosity, heat conduction, and diffusion. The variational formulation is first given in the Lagrangian description, from which the variational formulation in the Eulerian description is deduced. This is illustrated with the multicomponent Navier-Stokes-Fourier equations. In Section 5, we make some concluding remarks and mention further developments based on the variational formulation of nonequilibrium thermodynamics, such as variational discretizations, Dirac structures in thermodynamics, reduction by symmetries, and thermodynamically consistent modeling.

Classical Mechanics
One of the most fundamental statements in classical mechanics is the principle of critical action or Hamilton's principle, according to which the motion of a mechanical system between two given positions is given by a curve that makes the integral of the Lagrangian of the system critical (see, for instance, [39]).
Let us consider a mechanical system with configuration manifold Q. For instance, for a system of N particles moving in the Euclidean 3-space, the configuration manifold is Q = R 3N , whereas for a rigid body moving freely in space, Q = R 3 × SO(3), the product of the Euclidean 3-space and the rotation group. Let us denote by (q 1 , ..., q n ) the local coordinates of the manifold Q, also known as generalized coordinates of the mechanical system. Let L be a given Lagrangian of the system, which usually depends only on the position q and velocity v of the system and is hence defined on the tangent bundle or velocity phase space, TQ, of the manifold Q. Recall that tangent bundle of a manifold Q is the manifold TQ given by the collection of all tangent vectors in Q. As a set, it is given by the disjoint union of the tangent spaces of Q, that is, TQ = q∈Q T q Q, where T q Q is the tangent space to Q at q. The elements in T q Q are denoted by (q, v). The Lagrangian L is usually given by the kinetic minus the potential energy of the system: L(q, v) = K(q, v) − U(q).
Hamilton's principle is written as follows. Suppose that the system occupies the positions q 1 and q 2 at the time t 1 and t 2 . Then, the motion q(t) of the mechanical system between these two positions is a solution of the critical point condition where q(t, ), t ∈ [t 1 , t 2 ], ∈ [−a, a], is an arbitrary variation of the curve q(t) with fixed endpoints, i.e., q(t, )| =0 = q(t) and q(t 1 , ) = q(t 1 ), q(t 2 , ) = q(t 2 ), for all . The infinitesimal variation associated with a given variation q(t, ) is denoted by .
From the fixed endpoint conditions, we have δq(t 1 ) = δq(t 2 ) = 0. The Hamilton principle in Equation (1) is usually written in short form as for arbitrary infinitesimal variations δq, with δq(t 1 ) = δq(t 2 ) = 0. Throughout this paper, we always use this short notation for the variational principles and also simply refer to δq for variations. The direct application of Equation (1) gives, in local coordinates q = (q 1 , ..., q n ), where Einstein's summation convention is employed. Since δq is arbitrary and since the boundary term vanishes because of the fixed endpoint conditions, we get from Equation (3) the Euler-Lagrange equations: d dt We recall that L is called regular when the Legendre transform FL : TQ → T * Q, locally given by (q i , v i ) → (q i , ∂L ∂v i ), is a local diffeomorphism, where T * Q denotes the cotangent bundle or momentum phase space of Q. Recall that cotangent bundle of a manifold Q is the manifold T * Q = ∪ q∈Q T * q Q, where T * q Q is the cotangent space at each q given as the dual space to T q Q. The elements in T * q Q are covectors, denoted by (q, p). When L is regular, the Euler-Lagrange Equation (4) yields a second-order differential equation for the curve q(t).
The energy of a mechanical system with the Lagrangian L is defined on TQ by where , denotes a dual pairing between the elements in T * q Q and T q Q. It is easy to check that E is conserved along the solutions of the Euler-Lagrange Equation (4), namely, Let us assume that the mechanical system is subject to an external force, given by a map F ext : TQ → T * Q assumed to be fiber preserving, i.e., F ext (q, v) ∈ T * q Q for all (q, v) ∈ T q Q. The extension of Equation (2) to forced mechanical systems is given by for arbitrary variations δq, with δq(t 1 ) = δq(t 2 ) = 0. The second term in Equation (6) is the time integral of the virtual work F ext (q,q), δq done by the force field F ext : TQ → T * Q with a virtual displacement δq in TQ. The principle in Equation (6) leads to the forced Euler-Lagrange equations d dt

Systems with Nonholonomic Constraints
Hamilton's principle, as recalled above, is only valid for holonomic systems, i.e., systems without constraints or whose constraints are given by functions of the coordinates only, not the velocities. In geometric terms, such constraints are obtained by the specification of a submanifold N of the configuration manifold Q. In this case, the equations of motion are still given by Hamilton's principle for the Lagrangian L restricted to the tangent bundle TN of the submanifold N ⊂ Q.
When the constraints cannot be reduced to relations between the coordinates only, they are called nonholonomic. Here, we restrict the discussion to nonholonomic constraints that are linear in velocity. Such constraints are locally given in the form where ω α i are functions of local coordinates q = (q 1 , ..., q n ) on Q. Intrinsically, the functions ω α i are the components of k independent one-forms ω α on Q, i.e., ω α = ω α i dq i , for α = 1, ..., k. Typical examples of linear nonholonomic constraints are those imposed on the motion of rolling bodies, namely, the velocities of the points in contact should be identical.
For systems with nonholonomic constraints (Equation (8)), the corresponding equations of motion can be derived from a modification of the Hamilton principle called the Lagrange-d'Alembert principle, which is given by for variations δq subject to the condition together with the fixed endpoint conditions δq(t 1 ) = δq(t 2 ) = 0. Note the occurrence of two constraints with distinct roles. First, there is the constraint in Equation (8) These equations, together with the constraints in Equation (8), form a complete set of equations for the unknown curves q i (t) and λ α (t).
For more information on nonholonomic mechanics, the reader can consult [40][41][42]. Note that the Lagrange-d'Alembert principle (9) is not a critical curve condition for the action integral restricted to the space of a curve satisfying the constraints. Such a principle, which imposes the constraint via a Lagrange multiplier, gives equations that are, in general, not equivalent to the Lagrange-d'Alembert Equation (11), see, e.g., [42,43]. Such equations are sometimes referred to as the vakonomic equations.

Continuum Mechanics
Hamilton's principle permits a natural extension to continuum systems, such as fluid and elasticity. For such systems, the configuration manifold Q is typically a manifold of maps. We shall restrict the discussion here to fluid mechanics in a fixed domain D ⊂ R 3 that is assumed to be bounded by a smooth boundary ∂D. Hamilton's principle for fluid mechanics in the Lagrangian description has been discussed at least since the works of [44] for an incompressible fluid and [45,46] for compressible flows (see also [47] for further references on these early developments). Hamilton's principle has since then been an important modeling tool in continuum mechanics.

Configuration Manifolds
For fluid mechanics in a fixed domain and before the occurrence of any shocks, the configuration space can be taken as the manifold Q = Diff(D) of diffeomorphisms of D. In this paper, we do not describe the functional analytic setting needed to rigorously work in the framework of infinite dimensional manifolds. For example, one can assume that the diffeomorphisms are of some given Sobolev class, regular enough (at least of class C 1 ) so that Diff(D) is a smooth infinite-dimensional manifold and a topological group with a smooth right translation. The tangent bundle to Diff(D) is formally given by the set of vector fields on D covering a diffeomorphism ϕ and tangent to the boundary, i.e., for each ϕ ∈ Diff(D), we have The motion of the fluid is fully described by a curve ϕ t ∈ Diff(D) defining the position x = ϕ t (X) at time t of a fluid particle with label X ∈ D. The vector field V t ∈ T ϕ t Diff(D) defined by V t (X) = d dt ϕ t (X) is the material velocity of the fluid. In local coordinates, we write x a = ϕ a t (X A ) and V a t (X A ) = d dt ϕ a t (X A ).

Hamilton's Principle
Given a Lagrangian L : TQ → R defined on the tangent bundle of the infinite-dimensional manifold Q = Diff(D), Hamilton's principle formally takes the same form as Equation (2), namely, for variations δϕ such that δϕ t 1 = δϕ t 2 = 0. Let us consider a Lagrangian of the general form with L being the Lagrangian density and ∇ϕ being the Jacobian matrix of ϕ, known as the deformation gradient in continuum mechanics. The variation of the integral yields where N is the outward-pointing unit normal vector field to the boundary ∂D, and dS denotes the area element on the surface ∂D. Hamilton's principle thus yields the Euler-Lagrange equations and the boundary condition where the divergence operator is defined as . The tensor field is called the first Piola-Kirchhoff stress tensor (see, e.g., [48]).

The Lagrangian of the Compressible Fluid
For a compressible fluid, the Lagrangian has the standard form with ref (X) and S ref (X) being the mass density and entropy density in the reference configuration. The two terms in Equation (15) are, respectively, the total kinetic energy of the fluid and minus the total internal energy of the fluid. The function E is a general expression for the internal energy density written in terms of ref (X), S ref (X), and the deformation gradient ∇ϕ(X). For fluids, E depends on the deformation gradient only through the Jacobian of ϕ, denoted by J ϕ . This fact is compatible with the material covariance property of E , written as where the pull-back notation is defined as for some function f defined on D. From Equation (16), we deduce the existence of a function such that (see [48,49]). The function = (ρ, s) is the internal energy density in the spatial description expressed in terms of the mass density ρ and entropy density s. For the Lagrangian Equation (15) and with the assumption in Equation (16), the first Piola-Kirchhoff stress tensor (Equation (14)) and its divergence are computed as where p = ∂ ∂ρ ρ + ∂ ∂s s − is the pressure. Note that for all δϕ a parallel to the boundary, we have P A a N A δϕ a = −pJ ϕ (ϕ −1 ) A ,a N A δϕ a = 0, since (ϕ −1 ) A ,a δϕ a is parallel to the boundary. Hence, the boundary condition in Equation (13) is always satisfied. From Equation (19), the Euler-Lagrange Equation (13) becomes Equation (20) is the equation of motion for a compressible fluid in the material (or Lagrangian) description, which directly follows from the Hamilton principle in Equation (12) applied to the Lagrangian Equation (15). It is, however, highly desirable to have a variational formulation that directly produces the equations of motion in the standard spatial (or Eulerian) description. This is recalled below in Section 2.3 by using Lagrangian reduction by symmetry.

Lagrangian Reduction by Symmetry
When symmetry is available in a mechanical system, it is often possible to exploit it in order to reduce the dimension of the system and thereby facilitate its study. This process, called reduction by symmetry, is presently well understood on both the Lagrangian and Hamiltonian sides (see [50] for an introduction and references).
On the Hamiltonian side, this process is based on the reduction of symplectic or Poisson structures while, on the Lagrangian side, it is usually based on the reduction of variational principles (see [51][52][53]). Consider a mechanical system with a configuration manifold Q and Lagrangian L : TQ → R, and consider also the action of a Lie group G on Q, denoted here simply as q → g · q for g ∈ G, q ∈ Q. This action naturally induces an action on the tangent bundle TQ, denoted here simply as (q, v) → (g · q, g · v), called the tangent-lifted action. We say that the action is a symmetry for the mechanical system if the Lagrangian L is invariant under this tangent-lifted action. In this case, L induces a symmetry-reduced Lagrangian : (TQ)/G → R defined on the quotient space (TQ)/G of the tangent bundle with respect to the action. The goal of the Lagrangian reduction process is to derive the equations of motion directly on the reduced space (TQ)/G. Under standard hypotheses on the action, this quotient space is a manifold, and one obtains the reduced Euler-Lagrange equations by computing the reduced variational principle for the action integral  L dt. The main difference between the reduced variational principle and Hamilton's principle is the occurrence of constraints on the variations to be considered when computing the critical curves for t 2 t 1 dt. These constraints are uniquely associated with the reduced character of the variational principle and are not due to physical constraints as in Equation (10) earlier.
We now quickly recall the application of Lagrangian reduction for the treatment of fluid mechanics in a fixed domain (see Section 2.2) by following the Euler-Poincaré reduction approach in [54]. In this case, the Lagrangian reduction process encodes the shift from the material (or Lagrangian) description to the spatial (or Eulerian) description.
As we recalled above, in the material description, the motion of the fluid is described by a curve of diffeomorphisms ϕ t in the configuration manifold Q = Diff(D), and the evolution Equation (20) for ϕ t follows from the standard Hamilton principle.
In the spatial description, the dynamics are described by the Eulerian velocity v(t, x), the mass density ρ(t, x) and the entropy density s(t, x), defined in terms of ϕ t as Using these relations and Equation (18), the Lagrangian Equation (15) in the material description induces the following expression in the spatial description: The symmetry group underlying the Lagrangian reduction process is the subgroup of diffeomorphisms that preserve both the mass density ref and entropy density S ref in the reference configuration. So, we have Q = Diff(D) and G = Diff(D) red ,S ref in the general Lagrangian reduction setting described above. From the relations in Equation (21), we deduce that the variations δϕ used in Hamilton's principle in Equation (12) induce the variations where ζ = δϕ • ϕ −1 is an arbitrary time-dependent vector field parallel to ∂D. From Lagrangian reduction theory, the Hamilton principle in Equation (12) induces, in the Eulerian description, the (reduced) variational principle for variations δv, δρ, δs constrained by the relations in Equation (22) with ζ(t 1 ) = ζ(t 2 ) = 0. This principle yields the compressible fluid equations ρ(∂ t v + v · ∇v) = −∇p in the Eulerian description, while the continuity equations ∂ t ρ + div(ρv) = 0 and ∂ t s + div(sv) = 0 follow from the definition of ρ and s in Equation (21) (see [54]). We refer to [49] for an extension of this Lagrangian reduction approach to the case of fluids with a free boundary. The variational formulations in Equations (22) and (23) are extended in Section 4 to include irreversible processes and are illustrated using the Navier-Stokes-Fourier system as an example.

Variational Formulation for Discrete Thermodynamic Systems
In this section, we present a variational formulation for the finite-dimensional case of discrete thermodynamic systems that reduces to Hamilton's variational principle in Equation (2) in absence of irreversible processes. The form of this variational formulation is similar to that of nonholonomic mechanics recalled earlier (see Equations (8)-(10)) in the sense that the critical curve condition is subject to two constraints: a kinematic constraint on the solution curve and a variational constraint on the variations to be considered when computing the criticality condition. A major difference, however, with the Lagrange-d'Alembert principle recalled above is that the constraints are nonlinear in velocity. This formulation is extended to continuum systems in Section 4.
Before presenting the variational formulation, we recall below the two laws of thermodynamics as formulated in [38].

•
The two laws of thermodynamics Let us denote by Σ a physical system and by Σ ext its exterior. The state of the system is defined by a set of mechanical variables and a set of thermal variables. State functions are functions of these variables. Stueckelberg's formulation of the two laws is given as follows.

•
First law: For every system Σ, there exists an extensive scalar state function E, called energy, which satisfies where P ext W is the power associated with the work done on the system (here, work includes not only mechanical work by the action of forces but also other physical work, such as that by the action of electric voltages, etc.), P ext H is the power associated with the transfer of heat into the system, and P ext M is the power associated with the transfer of matter into the system. As we recall below, a transfer of matter into the system is associated with a transfer of work and heat. By convention, P ext W and P ext H denote uniquely the power associated with a transfer of work and heat into the system that is not associated with a transfer of matter. The power associated with a transfer of heat or work due to a transfer of matter is included in P ext M . Given a thermodynamic system, the following terminology is generally adopted: • A system is said to be closed if there is no exchange of matter, i.e., P ext M (t) = 0. When P ext M (t) = 0, the system is said to be open.

•
A system is said to be adiabatically closed if it is closed and there are no heat exchanges, i.e., P ext A system is said to be isolated if it is adiabatically closed and there is no mechanical power exchange, i.e., P ext From the first law, it follows that the energy of an isolated system is constant.
• Second law: For every system Σ, there exists an extensive scalar state function S, called entropy, which obeys the following two conditions (a) Evolution part: If the system is adiabatically closed, the entropy S is a non-decreasing function with respect to time, i.e., d dt where I(t) is the entropy production rate of the system accounting for the irreversibility of internal processes.
(b) Equilibrium part: If the system is isolated, as time tends to infinity, the entropy tends toward a finite local maximum of the function S over all thermodynamic states ρ compatible with the system, i.e., By definition, the evolution of an isolated system is said to be reversible if I(t) = 0, namely, the entropy is constant. In general, the evolution of a system Σ is said to be reversible if the evolution of the total isolated system with which Σ interacts is reversible.
Based on this formulation of the two laws, Stueckelberg and Scheurer [38] developed a systematic approach for the derivation of the equations of motion for thermodynamic systems; it is especially well suited for the understanding of nonequilibrium thermodynamics as an extension of classical mechanics. We refer, for instance, to [55][56][57] for the applications of Stueckelberg's approach to the derivation of equations of motion for thermodynamical systems.
We present our approach by considering systems with gradually increasing level of complexity. First we treat adiabatically closed systems that have only one entropy variable or, equivalently, one temperature. Such systems, called simple systems, may involve the irreversible processes of mechanical friction and internal matter transfer. Then, we treat a more general class of finite-dimensional adiabatically closed thermodynamic systems with several entropy variables, which may also involve the irreversible process of heat conduction. We then consider open finite-dimensional thermodynamic systems, which can exchange heat and matter with the exterior. Finally, we explain how chemical reactions can be included in the variational formulation.

Adiabatically Closed Simple Thermodynamic Systems
We present below the definition of finite-dimensional and simple systems following [38]. A finite-dimensional thermodynamic system Σ is a collection Σ = ∪ P A=1 Σ A of a finite number of interacting simple thermodynamic systems Σ A . By definition, a simple thermodynamic system is a macroscopic system for which one (scalar) thermal variable and a finite set of nonthermal variables are sufficient to entirely describe the state of the system. From the second law of thermodynamics, we can always choose the entropy S as a thermal variable. A typical example of such a simple system is the one-cylinder problem. We refer to [55] for a systematic treatment of this system via Stueckelberg's approach.

Variational Formulation for Mechanical Systems with Friction
We consider here a simple system which can be described only by a single entropy as a thermodynamic variable, besides mechanical variables. As in Section 2.1 above, let Q be the configuration manifold associated with the mechanical variables of the simple system. The Lagrangian of the simple thermodynamic system is thus a function: where S ∈ R is the entropy. We assume that the system involves external and friction forces given by fiber-preserving maps F ext , F fr : TQ × R → T * Q, i.e., such that F fr (q, v, S) ∈ T * q Q, similar to F ext . As stated in [1], the variational formulation for this simple system is given as follows: Find the curves q(t), S(t) which are critical for the variational condition subject to the phenomenological constraint and for variations subject to the variational constraint with Taking variations of the integral in Equation (24), integrating by parts, and using δq( From the variational constraint in Equation (26), the last term in the integrand of the above equation can be replaced by F fr i δq i . Hence, using Equation (25), we get the following system of evolution equations for the curves q(t) and S(t): This variational formulation is a generalization of Hamilton's principle in Lagrangian mechanics in the sense that it can yield irreversible processes in addition to the Lagrange-d'Alembert equations with external and friction forces. In this generalized variational formulation, the temperature is defined as minus the derivative of L with respect to S, i.e., T = − ∂L ∂S , which is assumed to be positive. When the Lagrangian has the standard form where the kinetic energy K is assumed to be independent of S, and U(q, S) is the internal energy, then T = − ∂L ∂S = ∂U ∂S recovers the standard definition of the temperature in thermodynamics. When the friction force vanishes, the entropy is constant from the second equation in Equation (27), and hence, the system in Equation (27) reduces to the forced Euler-Lagrange equations in classical mechanics for a Lagrangian depending parametrically on a given constant entropy S 0 .
The total energy associated with the Lagrangian is still defined by the same expression as in Equation (5) except that it now depends on S, i.e., we define the total energy E : Along the solution curve of Equation (27), we have where P ext W is the power associated with the work done on the system. This is nothing but the statement of the first law for the thermodynamic system, as in Equation (27).
The rate of entropy production of the system iṡ The second law states that the internal entropy production is always positive, from which the friction force is dissipative, i.e., F fr (q,q, S),q ≤ 0 for all (q,q, S). This suggests the phenomenological .., n are functions of the state variables, with the symmetric part of the matrix λ ij positive semi-definite, which are determined by experiments. (25) involves phenomenological laws for the friction force F fr , which is why we refer to it as a phenomenological constraint. The associated constraint in Equation (26) is called a variational constraint since it is a condition on the variations to be used in Equation (24). Note that the constraint in Equation (25) is nonlinear and also that one shifts from the variational constraint to the phenomenological constraint by formally replacing the time derivativesq,Ṡ by the variations δq, δS:

Remark 1 (Phenomenological and variational constraints). The explicit expression of the constraint in Equation
Such a systematic correspondence between the phenomenological and variational constraints will hold, in general, for our variational formulation of thermodynamics, as we present in detail below.

Remark 2.
In our macroscopic description, it is assumed that the macroscopically "slow " or collective motion of the system can be described by q(t), while the time evolution of the entropy S(t) is determined from the microscopically "fast " motions of molecules through statistical mechanics under the assumption of local equilibrium. It follows from statistical mechanics that the internal energy U(q, S), given as a potential energy at the macroscopic level, is essentially coming from the total kinetic energy associated with the microscopic motion of molecules, which is directly related to the temperature of the system. Example 1 (piston). Consider a gas confined by a piston in a cylinder as in Figure 1. This is an example of a simple adiabatically closed system, whose state can be characterized by (q, v, S).
where T is temperature and p = − ∂U ∂V is the pressure. The friction force reads F fr (q,q, S) = −λ(q, S)q, where λ(q, S) ≥ 0 is the phenomenological coefficient, which is determined experimentally.
Following Equations (24)- (26), the variational formulation is given by and for variations subject to the variational constraint From this principle, we get the equations of motion for the piston-cylinder system as consistent with the equations derived in Section 4 of [55]. We can verify the energy balance, i.e., the first law, as d dt E = F extq , where E = 1 2 mq 2 + U is the total energy.

Variational Formulation for Systems with Internal Mass Transfer
We here extend the previous variational formulation to the finite-dimensional case of discrete systems experiencing internal diffusion processes. Diffusion is particularly important in biology, as many processes depend on the transport of chemical species through bodies. For instance, the setting that we develop is well suited for the description of diffusion across composite membranes, e.g., composed of different elements arranged in a series or parallel array, which occurs frequently in living systems and has remarkable physical properties (see [58][59][60][61]).
As illustrated in Figure 2, we consider a thermodynamic system consisting of K compartments that can exchange matter by diffusion across walls (or membranes) of their common boundaries. We assume that the system has a single species, and we denote by N k the number of moles of the species in the k-th compartment, k = 1, ..., K. We assume that the thermodynamic system is simple; i.e., a uniform entropy S, the entropy of the system, is attributed to all the compartments. For each compartment k = 1, ..., K, the mole balance equation is where J →k = −J k→ is the molar flow rate from compartment to compartment k due to diffusion of the species. We assume that the simple system also involves mechanical variables, friction, and exterior forces F fr and F ext , as in (A). The Lagrangian of the system is thus a function: Thermodynamic displacements associated with matter exchange. The variational formulation involves the new variables W k , k = 1, ..., K, which are examples of thermodynamic displacements and play a central role in our formulation. In general, we define the thermodynamic displacement associated with an irreversible process as the primitive in time of the thermodynamic force (or affinity) of the process. This force (or affinity) thus becomes the rate of change of the thermodynamic displacement. In the case of matter transfer,Ẇ k corresponds to the chemical potential of N k . The variational formulation for a simple system with an internal diffusion process is stated as follows.
Find the curves q(t), S(t), W k (t), N k (t) which are critical for the variational condition subject to the phenomenological constraint and for variations subject to the variational constraint with Taking variations of the integral in Equation (29), integrating by parts, and using Then, using the variational constraint in Equation (31), we get the following conditions: These conditions, combined with the phenomenological constraint in Equation (30), yield the system of evolution equations for the curves q(t), S(t), and N k (t): The total energy is defined as in Equations (5) and (28) and depends here on the mechanical variables (q, v) ∈ TQ, the entropy S, and the number of moles N k , k = 1, ..., K, i.e., we define On the solutions of Equation (33), we have where P ext W is the power associated with the work done on the system. This is the statement of the first law for the thermodynamic system in Equation (33). The last equation in Equation (33) yields the rate of entropy production of the system aṡ where the two terms correspond, respectively, to the rate of entropy production due to mechanical friction and to matter transfer. The second law suggests the phenomenological relations where λ ij , i, j = 1, ..., n and G k , k, = 1, ..., K are functions of the state variables, with the symmetric part of the matrix λ ij positive semi-definite and with G k ≥ 0 for all k, .
Example 2 (mass transfer associated with nonelectrolyte diffusion through a homogeneous membrane). We consider a system with diffusion due to internal matter transfer through a homogeneous membrane separating two reservoirs. We suppose that the system is simple (so it is described by a single entropy variable) and involves a single chemical species. We assume that the membrane consists of three regions, namely, the central layer denotes the membrane capacitance in which energy is stored without dissipation, while the outer layers indicate transition regions in which dissipation occurs with no energy storage. We denote by N m the number of mole of this chemical species in the membrane and by N 1 and N 2 the numbers of mole in reservoirs 1 and 2, as shown in The variational condition for the diffusion process is provided by subject to the phenomenological constraint and for variations subject to the variational constraint with δW k (t i ) = 0 for k = 1, 2, m and i = 1, 2.
Thus, it follows thatṄ where T = − ∂L ∂S . Equations (38) and (39) are equivalent to those derived in ([61] Section 2.2). From Equations (38) and (39), we have energy conservation d dt U = 0, which is consistent with the fact that the system is isolated.

Adiabatically Closed Non-Simple Thermodynamic Systems
We now consider a general finite-dimensional system Σ = ∪ P A=1 Σ A composed of interconnected simple thermodynamic systems Σ A , as illustrated in Figure 4. This class of non-simple interconnected systems extends the class of interconnected mechanical systems (see [62]) to include the irreversible processes. In addition to the irreversible processes of friction and mass transfer described earlier, these systems can also involve the process of heat conduction.
The main difference from the previous cases is the occurrence of several entropy variables, namely, each subsystem Σ A has an entropy denoted by S A , A = 1, ..., P. Besides the variables S A , each subsystem Σ A may also be described by mechanical variables q A ∈ Q A and number of moles (N A,1 , ..., N A,K A ) ∈ R K A , where Q A is a configuration manifold for a mechanical variable associated with Σ A and where K A is the number of compartments in a simple system Σ A . For simplicity, we assume that independent mechanical coordinates q ∈ Q have been chosen to represent the mechanical configuration of the interconnected system Σ. The state variables needed to describe this system are (q, v) ∈ TQ, S A , A = 1, ..., P, N A,k , k = 1, ..., K A , A = 1, ..., P. We present the variational formulation for these systems in two steps, exactly as in Section 3.1, by first considering the case without any transfer of mass.

Variational Formulation for Systems with Friction and Heat Conduction
Besides the entropies S A , A = 1, ..., P, these systems only involve mechanical variables. The Lagrangian of the system is thus a function: We denote by F ext→A : T * Q × R P → T * Q the external force acting on subsystem Σ A . Consistent with the fact that the mechanical variables q = (q 1 , ..., q n ) describe the configuration of the entire interconnected system Σ, only the total exterior force F ext = ∑ P A=1 F ext→A appears explicitly in the variational condition in Equation (42). We denote by F fr(A) : T * Q × R P → T * Q the friction forces experienced by subsystem Σ A . This friction force is at the origin of an entropy production for subsystem Σ A and appears explicitly in the phenomenological constraint (Equation (43)) and the variational constraint (Equation (44) Thermodynamic displacements associated with heat exchange. To incorporate heat exchange into our variational formulation, the new variables Γ A , A = 1, ..., P are introduced. These are again examples of thermodynamic displacements in the same way as we defined W k before. For the case of heat exchange, Γ A corresponds to the temperature of the subsystem Σ A , where Γ A is identical to the thermal displacement employed in [37], which was originally introduced by [63]. The introduction of Γ A is accompanied by the introduction of an entropy variable Σ A whose meaning will be clarified later. Now, the variational formulation for a system with friction and heat conduction is stated as follows: Find the curves q(t), S A (t), Γ A (t), Σ A (t) which are critical for the variational condition subject to the phenomenological constraint and for variations subject to the variational constraint with δq(t 1 ) = δq(t 2 ) = 0 and δΓ A (t 1 ) = δΓ A (t 2 ) = 0, A = 1, ..., P.

The second equation yieldsΓ
where T A is the temperature of the subsystem Σ A . This implies that Γ A is a thermal displacement. Because of Equation (41), the last equation yieldsṠ A =Σ A . Hence, using Equation (43), we get the following system of evolution equations for the curves q(t) and S A (t): As before, we have d dt E = F ext ,q = P ext W , where the total energy E is defined in the same way as before. Since the system is non-simple, it is instructive to analyze the energy behavior of each subsystem. This can be done if the Lagrangian is given by the sum of the Lagrangians of the subsystems, i.e., L(q, v, S 1 , ..., S P ) = P ∑ A=1 L A (q, v, S A ).

The mechanical equation for Σ A is given as
where P ext→A W and P B→A W denote the power associated with the work done on Σ A by the exterior and that by the subsystem Σ B , respectively, and where P B→A H is the power associated with the heat transfer from Σ B to Σ A . The link between the flux J AB and the power exchange is thus Since entropy is an extensive variable, the total entropy of the system is S = ∑ P A=1 S A . From Equation (46), it follows that the rate of total entropy productionṠ = ∑ P A=1Ṡ A of the system is given byṠ The second law suggests the phenomenological relations where λ A ij and L AB are functions of the state variables, with the symmetric part of the matrices λ A ij positive semi-definite and with L AB ≥ 0 for all A, B. From the second relation, we deduce J AB = −L AB T A T B = −κ AB , with κ AB = κ AB (q, S A , S B ) being the heat conduction coefficients between subsystem Σ A and subsystem Σ B .

Example 3 (The adiabatic piston).
We consider a piston-cylinder system composed of two cylinders connected by a rod, each of which contains a fluid (or an ideal gas) and is separated by a movable piston, as shown in Figure 5. We assume that the system is isolated. Despite its apparent simplicity, this system has attracted a lot of attention in the literature because there has been some controversy about the final equilibrium state of this system when the piston is adiabatic. We refer to [55] for a review of this challenging problem and for the derivation of the time evolution of this system, based on the approach of [38]. § The system Σ may be regarded as an interconnected system consisting of three simple systems; namely, the two pistons Σ 1 , Σ 2 of mass m 1 , m 2 and the connecting rod Σ 3 of mass m 3 . As illustrated in Figure 5, q and r = D − − q denote, respectively, the distance between the bottom of each piston to the top, where D is a constant. In this setting, we choose the variables (q, v, S 1 , S 2 ) (the entropy associated with Σ 3 is constant) to describe the dynamics of the interconnected system, and the Lagrangian is given by where M := m 1 + m 2 + m 3 , and As in Equation (49), we have F fr(A) (q,q, S A ) = −λ Aq , with λ A = λ A (q, S A ) ≥ 0, A = 1, 2 and J AB = −κ AB =: −κ, where κ = κ(S 1 , S 2 , q) ≥ 0 is the heat conductivity of the connecting rod.
From the variational formulations (Equations (42)-(44)), we get the following system for q(t), S 1 (t), S 2 (t), in light of Equation (46), as These equations recover those derived in [55], (51)- (53). We have d dt E = 0, where E = 1 2 Mq 2 + U 1 (q, S 1 ) + U(q, S 2 ), consistent with the fact that the system is isolated. The rate of total entropy production is The equations of motion for the adiabatic piston are obtained by setting κ = 0.

Variational Formulation for Systems with Friction, Heat Conduction, and Internal Mass Transfer
We extend the previous case to one in which the subsystems Σ A not only exchange work and heat but also exchange matter. In general, each subsystem may itself have several compartments, in which case the variables are those listed in Equation (40). For simplicity, we assume that each subsystem has only one compartment. The reader can easily extend this approach to the general case. The Lagrangian is thus a function: where S A and N A are the entropy and number of moles of subsystem Σ A , A = 1, ..., P. Since the previous cases are presented in detail above, we here just present the variational formulation and the resulting equations of motion.
From Equations (51)-(53), we obtain the following system of evolution equations for the curves q(t), S A (t), and N A (t): We also obtain the conditionṡ where we defined the temperature T A and the chemical potential µ A of the subsystem Σ A . The variables Γ A and W A are again the thermodynamic displacements associated with the processes of heat and matter transfer. The total energy satisfies d dt E = P ext W and the detailed energy balances can be carried out as in Equation (47) and yields here P B→A The rate of total entropy production of the system is computed aṡ From the second law of thermodynamics, the total entropy production must be positive and hence suggests the phenomenological relations where the symmetric part of the n × n matrices λ A and of the 2 × 2 matrices L AB are positive. The entries of these matrices are phenomenological coefficients determined experimentally, which may generally depend on the state variables. From Onsager's reciprocal relations, the 2 × 2 matrix is symmetric for all A, B. The matrix elements L HH AB and L MM AB are related to the processes of heat conduction and diffusion between Σ A and Σ B . The coefficients L MH AB and L HM AB describe the cross-effects, and hence are associated with discrete versions of the process of thermal diffusion and the Dufour effect. Thermal diffusion is the process of matter diffusion due to the temperature difference between the compartments. The Dufour effect is the process of heat transfer due to difference of chemical potentials between the compartments. Example 4 (Heat conduction and diffusion between two compartments). We consider a closed system consisting of two compartments, as illustrated in Figure 6. The compartments are separated by a permeable wall through which heat conduction and diffusion is possible. The system is closed and, therefore, there is no matter transfer with exterior, while we have heat and mass transfer between the compartments.
Compartment Compartment 1 2 J 12 Figure 6. Non-simple closed system with a single chemical species, experiencing diffusion and heat conduction between two compartments.
The Lagrangian of this system is is the internal energy of the ith chemical species and the volume is assumed to be constant. In this case, the system in Equation (54) specifies where are the temperatures and chemical potentials of the Ath compartments. From Equation (56), it follows that the equation for the total entropy S = S 1 + S 2 of the system iṡ from which the phenomenological relations are obtained as in Equation (55). The energy balance in each compartment is d dt which shows the relation between the flux J 12 and the power P 1→2 = J 12 (T 2 − T 1 ) exchanged between the two compartments due to heat conduction, diffusion, and their cross-effects. The total energy E = U 1 + U 2 is conserved.
Remark 3 (General structure of the variational formulation for adiabatically closed systems). In each of the situation considered, the variational constraint can be systematically obtained from the phenomenological constraint by replacing the time derivative by the delta variation for each process. For the most general case treated above, we have the following correspondence: In the above, the quantities to be determined from the state variables by phenomenological laws are F fr(A) , J AB , and J B→A .
The structure of our variational formulation is better explained by adopting a general point of view. If we denote by Q the thermodynamic configuration manifold and by x ∈ Q the collection of all the variables of the thermodynamic system, for instance, x = (q, S A , N A , W A , Γ A , Σ A ), A = 1, ..., P in the preceding case, then the variational formulation for an adiabatically closed system falls into the following abstract setting. Given a Lagrangian L : TQ → R, an external force F ext : TQ → T * Q, and fiber-preserving maps A α : x Q, α = 1, ..., k, the variational formulation reads as follows: where the curve x(t) satisfies the phenomenological constraint and for variations δx subject to the variational constraint with δx(t 1 ) = δx(t 2 ) = 0. This yields the system of equations It is clear that all the variational formulations for the adiabatically closed system considered above fall into this category by appropriately choosing x, L(x,ẋ), F ext (x,ẋ), and A α (x,ẋ). The energy defined by E (x, v) = ∂L ∂v , v − L(x, v) satisfies d dt E = F ext ,ẋ . The constraints involved in this variational formulation admit an intrinsic geometric description. The variational constraint (Equation (59)) defines the subset C V ⊂ TQ × Q TQ given by The phenomenological constraint (Equation (58)) defines the subset C K ⊂ TQ given by Then, one notes that the constraint C K can be intrinsically defined from C V as Constraints C V and C K related in this way are called nonlinear nonholonomic constraints of thermodynamic type (see [1,64]).

Open Thermodynamic Systems
The thermodynamic systems that we considered so far are restricted to the adiabatically closed cases. For such systems, interaction with the exterior is only through the exchange of mechanical work, and hence the first law for such systems reads We now consider the more general case of open systems exchanging work, heat, and matter with the exterior. In this case, the first law reads where P ext H is the power associated with the transfer of heat into the system and P ext M is the power associated with the transfer of matter into the system. As we recall below, the transfer of matter into or out of the system is associated with a transfer of work and heat. By convention, P ext W and P ext H denote uniquely the power associated with work and heat that is not associated with a transfer of matter. The power associated with a transfer of heat or work due to a transfer of matter is included in P ext M . In order to get a concrete expression for P ext M , let us consider an open system with several ports, a = 1, ..., A, through which matter can flow into or out of the system. We suppose, for simplicity, that the system involves only one chemical species and denote by N the number of moles of this species. The mole balance equation is where J a is the molar flow rate into the system through the ath port so that J a > 0 indicates the flow into the system and J a < 0 indicates the flow out of the system. As matter enters or leaves the system, it carries its internal, potential, and kinetic energy. This energy flow rate at the ath port is the product E a J a of the energy per mole (or molar energy) E a and the molar flow rate J a at the ath port. In addition, as matter enters or leaves the system, it also exerts work on the system that is associated with pushing the species into or out of the system. The associated energy flow rate is given at the a-th port by J a p a V a , where p a and V a are the pressure and the molar volume of the substance flowing through the ath port. From this, we get the expression We refer, for instance, to [65,66] for the detailed explanations of the first law for open systems. We present below an extension of the variational formulation to the case of open systems. In order to motivate the form of the constraints that we use, we first consider a particular case of simple open system, namely, the case of a system with a single chemical species N in a single compartment with constant volume V and without mechanical effects. In this particular situation, the energy of the system is given by the internal energy written as U = U(S, N), since V = V 0 is constant. The balance of moles and energy are respectively given by (see Equation (61)), where H a = U a + p a V a is the molar enthalpy at the ath port and where U a , p a , and V a are, respectively, the molar internal energy, the pressure, and the molar volume at the ath port. From these equations and the second law, one obtains the equations for the rate of change of the entropy of the system as d dt where S a is the molar entropy at the ath port and I is the rate of internal entropy production of the system given by with T = ∂U ∂S being the temperature and µ = ∂U ∂N being the chemical potential. For our variational treatment, it is useful to rewrite the rate of internal entropy production as where we define the entropy flow rate J a S := J a S a and also use the relation H a = U a + p a V a = µ a + T a S a . The thermodynamic quantities known at the ath port are usually the pressure p a and the temperature T a , from which the other thermodynamic quantities, such as µ a = µ a (p a , T a ) or S a = S a (p a , T a ), are deduced in light of the state equations of the gas.
Here, we only show the variational formulation for a simplified case of open systems, namely, an open system with only one entropy variable and one compartment with a single species. So, the open system is a simple system. The reader is referred to [3] for the more general cases of open systems, such as the extensions of Equations (29)-(31) and (51)- (53) to open systems, as well as for the case when the mechanical energy of the species is taken into account.
The state variables needed to describe the system are (q, v, S, N) ∈ TQ, and the Lagrangian is a map L : TQ × R × R → R, (q, v, S, N) → L(q, v, S, N), We assume that the system has A ports, through which species can flow out of or into the system, and B heat sources. As above, µ a and T a denote the chemical potential and temperature at the ath port, and T b denotes the temperature of the bth heat source.
We note that the variational constraint (Equation (66)) follows from the phenomenological constraint (Equation (65)) by formally replacing the time derivativesΣ,q,Ẇ,Γ by the corresponding virtual displacements δΣ, δq, δW, δΓ and by removing all the terms that depend uniquely on the exterior, i.e., the terms J a µ a , J a S T a , and J b S T b . Such a systematic correspondence between the phenomenological and variational constraints extends to open systems the correspondence for adiabatically closed systems verified in Equations (25) (26), (30) (31), (43) (44), (52) (53); see also Remarks 1 and 3. Note that the action functional in Equation (64) has the same form as that in the case of adiabatically closed systems.
Taking variations of the integral in Equation (64), integrating by parts, and using δq(t 1 ) = δ(t 2 ) = 0, δW(t 1 ) = δW(t 2 ) = 0, and δΓ(t 1 ) = δΓ(t 2 ) = 0 and using the variational constraint (Equation (66)), we obtain the following conditions: By the second and fourth equations, the variables Γ and W are thermodynamic displacements as before. The main difference from the earlier cases is that nowṠ andΣ are no longer equal. The physical interpretation of Σ is given below. From Equation (65), it follows that the system of evolution equations for the curves q(t), S(t), N(t) is defined by The energy balance for this system is computed as From the last equation in Equation (68), the rate of entropy of the system is found by the equatioṅ where I is the rate of internal entropy production given by J a µ a − µ + J a S T a − T mixing of matter flowing into the system From the last Equations (67) and (69), we notice thatΣ = I is the rate of internal entropy production. The second and third terms in Equation (69) represent the entropy flow rate into the system associated with the ports and the heat sources. The second law requires I ≥ 0, whereas the sign of the rate of entropy flow into the system is arbitrary.
Example 5 (A piston device with ports and heat sources Figure 7). We consider a piston with mass m moving in a cylinder containing a species with internal energy U(S, V, N). We assume that the cylinder has two external heat sources with entropy flow rates J b i , i = 1, 2, and two ports through which the species is injected into or flows out of the cylinder with molar flow rates J a i , i = 1, 2. The entropy flow rates at the ports are given by J a i S = J a i S a i . The variable q characterizes the one-dimensional motion of the piston such that the volume occupied by the species is V = αq, with α the sectional area of the cylinder. The Lagrangian of the system is L(q,q, S, N) = 1 2 mq 2 − U(S, Aq, N).
The variational formulations (Equations (64)-(66)) yield the evolution equations for q(t), S(t), N(t) where p(q, S, N) = − ∂U ∂V is the pressure and I =Σ is the internal entropy production given by The first term represents the entropy production associated with the friction experienced by the moving piston, the second term is the entropy production associated with the mixing of gas flowing into the cylinder at the two ports a 1 , a 2 , and the third term denotes the entropy production due to the external heating. The second law requires that each of these terms is positive. The energy balance holds as For chemical reactions in a single compartment assumed to be adiabatically closed and without mechanical components, the variational formulation is given as follows.

The variational formulations (Equations
Given a time-dependent Lagrangian L : R × TQ → R and an external force F ext : R × TQ → T * Q, the variational formulations in Equations (57)- (59) are extended as follows.
where the curve x(t) satisfies the phenomenological constraint and for variations δx subject to the variational constraint with δx(t 1 ) = δx(t 2 ) = 0. This yields the system of equations The variational formulation for open systems falls into this category by appropriately choosing x and L. For instance, for Equations (64)-(66), one has x = (q, S, N, W, Γ, Σ), and L is the integrand in Equation (64). Note that in Equation (74), we chose the Lagrangian to be time-dependent for the sake of generality. In fact, all the variational formulations for thermodynamics presented above generalize easily to time-dependent Lagrangians. We refer to [3] for a full treatment.
The energy defined by E (t, x, v) = ∂L ∂v , v − L(t, x, v) satisfies the energy balance equation In the application to open thermodynamic systems, the first term is identified with P ext W , the second term is identified with P ext H+M , while the third term is due to the explicit dependence of the Lagrangian on the time.

Variational Formulation for Continuum Thermodynamic Systems
In this section, we extend Hamilton's principle of continuum mechanics (12) to nonequilibrium continuum thermodynamics, in the same way as Hamilton's principle of classical mechanics (Equation (2)) was extended to the finite-dimensional case of discrete thermodynamic systems in Section 3.
We consider a multicomponent compressible fluid subject to the irreversible processes of viscosity, heat conduction, and diffusion. In presence of irreversible processes, we impose no-slip boundary conditions, hence, the configuration manifold for the fluid motion is the manifold Q = Diff 0 (D) of diffeomorphisms that keep the boundary ∂D pointwise fixed.
We assume that the fluid has P components with mass densities A (t, X), A = 1, ..., P in the material description, and we denote by S(t, X) the entropy density in the material description. The motion of the multicomponent fluid is given as before by a curve of diffeomorphisms ϕ t ∈ Diff 0 (D), but nowφ t is interpreted as the barycentric material velocity of the multicomponent fluid. The Lagrangian of the multicomponent fluid with irreversible processes is L : T Diff 0 (D) × F (D) × F (D) P → R, (ϕ,φ, S, 1 , ..., P ) → L(ϕ,φ, S, 1 , ..., P ), where F (D) denotes a space of functions on D and is given by L(ϕ,φ, S, 1 , ..., P ) = K(ϕ,φ, 1 , ..., P ) − U(ϕ, S, 1 , ..., P ) The first term is the total kinetic energy of the fluid, where := ∑ P A=1 A is the total mass density. The second term is minus the total internal energy of the fluid, where E is a general expression for the internal energy density written in terms of A (X), S(X), and the deformation gradient ∇ϕ(X). As in Equation (16), E satisfies the material covariance assumption and depends on the deformation gradient only through the Jacobian J ϕ . As in Equation (18), there is a function , the internal energy density in the spatial representation, such that In the spatial description, the Lagrangian Equation (79) reads as Note that in absence of irreversible process, the Lagrangian (79) would just be defined on the tangent bundle T Diff(D) with A = refA , A = 1, ..., P and S = S ref seen as fixed parameters, exactly as in Equation (15) for the single-component case.
Remark 6 (Material vs spatial variational principle). As we present below, the variational formulation for continuum thermodynamical systems in the material description is the natural continuum (infinite-dimensional) version of that of discrete (finite-dimensional) thermodynamical systems described in Section 3. This is analogous to the conservative reversible case recalled earlier, namely, the Hamilton principle (Equation (12)); associated with the material description of continuum systems is the natural continuum version of the classical Hamilton principle Equation (2). This is why we first consider below in Section 4.1 the variational formulation of continuum systems in the material description and deduce from it the variational formulation in the spatial description later in Section 4.2. The latter is more involved since it contains additional constraints, as we have seen in the conservative reversible case in Section 2.3.

Variational Formulation in the Lagrangian Description
The variational formulation of a multicomponent fluid subject to the irreversible processes of viscosity, heat conduction, and diffusion is the continuum version of the variational formulations (Equations (51)-(53)) for finite-dimensional thermodynamic systems with friction, heat, and mass transfer. Analogous to the thermodynamic fluxes F fr , J AB , J B→A are the viscous stress, the entropy flux density, and the diffusive flux density given by P fr , J S , J A in the material description. Total mass conservation imposes the condition ∑ P A=1 J A = 0. We give below the variational formulation for a general Lagrangian with density L , i.e., L(ϕ,φ, S, 1 , ..., P ) = D L ϕ,φ, ∇ϕ, S, 1 , ..., P d 3 X.
The continuum version of the variational formulations (Equations (51)- (53)) that we propose are the following.
Taking variations of the integral in Equation (82), integrating by parts, and using δϕ(t i ) = δΓ(t i ) = δW A (t i ) = 0, i = 1, 2, and δϕ| ∂D = 0, it follows that Using the variational constraint (Equation (84)), integrating by parts, and collecting the terms proportional to δϕ, δΓ, δS, δW A , and δ A , we get δϕ : d dt together with the boundary conditions where N is the outward-pointing unit normal vector field to ∂D. The first boundary term vanishes since δϕ| ∂D = 0 from the no-slip boundary condition. The second and third conditions give i.e., the fluid is adiabatically closed.
for the fields ϕ(t, X), A (t, X), and S(t, X). The parameterization of the thermodynamic fluxes P fr , J S , J A in terms of the thermodynamic forces are discussed in the Eulerian description below.

Variational Formulation in the Eulerian Description
While the variational formulation is simpler in the material description, the resulting equations of motion are usually written and studied in the spatial description. It is therefore useful to have an Eulerian version of the variational formulations (Equations (82)-(84)). In order to obtain such a variational formulation, all the variables used in Equations (82)-(84) must be converted to their Eulerian analogue. We have already seen the relations s = ϕ * S and ρ A = ϕ * A between the Eulerian and Lagrangian mass densities and entropy densities, where the pull-back notation is defined in Equation (17). The Eulerian quantities associated with Σ, Γ, and W A are defined as follows The Eulerian version of the Piola-Kirchhoff viscous stress tensor P fr is the viscous stress tensor σ fr obtained via the Piola transform (see [2,48]).
From the material covariance assumption, the Lagrangian (81) can be rewritten exclusively in terms of spatial variables as v, s, ρ 1 , ..., ρ P = D L v, s, ρ 1 , ..., ρ P d 3 x, where the Lagrangian density is defined by Using all the preceding relations between Lagrangian and Eulerian variables, we can rewrite the variational formulations Equations (82)-(84) in the following purely Eulerian form.
The multicomponent Navier-Stokes-Fourier equations. For the Lagrangian v, s, ρ 1 , ..., ρ P = with µ A = ∂ ∂ρ A , T = ∂ ∂s , and p = µ A ρ A + Ts − . The system of Equation (91) needs to be supplemented with phenomenological expressions for the thermodynamic fluxes σ fr , j S , j A in terms of the thermodynamic affinities Def v, ∇T, ∇µ A compatible with the second law. It is empirically accepted that for a large class of irreversible processes and under a wide range of experimental conditions, the thermodynamic fluxes J α are linear functions of the thermodynamic affinities X α , i.e., J α = L αβ X β , where the transport coefficients L αβ (...) are state functions that must be determined by experiments or, if possible, by kinetic theory. Besides defining a positive quadratic form, the coefficients L αβ (...) must also satisfy Onsager's reciprocal relations [8] due to the microscopic time reversibility and the Curie principle associated with material invariance (see, for instance, [67][68][69][70]). In the case of the multicomponent fluid, writing the traceless part of σ fr and Def v as (σ fr ) (0) = σ fr − 1 3 (Tr σ fr )δ and (Def v) (0) = Def v − 1 3 (div v)δ, we have the following phenomenological linear relations Tr σ fr = ζ div v, (σ fr ) (0) = 2µ(Def v) (0) , where all the coefficients may depend on (s, ρ 1 , ..., ρ P ). The first linear relation describes the vectorial phenomena of heat conduction (Fourier law), diffusion (Fick law), and their cross-effects (Soret and Dufour effects); the second relation describes the scalar processes of bulk viscosity with coefficient ζ ≥ 0, and the third relation is the tensorial process of shear viscosity with coefficient µ ≥ 0. The associated friction stress reads σ fr = 2µ Def v + ζ − 2 3 µ (div v)δ.
All these phenomenological considerations take place with the phenomenological constraint (Equation (88)) and the associated variational constraint (Equation (89)), but they are not involved in the variational condition (87). Note that our variational formulation holds independently on the linear character of the phenomenological laws.

Remark 7.
For simplicity, we chose the fluid domain D as a subset of R 3 endowed with the Euclidean metric. More generally, the variational formulation can be intrinsically written on Riemannian manifolds (see [2]). Making the dependence of the Riemannian metric explicit, even if it is given by the standard Euclidean metric, is important for the study of the covariance properties [49].

Concluding Remarks
In this paper, we survey our recent developments on the Lagrangian variational formulation for nonequilibrium thermodynamics developed in [1][2][3], which is a natural extension of Hamilton's principle in mechanics to include irreversible processes.
Before going into details, we briefly review Hamilton's principle as it applies to (finite-dimensional) discrete systems in classical mechanics, as well as to (infinite-dimensional) continuum systems. Then, in order to illustrate our variational formulation for nonequilibrium thermodynamics, we first start with the finite dimensional case of adiabatically closed systems together with representative examples, such as a piston containing an ideal gas, a system with a chemical species experiencing diffusion between several compartments, an adiabatic piston with two cylinders, and a system with a chemical species experiencing diffusion and heat conduction between two compartments. Then, we extend the variational formulation to open finite-dimensional systems that can exchange heat and matter with the exterior. This case is illustrated with the help of a piston device with ports and heat sources. We also demonstrate how chemical reactions can be naturally incorporated into our variational formulation.
Second, we illustrate the variational formulation with the infinite-dimensional case of continuum systems by focusing on a compressible fluid with the irreversible processes due to viscosity, heat conduction, and diffusion. The formulation is first given in the Lagrangian (or material) description because it is in this description that the variational formulation is a natural continuum extension of the one for discrete systems. The variational formulation in the Eulerian (or spatial) description is then deduced by Lagrangian reduction and yields the multicomponent Navier-Stokes-Fourier equations.
One of the key issue of our variational formulation is the introduction and the use of the concept of thermodynamic displacement, whose time derivative corresponds to the affinity of the process. Thermodynamic displacement allows for systematically developing the variational constraints associated with the nonlinear phenomenological constraints. The variational formulations presented in this paper use the entropy as an independent variable, but a variational approach based on the temperature can be also developed by considering free energy Lagrangians (see [4]).

Further Developments
Associated with our variational formulation of nonequilibrium thermodynamics, there are the following interesting and important topics, which we have not described here due to lack of space, but they are quite relevant to the variational formulation of nonequilibrium thermodynamics, reviewed in this paper.

•
Dirac structures and Dirac systems: It is well known that when the Lagrangian is regular, the equations of classical mechanics can be transformed into the setting of Hamiltonian systems. The underlying geometric object for this formulation is the canonical symplectic form on the phase space T * Q of the configuration manifold. When irreversible processes are included, this geometric formulation is lost because of the degeneracy of the Lagrangians and the presence of the nonlinear nonholonomic constraints. Hence, one may ask: what is the appropriate geometric object that generalizes the canonical symplectic form in the formulation of thermodynamics? In [64,71], it was shown that the evolution equations for both adiabatically closed and open systems can be geometrically formulated in terms of various classes of Dirac structures induced by the phenomenological constraint and from the canonical symplectic form on T * Q or on T * (Q × R). • Reduction by symmetry: When symmetries are available, reduction processes can be applied to the variational formulation of thermodynamics, thereby extending the process of Lagrangian reduction from classical mechanics to thermodynamics. This is illustrated in Section 4.2 for the Navier-Stokes-Fourier equation, but it can be carried out in general for all the variational formulations presented in this paper. For instance, we refer to [72] for the case of simple thermodynamic systems on Lie groups with symmetries.

•
Variational discretization: Associated with the variational formulation in this paper, there exist variational integrators for the nonequilibrium thermodynamics of simple adiabatically closed systems (see [72,73]). These integrators are structure-preserving numerical schemes that are obtained by a discretization of the variational formulation. The structure-preserving property of the flow of such systems is an extension of the symplectic property of the flow of variational integrators for Lagrangian mechanics.

•
Modeling of thermodynamically consistent models: The variational formulation for thermodynamics can be also used to derive new models, which are automatically thermodynamically consistent. We refer to [74] for an application of the variational formulation to atmospheric thermodynamics and its pseudo-incompressible approximation.

Conflicts of Interest:
The authors declare no conflict of interest.