Why does filling a compressed air cylinder produces heat? And the opposite follow-up question: why does opening the air cylinder makes the air cooler?
What I know is that I can't find these answers using the ideal gas law, because that is an equation of state. I cannot use Charles' law (it requires pressure to remain constant) nor Boyle's law (it requires the temperature to remain constant).
Similarly, I cannot use Gay-Lussac's law ($P \propto T$), because that law requires both mass and volume to be constant (when filling an air cylinder I'm adding mass and/or I'm reducing the gas volume).
So, where can I find a physical justification for this effect?
 A: Because what you are doing is a flow process, with mass inflow and no mass outflow, you need to use the thermodynamic equation:
$dU_{cv}={m_{in}d}{H}_{in}-{m_{out}d}H_{out}+\delta Q-\delta W_{shaft}$
If you insulate your air cylinder well enough, $\delta Q = 0$.
Assuming that your air cylinder does not deform, $\delta W = 0$.
Since you are filling your cylinder with air and assuming no air escapes, ${m_{out}d}H_{out} = 0$
Therefore, the enthalpy of the gas which you are filling adds to the internal energy of the gas in the cylinder, and because the internal energy is positively correlated to temperature, the temperature in of the gas in the cylinder rises.
$\Delta{U_{cv}}={H_{in}}>0$, so
$\Delta{T} >0$
You may apply the reverse for the release of air from the cylinder. In this case:
$\Delta{U_{cv}}={-H_{out}}<0$, so
$\Delta{T} <0$
http://en.wikipedia.org/wiki/Thermodynamic_system#Flow_process
A: I would explain it by simply using the first law of thermodynamics:
$$Q-W=\Delta U$$
$Q$ is heat added to the system, $W$ is work done by the system, $U$ is the internal energy.
Keep in mind that internal energy is closely bound to temperature, so a change $\Delta U$ also results in a temperature change (which is what we are talking about).
If you look at the gas as a system - a control mass - then when you open the valve and let the gas out, you are letting this compressed gas do work on the surrounding air by pushing it out of the way. So $W>0$.
When filling the cylinder with some apparatus that compresses the gas to put more in, there is done work on the gas, meaning that the gas does negative work on the apparatus. $W<0$
Assuming no heat exchange with the surroundings (let's say this happens too fast for any significant heat transfer to occour), $Q=0$.
Since $W \neq 0$, the first law of thermodynamics then tells you that there must be a change in internal energy.
$$-W=\Delta U$$
And therefrom the temperature changes. Note that positive work (expansion) gives a decrease in internal energy, while negative work (compression) gives a rise.
This is experienced as heating or cooling by the observer that touches the cylinder because of the rapid heat conduction into the hand. Since the heat convection into surrounding air is much less effective, our assumption that $Q=0$ is fair as long as the cylinder doesn't touch any other good conducting material.
A: The energy change a gas is expressed by: 
$$dE = TdS - pdV +\mu dN$$
Admittedly, the process of filling a cylinder is rather complicated because several variables in this equation vary, and the way you fill it will influence their behaviour, but you can see that the result will give a production of heat.
When you fill the cylinder you are connecting it to a compressor, which takes bunches of air and compresses them adiabatically. So the total energy of a certain volume of air is concentrated now on a much smaller volume. And all this air is fed into the cylinder. The but the process of readjusting to the equilibrium conditions in this new volume requires the release of the excess energy. 
This is because the adiabatic compression is different from a "slow compression", since entropy and volume reduce and lead to a rapid increase of pressure and temperature, in such a way that the energy is conserved. But because of this the temperature inside the cylinder will end up being always higher than the outside, and will exchange heat with the external medium in the process of thermalization. 
As for the case of opening the air cylinder, the rapid adiabatic decompression takes out more energy than it should, and consequent drop of temperature follows much in the same way.     
A: The awful truth of the matter is that there is no reasonably coherent simple computational method for determining pressure and temperature rise in a depleted gas cylinder during recharge from a large high pressure gas reservoir.
It is an established fact that both pressure and temperature rise inside the cylinder being filled. The reservoir from which it is being filled can be assumed to be relatively at constant pressure and temperature since it's volume is much larger than the cylinder being filled.
I've looked extensively for a clear and practical method of computing the temperature and pressure rise but there simply isn't any.  Because there is mass flow between the fill reservoir and the cylinder being refilled the thermodynamics just isn't straightforward.
What you get when you ask this question are answers that change the subject, obfuscate with professorial treatises on thermodynamics that don't really provide an answer and a cat video or two thrown in for good measure.
If anybody out there has a real answer to this question that can be used in a practical setting - like actually filling gas cylinders - they aren't sharing it.
A: Use this equation:
$$\frac {P_1V_1}{T_1}=\frac {P_2V_2}{T_2}$$
Before, the pressure is 1 atm, the temperature is about 20°C and the volume is many cubic meters.
After, the pressure is above 100 atm, the volume is about 1 cubit meter, and the temperature is significantly warmer, say 100°C.
Filling in the equation:
$$\frac {(1atm)V_1}{393K}=\frac {(100atm)(1m^3)}{473K}$$
This gives the initial volume of about $83m^3$.
Although the numbers are guesses, the math shows that they are reasonable assumptions.
A: Because the question being asked is Why/How does filling a compressed air cylinder produce heat? The conventional answer is that because there are more gas molecules being forced into a confined space there are more gas molecule collisions and with more collisions comes an increase in friction and thus the cylinder heats up. Now when we are filling a compressed air cylinder there's another effect that's also taking place and it's called Physical Adsorption. Physical Adsorption is the result of Van Der Waal forces causing gas molecules to be attracted/bonding to the atoms making up the surface of the cylinder and when this occurs heat is released because it's exothermic. So not only will more gas collisions cause a temperature increase but this increase may also be due to Physical Adsorption. I don't know the degree to which Physical Adsorption adds to the  temperature increase but if it does occur it should be taken into account when trying to understand what's taking place when considering Why/How does filling a compressed air cylinder produce heat?
