When does gun barrel length become too long with a constant pressure? Just struck out of curiosity,
It is a fact that longer gun barrels do increase the acceleration of a projectile, but an infinitely long barrel does not give infinite acceleration. So then, with a fixed pressure of a bullet's explosion, at which length does it get most acceleration?
Thanks in advance!
 A: A bullet's explosion is not a fixed pressure. An explosion releases a certain fixed amount of gas, but as the volume of this gas expands - as the bullet is pushed down the barrel - the pressure of the gas reduces ($P \propto \frac{1}{V}$).
Since pressure is force per unit area, and the area of the bullet exposed to the pressure is constant whilst it is in the barrel, the force it experiences (which is proportional to its acceleration) decreases as the pressure in the barrel decreases.
When the bullet leaves the barrel, the build up of "explosion gas" can now immediately mix with the rest of the atmosphere, and the net horizontal force on the bullet drops immediately to zero - it is being pushed by atmospheric pressure by the same amount from the left and right.
So what is the ideal barrel length?
Given what has just been said, if the barrel were very short, the explosion pressure would be lost almost immediately, so the bullet would be subjected to very little acceleration.
On the other hand, if the barrel were extremely long then the pressure would decrease and decrease as the bullet moves along until eventually it would be less than the atmospheric pressure. At this point the force on the bullet from the atmospheric pressure would be larger than from the "explosion pressure" and it would actually start to decelerate before it even leaves the tube.
So you want your barrel to be adjusted according to the amount of gas that will be released in the explosion. You want it to be adjusted in just the right proportion so that when the bullet leaves the barrel, the pressure behind it from the explosion is exactly equal to the atmospheric pressure, so that it experiences the most possible amount of pushing from behind before it is expelled.
However, this is all assuming that there is no friction in the barrel. Of course, after accounting for this additional backwards force, working in the atmospheric pressure's favour, it is clear that we would be better off with a slightly shorter barrel as the point of no net force on the bullet is pushed back.
Furthermore, we haven't mentioned air resistance. I'm not actually sure how this would effect things as the picture is getting quite complicated now - it would probably work in the same way as friction, favouring a slightly shorter barrel length.
Oh, and of course this reasoning assumed that no gas could leak around the edges of the bullet in the barrel!
A: A barrel can be seen as a chamber that defines an opening closed by the bullet. Since the bullet is not forcibly held in place, an explosion in the chamber (which basically creates a lot of hot gas in a very short time) will exert a pressure on all walls of the chamber. Since the bullet is not maintained in place, it will start to accelerate due to this pressure. As the bullet accelerates, the pressure in the chamber gets lower. Therefore, the force exerted on the bullet also gets smaller, so you don't get an infinite speed. The acceleration is reduced as the gas expands in the barrel. Of note, by conservation of energy, the max energy you can give to your bullet is equal to the energy liberated in your explosion. In real life, you will lose some of it. 
Of course, this is not the only force exerted in the bullet. The bullet must move the air that is in front of it to accelerate. Also, there are frictional forces between the bullet and the walls of the barrel. Other effects come also into play, depending on the exact design of your gun. All this to say, that there is no single answer to your question. Given a perfectly hermetic barrel perfectly closed by the bullet, firing in vacuum, with no friction with between the barrel and the bullet (kind of contradicts the hermetic condition though), the bullet will continuously accelerate, but acceleration will get smaller and smaller as the pressure in the barrel is reduced. In real life, there will come a point where air resistance, friction with the wall, gas leaks and gas cooling by heat exchange with its environment will play a role and a longer barrel will give a slower projectile. 
