1 Introduction

Insight into dynamic processes in porous media has traditionally been reached by direct observations and measurements of the processes combined with analysis and simulations of physics-based models (PBMs). Continuous improvements in sensors and imaging give increased access to data of high quality and resolution. In parallel, the field of data science, including data-driven modeling (DDM), artificial intelligence, and machine learning, has emerged as an alternative modeling approach that utilizes real-time data and thus offers a complement to the physics-based models. This calls for a hybrid approach, herein denoted Hybrid Analysis and Modeling (HAM), where data are integrated into physics-based models in real-time using techniques from data science, enabling enhanced simulation accuracy and ultimately improved decision-making in operational contexts. Such enhanced models with tight integration between simulation models and the physical asset (the porous media) can be formalized trough the concept of digital twins (Rasheed et al. 2020). The purpose of this work is to present a digital twin which can access high-quality data from a porous medium laboratory experiment, integrate this data into a physics-based simulation model in real time, and use the digital twin to guide decisions on the operation of the physical asset.

Porous media-related data streams are undergoing a transformation with increased use of sensors and emerging imaging modalities. A range of imaging technologies provides data streams of high spatial and temporal resolution, which can be used to gain access to local fluid flows within the opaque porous media (Fernø et al. 2015; Brattekås et al. 2020). Recent focus on sub-Darcy-scale displacement processes utilizes \(\upmu\)CT (Berg et al. 2013) and microfluidics (Gauteplass et al. 2015) to study pore-scale phenomena for a wide range of flow processes. The growing access to data is not limited to laboratory experiments: Field-scale operations also increasingly rely on real-time monitoring of important processes, and regulations call for frequent seismic monitoring of carbon sequestration projects for prolonged time series (Arts et al. 2004). The amount of data generated can be substantial, with time-lapsed 3D or multimodal microscopic image sequences frequently generating several TB per experiment (Benali et al. 2022). This calls for efficient approaches to incorporating data into analysis frameworks that can be used to harness physical insights contained therein.

One such framework is modeling and simulation based on physics-based models, which has a long tradition in porous media applications (Aziz and Settari 1979; Chen et al. 2006; Helmig 1997). The foundations of physics-based models, with a combination of fundamental physics, e.g., conservation or energy minimization principles, and constitutive laws, make them strong candidates for systematic studies and analysis of physical processes. Data can be incorporated into simulation models in several ways, including long-loop parameter tuning where simulation models and setups are tweaked to honor observations (Williams et al. 1998), and more continuous data assimilation methods which are popular in subsurface applications (Oliver and Chen 2011; Caers 2011). Following trends in data science, data-driven models for porous media have recently been introduced, see, for instance, Ren et al. 2019; Kiaerr et al. 2020; Lie and Krogstad 2022. Compared to physics-based models, these data-driven models are computationally highly efficient, but not being based on physical principles, their use in interpreting physical phenomena is not straightforward.

When used as a supplement, or substitute, for representing dynamics in a concrete physical asset (e.g., a porous medium), a simulation model can be interpreted as a digital twin of said asset. The digital-twin concept has been around for decades, overviews of applications to porous media can be found in Wanasinghe et al. 2020; Sircar et al. 2022, while specific use cases include Kannapinn et al. 2022; Xiao et al. 2021; Ali et al. 2020. The concept is very wide, in a sense, any simulation model that aims to represent a specific porous media can be considered a digital twin. It is, therefore, relevant to classify digital twins in terms of their level of sophistication and hence their ability to represent the status of, and inform decisions relating to, the physical asset. As is illustrated by the classification shown in Fig. 1, this capacity can vary significantly.

Fig. 1
figure 1

Increasing levels of capability for a digital twin. The capacity ranges from standalone, where the digital twin has no connection to the physical world, to fully autonomous, where the digital twin can control the physical twin without human intervention. Adapted from San et al. (2021)

A critical component for enabling the higher capability levels is the digital twin’s ability to self-correct when provided with data that are incompatible with the current digital representation. In a sense, this is one goal of data assimilation and history matching techniques applied, e.g., in subsurface engineering. These techniques are, however, based on an assumption that all relevant physical processes are included in the governing equations and adequately represented in the discretized simulation model. If this is not the case, and it is often impossible to verify, the unresolved processes can only be represented by proxy.

