Optimal Thermodynamic Processes For Gases

In this paper, we consider an optimal control problem in the equilibrium thermodynamics of gases. The thermodynamic state of the gas is given by a Legendrian submanifold in a contact thermodynamic space. Using Pontryagin’s maximum principle, we find a thermodynamic process in this submanifold such that the gas maximizes the work functional. For ideal gases, this problem is shown to be integrable in Liouville’s sense and its solution is given by means of action-angle variables. For real gases considered to be a perturbation of ideal ones, the integrals are given asymptotically.


Introduction
The problem of optimal control of thermodynamic processes has been of wide interest since the 19th century when a classical work of Carnot [1] paved the way for investigation of optimal heat engines. A number of works is devoted to constructing heat engines with maximal efficiency in case of linear heat transfer laws (see [2,3]). In [3], the problem of optimal control was investigated by means of Pontryagin's maximum principle, which is formulated in [4] and is also described in [5]. In a relatively recent series of works [6], a non-equilibrium thermodynamic system is presented as a union of equilibrium subsystems with linear heat transfer laws between each pair of subsystems and a work of such system is maximized. Volumes of subsystems are considered to be control parameters, while state variables are entropies of subsystems. Thermodynamic optimization in some engineering problems is elaborated for example, in [7], and power optimization for irreversible thermodynamic cycles is studied in [8].
In the present work, we formulate thermodynamics as a theory of measurement of random vectors, namely extensive variables. This observation leads us to the definition of thermodynamic states as Legendrian and Lagrangian manifolds. This approach goes back to classical work [9] and is also reflected in papers [10,11]. Legendrian and Lagrangian manifolds are equipped with Riemannian structures and one of distinguishing points of this work is an observation that these structures naturally appear in measurement. This geometrical representation of thermodynamic states allows us to use Pontryagin's maximum principle to find optimal thermodynamic process maximizing the work functional. One of the main results of this paper is that a Hamiltonian system turns out to be integrable in Liouville's sense and we provide its exact solution. We also consider the case of real gases in virial approximation and provide commuting up to linear terms of virial expansion integrals of the Hamiltonian system for real gases.
The paper is organized as follows. In Section 2, we show relations between thermodynamics and measurement of random vectors. In Section 3, we describe Legendrian manifolds and geometric structures on them for gases in the form convenient for further optimal control problem statement. In Section 4, we state and solve the optimal control problem for ideal gases and construct asymptotics of commuting integrals for real ones.

Measurement and Thermodynamics
In this section, we briefly describe a link between thermodynamics and measurement of random vectors. Namely we show that thermodynamics can be seen as a measurement theory of extensive variables. Moreover, such a consideration leads to the notion of Legendrian manifolds representing any thermodynamic state and various geometric structures on it, in particular, Riemannian structures responsible for applicability conditions for state equations. These structures, as we shall see below, play a crucial role in control problems on Legendrian manifolds. More comprehensive discussion can be found in [12] and references therein.

Minimal Information Gain Principle
Let (Ω, A, p) be a discrete probability space, i.e., Ω = {ω 1 , . . . , ω k } is a set of elementary events, A is a σ-algebra on Ω and p is a probability measure, p = {p 1 , . . . p k }, where p i = p(ω i ). Let q = {q 1 , . . . , q k } be another probability measure equivalent to p. It means that measures p and q have the same zero measure sets. Introduce the surprise function as a random variable s p : A → R by determining its values on elementary outcomes as follows: Due to (1), we have relations s p (Ω) = 0, s p (∅) = +∞, therefore the notion "surprise" is justified. The average S(p) of the surprise function s p with respect to the measure p is Please note that formula (2) coincides with the Shannon's definition of entropy. If we change measure p to measure q, then we get the changing of the surprise function: and therefore the average of s(p, q) with respect to measure p called Kullback-Leibler divergence [13] or information gain is Generalization of (3) on the case of arbitrary probability space (Ω, A, p) is of the form I(p, q) = Ω ln dp dq dp, and if dp = ρdq, where ρ is the density, then formula (4) takes the form Let W be a vector space over R, dim W = n < ∞ and let X : (Ω, A, q) → W be a random vector. Let x ∈ W be a fixed vector, supposed to be a result of the measurement of random vector X, i.e., EX = x. If the initial measure q does not give us the required vector x ∈ W, then we have to choose another measure dp = ρdq, such that In other words, to get a fixed vector x ∈ W as a result of the measurement we need to find such a density ρ that conditions (5) hold. Obviously, conditions (5) cannot determine the density ρ uniquely, therefore we need an additional requirement, which is called the principle of minimal information gain: Thus, the problem of finding the density ρ can be formulated as an extremal problem. We need to find the probability density ρ satisfying constraints (5) and minimizing functional (6). Theorem 1. The extremal probability measure p is given by means of density ρ as follows where λ ∈ W * . The results of the measurement belong to a manifold The proof can be found in [12].
1. The function Z(λ) is called the partition function.

