  In 1870, R. Clausius found the virial theorem which amounts to introduce the
trace of the stress tensor when studying the foundations of thermodynamics, as
a way to relate the absolute temperature of an ideal gas to the mean kinetic
energy of its molecules. In 1901, H. Poincar{\'e} introduced a duality
principle in analytical mechanics in order to study lagrangians invariant under
the action of a Lie group of transformations. In 1909, the brothers E. and F.
Cosserat discovered another approach for studying the same problem though using
quite different equations. In 1916, H. Weyl considered again the same problem
for the conformal group of transformations, obtaining at the same time the
Maxwell equations and an additional specific equation also involving the trace
of the impulsion-energy tensor. Finally, having in mind the space-time
formulation of electromagnetism and the Maurer-Cartan equations for Lie groups,
gauge theory has been created by C.N. Yang and R.L. Mills in 1954 as a way to
introduce in physics the differential geometric methods available at that time,
independently of any group action, contrary to all the previous approaches. The
main purpose of this paper is to revisit the mathematical foundations of
thermodynamics and gauge theory by using new differential geometric methods
coming from the formal theory of systems of partial differential equations and
Lie pseudogroups, mostly developped by D.C Spencer and coworkers around 1970.
In particular, we justify and extend the virial theorem, showing that the
Clausius/Cosserat/Maxwell/Weyl equations are nothing else but the formal
adjoint of the Spencer operator appearing in the canonical Spencer sequence for
the conformal group of space-time and are thus totally dependent on the group
action. The duality principle also appeals to the formal adjoint of a linear
differential operator used in differential geometry and to the extension
modules used in homological algebra.
