@@ -8,76 +8,77 @@ This example contains a contaminant transported by a base groundwater flow in a
...
@@ -8,76 +8,77 @@ This example contains a contaminant transported by a base groundwater flow in a


## Model description
## Model description
Two different models are applied to simulate the system: In a first step, the groundwater velocity is evaluated under stationary conditions. Therefore the single phase model is applied.
Two different models are applied to simulate the system: In a first step, the groundwater velocity is evaluated under stationary conditions using the single phase model.
In a second step, the contaminant gets transported based on the groundwater velocity field. It is assumed, that the dissolved contaminant does not affect density and viscosity of the groundwater and thus, it is handled as a tracer by the tracer model. The tracer model is then solved instationarily.
In a second step, the contaminant is transported with the groundwater velocity field. It is assumed, that the dissolved contaminant does not affect density and viscosity of the groundwater, and thus, it is handled as a tracer by the tracer model. The tracer model is then solved instationarily.
### 1p Model
### 1p Model
The single phase model uses Darcy's law as the equation for the momentum conservation:
The single phase model uses Darcy's law as the equation for the momentum conservation:
```math
```math
\textbf v = - \frac{\textbf K}{\mu} \left(\textbf{grad}\, p - \varrho {\textbf g} \right)
\textbf v = - \frac{\textbf K}{\mu} \left(\textbf{grad}\, p - \varrho {\textbf g} \right),
```
```
With the darcy velocity $` \textbf v `$, the permeability $` \textbf K`$, the dynamic viscosity $` \mu`$, the pressure $`p`$, the density $`\rho`$ and the gravity $`\textbf g`$.
with the darcy velocity $` \textbf v `$, the permeability $` \textbf K`$, the dynamic viscosity $` \mu`$, the pressure $`p`$, the density $`\rho`$ and the gravity $`\textbf g`$.
Darcy's law is inserted into the continuity equation:
Darcy's law is inserted into the mass balance equation:
```math
```math
\phi \frac{\partial \varrho}{\partial t} + \text{div} \textbf v = 0
\phi \frac{\partial \varrho}{\partial t} + \text{div} \textbf v = 0
```
```
with porosity $`\phi`$.
where $`\phi`$ is the porosity.
The equation is discretized using a cell-centered finite volume scheme as spatial discretization for the pressure as primary variable. For details on the discretization scheme, have a look at the dumux [handbook](https://dumux.org/handbook).
The equation is discretized using a cell-centered finite volume scheme as spatial discretization for the pressure as primary variable. For details on the discretization scheme, have a look at the dumux [handbook](https://dumux.org/handbook).
### Tracer Model
### Tracer Model
The transport of the contaminant component $`\kappa`$ is based on the previously evaluated velocity field $`\textbf v`$ with the help the following mass balance equation:
The transport of the contaminant component $`\kappa`$ is based on the previously evaluated velocity field $`\textbf v`$ with the help of the following mass balance equation:
With the porosity $`\phi`$, the mass fraction of the contaminant component $`\kappa`$: $`X^\kappa`$, the porous medium diffusivity $` D^\kappa_\text{pm} `$ and the density of the fluid phase $`\varrho`$.
where $`X^\kappa`$ is the mass fraction of the contaminant component $`\kappa`$ and $` D^\kappa_\text{pm} `$ is the effective diffusivity.
The porous medium diffusivity is a function of the diffusion coefficient of the component $`D^\kappa`$, the porosity $`\phi`$ and the porous medium tortuosity $`\tau`$ by the following equation:
The effective diffusivity is a function of the diffusion coefficient of the component $`D^\kappa`$ and the porosity and tortuosity $`\tau`$ of the porous medium:
```math
```math
D^\kappa_\text{pm}= \phi \tau D^\kappa
D^\kappa_\text{pm}= \phi \tau D^\kappa.
```
```
The primary variable of this model is the mass fraction $`X^\kappa`$. We apply the same spatial discretization as in the single phase model and use the implicit Euler method for time discretization. For more information, have a look at the dumux handbook.
The primary variable of this model is the mass fraction $`X^\kappa`$. We apply the same spatial discretization as in the single phase model and use the implicit Euler method for time discretization. For more information, have a look at the dumux [handbook](https://dumux.org/handbook).
In the following, we take a close look at the files containing the set-up: At first, boundary conditions and spatially distributed parameters are set in `problem_1p.hh` and `spatialparams_1p.hh`, respectively, for the single phase model and subsequently in `problem_tracer.hh` and `spatialparams_tracer.hh` for the tracer model. Afterwards, we show the different steps for solving the model in the source file `main.cc`. At the end, we show some simulation results.
In the following, we take a close look at the files containing the set-up: The boundary conditions and spatially distributed parameters for the single phase model are set in `problem_1p.hh` and `spatialparams_1p.hh`.
For the tracer model, this is done in the files `problem_tracer.hh` and `spatialparams_tracer.hh`, respectively. Afterwards, we show the different steps for solving the model in the source file `main.cc`. Finally, some simulation results are shown.
## The file `spatialparams_1p.hh`
## The file `spatialparams_1p.hh`
In this file, we generate the random permeability field in the constructor of the `OnePTestSpatialParams` class. Thereafter, spatial properties of the porous medium such as the permeability and the porosity are defined in various functions for the 1p problem.
In this file, we generate a random permeability field in the constructor of the `OnePTestSpatialParams` class.
We want to generate a random permeability field. For this, we use a random number generation of the C++ standard library.
For this, we use the random number generation facilities provided by the C++ standard library.
```cpp
```cpp
#include<random>
#include<random>
```
```
In the file `properties.hh` all properties are declared.
We use the properties for porous medium flow models, declared in the file `properties.hh`.
```cpp
```cpp
#include<dumux/porousmediumflow/properties.hh>
#include<dumux/porousmediumflow/properties.hh>
```
```
We include the spatial parameters for single-phase, finite volumes from which we will inherit.
We include the spatial parameters class for single-phase models discretized by finite volume schemes.
The spatial parameters defined for this example will inherit from those.
```cpp
```cpp
#include<dumux/material/spatialparams/fv1p.hh>
#include<dumux/material/spatialparams/fv1p.hh>
namespaceDumux{
namespaceDumux{
```
```
In the `OnePTestSpatialParams` class, we define all functions needed to describe the porous matrix, e.g. porosity and permeability for the 1p_problem.
In the `OnePTestSpatialParams` class, we define all functions needed to describe the porous medium, e.g. porosity and permeability for the 1p_problem.
```cpp
```cpp
template<classGridGeometry,classScalar>
template<classGridGeometry,classScalar>
classOnePTestSpatialParams
classOnePTestSpatialParams
:publicFVSpatialParamsOneP<GridGeometry,Scalar,
:publicFVSpatialParamsOneP<GridGeometry,Scalar,
OnePTestSpatialParams<GridGeometry,Scalar>>
OnePTestSpatialParams<GridGeometry,Scalar>>
{
{
```
```
We introduce `using` declarations that are derived from the property system, which we need in this class.
We declare aliases for types that we are going to need in this class.
We generate random fields for the permeability using a lognormal distribution, with the `permeability_` as mean value and 10 % of it as standard deviation. A seperate distribution is used for the lens using `permeabilityLens_`.
We generate random fields for the permeability using lognormal distributions, with `permeability_` as mean value and 10 % of it as standard deviation.
A separate distribution is used for the lens using `permeabilityLens_`. A permeability value is created for each element of the grid and is stored in the vector `K_`.
@@ -120,7 +126,9 @@ We generate random fields for the permeability using a lognormal distribution, w
...
@@ -120,7 +126,9 @@ We generate random fields for the permeability using a lognormal distribution, w
}
}
```
```
### Properties of the porous matrix
### Properties of the porous matrix
We define the (intrinsic) permeability $`[m^2]`$ using the generated random permeability field. In this test, we use element-wise distributed permeabilities.
This function returns the permeability $`[m^2]`$ to be used within a sub-control volume (`scv`) inside the element `element`.
One can define the permeability as function of the primary variables on the element, which are given in the provided `ElementSolution`.
Here, we use element-wise distributed permeabilities that were randomly generated in the constructor (see above).
The top and bottom of our domain are Neumann boundaries:
The top and bottom of our domain are Neumann boundaries:
```cpp
```cpp
else
values.setAllNeumann();
values.setAllNeumann();
returnvalues;
returnvalues;
...
@@ -363,7 +372,7 @@ we retreive again the global position
...
@@ -363,7 +372,7 @@ we retreive again the global position
constauto&pos=scvf.ipGlobal();
constauto&pos=scvf.ipGlobal();
PrimaryVariablesvalues(0);
PrimaryVariablesvalues(0);
```
```
we assign pressure values in [Pa] according to a pressure gradient to 1e5 Pa at the top and 1.1e5 Pa at the bottom.
and assign pressure values in [Pa] according to a pressure gradient to 1e5 Pa at the top and 1.1e5 Pa at the bottom.
```cpp
```cpp
values[0]=1.0e+5*(1.1-pos[dimWorld-1]*0.1);
values[0]=1.0e+5*(1.1-pos[dimWorld-1]*0.1);
returnvalues;
returnvalues;
...
@@ -391,12 +400,13 @@ We leave the namespace Dumux.
...
@@ -391,12 +400,13 @@ We leave the namespace Dumux.
## The file `spatialparams_tracer.hh`
## The file `spatialparams_tracer.hh`
In this file, we define spatial properties of the porous medium such as the permeability and the porosity in various functions for the tracer problem. Further, spatial dependent properties of the tracer fluid system are defined and in the end two functions handel the calculated volume fluxes from the solution of the 1p problem.
In this file, we define spatial properties of the porous medium such as the permeability and the porosity in various functions for the tracer problem.
In the file `properties.hh`, all properties are declared.
Furthermore, spatial dependent properties of the tracer fluid system are defined and in the end two functions handle the calculated volume fluxes from the solution of the 1p problem.
We use the properties for porous medium flow models, declared in the file `properties.hh`.
```cpp
```cpp
#include<dumux/porousmediumflow/properties.hh>
#include<dumux/porousmediumflow/properties.hh>
```
```
As in the 1p spatialparams, we inherit from the spatial parameters for single-phase, finite volumes, which we include here.
As in the 1p spatialparams, we inherit from the spatial parameters for single-phase models using finite volumes, which we include here.
```cpp
```cpp
#include<dumux/material/spatialparams/fv1p.hh>
#include<dumux/material/spatialparams/fv1p.hh>
```
```
...
@@ -406,7 +416,6 @@ namespace Dumux {
...
@@ -406,7 +416,6 @@ namespace Dumux {
```
```
In the `TracerTestSpatialParams` class, we define all functions needed to describe spatially dependent parameters for the `tracer_problem`.
In the `TracerTestSpatialParams` class, we define all functions needed to describe spatially dependent parameters for the `tracer_problem`.
```cpp
```cpp
template<classGridGeometry,classScalar>
template<classGridGeometry,classScalar>
classTracerTestSpatialParams
classTracerTestSpatialParams
:publicFVSpatialParamsOneP<GridGeometry,Scalar,
:publicFVSpatialParamsOneP<GridGeometry,Scalar,
...
@@ -443,24 +452,30 @@ We do not consider dispersivity for the tracer transport. So we set the dispersi
...
@@ -443,24 +452,30 @@ We do not consider dispersivity for the tracer transport. So we set the dispersi
{return0;}
{return0;}
```
```
### Properties of the fluid system
### Properties of the fluid system
In the following, we define fluid properties that are spatial parameters in the tracer model. They can possible vary with space but are usually constants. Further spatially constant values of the fluid system are defined in the `TracerFluidSystem` class in `problem.hh`.
In the following, we define fluid properties that are spatial parameters in the tracer model.
They can possible vary in space but are usually constants.
Furthermore, spatially constant values of the fluid system are defined in the `TracerFluidSystem` class in `problem.hh`.
We define the fluid density to a constant value of 1000 $`\frac{kg}{m^3}`$.
We define the fluid density to a constant value of 1000 $`\frac{kg}{m^3}`$.
```cpp
```cpp
ScalarfluidDensity(constElement&element,
ScalarfluidDensity(constElement&element,
constSubControlVolume&scv)const
constSubControlVolume&scv)const
{return1000;}
{return1000;}
```
```
We define the fluid molar mass.
This interface defines the fluid molar mass within the sub-control volume `scv`.
We define a function which returns the field of volume fluxes. This is e.g. used to calculate the transport of the tracer.
We define a function which returns the volume flux across the given sub-control volume face `scvf`.
This flux is obtained from the vector `volumeFlux_` that contains the fluxes across al sub-control volume faces of the discretization.
This vector can be set using the `setVolumeFlux` function.
```cpp
```cpp
template<classElementVolumeVariables>
template<classElementVolumeVariables>
ScalarvolumeFlux(constElement&element,
ScalarvolumeFlux(constElement&element,
...
@@ -471,7 +486,8 @@ We define a function which returns the field of volume fluxes. This is e.g. used
...
@@ -471,7 +486,8 @@ We define a function which returns the field of volume fluxes. This is e.g. used
returnvolumeFlux_[scvf.index()];
returnvolumeFlux_[scvf.index()];
}
}
```
```
We define a function to set the volume flux. This is used in the main function to set the volume flux to the calculated value based on the solution of the 1p problem.
We define a function that allows setting the volume fluxes for all sub-control volume faces of the discretization.
This is used in the main function after these fluxes have been based on the pressure solution obtained with the single-phase model.
```cpp
```cpp
voidsetVolumeFlux(conststd::vector<Scalar>&f)
voidsetVolumeFlux(conststd::vector<Scalar>&f)
{volumeFlux_=f;}
{volumeFlux_=f;}
...
@@ -491,7 +507,7 @@ private:
...
@@ -491,7 +507,7 @@ private:
Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties.
Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties.
### Include files
### Include files
Again, we have to include the dune grid interface:
Again, we use YaspGrid, the implementation of the dune grid interface for structured grids:
```cpp
```cpp
#include<dune/grid/yaspgrid.hh>
#include<dune/grid/yaspgrid.hh>
```
```
...
@@ -507,7 +523,7 @@ We include again the porous medium problem class that this class is derived from
...
@@ -507,7 +523,7 @@ We include again the porous medium problem class that this class is derived from
```cpp
```cpp
#include<dumux/porousmediumflow/problem.hh>
#include<dumux/porousmediumflow/problem.hh>
```
```
and the base fluidsystem
and the base fluidsystem. We will define a custom fluid system that inherits from that class.
```cpp
```cpp
#include<dumux/material/fluidsystems/base.hh>
#include<dumux/material/fluidsystems/base.hh>
```
```
...
@@ -561,30 +577,34 @@ We define the spatial parameters for our tracer simulation:
...
@@ -561,30 +577,34 @@ We define the spatial parameters for our tracer simulation: