In astrophysics, the energy momentum tensor is usually described by perfect fluid model
Theoretical analysis and experiments all show that (1.1) is a successful approximation. Some researchers such as Israel and Stewart   , Carter  and Lichnerowicz  disclose that, the energy momentum tensor includes abundant contents for classical fluid theory, which includes not only energy and momentum, but also heat flux, spatial stress and viscosity   . Furthermore, the relativistic hydrodynamics with variation principle and Cartan’s exterior algebra was discussed in  .
The cooling mechanism of the expanding universe is one of the most interesting problems of the students. The answers given by pedagogical articles     are usually , which is derived from the classical thermodynamics. In      , the author solved the thermo- dynamical relations according to the Gibbs’ law
The problem looks underdetermined due to (1.2) including a number of undetermined quantities. So we have to introduce some new relations such as multi fluid with energy exchange, the apparent horizon entropy, the decay of vacuum, to get a solution. As pointed out in  , these approaches cannot convince the students and satisfy their curiosity. Dividing the velocity of particles into Hubble velocity and peculiar velocity , and then analyzing the geodesic of a particle, the author qualitatively reached the conclusion . Then by mass-energy relation , he concluded that the cosmic temperature should be for the ultra-relativistic gas but for the non-relativistic gas.
As a matter of fact, free particles in gravitational field will automatically move along geodesics, until they collide with each other. So the functions of state of gases consistent with general relativity should be naturally derived under background of gravity. This is the purpose of the paper. We derive the functions in microscopic point of view. From the calculation, indeed we can get complete functions of state, which automatically satisfy the requirement of relativity and remove the singularity from solutions to the Einstein’s field equation  .
2. Ideal Gas in FRW Space-Time
For dark spinors with self-interactive potential, in microscopic view, the energy momentum tensor can be expressed by 
where is the proper mass of the n-th spinor, is the proper potential of self-interaction, 4-vector velocity, the usual 3-d speed, the central coordinate. In the case of ideal gas, we have , and then we have the energy-momentum tensor (1.1)  . In case , the complete average formalism of energy-momentum tensor should be
where W is a new function of state reflect the self-potential of particles, which acts like negative pressure and is defined by
The functions of state in (2.1) and (2.3) including relativistic factor , which cannot calculate directly. We solve the problem by the following method, which naturally includes the interaction with gravity. To research the thermodynamical properties of gas, we use piston and cylinder to drive gas. In astrophysics, we have more ideal piston and cylinder that is the space-time with Friedmann-Robertson-Walker (FRW) metric, which is absolutely adiabatic and reversible. The FRW metric drives the gases homogeneously expanding and contracting as the scale factor a varies, and the results have general meanings according to the principle of equivalence.
In the microscopic view, for the ideal gases and photons, the particles are only driven by average gravity and move along geodesics, and the collisions between particles can be treated as instantaneous behavior. So all thermodynamic functions can be rigorously solved according to dynamics and statistics. In this section we set in (2.1) for simplicity.
For FRW space-time, we have the line element in conformal coordinate system
The energy conservation law in this case is equivalent to (1.2) while , or manifestly
For a given equation , we can solve the function from (2.6) or vice versa.
To solve geodesic in FRW space-time, we have the following result.
Lemma 1. If the line element of the orthogonal subspace has the following form,
where and only depend on the coordinate t, then the geodesic in this subspace can be solved by
where are constants, and .
Lemma 1 can be checked directly. For the FRW metric (2.4), the line element in the orthogonal subspace is given by . According to Lemma 1, we have the geodesic equation
where C is a constant only depends on the initial data. By (2.9) we get the drifting speed of a particle in usual sense
So the momentum of a particle satisfies
where is the proper mass of the particle. For the massless photons, we can check that the wavelength satisfies , so their momentum p
also satisfy (2.11). Although (2.11) is derived in subspace-time , but it is suitable for all particles due to the symmetry of the FRW metric.
The relation between momentum p and the kinetic energy K is given by
By (2.11) we have , where are constants only depending on the
initial data at . Then on one hand, for all particles we have the mean square momentum directly
where is a constant only determined by initial data at . One may argue that (2.13) is probably broken by the collision of the particles. The following Lemma shows that (2.13) holds in statistical sense.
Lemma 2. The mean square momentum of the ideal gas is independent of the elastic collision of the particles.
Proof. For any elastic collision, we have momentum conservation law , and then
Taking average for (2.14), we have
Since the elastic collision is a reversible process, in statistical sense, we have the exactly equal numbers of reversible process, so we also have
Comparing (2.15) with (2.16), we have and . Since collision is finished instantaneously, (2.13) holds for all time t.
On the other hand, can be calculated according to statistical principle. Assuming the distribution of kinetic energy K of the particles is given by
then we have
where the second formula can be regarded as definition of temperature, is a constant reflecting the concrete distribution function of particles. In statistical mechanics, we usually use the distribution functions of momentum, which is inconvenient for calculation in the case of relativistic gases. Since the following discussions have nothing to do with explicit function , and at most uses the second order moment, so the kinetic energy distribution (2.17) is much convenient. In case of Maxwell distribution, we have
By the moments (2.18) we have
where N is the number of particles with mass in the volume . Comparing (2.20) with (2.13), we get the equation of as follows
where is the average mass of all particles, and b is a constant only depending on initial data. Solving (2.21), we get
Theorem 3. The temperature of ideal gases in FRW space-time satisfies
where b is constant determined by the initial data and . acts as intermediate parameter.
By the theorem we find that, the cosmic temperature is different from the results directly derived from classical thermodynamics. In what follows we derive the relations between and as well as the equation of state.
In microscopic point of view, the Lagrangian of FRW space-time coupling with particles is given by  
where is the coordinate of n-th particle, the scalar curvature
in which the prime stands for , and the drifting speed of n-th particle in usual sense
are independent variables related to a for variation. Noticing that , by variation of with respect to a, we get
where is any given comoving volume with volume element , which is independent of a. Substituting (2.10) into (2.25), we get
Multiply (2.26) by and integrate it, again by (2.10) we have
where is a constant, for classical particles  .
By Friedmann equation and (2.22), making statistical average of (2.27) we get
where is defined by (1.1) and by the following
in which is the comoving density independent of a. Comparing (2.28) with (2.21), we get
Theorem 4. For the ideal gas in FRW space-time, the mass density satisfies
where is a constant.
Substituting (2.30) into (2.6), we get
Theorem 5. The equation of state for ideal gas in FRW space-time is given by
The final expressions of function of state (2.30) and (2.32) are independent of metric a which is only used as “piston-cylinder” to drive the particles. So the state functions (2.30) and (2.32) are generally valid for ideal gases in general relativity.
Denoting , by (2.30) and (2.32) we have asymptotic properties of equation of state (EOS) for the particles
The velocity of sound
Obviously the EOS satisfies the increasing and causal conditions which are consistent with relativity.
3. Functions of State Including Self-Potentials
In this section, we consider the case in (2.1). By (2.10), we have relation
This is the key relation to calculate the relativistic factor . Substituting it into (2.21), and using (2.22) and (2.18), we get
where the mean parameters are defined by
In the case , by (3.3) we have
For the same kind particles , we find . If the scale of the
space-time is stable and varies slowly, e.g. in a galaxy, all the proper parameters such as and can be treated as constants.
If we define the mass-energy density and pressure of the particles from (2.1) in micro form as usual 
then in mean sense we get
Again we get (2.30). By (3.2) and (3.6), we have
Again we get (2.32). Similarly, by (2.3) and (3.3) we get W in average form
The equations of state (3.7), (3.8) and (3.9) are valid for any ideal gases in local equilibrium. They have the following dimensionless form,
where is a constant depending on parameters , and .
Among the functions of state only the temperature or is independent variable.
Equations (3.10)-(3.13) are based on the assumption that the particles move along geodesic. This is valid for . In general cases, these functions can be modified by the following treatments. In (3.10)-(3.13), we take density or equivalently the volume as an independent state function, and then derive the function according to energy conservation law.
In the comoving coordinate system with the following Gaussian type metric  
where is the spatial metric, for energy-momentum tensor (2.2), we have
Theorem 6. For the particles with energy-momentum tensor (2.2), we have the following Gibbs-Duhem’s law
where denotes the heat received by the N particles, and
is the micro spatial volume occupied by N given particles.
This can be checked as follows. We trace the motion of these particles. In the adiabatic process, we have . Then by , we get the continuity equation for (2.2) as
Denoting the proper time by , then , (3.17) becomes
where . In the comoving system, we have and , then we get
Multiplying (3.18) by the comoving volume element for the N given particles, (3.18) gives (3.15) in the case . In the case of , (3.15) holds due to energy conservation law.
Now we derive the relation from (3.15) for the equilibrium process with . For clearness, we use the the static mass density to
replace V. Substituting (3.7), (3.8) and (3.9) into (3.15), we get dimensionless differential equation
The solution is given by
where parameters are defined by
(3.21) shows how the internal potentials influence the mass density. (3.21) reduces to (3.10) if .
4. Discussion and Conclusion
1) The above calculations show that functions of state consistent with relativity should include the influences of gravity. The energy-momentum tensor and geodesics connect the macro concepts with micro movements of particles.
2) In the case of ideal gas with at low temperature, (3.11)-(3.12) give the equation of state for the adiabatic monatomic gas
which is identical to the empirical law in thermodynamics. When , we have , so the adiabatic index is not a constant for large range of
temperature due to the relativistic effect. These results show the validity of (3.11)-(3.13) and the consistence with normal thermodynamics.
3) By (3.11), letting or , we get the Stefan-Boltzmann’s law . This means that the above results automatically include photons, and the Stefan-Boltzmann’s law is also valid for the ultra-relativistic particles.
4) In general relativity, all processes occur automatically, and is independent of any practical process. Of course, is related to the property of particles. Furthermore, equation of state (3.11)-(3.12) provides a singularity-free stellar structure in thermal equilibrium  .
5) In the case , the motion of the particles will slightly deviate from the geodesic. By (3.21) we find, leads to , which means the
zero temperature can not reach. The physical reason for such conclusion is unclear.
The author is grateful to Prof. Ta-Tsien, Prof. Tie-Hu Qin and Prof. Ji-Zong Li for encouragement.