Post History
Your basic logic is correct, but you are ignoring some effects. Ultimately you can't have a situation that you could theoretically extract more energy from than exists in the system. You are miss...
Answer
#1: Initial revision
Your basic logic is correct, but you are ignoring some effects. Ultimately you can't have a situation that you could theoretically extract more energy from than exists in the system. You are missing some factors like temperature and momentum. The <i>average</i> energy of whatever volume you try to contain the explosive in can't exceed the energy in the explosive, but that doesn't say anything about localized peaks. Depending on the shape of the explosive, the shape of the container, and how the explosion propagates thru the material, it may be that the pressure in a shock wave significantly exceeds the average pressure. That means other regions have lower than the average pressure until shocks stop bouncing around and the pressure approaches the average everywhere. This would not violate conservation of energy. For any real world device to contain explosions, the temperature of what it must contain also has to be taken into account. Most materials would vaporize quickly if trying to contain a cubic meter of TNT in a cubic meter once it was detonated. Vapor generally has a hard time containing high pressure. Much tamer versions of what you describe are actually used in the real world. Making sure industrial equipment doesn't make explosive atmospheres go boom is a big issue. There are a number of officially sanctioned ways to build equipment that is allowed to operate in explosive atmospheres without driving up your insurance costs. These include such things as <i>Intrinsic Safety</i> (making sure electric circuits don't have enough power and stored energy to create sparks), <i>Inert Gas</i> (fill the equipment with something inert so that sparks don't matter), <i>Explosion proof</i>, and others. The latter lets explosions happen inside a box, but makes sure that the explosion is contained so that it can't ignite the flammable atmosphere outside.