Hybrid Analysis and Modeling (HAM) offers an alternative version of self-correcting digital twins, which can account for mis- or underrepresented physics due to both poor parameter values and under-resolved physical processes. The COrrective Source-Term Approach (COSTA) (Blakseth et al. 2022), which falls under the HAM umbrella, employs an artificial neural network, trained on time series of combined observation and simulation data, to correct and enhance simulation results. This allows for  the systematic inclusion of observations into a real-time simulation workflow and the use of these observation to enhance the predictive accuracy of the simulations.

Herein, we describe the setup of a digital twin for fluid flow and tracer transport in a porous medium. The physical asset is a FluidFlower rig, which is essentially two-dimensional and provides a data-rich environment through imaging and advanced image processing. The digital twin consists of a COSTA-enhanced physics-based model, and the physical asset and digital twin are coupled using cloud technology. Our contributions in this work can be summarized as follows:

  • We probe the ability of the digital twin to reproduce results from experiments without any feedback, thereby realizing a one-way coupling from the physical asset to the digital twin.

  • We verify the ability of a data-driven model to correct unresolved and erroneous physics in a physics-based model. Moreover, we present results for geologically complex media.

  • We demonstrate two-way real-time communication between the physical asset and its digital twin, by considering an experiment in a meter-scale flow rig. In this case, we couple the digital twin to an optimization framework wherein well controls in the physical asset are manipulated to steer the migration of the tracer plume, thus demonstrating the prescriptive capabilities of the digital twin.

As a result, the results presented herein demonstrate the feasibility of achieving level 4, autonomy (in the context of the classification scheme cited in Fig. 1). To the best of our knowledge, no digital twin with similar capabilities has previously been presented for porous media.

The rest of the article is structured as follows: Sect. 2 explains the different components that build up the experimental setup and the digital twin. In Sect. 3, we present examples of one-way couplings from the physical to the digital twin, designed to probe the accuracy of the digital twin, while an example of a two-way coupling is shown in Sect. 4. Finally, in Sect. 5, conclusions are given and potential future work is presented.

2 Components of the PoroTwin Framework

Here, we present the components that together make up the digital twin framework, termed PoroTwin: the physical asset, the digital twin, and the communication protocols that enable data exchange between the components. The latter entails both flow of information and data postprocessing, for example, image processing. To indicate how the components are coupled together, Fig. 2 shows processes and information flows in the context of controlled injection of a tracer, as is studied in Sect. 4.

Fig. 2
figure 2

The components of the physical and digital twins assembled for the optimization experiment presented in Sect. 4. Data from the physical asset are filtered through image processing and sent to an optimization controller. This runs an optimization loop, consisting of forward simulation followed by a HAM correction, and the optimized well rates are then fed to the physical asset

. While the workflow as described below is to some extent tailored for the context of our physical asset and the experiments presented in the results sections, the framework can also be adapted to other data-rich settings. These are for the moment limited to laboratory experiments as any application to subsurface flows will entail dealing with lower quality and less frequent data. The digital twin can be employed for other purposes than optimization by modifying the central hub, while the other components remain relatively unchanged. This opens the door for considering risk assessment, ‘what if?’ analysis, uncertainty quantification, and process optimization. Furthermore, the digital twin can also be generalized to a set of digital siblings, i.e., a set of different physics-based simulators (Rasheed et al. 2020).

2.1 The Physical Asset

Here, we describe the physical asset in our setup, together with the data streams used in our experiments.

2.1.1 The FluidFlower Rig

The FluidFlower enables meter-scale multiphase quasi two-dimensional flow experiments on model geological geometries with unprecedented data acquisition and repeatability. The design allows for repeated injection tests with near identical initial conditions, allowing physical uncertainty and variability to be addressed using the same geological geometry. This also enables well-confined sensitivity studies to evaluate large parameter spaces because each parameter may be varied while keeping others constant. The model geological geometry is constructed using unconsolidated sands and held in place between an optically transparent front panel and a technical back panel. The back panel has perforations that enable a range of well configurations (injector, producer, monitoring, or plugged) for porous media flow studies. The optical access of the front panel facilities detailed investigation of flow processes through a high-resolution camera combined with a tracer.

FluidFlower rigs of two different sizes are employed in this study: A small rig with an extent of slightly less than a meter is considered in the experiments reported in Sects. 3.1 and 4, while a larger rig was used for the experiments reported in Sect. 3.2. For all experiments, a passive tracer is used to focus on the effect of well operation and, for the experiments reported in Sect. 3.2, how the flow is influenced by local geological features such as faults and multi-scale heterogeneity. Further details on the rig and the experimental setups are given in Sect. 3.

