Would the temperature of a gas change when accelerated in a train?

In principle, YES.

Remember, temperature is related to the velocity distribution of the particles inside the gas. The key word here is $collision$.

Accelerating the train and suddenly stopping it is akin to shaking a container that contains fluid once. The sudden acceleration and deceleration of the contained will impart momentum from the wall of the container to the particles inside. I see two cases.

(a) If the container contains liquid and is not completely full, you could increase its temperature because you are imparting momentum of the particles inside the liquid by virtue of them sloshing inside the container.

(b) If the container contains liquid and is completely full, you could increase its temperature in the same principle but not significantly. Similarly, for a gas, while in principle you could have the same effect as in a container filled with gas, the density of the gas is so much lower than the liquid, the effect would have to be negligible.


Interesting question! Thinking about this as two pistons of equal velocity - rather than a train carriage - helped me conceive the problem:

First, think about it as a continuum problem - you are talking about a gas, but for the acceleration stage I think this does not affect the picture materially. Taking the reference frame of the gas between the two pistons, and noting this is not an inertial reference frame during acceleration, then there will be higher pressure on the rear piston if the gas is undergoing linear acceleration [note that I have considered the acceleration as an inertial force - I think it helps to use the non-inertial reference frame of the gas]: $$\sum F_x = P_1\cdot A - P_2\cdot A - \rho_{g,0}\cdot A\cdot L \cdot a_x = 0$$

Depending on the acceleration, you can now compute the pressure difference that would be observed, which depends on the density of the gas and the length of the cylinder and is independent of the area. Turning the problem on its side, it resembles the hydrostatic force balance (note that I have used the initial density; for strong accelerations, there will be a non-negligible density gradient opposite to the acceleration - but it doesn't affect this calculation).

If the acceleration is extremely gradual, then this pressure difference is extremely small, such that the acceleration could be considered 'quasistatic'. Under this scenario, the gas should acquire axial momentum without any change to its incoherent motion (in its reference frame). After the acceleration is removed, the pressures are equal on the front and rear pistons, and the gas has acquired a coherent kinetic energy of $\rho_g\cdot A\cdot L \cdot \frac{V_x^2}{2}$ (this is equal to the work done by the pistons - the train has had to accelerate this gas, and the kinetic energy is the 'deceleration potential energy' relative to a particular reference frame). The coherent component of kinetic energy can be separated from the incoherent kinetic energy of the gas (which is treated as one component of the internal energy): $$u_1 + w = u_2 + \frac{V_2^2}{2}$$ By assuming the acceleration was quasistatic and adiabatic, the internal energy of the gas hasn't changed. Its density also hasn't changed, so the thermodynamic state of the gas is unchanged.

If the train were very gradually decelerated, then this process could be reversed - and the gas temperature would again be unchanged, and the work done decelerating the gas could be used to raise a weight, or coil a spring (or heat the brakes of the train for that matter). But this isn't what you asked.

Intuition suggests that the limiting case is where no work is extracted from the deceleration process - the container stops instantaneously, and it is an irreversible process. By conservation of energy, if the box is adiabatic and constant-volume: $$u_2+\frac{V_2^2}{2} = u_3$$

If we were on a Maglev train, traveling at around 167 m/s, this would be 14 kJ/kg of coherent kinetic energy that goes to internal energy (incl. incoherent kinetic energy).

If the gas was room-temperature air, and we treat $c_v$ as constant with a value 718 J/kg.K, the temperature rise would then be: $$\Delta T = \frac{\Delta u}{c_v} = \frac{14000}{718} = 19 \mathrm{K}$$