Microscopic theory of hysteretic hydrogen adsorption in nanoporous materials.