Gases and Heat

We divers all learn our gas laws and, if we are lucky, we remember them. However, although we might remember the universal gas law (PV/T=constant), we always use Boyle's law that PV = constant at constant temperature.
Then we go for a fill and feel the tank getting warmer and we know that the warmth means that the pressure is higher for the quantity of gas so when we get it home and it has cooled down it will have less pressure than we hoped.
Typical dive shop. Short filled again. Why can't they use cool air when they know I'm in a hurry?

This short page is to discuss the effects of compressing a gas on its temperature so we have some feel for the numbers involved and maybe excuse the dive shop a bit.

If you're not really interested in the maths skip down to the bottom where there is a log of a blending session with before and after cooling pressures to give the feel.

The whole problem with the universal gas law is that it has three variables in it. If we know the first state exactly, ie: we know pressure, volume and temperature, and we know two of the final values we can calculate the third. Just so you can check you're with it consider that we have two tanks: the first 200bar in 12L at 20°C and a second tank with 100bar at 10L also at 20°C and we want to even them up so we can both do a second dive together so we connect them together with a whip and then we will wait till it all cools back to 20°C:
200*12/(273+20) + 100*10/(273+20) = P*22/(273+20) so P = 154.5bar.

But what if we only know the volume and we don't know the temperature?

We really can't solve problems that can flop about in lots of variables but if we are prepared to accept certain constraints we can work things out and then allow for those constraints. So...

Adiabatic gas laws

Adiabatic is a big word that just says that rather than keeping the temperature constant we just will not consider heat entering or leaving the gas. This is quite realistic if we are considering a sudden change and when we do the sums we see why we don't want to do sudden changes
The law is PVγ = const where "γ" (the Greek letter gamma) represents a constant that is about 1.4 for air. Actually for monatomic gases (like helium) it gets up to 1.66 but for big multi-atom (hydrocarbons) it is almost down to 1.

OK let's take 10L of air at 100bar and instantly halve its volume to 5L. What happens?
soP1V1γ = P2V2γ
as inP2/P1 = V1γ/ V2γ
otherwizeP2/P1 = (V1/ V2)γ
wellV1/ V2 = 10/5 = 2
hence(V1/ V2)γ = 21.4 = 2.64 = P2/P1
So the pressure didn't go from 100 to 200bar but to 264bar and the ideal gas law tells us that the temperature did PV/T=const
100*10/(273+20)=264*5/(273+T) so T=115°C ie: above the boiling point of water

And that was just halve the volume.

Let's reverse things and expand air from 10 bar to 1 bar instantly. This is pretty much what happens in your second stage regulator at the surface.
We have PVγ = const1 but we don't really care about volume so grab our old friend PV/T = const2 and substute out V.
PV/T = C2 becomes V = TC2/P
putting that in PVγ = C1 gives us P(TC2/P)γ = C1
Remember your old school maths rules for powers ie: x-a = 1/xa and xa * xb = xa+b and if xa=y the y1/a=x
gives P*Tγ*P = C3
so P(1-γ)*Tγ = C3
so Tγ = C3/P(1-γ) = C3*P(γ-1)
so T = C4*P(γ-1)/γ
A quick assumption that we are dealing with air (γ=1.4) and (γ-1)/γ resolves to 0.286
so T/P0.286 = constant
and T2 = T1*(P2/P1)0.286
(1/10)0.286 = 0.518
so if T1 is 20°C = 293K then T2 is 293*0.518 = 151K = -121°C

That's cold! It just dropped 140°C. No wonder regs ice up.

Thankfully the specific heat of air is about 1000J/Kg.K and water is 4200J/Kg.K so it takes a lot of air to freeze a small amount of water.

You want to do 200 times compression? Well the gas laws are falling apart by then but to give you the flavour....
OK we need a cylinder with 200x12 ie: 2400L (2.4 cubic meters of air) in it. We want a piston that will squeeze this down to a little 12L tank and we need something to push the piston. I'll supply the gas. You get the hardware. OK?
wellV1/ V2 = 2400/12 = 200
henceP2/P1 = 2001.4 = 1665
Cooling coils on a Hamsworthy compressor Yes you read that right! 1665bar. The ideal gas law is a joke at those pressures but for the record that works out at 2175°C. Your aluminium tank melted at about 650°C and your steel one at 1515°C.
Incidentally that is about 7M joules, about 2Kw - hours to buy from the electricity supply people and the equivalent of leaving a 2 bar fire on for an hour so no wonder the compressor room of the dive shop is warm.

So why don't tanks melt? Because the compressor delivers hot compressed air to its cooling coils and then to the bank. Even if it supplies it directly to your tank it has cooled a lot before it reaches the valves in the filling panel and then as it passes from the high pressure panel into you still relatively empty tank it expands as the pressure drops so the dive centre is filling your tank with very cold gas which then compresses warming up a bit.

So what happens in real life? Here's my log for a gas blending session.
This is what I logged blending a set of tanks after a big dive on the Saterday ready for next weekend. I didn't rush filling anything but once it was filled I walked away from it for at least a few hours and then came back and measured it. The 'Implied gas temperature' column in just what I back calculated based on how much it dropped when it had cooled.

TankTimeActionImplied gas temperature
3L OxygenSunday 1145Starts at 99bar left from last dive 
  Fill to 230bar50°C
 Sunday 1345Tank cooled to 211bar 
  Refill to 240bar 
3L 14/50 TrimixSunday 1350Start from empty 
  Add 15 bar of oxygen. 
  Add helium to 134bar48°C
 Sunday 1536Tank has cooled to 124bar 
  top up to 134bar then air top to 233bar 
 Sunday 1635Tank has cooled to 223bar37°C
  Top to 240bar 
7L 18/40 stageSunday 1645Started as 156bar of 18/30 
  Add O2 to 165bar28°C
 Sunday 1727Cooled to 163bar, topup 
  Add helium to 220bar35°C
 Sunday 1843Cooled to 212bar, topup and air fill to 240bar 
 -not logged--retop up 
1.5L ArgonSunday 2126Slow fill to 128bar then pump to 20040°C
 Monday 0919Cool to 190bar, top up 
7L 50% O2Monday 0930Start at 190bar, Oxygen fill to 206bar30°C
 Monday 1038Cooled to 202bar, top and air fill to 240bar35°C
 Monday 1149Cooled to 231bar topup 
3L 18/30Monday 1700Fill from empty, 16bar of O2 
 Monday 1719Helium to 110bar38°C
 Monday 1809Cooled to 105bar, top up and air to 240bar40°C
 Tuesday 1327Cooled to 227bar topup 
3L Air 300barTuesday 1337Start at 274bar, pump to 30030°C
 Tuesday 1938Cooled to 294, topup 

So let's rework the example of the 18/40 stage assuming we just did it hot.
So we just put in the Oxygen to 125bar and went straight onto the helium.
The Oxygen would be 2 bar short and the helium 8+2=10 bar short.
Now if we then air topped to 240 bar that would be probably another 2 bar short.
Putting those values reversed into the blender program (O2 to 123, He to 210, Air to 228) we get 17/39 - quite good.

Now try the 14/50 with O2 to 15, He to 124 and air to 220 and we get 15.5/55 which is a bit rich on O2 but I'd probably dive it.

Well I'd be quite happy with those numbers. OK the short fill might annoy me but it's not that short and it's all diveable.