The function H(λ) is called the Hamiltonian.
Please note that a manifold Φ = W × W * is equipped with the symplectic structure A pair (Φ, ω) is therefore the symplectic manifold. Moreover, the manifold L H turns out to be Lagrangian, i.e., ω| L H = 0.
Thus, the results of the measurement of random vectors are given by a Lagrangian manifold, and having given a Lagrangian manifold one can find out both extreme probability measure p and expectation x of random vector X.
Let us now introduce the information gain into the picture. To that end, construct the contactization Φ of Φ by the following way: Equip Φ with the contact form Thus, ( Φ, θ) is a contact space. Let a = (x, λ) ∈ L H and construct a manifold L of dimension n as follows: Theorem 2. The manifold L is Legendrian, i.e., θ| L = 0.
Proof. First of all, introduce a function J(x, λ): Let us show that J| L H = I. Indeed, using (7) we have Taking into account the equality J| L H = I, we get θ| L H = dI. Finally, It is worth saying that a canonical projection π : Φ → Φ, π(u, x, λ) = (x, λ) being restricted to the Legendrian manifold L becomes a local diffeomorphism with the image L H , i.e., π( L) = L H and the differential 2-form dθ is a pullback of the symplectic form ω, dθ = π * (ω).
Summarizing all above discussion, we conclude that any measurement of random vectors can be represented by means of Legendrian submanifold L in the contact manifold Φ. This Legendrian manifold gives us knowledge of extremal measure p (or, equivalently, the probability density ρ), average values x of random vector X and additionally the values of the information gain function I(λ).

Variance of Random Vectors
The next step is to analyze the variance of random vector X. Recall that the second moment is a symmetric 2-form µ 2 ∈ S 2 (W) defined by the formula Variance is a central second moment, i.e., a symmetric 2-form σ 2 ∈ S 2 (W)

Theorem 3 ([12]). The variance of a random vector X is
Please note that the symplectic manifold Φ is equipped with the universal quadratic form κ: Its restriction to the Lagrangian manifold L H Coincides with the variance of random vector X. Since the variance is positive, the only areas on L H make sense where the differential quadratic form κ| L H defines a Riemannian structure.
Thus, we showed that measurement of random vectors leads us to the following geometric structures on Φ = W × W * .
• symplectic structure Moreover, Lagrangian manifolds L H ⊂ (Φ, ω) representing expectations of random vectors X consist of areas where the quadratic form κ| L H is either positive, which we call applicable phases, or not.