Two types of data from the FluidFlower are made available to our digital twin: In addition to injection and production rates, the migration of the injected tracer is monitored using imaging as detailed next.

2.1.2 Image Processing

The measurement instrument in the considered workflow is the combination of photographs taken of the physical asset and image processing. High-quality, high-resolution images provide dense data with low noise-to-signal ratio, as well as they resolve the medium up to sand grains. This high amount of details is beneficial in the further process. The high resolution, on the other hand, also provides a challenge, as it is important to emphasize that in the context of autonomous digital twins, all image processing must be fully automatic and real-time. As a whole, the role of the image analysis in this work is, in contrast with its typical applications, more a signal-to-data conversion and less a tool for noise reduction. With that it is also the mediator of data from the physical to the digital twin.

To convert a series of images of the conducted tracer experiments to spatio-temporal tracer concentration maps, the following steps are performed. First, a set of preprocessing routines is applied, including aligning all images with respect to a fixed point based on feature detection, cropping to a region of interest, and transforming the color spectrum such that the recorded colors of an attached color palette match a set of reference colors. Applying these to all images ensures a unified set of images. Next, to extract the tracer, the sand grains are removed by considering differences of images, using a baseline image taken before the start of the injection. Here, the high quality of images comes into play. The removal of sand grains can be viewed as nearly noise free; yet, it leaves areas with little to no signal. We choose to apply total variation denoising (Rudin et al. 1992) as a combined tool for inpainting low-data regions (i.e., sand grains) and simultaneous denoising. Converting the images to a monochromatic color space provides scalar data in the interval [0, 1]. The choice of the monochromatic color depends on the used tracer; here, grayscale images are considered suitable. Finally, a globally constant rescaling and clipping value at 1 is applied to convert the scalar signal to actual volumetric tracer concentration data. For this, a time series of images taken of a representative flow experiment with known injection rate is used for calibration. The final scaling parameter is obtained as the result of a RANSAC algorithm (Fischler and Bolles 1981), aiming at matching the effective injection rate for the rescaled images, while excluding outliers. The result of the image processing is illustrated in Fig. 3.

Fig. 3
figure 3

Illustration of the image analysis, from taken photograph to extracted spatial tracer concentration map

Special care has to be applied in the context of heterogeneous media, as considered in Sect. 3.2. As luminous emittance highly depends on the underlying material, the recorded signal becomes discontinuous over interfaces of different materials. Assuming piecewise homogeneous materials, materialwise constant scaling is applied, with values minimizing the signal jumps over interfaces in a least-squares fashion. Again, calibration is applied based on a representative set of images.

For the implementation of the image processing, DarSIA (short for Darcy-Scale Image Analysis toolbox) (Nordbotten et al. 2023) is used, which is an open-source tool specifically developed for analyzing high-resolution images of porous media flow experiments, with integrated capabilities for converting data to continuum/Darcy scale. It includes both preprocessing routines as well as analysis tools for concentration- and deformation-based scenarios.

2.2 The Digital Twin

The digital twin in our setup combines traditional components of physics-based modeling and data-driven modeling in a hybrid analysis and modeling context as elaborated in the following section.

2.2.1 Physics-Based Model

The fluid flow in the porous medium is modeled as incompressible and single-phase and is governed by

$$\begin{aligned} {\textbf{q}}&= -K\nabla p, \end{aligned}$$
(1)
$$\begin{aligned} \nabla \cdot {\textbf{q}}&= f. \end{aligned}$$
(2)

Here, \({\textbf{q}}\) is the Darcy flux, K is the hydraulic conductivity, p is fluid potential, and f represents volumetric source and sink terms. The transport of a passive tracer is given as follows:

$$\begin{aligned} \varphi \frac{\partial c}{\partial t} + \nabla \cdot ({\textbf{q}}c) = f_c, \end{aligned}$$
(3)

where \(\varphi\) denotes porosity, c is the tracer concentration, t represents time, and \(f_c\) is tracer sinks and sources.

The above model ignores gravitational effects caused by minor density differences between water and the tracer, which may have an impact in the longer simulations presented in Sect. 3.2. Moreover, we model the FluidFlower as two-dimensional and thus ignore variations in the (thin) third dimension.

To solve Eqs. (1)–(3) in the forward simulator of the digital twin, we consider two different numerical tools: The toolbox IFEM is used for the experiments in homogeneous porous media presented in Sects. 3.1 and 4. IFEM is an open-source object-oriented toolbox for implementing isogeometric finite element solvers for linear and nonlinear partial differential equations (Kvamsdal et al. 2022). For the simulations in the geologically complex medium reported in Sect. 3.2, we employ finite volume methods as implemented in the open-source tool PorePy (Keilegavlen et al. 2021).

