Capillary pressure can significantly affect the phase properties and flow of liquid-gas fluids in porous media, and thus, the phase equilibrium calculation incorporating capillary pressure is crucial to simulate such problems accurately. Recently, the phase equilibrium calculation at specified moles, volume and temperature (NVT-flash) becomes an attractive issue. In this paper, capillarity is incorporated into the phase equilibrium calculation at specified moles, volume and temperature. A dynamical model for such problem is developed for the first time by using the laws of thermodynamics and Onsager's reciprocal principle. This model consists of the evolutionary equations for moles and volume, and it can characterize the evolutionary process from a non-equilibrium state to an equilibrium state in the presence of capillarity effect at specified moles, volume and temperature. The phase equilibrium equations are naturally derived. To simulate the proposed dynamical model efficiently, we adopt the convex-concave splitting of the total Helmholtz energy, and propose a thermodynamically stable numerical algorithm, which is proved to preserve the second law of thermodynamics at the discrete level. Using the thermodynamical relations, we derive a phase stability condition with capillarity effect at specified moles, volume and temperature. Moreover, we propose a stable numerical algorithm for the phase stability testing, which can provide the feasible initial conditions. The performance of the proposed methods in predicting phase properties under capillarity effect is demonstrated on various cases of pure substance and mixture systems.