Relations with Thermodynamics
First of all, we recall that any thermodynamical system is described by two types of variables, extensive (volume, energy, mass) and intensive (pressure, temperature, chemical potential). A distinctive property of extensive variables is their additivity with respect to division of the system to a disjoint union of subsystems. Secondly, the main law of thermodynamics (in particular, for gas-like systems) including the first and the second laws states that the differential form must be zero. Here S is entropy, E is energy, V is volume, m is mass, T and p are temperature and pressure respectively, γ is a chemical potential.
where the main law of thermodynamics holds, i.e., θ| L = 0. Moreover, form (8) coincides with (9) if one puts Therefore, on the surface L we have the relation S = −I + α, where α is a constant. This means that thermodynamics can be viewed as a theory of measurement of extensive variables and entropy is an information gain up to a sign and additive constant. This in turn implies that principle of minimal information gain is exactly what in thermodynamics usually called principle of maximum entropy.
As in measurement theory, consider projection π : R × W int × W ext → W int × W ext . Then, its restriction to the manifold L gives us an immersed Lagrangian manifold L ⊂ W int × W ext and Φ = W int × W ext is a symplectic space with structure form Condition for L to be Lagrangian is expressed as ω| L = 0. Again, we can see analogies with measurement.
Pseudo-Riemannian structures coming from measurement of random vectors are inherited in thermodynamics as well. Let us define the differential quadratic form κ on Φ = W int × W ext using (10) by the following way: and its restriction κ| L to the Lagrangian manifold L has to be positive. We shall see below that domains where form κ| L is positive correspond to phases of the medium and conditions for L to be Riemannian with respect to quadratic form κ| L are conditions of thermodynamic stability.

Legendrian Manifolds For Gases
In this section, we describe Legendrian and Lagrangian manifolds for gases (see also [14][15][16]). We pay special attention to ideal gases and virial model of real gases [17], which are used further in optimal control problem.
Let us choose the extensive variables (E, V, m) as coordinates on the Legendrian manifold L. Then, on L we have entropy as a function S(E, V, m). Since entropy is an extensive quantity, the function S(E, V, m) is homogeneous of degree 1: Introducing specific variables e = E/m-specific energy, v = V/m-specific volume, s(e, v)-specific entropy, we get the following expression for contact structure θ: on a given Legendrian manifold θ| L = 0, and therefore we get −ds + T −1 de + pT −1 dv = 0, γ = e − Ts + pv.
The differential quadratic form κ in terms of specific variables takes the form and since m > 0, the condition of positivity of κ becomes equivalent to negativity of the form −m −1 κ, which we will continue denoting by κ: Summarizing, we have the following description of thermodynamic states of gases. Consider the contact space (R 5 , θ) equipped with coordinates (s, e, v, p, T) and structure form By a thermodynamic state we mean a Legendrian manifold L, such that θ| L = 0. It can be defined by a given function σ(e, v): To eliminate the specific entropy form our consideration we use a projection π : R 5 → R 4 , π(s, e, v, p, T) = (e, v, p, T). Its restriction to the Legendrian manifold L gives an immersed Lagrangian manifold L ⊂ R 4 , such that ω| L = 0, where defines a symplectic structure on R 4 (e, v, p, T). Since any 2-dimensional surface L ⊂ (R 4 , ω) can be given by two functions (state equations) is the Poisson bracket with respect to the symplectic structure ω: The expression for the bracket [ f 1 , f 2 ] in coordinates is given by the formula: Suppose that functions f 1 and f 2 are given in a usual for thermodynamics of gases form Then the equation where R is the universal gas constant.
Using the Massieu-Planck potential one can write the differential quadratic form (11) in the following way: and we conclude that conditions of applicability for the thermodynamic state model are Using (14) we obtain that inequalities (15) are equivalent to e T > 0, p v < 0, which are the conditions of thermodynamic stability.
By a thermodynamic process we shall mean a contact transformation of Φ = R × W int × W ext = R 5 (s, p, T, v, e) preserving the Legendrian manifold L. Infinitesimally, such a transformation is given by a contact vector field X, i.e., L X (θ) ∧ θ = 0, where L X is a Lie derivative along the vector field X. Contact vector fields are defined by generating functions (see, for example, [18]) and in thermodynamic case have the form [12]: where f ∈ C ∞ ( Φ) is a generating function of the vector field X f . One can show that L X f ( f ) = X f ( f ) = f f s and therefore the vector field X f is tangent to the surface { f = 0}. Thus, for a given Legendrian manifold L = { f 1 = f 2 = f 3 = 0} the restriction of the process X f to L is represented as [12] where a j are functions on L. Using (12) we get that restrictions Y j of vector fields X f j to L are Example 1 (Ideal gases). For ideal gases, the Legendrian manifold L is given by state equations where n is a degree of freedom. The differential quadratic form κ on L is It is negative and applicable domain is therefore entire manifold L. Vector fields Y 1 and Y 2 have the following form Example 2 (van der Waals gases and virial model). One of the most important models of real gases is the van der Waals model: where a and b are constants responsible for particles' interaction and their volume respectively. The differential quadratic form κ in coordinates (T, v) for van der Waals gases is [16] This form can change its sign and applicable domain in a plane (T, v) for van der Waals model is given by inequality The virial model for real gases' state equations was proposed in [17] and is of the form For van der Waals gases, we will mainly be interested in the first term of the expansion which has the form In this approximation, vector fields Y 1 and Y 2 are