2.2.2 Corrective Source-Term Approach

The COrrective Source-Term Approach (COSTA) is a methodology for combining the prediction from the physics-based simulator with data, in this case concentration maps from analyzed images, from the physical asset. COSTA is designed to operate solely on source terms, while keeping the simulation model intact. In this section, we motivate the formulation of COSTA by considering a hypothetical setting where the true solution, in our setting the image data obtained through the analysis described in Sect. 2.1.2, is available. In practice, the purpose of the physics-based model, thus of the COSTA correction, is to predict an unknown future state based on information of the current state of the system. To that end, a practical implementation of COSTA is described in Sect. 2.2.3.

Let us represent the physics-based model as a (in this context linear) operator \({\mathcal {L}}\) over a domain \(\Omega\) as

$$\begin{aligned} {{\mathcal {L}}}c:=\phi \frac{\partial c}{\partial t} + \nabla \cdot ({\textbf{q}}c) \end{aligned}.$$
(4)

Using the above operator, Eq. (3 ) reads

$$\begin{aligned} {{\mathcal {L}}} {\tilde{c}}&= {\tilde{f}}_c, \quad \forall \ c \in \Omega \end{aligned},$$
(5)

where \({\tilde{c}}\) represents the solution obtained by the physics-based model, which here is assumed to contain deviations from the true solution c (in our case, the image data) due to errors in the right hand side \({\tilde{f}}_c\).

It is instructive to consider potential sources of errors in the solution obtained from the physics-based model compared to a (hypothetical) solution operator for the continuous problem Eqs. (1)–(3). The solution obtained from the physics-based model may carry the effect of incorrect parameters (e.g., the hydraulic conductivity K), poor modeling assumptions (e.g., neglecting three-dimensional effects), and numerical errors. In addition, the physics-based model may be assigned an incorrect source term, in our case corresponding to mismatches between prescribed and actual injection and production rates. All these cases can be treated by adding a correction term r to Eq. (5) and define the COSTA solution as

$$\begin{aligned} {{\mathcal {L}}}c_{\textsc {costa}}= {\tilde{f}}_c + r \end{aligned}.$$
(6)

In practice, the correction term will be identified by the DDM; however, in the hypothetical case where it is known exactly, we see that the COSTA solution is consistent with the true solution whenever the correction term corresponds to the residual error \(r={{\mathcal {L}}}c - {\tilde{f}}_c\):

$$\begin{aligned} {{\mathcal {L}}}(c_{\textsc {costa}}-c)= {\tilde{f}}_c + r - {{\mathcal {L}}}c = ({\tilde{f}}_c-{\tilde{f}}_c) - ({{\mathcal {L}}}c - {{\mathcal {L}}}c) = 0 \end{aligned}.$$
(7)

For more information on COSTA and its treatment of different sources of errors, see Blakseth et al. (2022).

2.2.3 COSTA Implementation as a Data-Driven Model

Having motivated the COSTA correction term, we next turn to its practical implementation where the true solution c is not known. Specifically, to apply COSTA to the problem of tracer migration, the task is to compute \(c_{\textsc {costa}}^{n+1}\) from a known state \(c^{n}\) and a prediction \({\tilde{c}}^{n+1}\) obtained by the physics-based model. Our aim is to use the digital twin to predict the future state of the physical asset in an application setting where \(c^{n+1}\) is unavailable; thus, the exact residual \(r^{n+1} = \mathcal {L}( c^{n+1} - {\tilde{c}}^{n+1})\) cannot be computed.

The COSTA approach relies on the availability of historical time series as training data to construct a data-driven model that approximates \(r^{n+1}\) by

$$\begin{aligned} \sigma ^{n+1} = DDM(c^n, {\tilde{c}}^{n+1}) \end{aligned}$$
(8)

to the source term and apply these in Eq. (6) so that this reads

$$\begin{aligned} {{\mathcal {L}}}c_{\textsc {costa}}^{n+1}= f_c + \sigma ^{n+1}. \end{aligned}$$
(9)

