Temperature and particles and fields When I studied Thermodynamics the way I learned things and the way I understood them is that temperature is a quantity that appears and is relevant just when studying macroscopic matter.
Indeed, all the framework I've learned to deal with temperature was connected to this "macroscopic matter approach", so that it all starts with a fundamental relation $U = U(S,X_1,\dots,X_n)$ where $S$ is the entropy and $X_i$ are extensive parameters of the macroscopic system.
In that setting the temperature is:
$$T = \dfrac{\partial U}{\partial S}.$$
So there are some remarks here:


*

*$T$ is a function of the parameters describing the macroscopic body;

*$T$ is not a function defined pointwise in space;

*$T$ only makes sense for a very specific macroscopic body, namely, the one described by the extensive parameters $X_1,\dots,X_n$ and whose fundamental relation is $U = U(S,X_1,\dots,X_n)$.


Even when I studied statistical mechanics everything remained the same, the only difference was that statistical mechanics gave a way to compute $S$ or the other potentials, starting from microscopic considerations.
Now, I've seem some times now some discussions where temperature is involved in phenomena related to fields and particles, like when talking about the big bang and the evolution of the universe after it.
But in this framework I learned it simply doesn't make any sense bringing these things together.
So, how can temperature ever relate to phenomena involving fields and particles, and how do we deal mathematically with temperature in these situations, since, as I said, the traditional framework, just relates temperature to equilibrium states of macroscopic matter?
 A: From the statistical mechanics point of view, the temperature $T$ is just a parameter entering the definition of the equilibrium state
$$\rho = \frac{{\rm e}^{-\beta H}}{{\rm Tr}\left[{\rm e}^{-\beta H}\right]},$$
where $\beta = 1/k_B T$ and $H$ is the Hamiltonian of the system in question. This microscopic definition agrees with the classical thermodynamics definitions if you identify the mean values of observables like the energy $U = {\rm Tr}\left[\rho H \right]$ with the extensive thermodynamic parameters. However, the statistical mechanics approach is more general, because there is no requirement for the system to be macroscopic: it could be a single particle or a quantum field etc. 
However, the state of the system must be of the form above (or, more generally, the equivalent Gibbs form from another ensemble, e.g. grand canonical). In other words, the entropy of the system must be maximised subject to the constraint of fixed $U$ (plus any other extensive conserved quantities e.g. particle number), which uniquely defines $\rho$ and $\beta$ (plus any other thermodynamic potentials e.g. chemical potential). Any time someone is discussing thermodynamic temperature in any context, they are implicitly assuming that the system is an equilibrium (maximum entropy) state. Otherwise $T$ is undefined. 
