What are the applications of calculus of variations, if any, to the subject of thermodynamics? If we apply calculus of variations to Newtonian mechanics, we can discuss of functionals such as the lagrangian and how optimizing it leads to the equations of motion. However, does there exist application of the subject in thermodynamics?
I'm not sure how to phrase it precisely but I think there is a similarity in the notions of the concept of path dependence and functionals. In the sense that, in both we are talking function of functions, for example the work:
$$ W= \int_{V_1}^{V_2}P dV$$
Is a function dependent on the kind of path you take in the PV curve, this is extremely similar to the notion of a functional!
 A: There have been many attempts to apply Lagrangean variational techniques in thermodynamics, the most famous one is probably Prigogine's minimum entropy production principle. A nice description of it is a series of publications by James Li [1,2,3,4] of which I summarize one here.
Starting with the result that the entropy $S$ in equilibrium is a convex function of its extensive parameters, the matrix $$[D^2 S]=\frac{\partial ^2 S}{\partial A_i \partial A_j}\le 0 \tag{1}\label{1}$$ is negative definite, where it is assumed that the extensive parameters $A_i$ represent conserved quantities, we wish to derive the non-equilibrium heat conduction (Fourier equation) from a variational principle on the steady state entropy production rate.
Now we assume that the equilibrium convexity property also holds for infinitesimal volumes and rates as follows: for any positive function of the coordinates $f=f(x,y,z)>0$ $$\int_V dV f\sum_{i,j}\frac{\partial ^2 S}{\partial A_i \partial A_j}\dot{A}_i\dot A_j \le 0 \tag{2}\label{2}$$
Li argues that since in equilibrium $S$ is a maximum of its variables there must exist $f>0$ such that the integral is a (total) time derivative, in other words, there must exist a time function $\mathfrak K = K(t)$ so-called thermokinetic potential that is derivable from the $D^2S$ matrix with an integrating factor $f$.
$$\delta \mathfrak K = \int_V dV f\sum_{i,j}\frac{\partial ^2 S}{\partial A_i \partial A_j}\dot{A}_i \delta A_j \tag{3}\label{3}$$
The thermokinetic potential can only decrease in time, at least in this near equilibrium, ie., linear regime, that is $\delta \mathfrak K \le 0$ and in steady-state it reaches its minimum and as such it can be used as variational principle when characterizing the steady state. This is not the minimum entropy production principle but rather the minimum thermokinetic potential production principle, a mouthful.
As an example take the heat conduction problem where we assume that the only extensive conserved parameter of interest is internal energy $U$, then $S=S(T,U)$ and  ($V=const$ throughout):
$$\frac{\partial S}{\partial U}=\frac{1}{T} \tag{4}\label{4}$$
$$\frac{\partial ^2 S }{\partial U^2} = -\frac{1}{T^2}\frac{\partial T}{\partial U}=-\frac{1}{c\rho T^2}\tag{5}\label{5}$$
$$\frac{\partial U}{\partial t}=c \rho \frac{\partial T}{\partial t}\tag{6}\label{6}
$$.
If now one sets $f=2T^2 >0$ and assumes that the temperature is fixed at the boundaries by $\delta T=0$ then a thermokinetic potential can be defined as $$\mathfrak K= \int_V dV (\nabla T)^2 \tag{7}\label{7}$$ for an homogeneous isotropic thermally conducting body and thereby derive the Fourier conduction in steady state. By making various other choices for $f$ one gets different heat conduction equations, e.g., for the non-isotropic, inhomogeneous, temperature dependent conductivity cases, see for details in [1].
[1]"THERMOKINETIC ANALYSIS OF HEAT CONDUCTION", Int. J. Heat Mass Transfer. Vol. 7, pp. 1335-1339.
[2] Thermodynamics of nonequilibrium systems. The Principle of Macroscopic Separability and the Thermokinetic Potential, JOURNAL OF APPLIED PHYSICS VOLUME 33, NUMBER 2 FEBRUARY, 1962
[3]"Stable Steady State and the Thermokinetic Potential", THE JOURNAL OF CHEMICAL PHYSICS VOLUME 37, NUMBER 8 OCTOBER IS, 1962
[4] "CARATHEODORY’S PRINCIPLE AND THE THERMOKINETIC POTENTIAL IN IRREVERSIBLE THERMODYNAMICS", The Journal of Physical Chemistry 66.8 (1962): 1414-1420.
A: The change in entropy of a system between an initial thermodynamic equilibrium state and a final thermodynamic equilibrium state is an extremum.  It is the maximum value of the integral of $dq/T_{boundary}$ over all possible process paths between the initial state and the final state, where $T_{boundary}$ is the temperature at the boundary (interface) of the system through which the heat dq flows.