The approximation \(\sigma ^{n+1}\) is implemented by training a deep convolutional neural network on data generated from time series of tracer migration: For each snapshot of the tracer, the physics-based model is invoked to predict the tracer distribution at the time of the next snapshot, and this is compared with the actual tracer distribution to compute a residual. Using this training data, the data-driven model is constructed to correct for errors in the physics-based model, with the intention that the correction terms should be accurate also for the tracer profiles encountered in the application phase.

The convolutional neural network used in the current work is depicted in Fig. 4 and can be expressed as follows:

$$\begin{aligned} \hat{\textbf{y}}=\hat{\textbf{f}}({\textbf{X}})=({\varvec{\Phi }}_{\textbf{Q}} \circ \cdots \circ {\varvec{\Phi }}_{\textbf{2}} \circ {\varvec{\Phi }}_{\textbf{1}})({\textbf{X}}). \end{aligned}$$
(10)

In our case, the data \({\textbf{X}}\) are the predicted tracer profile \({\tilde{c}}^{n+1}\), and \(\hat{\textbf{y}}\) is \(\sigma ^{n+1}\). The layers in the neural network, denoted \({\varvec{\Phi }}_{\textbf{i}}\), may represent different operations, including convolution, activation, and/or maxpooling. As an illustration, in Fig. 4, the input data represented by a matrix \({\textbf{X}}\) of dimension \(M\times N\) are subjected to 5 convolution operations (filter dimension \(5\times 5\)) followed by 5 max-pooling (filter dimension \(2\times 2\)) operations. After that follows a number of pure \(5 \times 5\) convolution operations, without max-pooling. Finally, two dense layers consisting of 100 nodes each are utilized. Within these dense layers, known parameters such as pump settings are concatenated. The output layer (not shown in the figure) is of the same size and shape as the input. The precise number of layers used in each operation varies and is clarified in the text as necessary.

Fig. 4
figure 4

Conceptual visualization of the neural network architecture used, see the text for a description of the individual components

The activation function used in this work is ReLU. Since this is a regression problem, the mean-squared error (MSE) was utilized as a loss function to be minimized. The loss for the training batch \(\mathcal B\) given weights and biases \(\varvec{\theta }\) is then

$$\begin{aligned} J_{\textsc {mse}}({{\mathcal {B}}}; \varvec{\theta }) = \frac{1}{|\mathcal B|} \sum _{k\in {{\mathcal {B}}}} \Vert {\textbf{y}}_k - \hat{\textbf{y}}_k \Vert^2 \end{aligned},$$
(11)

where \(({\textbf{x}}_k, {\textbf{y}}_k)\) is the kth pair in the dataset \({\mathcal {D}}\). For more detailed explanation of the CNN, we refer to Goodfellow et al. (2016). The neural network was implemented using the tensorflow library (Abadi et al. 2015).

2.3 Information Flow and Communication Protocols

In addition to the physical and digital twin, our framework also constitutes a central hub which controls the action of the physical and digital assets. Communication between the components is implemented using an Internet-of-Things (IoT) model, with two types of agents and modes of communication:

  • devices or servers, which can emit one-to-many messages and respond to one-to-one queries from clients, and

  • clients, which can listen to one-to-many messages from devices, and make one-to-one requests.

The physical and digital assets are made available to the IoT network as devices. Other components of the system may optionally be published as IoT devices as well, such as the physics-based and data-driven models. The central hub is implemented as a client. A typical purely predictive data flow may look like this:

  1. 1.

    The physical asset emits a one-to-many message notifying listeners of a new system state.

  2. 2.

    The hub receives it and queries the physics-based model, using a one-to-one request, for a prediction from (5).

  3. 3.

    The hub in turn queries the data-driven model for a correction, using (8).

  4. 4.

    The hub queries the physics-based model again for a corrected prediction from (9).

  5. 5.

    The hub emits a suitably accurate future prediction to the digital asset.

In a correction setting, the hub may instead make multiple queries for different control parameters (e.g., well rates) and finally respond back to the physics-based model with updated and optimal settings. In Sect. 4, we present a case where the hub employs the digital twin in an optimization framework to steer tracer migration in the physical asset, with a workflow illustrated in Fig. 2.

The IoT model was realized using Microsoft Azure’s IoT hub resources with cloud-based communication. Due to technical limitations with the pump-controlling software, the well controls in the physical twin could not be readily automatized, so the control messages are, therefore, communicated by audio. The communication framework is implemented as open-source software and available at Fonn et al. (2022).

3 Accuracy of the Digital Twin