Optimal Control
In this section, we formulate the control problem for thermodynamic processes of gases and provide exact solution for ideal gases and asymptotic expansion of integrals for real ones.
Let thermodynamic state of a gas be given by a Legendrian manifold L and let us choose vector fields Y 1 and Y 2 defined by formula (16) as a basis in module of vector fields on L. We will use the notation x = (e, v). Let x (1) = (e 1 , v 1 ) and x (2) = (e 2 , v 2 ) be two fixed points in applicable domains on L. Let l ⊂ L be an integral curve of the unknown vector field Y = u 1 Y 1 + u 2 Y 2 and let α = pdv be a work 1-form. Introduce a quality functional J: Physical meaning of J is a work of the gas along the process curve l. We are looking for a process Y = u 1 Y 1 + u 2 Y 2 such that functional (20) reaches its maximum value. Vector u = (u 1 , u 2 ) is a vector of control parameters. If t is a parameter on l, then we will suppose that t = 0 corresponds to the point x (1) and t = t 0 , where t 0 is a given value of the parameter t, corresponds to x (2) . Rewrite the vector field Y as where coefficients Y (1) , Y (2) are defined by means of (16). We define the domain of admissible control parameters by means of the differential quadratic form κ. On the Legendrian manifold its physical meaning is (up to a sign) the variance of extensive variables (e, v), we limit a relative variance by a positive number δ: Therefore, for a given point x ∈ L, the boundary ∂U of the admissible domain U for control parameters is an ellipse with a centre at that point and whose semi-axes depend, in general, on x.
Summarizing, we formulate an extremal problem for finding the process Y in the form: The Hamiltonian of problem (21) has the form where λ = (λ 1 , λ 2 ) are Lagrangian multipliers.

