The porous microenvironment of soil offers various environmental functions which are governed by physical and reactive processes. Understanding reactive transport processes in porous media is essential for many natural systems (soils, aquifers, aquatic sediments or subsurface reservoirs) or technological processes (water treatment or ceramic and fuel cell technologies). In particular, in the vadose zone of the terrestrial subsurface the spatially and temporally varying saturation of the aqueous and the gas phase leads to systems that involve complex flow and transport processes as well as reactive transformations of chemical compounds in the porous material. To describe these interacting processes and their dynamics at the pore scale requires a well-suited modelling framework accounting for the proper description of all relevant processes at a high spatial resolution. Here we present P3D-BRNS as a new open-source modelling toolbox harnessing the core libraries of OpenFOAM and coupled externally to the Biogeochemical Reaction Network Simulator (BRNS). The native OpenFOAM volume-of-fluid solver is extended to have an improved representation of the fluid–fluid interface. The solvers are further developed to couple the reaction module which can be tailored for a specific reactive transport simulation. P3D-RBNS is benchmarked against three different flow and reactive transport processes: (1) fluid–fluid configuration in a capillary corner, (2) mass transfer across the fluid–fluid interface and (3) microbial growth with a high degree of accuracy. Our model allows for simulation of the spatio-temporal distribution of all biochemical species in the porous structure (obtained from

Subsurface environments (soils, aquifers, aqueous sediments) are (typically) porous media that host a multitude of biogeochemical processes and interactions and provide different versatile ecosystem functions (e.g.

In soils (or more generally the vadose zone), the dynamically varying distribution of the aqueous and gaseous phase leads to specifically complex and variable constraints for biogeochemical processes. In the past, obtaining (bio)chemical and microbiological information at the pore level was neither economically nor logistically a feasible option (Baveye et al., 2014). Also for the sake of applicability, traditionally, researchers had more tendency to look for Darcy-scale solutions to tackle environmental issues (White and Brantley, 2003). The Darcy-scale view (experimental, theoretical or a mixture of both) serves the purpose of practical applicability well (White and Brantley, 2003), but, for example, in the context of microbially mediated degradation processes in the vadose zone, it fails to provide insights on the driving mechanisms, as it overlooks important contributing factors, such as the tortuous porous structure/pathways open to the transport of (bio)geochemical species and the non-uniform distribution of water and air phases, as well as the nonlinear dependency between changes of the local nutrient and biomass concentrations and the bulk concentrations of (bio)geochemical species. Evidence at the microscopic level has shown that biological activity and evolution are more locally organized (Kuzyakov and Blagodatskaya, 2015) where Darcy-scale studies lead to loss of crucial information. This has motivated the development of sophisticated physics-based models implementing all aspects of hydrological, geochemical and biological processes involved in microbial growth and evolution.

Reactive transport models (RTMs) are a class of mathematical models that have been applied extensively to study biogeochemical systems for about four decades (Parkhurst and Appelo, 1999; Thullner et al., 2005; Thullner and Regnier, 2019; Meile and Scheibe, 2019). There is a long list of principal factors and mechanisms governing biogeochemical reactions at the pore scale. Numerically, these processes can be defined and solved either by fully (global) implicit approaches or by separating and solving different components one at a time. For the Darcy scale, a wide range of reactive transport models exist which allow for the simulation of biogeochemical processes (Steefel et al., 2015b). In turn, at the pore scale, models combining the simulation of flow, transport and reactive (biogeochemical) processes are scarce, and existing model developments are often driven by specific research questions and/or are subject to severe simplifications in the description of the pore space (Golparvar et al., 2021). Integrated models explicitly capturing the structural properties of the soil at the pore scale, the resulting multiphase flow and multispecies reactive transport simultaneously are hardly available (Tian and Wang, 2019).

Recently, new frontiers of pore-scale RTMs are emerging with the advances in computational power as well as with huge improvements in imaging techniques. The latter includes, for example, the static and dynamic scanning of porous structure as well as of fluids' distribution (Schlüter et al., 2019) or the detection of bacterial distributions in soil using the catalysed reporter deposition with fluorescence in situ hybridization (CARD-FISH) technique (Schmidt et al., 2015). Direct numerical models (DNMs) are becoming the nexus of the next generation of RTMs as they represent the porous structure in a fully explicit manner (directly obtained from soil samples, digitized and fed into RTMs) in addition to offering a more flexible coupling of different components of reactive transport models (Baveye et al., 2018; Raeini et al., 2012; Li et al., 2010; Yan et al., 2016). Another advantage of using DNMs is that they offer a great deal of flexibility in considering settings and conditions that are experimentally impossible to impose (Tian and Wang, 2019).

In this work, we introduce the pore-scale RTM package P3D-BRNS explicitly involving the structure and topology of the pore space, the co-existence/co-flow of both the aqueous and the gaseous phase, the advective–diffusive transport of species in each phase, and an arbitrary set of reactive processes controlled by kinetic rate laws or thermodynamic constraints. The fluid flow field is updated via solving the Navier–Stokes (NS) equations (Patankar and Spalding, 1972). The volume-of-fluid (VOF) approach is adopted to account for different phase distribution (Hirt and Nichols, 1981). The transport of chemical species is considered via solving the advection–diffusion–reaction equation (ADRE), where the concentration jump for soluble/volatile compounds across the fluid–fluid interface is modelled via the continuous species transfer (CST) method (Haroun et al., 2010). Reactive processes are defined and simulated externally via coupling the flow and transport model to the BRNS (Biogeochemical Reactions Network Solver) package (Regnier et al., 2002; Aguilera et al., 2005). The model structure is introduced, and the model performance is shown and compared with analytical counterparts. The model capabilities are depicted for a fully three-dimensional case.

The entire numerical domain

Evolution of a single/multi-phase, isothermal, incompressible, immiscible fluid(s) can be expressed by basic conservation principles. These can be formulated into a single-field formalism (Hirt and Nichols, 1981):

Illustration of a porous medium at the pore scale with one fluid invading the other (on the left). Mathematical representation of the phase saturation in the computational cells around the interface (on the right). The dashed line shows the actual location of the interface while values in each cells show the amount of water saturation relevant to topology of the dashed line. Black dots represent volatile compounds able to cross the fluid–fluid interface, and green dots represent non-volatile compounds restricted to the transport in the aqueous phase.

In the case of simultaneous flow of two different phases, their locations and distribution are represented via introducing an indicator function,

In the context of the finite-volume method (FVM), discretization of the physical domain produces a finite subset of discrete volumes (taking the shape of a polyhedral). The key implication of the volume-of-fluid method is to define and solve for global variables, rather than having one equation for each variable in each phase. Hence, the idea is to transform the integro-differential equations into their global versions by averaging them over each cell volume (Whitaker, 2013). For multiphase systems, after a few steps of linearization and approximation (see Hirt and Nichols, 1981, for a detailed derivation), the volume-of-fluid formulation of the momentum equation (Eq. 2) is obtained as

Since we are dealing with only two fluids, index

To calculate the interfacial tension force,

Given the curvature, the interfacial tension force can be approximated as

Concentrations of mobile species are affected by advection (i.e. transport with the moving fluid), molecular diffusion and reactive transformation. Also, in the case of having two fluids simultaneously in the system, different species can cross the fluid–fluid interface, causing local fluctuations in concentration values. In general to account for all the changes in species concentrations, the ADRE for biogeochemical reactive components can be written as

Simulated reactions include kinetically as well as thermodynamically constrained reactions. For a kinetically constrained reaction

There are various types of boundary conditions, corresponding to the real physical conditions, most of which can be derived from two basic types:

the Dirichlet boundary (fixed value), which relates the value of a variable at a given geometric location to a constant value, for example,

the von Neumann boundary (fixed gradient), which provides the value of a variable's gradient at the face of the boundary cell, for example,

The mass conservation (Eq. 1), momentum (NS – Eq. 2) and indicator function (Eq. 7) equations are all implemented within the open-source computational fluid dynamics (CFD) package, OpenFOAM (Greenshields, 2015). OpenFOAM utilizes the finite-volume methodology (FVM), a common choice for CFD problems as FVM works only with conservative flux evaluation at each computational cell's boundaries, making it robust in handling nonlinear transport problems. Also all the differential equations mentioned before are first written in their integral form over each cell volume and then converted to the surface summations using Green's theorem.

The original two-phase (VOF) flow solver, i.e. interFoam, is modified to construct our biogeochemical reactive transport package. The momentum equation (Eq. 2) is linearized in a semi-discrete form as

The velocity–pressure coupling of Eqs. (1) and (2) is solved using Pressure Implicit with Splitting of Operators (PISO) (Issa, 1986). PISO embodies a predictor–corrector strategy to simultaneously update pressure and velocity within each time step. The resultant system of equations is solved on the cell faces and then interpolated back to calculate velocities and pressure at the cell centres. The coupling of the indicator function (Eq. 7) and momentum equation is explicitly defined and solved right after the PISO step is finished. Within the same time step, transport and reaction of different species are then solved sequentially – using a sequential non-iterative algorithm (Steefel et al., 2015a; Steefel and MacQuarrie, 1996). Time step size is controlled by introducing a Courant number. Time is discretized using either Euler or Crank–Nicolson methods, and spatial discretization is performed using the van Leer second-order total variation diminishing scheme (TVD) (van Leer, 1979).

The reaction network is built separately and externally solved within the BRNS package – which employs first-order Taylor series expansion terms and uses the Newton–Raphson method to iteratively solve the system of linear equations (Regnier et al., 2002). BRNS utilizes MAPLE programming language to construct the Jacobian matrix (which contains the partial derivatives of unknown parameters, i.e. concentrations) and other problem-related data such as rate parameters and translating them to a FORTRAN package. The FORTRAN code is then compiled to generate shared objects (*.so file) that can be dynamically called later from the transport solver (Centler et al., 2010). The significance of having dynamically shared object files is more apparent when running computationally demanding cases/scenarios while decomposing and running the application in parallel. BRNS is invoked once the new concentrations are computed from the transport solver. The updated concentrations from the BRNS library (i.e. updating concentrations from redox reactions) are then fed back into the transport solver before moving to the next time step. This process repeats until the final time is reached. This coupling scheme has been successfully used for other RTM approaches before (Centler et al., 2010; Gharasoo et al., 2012; Nick et al., 2013). As the reactions are localized, the reaction solver is modular, and OpenFOAM inherently provides parallelized simulations (via domain decomposition). The P3D-BRNS can easily be used to model larger systems. To achieve higher performance, it is recommended to utilize physical cores rather than hyper-threading. The parallelization of our model strengthens its scalability in the sense of the size (pore scale or Darcy scale) of the simulated system. However, in terms of upscaling (e.g. from the pore scale to the Darcy scale), an intermediate step would be required depending on the complexity of the processes that are involved and on the size of the domain.

Full solution procedure to simulate a reactive transport process at its fullest complexity.

Prior to run simulations, the physical settings of the domain are required to be specified; i.e. the physical geometry of the pore space with proper boundaries and the meshing scheme should be designed. OpenFOAM provides a basic utility for defining boundaries as well as mesh generation which are translatable by the OpenFOAM engine. Any other meshing software/freeware can be freely used as long as an OpenFOAM-compatible format for the meshed file can be created. The overall workflow required to build and run a case/scenario is summarized in Fig. 2.

The presented reactive transport model is designed (1) to capture real-world pore structures in up to three dimensions, (2) to explicitly simulate the transient distribution of a gas and a liquid phase within the entire pore space, and (3) to simulate a full set of advection–diffusion–reaction mechanisms. Capturing the correct curvature of the interface depends heavily on the grid resolution. For a fixed velocity magnitude, a higher grid resolution enforces a shorter time step size (from Courant number) for the numerical simulations to converge. Also, to validate different features of the model various, simplified scenarios were used which allow the use of analytical expressions as reference for the numerical results. Here we show three representative test scenarios addressing different features of the model (two-phase flow, mass transfer across the fluid–fluid interface and reactive transport) individually. Subsequently, the model capabilities are depicted in a final biodegradation scenario, making use of the various model features simultaneously.

Initial condition

In order to test our model's performance in simulating two-phase flow, we have zoomed into a two-dimensional porous structure and isolated only one single corner, taking the shape of an equilateral triangle. A triangulated mesh is adopted that naturally conforms to the overall shape of the domain. Initially, two immiscible fluids (one wetting and one non-wetting, for example, water and air) are placed in such a way that their interface forms a straight line (Fig. 3a). The side length of the triangle is 1 mm with a mesh size of 1

Mass transfer of dissolved species between different phases is particularly of importance for various biogeochemical processes in unsaturated subsurface environments.

Model performance in simulating mass flux across the fluid–fluid interface is validated via a numerical experiment in which two immiscible stationary fluids (an aqueous –

Three scenarios with low, neutral and high affinity of the volatile compound towards the gaseous phase are considered with corresponding Henry coefficients of 0.01 (low-volatility, similar to naphthalene), 1 (moderate-volatility, for example, vinyl chloride) and 100 respectively (high-volatility, for example, heptane). For a low value of

Our modelling framework can parameterize any type of reactions; we put the main focus in this subsection on microbially driven redox transformations (i.e. a type of reactions commonly encountered in soils and other porous media environments) and on the implementation of the corresponding mathematical formulation. To validate our model with a scenario in which bacterial biomass is allowed to evolve (i.e. to grow and to decay), we adapted a conceptual biodegradation scenario from Cirpka and Valocchi (2007) in which a fully water-saturated, two-dimensional channel is subjected to a constant flux of two different components, ED (electron donor, for example, hydrocarbon) and EA (electron acceptor, for example oxygen). The imposed uniform flow field is assumed to be constant over time and only has the

The numerical experiment is designed to have ED and EA, occupying 25 % and 75 % of the inlet respectively, and, simultaneously, invading the domain under a constant uniform velocity field, with concentration of

Parameter values used for simulating microbial growth.

The scenarios described above are designed to serve as the sole purpose of creating a baseline for validating the numerical toolbox – simple enough where analytical solutions could exist. Unlike the simplicity introduced in previous sections, simulating soil processes with all of the complexities, though, would require having all the modelling elements to be present. We thus present here a scenario with an unsaturated soil hosting the facultative anaerobic bacteria

Cross-sectional view of the three-dimensional porous medium. The cutting plane is arbitrary, cutting through the middle of the porous structure, meaning at some locations that the phases are continuous perpendicular to the plane. The opaque greyish background represents the 3D porous structure that is extracted and digitized from a

Reactive transport simulations were performed until a quasi-steady state was achieved. This was characterized by all chemical species concentrations reaching a steady state, as determined by the degradation activity of the given distribution of microorganisms. Since microbial growth takes place at much larger timescales than the pore-scale transport processes, no significant growth takes place during the simulated time period, and results shown are nearly identical to the initial conditions. Simulation results show that the presence of air in this two-phase system affects the distribution of biochemical species. Air, in the non-wetting phase, occupies the central part of the pore space, while the aqueous phase is expected to cover the corners and crevices (Fig. 6a). For oxygen with

The presented results highlight the ability of the model to combine a high-resolution simulation of multi-phase flow and transport processes with the simulation of complex biogeochemical processes. This allows for a realistic simulation of the pore-scale distribution of reactive processes and for the derivation of an accurate aggregated description of these processes.

As it can be seen from Fig. 6, our model can be used (among other options) to identify clusters in which succinate is most and least depleted. This would ease the process of analysing the results by isolating the parameters that are boosting/limiting the degradation of the carbon source. A 3D visualization of the oxygen and succinate distributions can be found in Golparvar (2022).

In this paper, we have presented a newly developed modelling framework for simulating reactive transport processes in real porous soil structures obtained from

The presented model provides a novel and unique combination of pore-scale simulations of two-phase flow, transport of dissolved and volatile species, and their reactive transformations. This makes it an accurate and powerful tool for the simulation of soil systems or other unsaturated porous media and of the reactive transport processes therein. While developed with the aim for simulating biogeochemical processes in soils, the model is equally applicable for simulating other abiotic reactive processes coupled to the dynamics of flow and transport in variably saturated pore structures of arbitrary geometry. Our modelling framework is properly designed for simulating biogeochemical processes such as carbon–nitrogen–sulfur–phosphorus cycles in soil as well as mixing and migration of contaminants in both unsaturated soil and water aquifers. It comes with the benefit of explicit recognition of the soil structure (i.e. using the 3D structure as close to the original shape as possible with the least number of simplifications/modifications), phase dynamics/distributions, and the capability of designing the complete redox reactions necessary for a given process in a straightforward fashion. It is best suitable for running pre-pilot tests as feasibility scenarios where the stakes for the success of the project are high. Also, our model provides the best tool for designing hypothetical experiments that are hard (if not impossible) to implement experimentally (e.g. a specific distribution of biomass–reactants within the domain, or variation of specific properties of reactive compound and/or the porous matrix). Furthermore, the high-resolution modelling results provided by this model support the upscaling of reactive transport process description from the pore to the Darcy scale and from the process to the observation scale respectively.

Although the current version of our numerical model is already covering a wide range of biophysiochemical properties of the soil constituents, for having a more realistic representation of multiphase, multicomponent reactive transport in partially saturated porous media, a few more factors still might be considered in future developments of the model: (1) shrinkage/expansion of the air/aqueous phase due to mass transfer of chemical species across the fluid–fluid interface; (2) the accounting of gas compressibility by adding an equation of state for tracking changes of air volume/density under flowing conditions; (3) translation of accumulated biomass on the grain surfaces into new flow-resistance components, which would potentially change the velocity streamlines (i.e. bioclogging); (4) changes of the grain surface structures and of the associated solid–liquid interface due to mineral precipitation/dilution or due to accumulation/depletion of solid organic material; (5) chemotactic behaviour of the microbial species; and (6) osmotic forces and electro-migration. Due to the modular structure of P3D-BRNS, such features can be relatively easily included in future upgrades of our model.

The source codes, benchmark and demonstration cases, along with instruction for installing and running each case that are presented in this paper, are archived at

The supplement related to this article is available online at:

AG was responsible for model/software curation, validation and visualization. Conceptualization and methodology development were managed by AG, MK and MT. The writing of the original manuscript was handled by AG, while all authors contributed to the revision and curation of the final draft. The entire work is supervised by MT.

The contact author has declared that none of the authors has any competing interests.

Publisher’s note: Copernicus Publications remains neutral with regard to jurisdictional claims made in the text, published maps, institutional affiliations, or any other geographical representation in this paper. While Copernicus Publications makes every effort to include appropriate place names, the final responsibility lies with the authors.

This work was funded by the Helmholtz Association via the integrated project “Controlling Chemicals' Fate”.

This research has been supported by the Helmholtz Association (Controlling Chemicals' Fate).The article processing charges for this open-access publication were covered by the Helmholtz Centre for Environmental Research – UFZ.

This paper was edited by Richard Neale and reviewed by two anonymous referees.