To establish the accuracy of the digital twin, including both the forward simulator and its COSTA enhancement, we performed two sets of simulations. The first probed COSTA’s ability to compensate for unresolved physics, specifically to correct an artificially high numerical diffusion. The second considered simulations in a medium of complex geometry.

3.1 Performance of COSTA

We first considered simulations of tracer injection into a medium with homogeneous hydraulic conductivity. The numerical setup, using IFEM, was defined so that the physics-based model had unusually (and artificially) high numerical diffusion  thus the predicted tracer profiles were overly diffusive. A COSTA module was trained to compensate for this deficiency. In addition to the known errors caused by high diffusion, there may have been other sources of errors as noted in Sect. 2.2.2, but these could not be measured nor distinguished from the diffusion-related errors.

The physical setup, used both for this experiment and in the experiment reported in Sect. 4, was as follows: The flow rig had dimensions \(0.934 \,\textrm{m} \times 0.562 \,\textrm{m}\) in the x- and z-directions, respectively. The extent in the y-direction was \(0.010 \,\textrm{m}\), but for simulation purposes, the rig was considered a two-dimensional medium. In total, five wells were utilized in the flow experiments. One of these, termed Producer, was reserved for production while the others could be used for injection of tracer and water.  These wells are called, respectively, Injector and Control 1 through 3, reflecting their role in the experiment reported in Sect. 4. The locations of the wells are given in Table 1.

Table 1 Location of wells in the flow rig used for the experiments reported in Sects. 3.1 and 4

For a given tracer distribution, the evolution of the tracer plume depends on the rates of injection and production in the wells. To train the artificial neural network underlying our implementation of COSTA, we collected tracer profiles from a range of experiments in the physical twin, injecting tracer in the different wells. The resulting time series of tracer profiles, all taken 30 s apart, together with time series of the injection rates, were used to train COSTA following the protocol described in Sects. 2.22.3. The neural network for this case was modeled according to the framework of Fig. 4, with five combined convolution and max-pooling layers, no pure convolution layers, and three pure linear layers.

The effect of the COSTA correction is illustrated for two different timesteps, thus different tracer profiles, in Figs. 5 and 6. We observe that while the prediction quality for the tracer profile was poor due to to the artificially high diffusion, the corrected solution is remarkably similar to the actual state. Minor discrepancies can still be observed near the outer boundary of the predicted tracer profile, where COSTA failed to fully correct for the overly diffused profile, as well as in a region near the injection point, where the concentration reached a plateau of value 1. Nevertheless, keeping in mind that the error in the predicted state was artificially large, the improvement in the simulation result from COSTA is notable.

Fig. 5
figure 5

COSTA results at 10 min. At the top is the true experimental concentration field 30 s into the future. In the middle, we see the predicted concentration field with pure IFEM (left) and the logarithmic error (right). At the bottom is the corrected COSTA prediction (left) and its logarithmic error (right)

Fig. 6
figure 6

COSTA results at 30 min. See Fig. 5 for explanation

3.2 Performance in Heterogeneous Medium

As a second test of the digital twin, we considered simulation of tracer injection into a domain with a complex hydraulic conductivity distribution. Specifically, we considered the geometry of the benchmarking exercise defined in Nordbotten et al. (2022) and aimed to mimic the results of the well test by tracer injection, which was part of the benchmark description.

In this case, the porous medium had a size of \({2.8}{\,\hbox {m}} \times {1.5}{\,\hbox {m}}\). and was built from sands with different grain sizes, which translate into a hydraulic conductivity field that spanned 2–3 orders of magnitude. The spatial distribution of the hydraulic conductivity field is visualized in Fig. 7, together with the location of the two injection wells used in the tracer test. To account for the variable depth of this FluidFlower rig, see Nordbotten et al. (2022), the parameter fields were rescaled with depth variations incorporated into the cell volumes and hydraulic conductivity, so that a two-dimensional simulation model could be applied.

Fig. 7
figure 7

Complex geometry and example photograph of the tracer test from the International FluidFlower benchmark study, together with the postprocessed concentration profile (cutoff at small values for illustration purposes) on on top of the spatial conductivity distribution

Tracer was injected in the two wells following the injection schedule described in Nordbotten et al. (2022). In short, with a total duration of 27.5 h, tracer (partially alternating with water) was injected in pulses of 30 min with longer breaks varying from 30 min to 14.5 h; the final tracer distribution is displayed in Fig. 7a. Images were taken every 5 min providing the input data for the image analysis, which returned continuous concentration maps as described in Sect. 2.1.2. While the physics-based model assumes a perfectly passive tracer, in reality, the tracer has a density slightly larger than water. During the longest injection break, notable displacement of the tracer can be observed in the physical experiment. Thus, buoyancy effects play a role which are not accounted for in the governing equations underlying the physics-based model.

