Suppose we have
The last may be construed as a rate of variation in the total energy inside the volume. The pressure may be assumed to be constant throughout the volume (albeit this involves supposing the density of the gas times any difference in gravitational potential within the volume is negligible compared to the pressure).
The analysis of such a system follows the standard form of statistical physics. It remains to introduce an analysis of the single particle states of the system, in each of which a single molecule of one component of the gas is studied. It suffices to characterise a set of such states that form, via superposition, a basis of the possible states. Since energy is one of our observables, we can factorise our solutions of Schrödinger's equation into a simple exp(−i.E.t/ℏ) time-dependence combined with a time-independent spatial field, as long as the volume's size and shape are constant.
The fact that our gas is constrained to the volume amounts to the potential being a function that's zero inside the volume and infinite outside. Since it's constant in the interior, the spatial solution is simply a superposition of plane waves, each of constant amplitude.
First, consider the case where the volume of space is a cuboid, with mutually perpendicular edges ({vectors}: b |dim), in which dim is the number of space-like dimensions of space-time (which you're welcome to believe is three). Analysis of the single particle of gas considered as a particle imposes no constraint on its possible momenta or, within the box, positions. Analysis of it as a wave, however, requires it to form a standing wave within the box, to avoid destructively interfering with itself. Assuming reflection off each wall of the box with a node of the wave at the wall, we find that the particle's wave covector must map each edge vector, b(i) for i in dim, to a multiple of a half turn. (We get the same constraint if we require an antinode at each wall.) The covectors satisfying this constraint form a lattice, {sum(n.q): ({integers}:n|dim)} for some ({covectors}:q|dim) for which q(i)·b(j) is zero unless i = j, in which case it is a half turn.
Each such covector describes a particle going in one direction; since the particle must not leave the box, we must combine the solution this covector describes with its mirror images in the walls of the box to yield a solution which describes the particle bouncing around inside the box. Thus every actual solution combines power(dim, 2) of these covectors.
These feasible wave covectors imply feasible momenta {h.sum(n.q)/g:
({integers}:n|dim)}, where g is the metric of space-time, which turns each q(i)
into a vector; since the b(i) were given to be orthogonal, each q(i)/g is in
fact parallel to b(i). The lengths of each q(i)/g is just a half turn divided
by the length of the matching b(i); their product is thus power(dim, turn/2)
divided by the volume of our cuboid. Our lattice divides up the space of
possible momenta into cuboid boxes, each with volume power(dim, h) times the
product of lengths of the q(i), so power(dim, h.turn/2) divided by the volume,
V, of our cuboid. We have one feasible momentum per power(dim, 2) boxes of this
size, hence a density of V/power(dim, h.turn) states per unit volume
in
momentum space.
The case of non-cuboid volumes is somewhat trickier to analyse; and, in any case, these pure momentum states only provide a rough guide to the actual gas, since its particles' (elastic) collisions with one another would preclude their actually being in such a pure momentum state. However, it seems reasonable to conjecture that the density of states remains V/power(dim, h.turn) in momentum space even in the more complex case, if only because this expression of the density in terms of V is independent of the lengths of individual sides of the box. We may also justify the conjecture by considering decomposing our more irregular volume up into a large number of mostly cuboid volumes and summing the state densities they imply. In any case, let us take it that we have a basis of our possible states for which the number of basis members per unit volume of momentum space is uniformly V/power(dim, h.turn).
The kinetic energy of a particle of mass m and momentum p is g(p,p)/m/2 and
our potential is zero throughout our volume of space, so a basis state at
location p in momentum space has eigenvalue E = g(p,p)/m/2 of the energy
operator. (For present purposes, I'm taking the energy operator's arbitrary
zero point
to include the energy implicit in the mass of the gas as part
of the background.)
In the cuboid box, a basis member with momentum p = h.sum(n.q)/g exchanges momentum 2.h.n(i).q(i)/g with each wall perpendicular to b(i) each time it hits one; its speed perpendicular to these walls is h.n(i).q(i)/g/m and it travels a distance equal to twice the lenghth of b(i) between collisions with either of these walls, so takes a time 2.m.length(b(i))/length(q(i)/g)/n(i)/h between collisions with each wall; so it contributes a net force on each wall perpendicular to b(i) of magnitude
which we'll be dividing by the area of the wall – which is the product of the lengths of the other b(j) in dim, j≠i – to get a pressure contribution
Now, g(p, b(i)) = h.n(i).q(i)·b(i) = h.n(i).turn/2, so let u = (: b(i)/length(b(i)) ←i |dim) and we can re-write this pressure contribution as power(2, g(p, u(i)))/m/V; and note that summing this over i in dim simply yields g(p, p)/m/V or 2.E/V.

Written by Eddy.