Lagrangian formulation of a themodynamics problem
I was wondering whether it is possible to derive the model of a thermodynamical system by combining thermodynamic equations and Lagrangian mechanics. Let's consider the following closed system. A mass $m$ is glued to the top of cylinder full of air. Inside of the cylinder we have an electrical resistance $R$ that can be used to heat the air in the cylinder. Since the system is not isolated, we can have heat and mechanical work exchange between the system and the environment (considered as the thick borders of the cylinder). In particular, for heat, we have radiation $P_r$ and (for simplicity) only forced convection $P_c$. We consider only forced convection because we have a fan inside of the cylinder whose angular velocity is a function of $\dot{x}$ and we want to study the system while the mass is moving. 101
As a consequence we are interested only in the temperature of the air inside of the cylinder $T_c$ and the temperature of the frame of the cylinder $T_f$. From a thermodynamical point of view we can write the following balance equation (neglecting work because will be included using the Lagrangian): $$ C_v \frac{dT}{dt} = P_{in} - P_c - P_r $$ Where $C_v$ is the heat capacity, and $P_{in} = R i^2$ is the input power with $i$ being the current flowing through the resistance.
Assumption 1: Considering that the velocity $v$ of the air inside of the cylinder is some non linear function of the velocity of the mass $\dot{x}$ (because of the fan) we can describe the heat transfer coefficient $\alpha$ as a <PERSON> expansion of a function of the temperatures $T_f$ and $T_c$, and the velocity of the mass $\dot{x}$ (considering that the Nusselt number is a function of the <PERSON> and <PERSON> numbers, where the latter includes the fluid velocity $v$) Thanks to this assumption the convection power $P_c$ is also a function of the mass velocity.
Assumption 2: If we integrate the product $C_v \frac{dT}{dt}$ we obtain a "thermal potential energy" $E_T$.
We can now introduce the Lagrangian by assuming as generalized coordinate the position of the mass $x$. Including also the thermal potential energy we should have: $$ L = E_K - (E_P + E_T) $$ Where $E_K$ is the kinetic energy of the mass, while $E_P$ is its potential energy as the sum of gravitational potential energy and elastic potential energy of the spring $k$. Therefore we can write the following <PERSON>'s equation of motion: $$ \frac{d}{dt} \left( \frac{\partial L}{\partial \dot x} \right) = \frac{\partial L}{\partial x} - \frac{\partial E_D}{\partial \dot x} $$ Where $E_D = E_r + E_c$ is the thermal dissipative term, being $E_r$ the integral of $P_r$ and $E_c$ the integral of $P_c$. Observe that thanks to the previous assumption the latter is a function of $\dot x$.
The model is not complete, but I am not sure about the approach (in particular the two assumptions). The goal would be to obtain a model of the displacement of the mass which includes the air temperature, subsequently another model to compute the air temperature could be derived by the thermodynamical balance. I am interested in your thoughts and comments about the approach and it would be nice if you can please also give me some hints to understand which would be the proper way to obtain the model for such a system. 37