A statistical mechanics framework for immiscible and incompressible two-phase flow in porous media. (January 2023)