@@ -32,21 +32,23 @@ To see more components, fluidsystems and binarycoefficients implementations, hav
### 2. Implement a new component
In the following the basic steps required to set the desired fluid system are outlined. Here, this is done in the __problem file__, i.e. for this part of the exercise the code shown below is taken from the `2pproblem.hh` file.
In the following, the basic steps required to set the desired fluid system are outlined. Here, this is done in the __problem file__, i.e. for this part of the exercise the code shown below is taken from the `2pproblem.hh` file.
In this part of the exercise we will consider a system consisting of two immiscible phases. Therefore, the _TypeTag_ for this problem derives from the _BoxTwoP_ _TypeTag_ (for a cell-centered scheme, you would derive from _CCTwoP_). In order to be able to derive from this _TypeTag_, The declaration of the _BoxTwoP_ _TypeTag_ is found in the file `dumux/porousmediumflow/2p/implicit/model.hh`, which has been included in line 28:
In this part of the exercise we will consider a system consisting of two immiscible phases. Therefore, the _TypeTag_ for this problem (_ExerciseThreeBoxTwoPTypeTag_) derives from something (_ExerciseThreeTwoPTypeTag_) that derives from the _TwoP_ _TypeTag_.
Additionally we derive from the _ExerciseThreeSpatialParams_ _TypeTag_ in order to set all the types related to the spatial parameters also for our new _TypeTag_ _ExerciseThreeProblem_. In this case, only one property is set for _ExerciseThreeSpatialParams_ (see lines 43 to 60 in `spatialparams.hh`). Alternatively, we could have defined this also here in the problem without defining a new type tag for the spatial parameters. However, in case you want to define several properties related to the spatial parameters it is good practice to define a separate _TypeTag_ and derive from this, as it is done here.
In order to be able to derive from this _TypeTag_, The declaration of the _TwoP_ _TypeTag_ is found in the file `dumux/porousmediumflow/2p/model.hh`, which has been included in line 28:
Additionally, the TypeTag_ for this problem (_ExerciseThreeBoxTwoPTypeTag_) derives from the _BoxModel_ _TypeTag_, to specify the discretization scheme. For a cell-centered scheme, you would derive from _CCTpfaModel_ or _CCMpfaModel_.
As wetting phase we want to use water and we want to precompute tables on which the properties are then interpolated in order to save computational time. Thus, in a first step we have to include the following headers:
```c++
...
...
@@ -71,36 +73,36 @@ As mentioned above, we want to simulate two non-mixing components. The respectiv
This fluid system expects __phases__ as input and so far we have only included the components, which contain data on the pure component for all physical states. Thus, we need to include
```c++
// We will only have liquid phases Here
// We will only have liquid phases here
#include<dumux/material/fluidsystems/1pliquid.hh>
```
which creates a _liquid phase_ from a given component. Finally, using all of the included classes we set the the fluid system property by choosing a liquid phase consisting of the incompressible fictitious component as non-wettingphase and tabulated water as the wetting phase in the immiscible fluid system:
which creates a _liquid phase_ from a given component. Finally, using all of the included classes we set the fluid system property by choosing that the non-wetting phase is a one-phase liquid (OnePLiquid) consisting of the incompressible fictitious component and that the wetting-phase consists of tabulated water in the immiscible fluid system:
Open the file `myincompressiblecomponent.hh`. You can see in line 40 that a component should always derive from the _Base_ class (see `dumux/material/components/base.hh`), which defines the interface of a _DuMuX_ component with all possibly required functions to be overloaded by the actual implementation. Additionally it is required for liquids to derive from the _Liquid_ class (see `dumux/material/components/liquid.hh`), for gases to derive from the _Gas_ class (see `dumux/material/components/gas.hh`) and for solids to derive from the _Solid_ class (see `dumux/material/components/solid.hh`).
Open the file `myincompressiblecomponent.hh`. You can see in line 42 that a component should always derive from the _Base_ class (see `dumux/material/components/base.hh`), which defines the interface of a _DuMuX_ component with possibly required functions to be overloaded by the actual implementation. Additionally it is required for liquids to derive from the _Liquid_ class (see `dumux/material/components/liquid.hh`), for gases to derive from the _Gas_ class (see `dumux/material/components/gas.hh`) and for solids to derive from the _Solid_ class (see `dumux/material/components/solid.hh`), with functions specific to liquid, gas or solid.
```c++
/*!
...
...
@@ -110,7 +112,9 @@ Open the file `myincompressiblecomponent.hh`. You can see in line 40 that a comp
where $`p`$ is the pressure and $`\rho_{min} = 1440 `$, $`\rho_{max} = 1480 `$ and $`k = 5 \cdot 10^{-7} `$. Also, make sure the header is included in the `2pproblem.hh` file by uncommenting line 42. Furthermore, the new component has to be set as the non-wetting phase in the fluid system, i.e. comment line 81 and uncomment line 82. The non-wetting density distribution at the final simulation time should look like this:
where $`p`$ is the pressure and $`\rho_{min} = 1440 `$, $`\rho_{max} = 1480 `$ and $`k = 5 \cdot 10^{-7} `$. Also, make sure the header is included in the `2pproblem.hh` file by uncommenting line 45. Furthermore, the new component has to be set as the non-wetting phase in the fluid system, i.e. comment line 90 and uncomment line 91. The non-wetting density distribution at the final simulation time should look like this:

### 3. Implement a new fluid system
The problem file for this part of the exercise is `2p2cproblem.hh`. We now want to implement a new fluid system consisting of two liquid phases, which are water and the previously implemented compressible component. We will consider compositional effects, which is why we now have to derive our _TypeTag_ from the _BoxTwoPTwoC_ _TypeTag_:
The problem file for this part of the exercise is `2p2cproblem.hh`. We now want to implement a new fluid system consisting of two liquid phases, which are water and the previously implemented compressible component. We will consider compositional effects, which is why we now have to derive our _TypeTag_ (_ExerciseThreeBoxTwoPTwoCTypeTag_) from a _TypeTag_ (_ExerciseThreeTwoPTwoCTypeTag_) that derives from the _TwoPTwoC_ _TypeTag_:
```c++
// The numerical model
...
...
@@ -173,7 +178,8 @@ The problem file for this part of the exercise is `2p2cproblem.hh`. We now want
The new fluid system is to be implemented in the file `fluidsystems/h2omycompressiblecomponent.hh`. This is already included in the problem and the fluid system property is set accordingly.
...
...
@@ -185,12 +191,12 @@ The new fluid system is to be implemented in the file `fluidsystems/h2omycompres
You will observe an error message and an abortion of the program. This is due to the fact that in order for the constraint solver and other mechanisms in the two-phase two-component model to work, two additional functionalities in the component have to be implemented. The model has to know whether or not the liquid pure component is compressible and it needs the vapour pressure. As in the previous exercise, check the `dumux/material/components/base.hh`and `dumux/material/components/liquid.hh`files for these two functions and implement them into `mycompressiblecomponent.hh`. For the vapour pressure, use a value of $`3900`$ Pa.
You will observe an error message and an abortion of the program. This is due to the fact that in order for the constraint solver and other mechanisms in the two-phase two-component model to work, an additional functionality in the component has to be implemented. The model has to know the vapour pressure. As in the previous exercise, check the `dumux/material/components/base.hh` file for this function and implement it into `mycompressiblecomponent.hh`. For the vapour pressure, use a value of $`3900`$ Pa.