The derivation of a thermodynamical Lagrangian for the non-adiabatical case using the techniques of the irreversible thermodynamic solves existing numerical problems. The usual method consists in obtaining the non-adiabatic solution by solving numerically the equation of motion, using as initial solution that of the adiabatic case. The variational principle associated with the thermodynamical Lagrangian permits to identify the non-adiabatic cases and to adjust the boundary conditions.