A model of spontaneous flow driven by capillary pressure in nanoporous media