Tony, the question you're asking is actually a very difficult one to understand in my opinion, but a very good question.
Most gasses when expanding through a throttling valve or other restriction, will decrease in temperature while a small number of gasses such as helium for example, actually increase in temperature after expanding through a restriction.
Regardless of if the gas cools or heats up, two er... three things are true:
1) The gas decreases to a lower pressure.
2) The gas will increase in volume.
3) Enthalpy will stay the same (one caveat regards overall fluid velocity, but for your typical fluid system, this contribution to enthalpy can be neglected).
Enthalpy is:
H = U + PdV
Where H = enthalpy
U = internal energy
PdV is a pressure energy term.
For example, if we have helium at 100 psia, 0 F, we have a specific volume of 12.3736 ft3/lbm. From this information we can determine the PdV term. Since this is a state, PdV is simply the pressure times the volume or:
PV = (100 lb/in2) * (12.3736 ft2/lbm) * (0.001286 Btu/lb ft2) * (144 in2/ft2) = 229.1 Btu/lbm
So if we knew internal energy, we can add PV to get enthalpy.
If we had isenthalpic throttling across a valve, the difference in internal energy would be the difference of the two PV terms. Assuming we expanded helium from 100 psia and 0 F down to 10 psia, the new temperature would be very slightly warmer (about 0.7 F). Recalculating PV for this new state we have:
PV = (10 lb/in2) * (123.475 ft2/lbm) * (0.001286 Btu/lb ft2) * (144 in2/ft2) = 228.7 Btu/lbm
Note that these two values of PV are almost identical. Despite the very large drop in pressure, the helium expands to a very large volume. In this case the helium warms very slightly. Note also this is the "irreversible free expansion" which can not be recovered that we talked about earlier.
Internal energy is a combination of a large number of factors.
Microscopic Energy:
Internal energy involves energy on the microscopic scale. For an ideal monatomic gas, this is just the translational kinetic energy of the linear motion of the "hard sphere" type atoms , and the behavior of the system is well described by kinetic theory. However, for polyatomic gases there is rotational and vibrational kinetic energy as well. Then in liquids and solids there is potential energy associated with the intermolecular attractive forces. A simplified visualization of the contributions to internal energy can be helpful in understanding phase transitions and other phenomena which involve internal energy.
Ref:
http://hyperphysics.phy-astr.gsu.edu/hbase/thermo/inteng.html#c3
So internal energy may increase, or it may decrease.
1) If internal energy DECREASES, the temperature will be LOWER, and the PV term will be HIGHER after expansion. This is the most common case.
2) If internal energy INCREASES, the temperature will be HIGHER, and the PV term will be LOWER after expansion. This is more unusual.
Note also the internal energy may not change significantly, the PV term will remain the same, and the temperature will also remain the same.
So the temperature after expansion is dependant on how the atoms or molecules rearrange themselves after expanding, which is dependant on the amount of different types of 'microscopic' energy available to the atom or molecule.
Edit: I can't count to 3... lol