The problem setup is identical to the previous [_Exercise Basic_](../exercise-basic/README.md).
The problem setup is identical to the two-phase incompressible test from DuMu<sup>x</sup>.
## Preparing the exercise
* Navigate to the directory `exercise-properties`
_Exercise Properties_ deals with a two-phase compositional problem (__2p2c__). Goal is to learn how to use compile and runtime parameters and the _DuMu<sup>x</sup> property system_.
_Exercise Properties_ deals with a two-phase immiscible incompressible problem (__2p__). The goal is to learn how to adapt compile-time parameters by employing the _DuMu<sup>x</sup> property system_.
<br><br>
### Task 1: Getting familiar with the code
...
...
@@ -16,12 +16,11 @@ _Exercise Properties_ deals with a two-phase compositional problem (__2p2c__). G
Locate all the files you will need for this exercise
* The __main file__: `exercise_properties.cc`
* The __problem file__: `injection2p2cproblem.hh`
* The __spatial parameters file__: `injection2p2cspatialparams.hh`
* The __problem file__: `problem.hh`
* The __spatial parameters file__: `spatialparams.hh`
* The __input file__: `exercise_properties.input`
*Two header files containing:
*One header file containing:
* a custom __local residual__ in: `mylocalresidual.hh`
* a custom __material law__ in: `mymateriallaw.hh`
<hr><br><br>
...
...
@@ -46,88 +45,32 @@ make exercise_properties
./exercise_properties
```
Note: Because the input file has the same name as the
executable, DuMuX will find it automatically.
If gnuplot is installed on your system, you should see a plot of the capillary pressure - saturation relationship.
<hr><br><br>
### Task 3: Implement and use a different material law
<hr>
DuMuX uses the term _material law_ to describe the law used to compute
* pc-Sw relations
* kr-Sw relations
* their inverse relations
The file `mymateriallaw.hh` contains a custom implementation of such a material law.
* Implement the method `Scalar pc(const Params ¶ms, Scalar swe)` by implementing your own capillary pressure relationship, e.g. a simple linear relationship $`p_C(S_w) = 1\cdot 10^5 \cdot (1-S_w) + p_e`$.
Note: `MyMaterialLaw` uses the `BrooksCoreyParams` class as parameter input. You can get the entry pressure that is set in the spatial params as follows
```c++
constautope=params.pe();
```
The type (i.e. C++ type) of the material law is set in the file `injection2p2cspatialparams.hh` by declaring the following alias in the public section of the spatial parameters class:
* Make DuMuX use your own material law by including the header `mymateriallaw.hh` and changing the alias `MaterialLaw`. This will make sure that your material law is used everywhere else in the code.
Note: Also use the wrapper class `EffToAbsLaw`. It takes care of converting absolute to effective saturations considering residual saturations. `MyMaterialLaw`
as other material laws (like Brooks-Corey, VanGenuchten, ...) in DuMuX only deals with effective saturations.
* Verify your changes by recompiling and running the program. You should see a plot of your new function.
For the next task, disable the plotting feature by changing the settings in the input file `exercise2.input`
```ini
[Problem]
OnlyPlotMaterialLaws=false
```
executable, DuMu<sup>x</sup> will find it automatically.
<hr><br><br>
### Task 4: Implement a custom local residual
### Task 3: Implement a custom local residual
<hr>
Most types in DuMuX are properties that can be changed just like the material law. In the following task we implement our own 2p2c local residual, i.e. the class that computes the element residual in every Newton iteration. The file `mylocalresidual.hh` contains a copy of the similar to the original local residual class used for all compositional models renamed to `template<class TypeTag> class MyCompositionalLocalResidual`.
Many types in DuMu<sup>x</sup> are properties that can be changed on the problem level by using the property system. In the following task we implement our own 2p local residual, i.e. the class that computes the element residual in every Newton iteration. The file `mylocalresidual.hh` contains a copy of the original local residual class used for all immiscible models renamed to `template<class TypeTag> class MyLocalResidual`.
* Make DuMuX use this new local residual by inluding the header `mylocalresidual.hh` and setting the corresponding property in the `Property` namespace in the file `injection2p2cproblem.hh`
* Make DuMu<sup>x</sup> use this new local residual by including the header `mylocalresidual.hh` and setting the corresponding property in the `Property` namespace in the file `problem.hh`
```c++
// note that every property struct knows about TypeTag
SET_PROP(Injection2p2cTypeTag,LocalResidual)
SET_PROP(TwoPIncompressible,LocalResidual)
{
usingtype=MyCompositionalLocalResidual<TypeTag>;
usingtype=MyLocalResidual<TypeTag>;
};
// or using the convenience macro
SET_TYPE_PROP(Injection2p2cTypeTag,LocalResidual,
MyCompositionalLocalResidual<TypeTag>);
SET_TYPE_PROP(TwoPIncompressible,LocalResidual,
MyLocalResidual<TypeTag>);
```
You want to make the new local residual special by adding a switch enabling / disabling diffusion. We will achieve this with a DuMuX parameter which is read from the input file and defaults to a property value if the input file doesn't contain the parameter.
You want to make the simplify the original local residual special by using the assumption that incompressible fluid phases are present. As a consequence, one can balance phase volume instead of phase mass.
* Modify the `computeFlux` method to only call the `diffusiveFlux` method if diffusion is enabled. You can get the new parameter by adding the lines
```c++
// ... in the computeFlux method of MyCompositionalLocalResidual
You can now enable and disable diffusion through the input file
```ini
[Problem]
EnableDiffusion=true / false
```
* Eliminate the density from the `computeStorage` and the `computeFlux` methods.
* Verify the difference in the parameter $`x_w^{N2}`$, i.e. the mole fraction of nitrogen in the
water phase, with and without diffusion.
* Adapt the relevant routine in the problem file such that volume instead of mass is injected. The density of the employed NAPL is 1460 kg/m^3. For a first try, you can use the hardcoded value.
Note that due to diffusion being a slow process you
can only see the difference in later times.
* Generalize your approach by using the component's `liquidDensity(t, p)` function instead of the hardcoded value.