Ideal Gases
For ideal gases, vector fields Y 1 and Y 2 have form (18) and vector field Y is Therefore using expression (17) for the differential quadratic form κ in case of ideal gases we get the domain U of admissible control parameters: and its boundary is an ellipse with constant semi-axes. The commutator of vector fields Y 1 and Y 2 is The dual basis is generated by 1-forms Due to the Lie-Bianchi theorem (see, for example, [18]), 1-form ξ 2 is exact, i.e., ξ 2 = dq 1 , where q 1 = nR(2e) −1 . The restriction of the form ξ 1 to the curve q 1 = C 1 is exact too and its potential is q 2 = −C 1 ln v + C 2 , where C i are constants. Let q = (q 1 , q 2 ) be new coordinates on L. Then, the inverse transformation is In new coordinates (q 1 , q 2 ) vector fields Y 1 and Y 2 take the form: Therefore Hamiltonian (21) will take the form Since Hamiltonian (23) is linear with respect to control parameters (u 1 , u 2 ), it reaches its extremal values on the boundary ∂U. Let τ be a parameter on ∂U. Then control parameters (u 1 , u 2 ) can be written as and the Hamiltonian H(q, λ, u) takes the form (24) To find the points where the Hamiltonian H(q, λ, τ) reaches its maximum one has to resolve the equation H τ = 0 with respect to τ: Its solution is Substituting roots (25) into (24) we get the following expression for Hamiltonian H(q, λ): To find the optimal process, one needs to solve the systeṁ where the Hamiltonian H(q, λ) is given by (26). Since the Hamiltonian H(q, λ) does not depend on the parameter t explicitly, it is the integral of system (27). Moreover, the following theorem is valid: Thus, Hamiltonian system (27) has two commuting integrals and is therefore integrable in Liouville's sense.
To construct solution to (27) we use the method of action-angle variables (see, for example, [19]). The invariant manifold M of system (27) is given by levels H 1 and H 2 of its integrals: Choose (q 1 , q 2 ) as local coordinates on M. Then we have where D = 2Rδn 4H 2 1 q 4 1 − δRn 2 (R − H 2 q 1 ) 2 . Therefore the manifold M can have different numbers of connected components depending on the number of roots of polynomial D.
Otherwise, the manifold M has two connected components.
Singularities of projection of M to the plane (q 1 , q 2 ) are given as Σ = ∪Σ j , where Thus, for a given initial point (q (0) , λ (0) ) the reachability set consists of points of M belonging to the same connected component as (q (0) , λ (0) ) does.
Let us choose two Hamiltonian vector fields X 1 = X H and X 2 = X G as a basis in module of vector fields on phase space R 4 (q, λ). Here We need to find two closed 1-forms κ 1 and κ 2 dual to restrictions Z 1 and Z 2 of vector fields X 1 and X 2 on M, i.e., κ i (Z j ) = δ ij , where δ ij is the Kronecker symbol. On each connected component of M the forms κ 1 and κ 2 are exact, i.e., κ i = dΩ i and functions Ω i are called angles. Expressions for Ω 1 and Ω 2 are given by the following theorem, which is the result of straightforward computations. Theorem 7. Angle variables Ω 1 and Ω 2 are of the form Hamiltonian system (27) is equivalent toΩ Thus, the solution of (27) is given as where constants α 1 and α 2 are derived from conditions at the ends. By means of inverse transformation (22) one can obtain the corresponding solutions in terms of thermodynamic variables (e, v).

Real Gases
Here, we again will look for a process Y = u 1 Y 1 + u 2 Y 2 , where vector fields Y 1 and Y 2 are given by (19). Following the case of ideal gases, we finally get the Hamiltonian H vdW (q, λ) in the form H vdW (q, λ) = H(q, λ) + aH a (q, λ) + bH b (q, λ) + . . . , where the first order corrections H a and H b are H a (q, λ) = e q 2 /q 1 q 2 1 (Rδn 3 λ 2 2 − 8H 2 (q, λ)) − R 2 λ 2 n 3 δ 4q 1 nRH(q, λ) , H b (q, λ) = e q 2 /q 1 Rδn 2 λ 2 (R − λ 2 q 2 1 ) 4H(q, λ)q 2 1 . We will restrict ourselves to the linear with respect to parameters a and b corrections only. From now and on, we will assume that all the functions are expressed in terms of angle variables (Ω 1 , Ω 2 ) given by (28) instead of (q 1 , q 2 ). This can be done by resolving (28) with respect to (q 1 , q 2 ). In these new coordinates, vector fields Z 1 and Z 2 have the form To integrate the Hamiltonian system with Hamiltonian (29), one needs to find the second commuting integral G vdW (q, λ). We will look for that integral in the form G vdW (Ω 1 , Ω 2 ) = G(Ω 1 , Ω 2 ) + aG a (Ω 1 , Ω 2 ) + bG b (Ω 1 , Ω 2 ) + . . . , Using a well-known relation [ f , g] = X g ( f ) and (30), we get system (31) as and finally we obtain Thus, we have the second integral for the extremal problem commuting with the Hamiltonian up to linear in a and b terms and therefore the Hamiltonian system is integrable in Liouville's sense in this approximation.

Conclusions
We showed that considering thermodynamics as a theory of measurement of random vectors one can describe thermodynamic states as Legendrian or Lagrangian manifolds equipped with the differential quadratic form responsible for the variance of extensive variables. Thermodynamic processes are interpreted as curves on Legendrian manifolds. The Hamiltonian system arising from the problem of finding an optimal curve maximizing the work functional is shown to be integrable in Liouville's sense and its solution is constructed explicitly by means of action-angle variables. We also provided a method of finding asymptotically commuting integrals for real gases in virial approximation.