A data-driven COSTA model was trained to correct single-timestep errors in this physics-based model. The model was built with two downscaling convolution layers, five pure convolution layers followed by five dense linear ‘bottleneck’ layers. In addition to the pure image inputs from the physical asset, the data-driven model was also provided with the exact injection schedule as additional input to the dense layers. See Fig. 4 for details.

The physics-based model was able to predict the next image with approximately 1% relative error, with the exception of five distinct time intervals within the 1–6 h range after the start of injection, see Fig. 8. Although some modeling error must be accountable for this effect, using COSTA we were able to correct the predictions in these intervals to match the background noise error levels. See Fig. 9 for spatial error distributions at two selected timesteps.

Fig. 8
figure 8

Uncorrected and corrected error in the geologically complex medium for one timestep (i.e., no accumulating time error). COSTA is able to correct the modeling errors made in certain time intervals

Fig. 9
figure 9

Errors for a single timestep, before correction (left) and after correction (right). Above: 3 h and 50 min after start. Below: 4 h and 40 min after start

Although COSTA was trained to correct for single-timestep errors, i.e., errors accrued by a single application of a timestepping routine given the true concentration image as input, it is still of interest to analyze the ability of COSTA to correct for errors over longer timestepping sequences, that is, with less frequent access to true concentration data. In this case, we used corrected predictions from the previous timestep as input to the next timestep. COSTA was thus exposed to data it had not been trained for. The results are shown in Fig. 10. This figure shows the accumulated errors for long sequences of timesteps from a single starting point (at 1 h and 6 min into the experiment) for both the pure PBM and the COSTA-corrected timestepper.

Fig. 10
figure 10

Accumulated time errors for the corrected and uncorrected timestepping, beginning at 1 h and 6 min after start and then predicting many timesteps into the future. The green line shows the error accumulated by a pure PBM predictor, and the orange line shows the errror accumulated by a corrected COSTA predictor. For reference, the blue line shows the single-timstep corrected errors (the errors accrued for a single timestep when the timestepper receives the true concentration map as input)

This plot shows that, while the single-timestep corrected error remains low, COSTA faces challenges in generalizing the training set to perform corrections on initial conditions that are predicted and not sourced from ‘exact’ image data. COSTA has shown itself capable of doing this in other work, e.g., Blakseth et al. (2022). Thus, we attribute the deteriorating results in this case to potential overfitting on a narrow dataset.

4 Application: Applying the Digital Twin for Controlling Tracer Plume Migration

The experiments presented in Sect. 3 studied performance of the digital twin in a one-way coupling from the physical to the digital twin. Here, we applied the digital twin to steer the physical twin, thus achieving a two-way coupling between the physical and digital twins, and arguably showing that the digital twin has reached capacity level 4 referring to Fig. 1. COSTA was set up using the same training data as described in Sect. 3.1, but the injection pattern, thus tracer profiles, in this experiment was not present in the training set and not fed to the network.

We considered tracer injection into the same geometry as used in Sect. 3.1, with the injection rate in well 1 fixed to 500 mL/h. This resulted in a tracer plume, and the task of the digital twin was to steer the plume away from the upper part of the domain, with a demarcation line shown in Fig. 11. This corresponds to a hypothetical situation where injection of a waste (e.g., dissolved \(\hbox {CO}_{2}\)) is controlled to stay within an operation licence.

Fig. 11
figure 11

Disallowed zone for the tracer plume (left) and fuzzy mask \(\psi\) (right)

To this end, the digital twin was allowed to manipulate injection and production wells under the following constraints:

  • The injection rate for an individual control well could not surpass 500 mL/h.

  • The total injection rate in the control wells could not surpass 500 mL/h.

  • The production rate had to match the total injection rate so that the net injection rate was zero.

By corollary, the production rate was limited to 1000 mL/h, the sum of the fixed tracer injection rate and the maximal total control injection rate.

From the start of tracer injection, photographs of the tracer distribution were taken every 30 s and submitted to the digital twin. The digital twin then performed an optimization routine, minimizing a cost function

$$\begin{aligned} f(c_1, c_2, c_3) = \int _\Omega c(x; \Delta t, c_1, c_2, c_3) \psi (x) \;\text {d}x \end{aligned}$$
(12)

