AFiD-2phaseDarcy: An efficient finite difference solver for two-phase convective flow in porous media
Description
We introduce AFiD-2phaseDarcy, an efficient, open-source and massively parallelized finite-difference solver tailored for large-scale simulations of buoyancy-driven incompressible multiphase convection in porous media. Built within the well-established AFiD framework, the solver extends the original wall-bounded buoyancy-driven convection code to handle fully coupled multiphase Darcy momentum transport, saturation and scalar transport equations. Spatial operators are discretized using finite-difference schemes, while temporal integration is performed using a low-storage third-order Runge–Kutta scheme combined with a Crank–Nicolson formulation for implicit terms. To alleviate the computational bottleneck associated with pressure–velocity coupling, a fractional-step projection method is employed. The resulting global variable-coefficient Poisson equation is decomposed using a pressure-splitting approach and solved using a Fast Fourier Transform (FFT)-based algorithm, substantially reducing parallel communication overhead. The numerical accuracy of AFiD-2phaseDarcy is rigorously verified against a series of benchmark cases, including canonical single-phase porous-media convection, isothermal two-phase flow and multiphase thermal convection. Performance benchmarks demonstrate that the proposed FFT-based pressure-splitting solver achieves an approximately fivefold computational speedup over the conventional monolithic direct solver implemented using the parallel PETSc framework, while maintaining comparable computational accuracy. Furthermore, distributed strong-scaling tests on the SCNet platform demonstrate near-linear speedup and high parallel efficiency on up to 2000 CPU cores. This open-source framework provides an efficient numerical tool for large-scale simulations of subsurface transport processes, with potential applications including geological carbon sequestration and geothermal energy exploitation.