First-principles calculations of dynamic permeability in porous media.