where \(c_1, c_2, \hbox{and } c_3\) are the injection rates for the three control wells subject to optimization, c is the predicted future tracer distribution, and \(0 \le \psi \le 1\) is a ‘fuzzy’ map of the disallowed zone, see Fig. 11. This fuzzing was done with the intention of allowing the digital twin to respond with suitable control rates before the tracer plume actually reached the disallowed zone, without necessarily needing to simulate so far into the future.

The minimization of f was performed with the COBYLA method (Powell 1994), a suitable algorithm able to handle all the constraints without requiring higher order data, such as derivatives. The implementation was provided by SciPy 1.5.4.

The implemented well control rates, as recommended by the optimization algorithm, are visualized in Fig. 12, while the evolution of the plume is shown in Fig. 13. As can be seen, in the initial state, the algorithm recommended controlling tracer migration through injection at close to the maximum allowed rate into Control 1, with some injection also into Control 2. After about 15 min, the injection strategy switched to mainly prioritizing Control 2. This pattern was mainly kept for the remainder of the experiment, interrupted by short periods of injection also into Control wells 1 and 3. In practice, the measured production rate was at times approximately 1% lower than the prescribed rate due to mechanical irregularities in the operation of the pump. This discrepancy was automatically accounted for in the digital twin through the source correction term described in Sect. 2.2.

Fig. 12
figure 12

Well rates used in the optimization experiments. All rates refer to injection, except the producer. The injector rate is kept constant at 500 mL/h

The impact of the control wells can clearly be seen in the evolution of the tracer plume: Initially, injection in Control 1 leads to a deviation from the circular plume shape of an isolated injection. The switch to injection in Control 2 seems consistent with an attempt to minimize migration into the disallowed zone, as does the reactivation of Control 1 late in the experiment. Figure 13 also shows the difficulty of the assigned optimization task, due to the combination of the geometry of the disallowed zone, the placement of the control wells, and the requirement that the tracer injection rate is fixed at 500 mL/H. Nevertheless, the example proves that our framework is capable of handling real-time interaction between the physical and digital twins.

Fig. 13
figure 13

Evolution of the tracer plume, shown at, respectively, 10 min, 35 min, 60 min and 80 min from the start of the experiment

5 Conclusions and Outlook

We have presented a physical and digital twin for laboratory experiments of tracer transport in porous media. The physical twin is a meter-scale FluidFlower rig, while the digital twin consists of a traditional physics-based simulator augmented with a Hybrid Analysis and Modeling (HAM) component. The latter aims to capture physical effects that are not in the solution space of the simulator, and was in this case implemented using a COrrective Source-Term Approach (COSTA). COSTA’s ability to augment the physics-based simulator was illustrated with simulations in homogeneous and heterogeneous porous media.

We demonstrated the capabilities of the digital twin and the possibilites in real-time communication between physical asset and digital twin, by controlling tracer migration in the physical twin by optimizing on well controls. More broadly, we believe that the framework presented herein opens wide opportunities in combined experiments and simulations to study porous media dynamics in data-rich settings: The tight integration offers a natural way to include data from observations into simulation models. In contrast with traditional methods for data assembly, the COSTA framework needs no assumptions on which parameters are uncertain, and it can enhance the range of the physics-based model to include effects not represented in the governing equations. This makes our approach an ideal tool for exploring and interpreting advanced laboratory experiments.

Two natural extensions of our approach are the inclusion of more complex physics, for instance, multiphase flow, and the inclusion of spatially (and temporally) sparse data. Multiphase flow will introduce at least two significant challenges: Image processing becomes considerably more difficult, and while DarSIA can be applied also in this setting, development of an accurate tool that does not require manual tuning during the experiment may require further efforts; see Nordbotten et al. (2023) for more information. The more complex flow patterns in multiphase flow, such as gravitational and capillary effects, will also put extra requirements on the machine learning component of our framework. While it it safe to say that these effects must be included in the training data for any machine learning approach, it is at the moment unclear whether COSTA as applied herein can also be applied to multiphase problems. Similarly, we have not yet attempted to apply the digital twin to sparse data, for instance, pressure measurements. While the location of the pressure sensors can be guided by optimal sensor placement techniques, the sparse data will need to be optimized prior to application of a COSTA version based on convolutional neural network. We have not investigated this, but expect achieving interpolation accuracy to be a challenge in the presence of geological heterogeneities and multiphase flows. Further work on image processing and data inclusion is thus needed to extend the digital twin framework to more complex problems.