2012-02-13 12:44:10 -06:00
\section [Fully-Implicit Model] { Solving a Problem Using a Fully-Coupled Model} \label { tutorial-coupled}
2008-08-01 02:07:43 -05:00
2012-02-09 09:48:16 -06:00
The process of setting up a problem using \Dumux can be roughly divided into four parts:
2008-09-25 03:11:11 -05:00
\begin { enumerate}
2012-02-09 09:48:16 -06:00
\item A suitable model has to be chosen.
2008-09-25 03:11:11 -05:00
\item The geometry of the problem and correspondingly a grid have to be defined.
2010-10-19 04:16:57 -05:00
\item Material properties and constitutive relationships have to be selected.
2012-02-14 08:52:59 -06:00
\item Boundary conditions and initial conditions have to be specified.
2008-09-25 03:11:11 -05:00
\end { enumerate}
2012-02-09 09:48:16 -06:00
The problem being solved in this tutorial is illustrated in Figure \ref { tutorial-coupled:problemfigure} .
2012-02-23 08:48:40 -06:00
A rectangular domain with no-flow boundaries on the top and on the bottom, which is initially saturated with oil, is considered.
2012-02-09 09:48:16 -06:00
Water infiltrates from the left side into the domain and replaces the oil. Gravity effects are neglected here.
2008-09-25 03:11:11 -05:00
2012-02-07 11:53:55 -06:00
\begin { figure} [ht]
2008-09-25 03:11:11 -05:00
\psfrag { x} { x}
\psfrag { y} { y}
\psfrag { no flow} { no flow}
\psfrag { water} { \textbf { water} }
\psfrag { oil} { \textcolor { white} { \textbf { oil} } }
\psfrag { p_ w = 2 x 10^ 5 [Pa]} { $ p _ w = 2 \times 10 ^ 5 $ [Pa]}
\psfrag { p_ w_ initial = 2 x 10^ 5 [Pa]} { \textcolor { white} { \textbf { $ \mathbf { p _ { w _ { initial } } = 2 \times 10 ^ 5 } $ [Pa]} } }
\psfrag { S_ n = 0} { $ S _ n = 0 $ }
2008-10-09 12:49:28 -05:00
\psfrag { S_ n_ initial = 0} { \textcolor { white} { $ \mathbf { S _ { n _ { initial } } = 1 } $ } }
2008-09-25 03:11:11 -05:00
\psfrag { q_ w = 0 [kg/m^ 2s]} { $ q _ w = 0 $ $ \left [ \frac { \textnormal { kg } } { \textnormal { m } ^ 2 \textnormal { s } } \right ] $ }
2010-12-07 05:12:19 -06:00
\psfrag { q_ n = -3 x 10^ -4 [kg/m^ 2s]} { $ q _ n = - 3 \times 10 ^ { - 2 } $ $ \left [ \frac { \textnormal { kg } } { \textnormal { m } ^ 2 \textnormal { s } } \right ] $ }
2008-09-25 03:11:11 -05:00
\centering
\includegraphics [width=0.9\linewidth,keepaspectratio] { EPS/tutorial-problemconfiguration}
\caption { Geometry of the tutorial problem with initial and boundary conditions.} \label { tutorial-coupled:problemfigure}
\end { figure}
2012-02-09 09:48:16 -06:00
The solved equations are the mass balances of water and oil:
2009-06-18 11:46:37 -05:00
\begin { align}
\label { massbalancewater}
\frac { \partial (\phi \, S_ { w} \, \varrho _ { w} )} { \partial t}
2010-12-10 09:05:12 -06:00
-
2010-11-11 08:52:18 -06:00
\nabla \cdot \left ( \varrho _ { w} \, \frac { k_ { rw} } { \mu _ { w} } \, \mathbf { K} \; \nabla p_ w \right )
2009-06-18 11:46:37 -05:00
-
2010-11-11 08:52:18 -06:00
q_ w
2009-06-18 11:46:37 -05:00
& =
0 \\
\label { massbalanceoil}
\frac { \partial (\phi \, S_ { o} \, \varrho _ { o} )} { \partial t}
2010-12-10 09:05:12 -06:00
-
2010-11-11 08:52:18 -06:00
\nabla \cdot \left ( \varrho _ { o} \, \frac { k_ { ro} } { \mu _ { o} } \, \mathbf { K} \; \nabla p_ o \right )
2009-06-18 11:46:37 -05:00
-
2010-11-11 08:52:18 -06:00
q_ o
2009-06-18 11:46:37 -05:00
& =
0
\end { align}
2012-02-13 12:44:10 -06:00
\subsection { The Main File}
2009-06-18 11:46:37 -05:00
2012-02-09 09:48:16 -06:00
Listing \ref { tutorial-coupled:mainfile} shows the main application file
2010-10-19 04:16:57 -05:00
\texttt { tutorial/tutorial\_ coupled.cc} for the coupled two-phase
2012-02-09 09:48:16 -06:00
model. This file has to be compiled and executed in order to solve the problem described
2009-06-18 11:46:37 -05:00
above.
\begin { lst} [File tutorial/tutorial\_ coupled.cc]\label { tutorial-coupled:mainfile} \mbox { }
2012-02-24 05:16:37 -06:00
\lstinputlisting [style=DumuxCode, numbersep=5pt, firstline=29] { ../../tutorial/tutorial_ coupled.cc}
2008-09-25 03:11:11 -05:00
\end { lst}
2009-06-18 11:46:37 -05:00
From line \ref { tutorial-coupled:include-begin} to line
2012-02-23 08:48:40 -06:00
\ref { tutorial-coupled:include-end} the required headers are included.
2009-06-18 11:46:37 -05:00
At line \ref { tutorial-coupled:set-type-tag} the type tag of the
2012-02-13 12:44:10 -06:00
problem, which is going to be simulated, is specified. All other data
types can be retrieved via the \Dumux property system and only depend
2012-02-23 08:48:40 -06:00
on this single type tag. For a more thorough introduction to the
2012-02-13 12:44:10 -06:00
\Dumux property system, see chapter~\ref { sec:propertysystem} .
2012-02-23 08:48:40 -06:00
After this, the default startup routine \texttt { Dumux::start()} is
2012-02-14 10:33:33 -06:00
called on line \ref { tutorial-coupled:call-start} . This function deals
with parsing the command line arguments, reading the parameter file,
2012-02-23 08:48:40 -06:00
setting up the infrastructure necessary for \Dune , loading the grid, and
starting the simulation.
Required parameters for the start of the simulation,
such as the initial time-step size, the simulation time or details of the grid,
can be either specified by command line arguments of the form
2012-02-14 10:33:33 -06:00
(\texttt { -ParameterName ParameterValue} ), in the file specified by the
\texttt { -parameterFile} argument, or if the latter is not specified,
2012-02-23 08:48:40 -06:00
in the file \mbox { \texttt { tutorial\_ coupled.input} } .
If a parameter is
2012-02-14 10:33:33 -06:00
specified on the command line as well as in the parameter file, the
values provided in the command line have
precedence. Listing~\ref { tutorial-coupled:parameter-file} shows the
default parameter file for the tutorial problem.
\begin { lst} [File tutorial/tutorial\_ coupled.input]\label { tutorial-coupled:parameter-file} \mbox { }
2012-02-24 05:16:37 -06:00
\lstinputlisting [style=DumuxCode] { ../../tutorial/tutorial_ coupled.input}
2012-02-14 10:33:33 -06:00
\end { lst}
To provide an error message, the usage message which is displayed to
the user if the simulation is called incorrectly, is printed via the
custom function which is defined on
2012-02-23 08:48:40 -06:00
line~\ref { tutorial-coupled:usage-function} .
In this function the usage message is customized to the problem at hand.
This means that at least the necessary parameters are listed here.
For more information about the input file please refer to section \ref { sec:inputFiles} .
2012-02-14 08:52:59 -06:00
2012-02-13 12:44:10 -06:00
\subsection { The Problem Class}
2009-06-18 11:46:37 -05:00
When solving a problem using \Dumux , the most important file is the
2012-02-13 12:44:10 -06:00
so-called \textit { problem file} as shown in
listing~\ref { tutorial-coupled:problemfile} .
2009-06-18 11:46:37 -05:00
\begin { lst} [File tutorial/tutorialproblem\_ coupled.hh]\label { tutorial-coupled:problemfile} \mbox { }
2012-02-24 05:16:37 -06:00
\lstinputlisting [style=DumuxCode, numbersep=5pt, firstline=28] { ../../tutorial/tutorialproblem_ coupled.hh}
2008-09-25 11:55:15 -05:00
\end { lst}
2010-10-18 03:59:51 -05:00
First, a new type tag is created for the problem in line
2009-06-18 11:46:37 -05:00
\ref { tutorial-coupled:create-type-tag} . In this case, the new type
2012-02-13 12:44:10 -06:00
tag inherits all properties from the \texttt { BoxTwoP} type tag, which
means that for this problem the two-phase box model is chosen as
discretization scheme. Further, it inherits from the spatial
parameters type tag, which is defined in the problem-dependent spatial
parameters file (line
\ref { tutorial-coupled:define-spatialparameters-typetag} ). On line
\ref { tutorial-coupled:set-problem} , a problem class is attached to the
new type tag, while the grid which is going to be used is defined in
line \ref { tutorial-coupled:set-grid} -- in this case that is
\texttt { Dune::YaspGrid} . Since there's no uniform mechanism to
allocate grids in \Dune , \Dumux features the concept of grid creators.
In this case the generic \texttt { CubeGridCreator} which creates a
2012-02-14 08:52:59 -06:00
structured hexahedron grid of a specified size and resolution. For
this grid creator the physical domain of the grid is specified via the
2012-02-13 12:44:10 -06:00
run-time parameters \texttt { Grid.upperRightX} ,
\texttt { Grid.upperRightY} , \texttt { Grid.numberOfCellsX} and
\texttt { Grid.numberOfCellsY} . These parameters can be specified via
2012-02-23 08:48:40 -06:00
the command-line or in a parameter file.
2012-02-13 12:44:10 -06:00
Next, the appropriate fluid system, which specifies the thermodynamic
relations of the fluid phases, has to be chosen. By default, the
two-phase model uses the \texttt { TwoPImmiscibleFluidSystem} , which
2012-02-23 08:48:40 -06:00
assumes immiscibility of the phases, but requires the components
2012-02-13 12:44:10 -06:00
used for the wetting and non-wetting phases to be explicitly set. In
this case, liquid water which uses the relations from
2010-11-10 08:24:22 -06:00
IAPWS'97~\cite { IAPWS1997} is chosen as the wetting phase on line
2012-02-13 12:44:10 -06:00
\ref { tutorial-coupled:wettingPhase} and liquid oil is chosen as the
non-wetting phase on line \ref { tutorial-coupled:nonwettingPhase} . The
last property, which is set in line \ref { tutorial-coupled:gravity} ,
tells the model not to use gravity.
Parameters which are specific to a physical set-up to be simulated,
such as boundary and initial conditions, source terms or temperature
within the domain, and which are required to solve the differential
equations of the models are specified via a \textit { problem} class. If
the two-phase box model is used, this class should be derived from
\texttt { TwoPBoxProblem} as done in line
\ref { tutorial-coupled:def-problem} .
2009-06-18 11:46:37 -05:00
The problem class always has at least five methods:
2008-09-25 11:55:15 -05:00
\begin { itemize}
2012-02-09 09:48:16 -06:00
\item A method \texttt { boundaryTypes()} specifying the type of
boundary conditions at each vertex.
2009-06-18 11:46:37 -05:00
\item A method \texttt { dirichlet()} specifying the actual values for
2012-02-13 12:44:10 -06:00
the \textsc { Dirichlet} conditions at each \textsc { Dirichlet} vertex.
2009-06-18 11:46:37 -05:00
\item A method \texttt { neumann()} specifying the actual values for
2012-02-13 12:44:10 -06:00
the \textsc { Neumann} conditions, which are usually evaluated at the
integration points of the \textsc { Neumann} boundary faces.
2012-02-09 09:48:16 -06:00
\item A method for source or sink terms called \texttt { source()} , usually evaluated at
2012-02-13 12:44:10 -06:00
the center of a control volume.
2009-06-18 11:46:37 -05:00
\item A method called \texttt { initial()} for specifying the initial
2012-02-09 09:48:16 -06:00
conditions at each vertex.
2008-09-25 11:55:15 -05:00
\end { itemize}
2012-02-13 12:44:10 -06:00
For the definition of the the boundary condition types and of the
values of the \textsc { Dirichlet} boundaries, two parameters are
available:
2011-02-25 08:01:32 -06:00
\begin { description}
\item [values:] A vector which stores the result of the method. What
2011-09-01 04:47:38 -05:00
the values in this vector mean is dependent on the method: For
2011-02-25 08:01:32 -06:00
\texttt { dirichlet()} it contains the actual values of the primary
variables, for \texttt { boundaryTypes()} it contains the boundary
2012-02-09 09:48:16 -06:00
condition types. It has as many entries as the model has primary variables / equations.
For the typical case, in which all equations have the same boundary
condition type at a certain position, there are two methods that set the appropriate conditions
2012-02-13 12:44:10 -06:00
for all primary variables / equations: \texttt { setAllDirichlet()} and \texttt { setAllNeumann()} .
\item [vertex:] The boundary condition and the Dirichlet values are
specified for a vertex, which represents a control volume in the box
discretization. This avoids the specification of two different
boundary condition types for one equation at different control
2012-02-23 08:48:40 -06:00
volumes. Be aware that the second parameter is a Dune grid entity
2012-02-13 12:44:10 -06:00
with the codimension \texttt { dim} .
2011-02-25 08:01:32 -06:00
\end { description}
2012-02-13 12:44:10 -06:00
To ensure that no boundaries are undefined, a small safeguard value
\texttt { eps\_ } is usually added when comparing spatial
2012-02-23 08:48:40 -06:00
coordinates. The left boundary is hence not detected by checking, if the
first coordinate of the global position is equal to zero, but by testing whether it is
2011-02-25 08:01:32 -06:00
smaller than a very small value \texttt { eps\_ } .
2012-02-13 12:44:10 -06:00
Methods which make statements about boundary segments of the grid
2012-02-23 08:48:40 -06:00
(such as \texttt { neumann()} ) are called with six arguments:
2009-06-18 11:46:37 -05:00
\begin { description}
2011-02-25 08:01:32 -06:00
\item [values:] A vector \texttt { neumann()} , in which the mass fluxes per area unit
over the boundary segment are specified.
2009-06-18 11:46:37 -05:00
\item [element:] The element of the grid where the boundary segment
is located.
\item [fvElemGeometry:] The finite-volume geometry induced on the
finite element by the box scheme.
2012-02-09 09:48:16 -06:00
\item [isIt:] The \texttt { Intersection} of the boundary segment as given by the grid.
2009-06-18 11:46:37 -05:00
\item [scvIdx:] The index of the sub-control volume in
2012-02-23 08:48:40 -06:00
\texttt { fvElementGeometry} which is assigned to the boundary segment.
2009-06-18 11:46:37 -05:00
\item [boundaryFaceIdx:] The index of the boundary face in
\texttt { fvElementGeometry} which represents the boundary segment.
\end { description}
2010-10-13 10:48:08 -05:00
Similarly, the \texttt { initial()} and \texttt { source()} methods
2012-02-13 12:44:10 -06:00
specify properties of control volumes and thus only get
2009-06-18 11:46:37 -05:00
\texttt { values} , \texttt { element} , \texttt { fvElemGeom} and
2012-02-13 12:44:10 -06:00
\texttt { scvIdx} as arguments.
2009-06-18 11:46:37 -05:00
In addition to these five methods, there might be some model-specific
2012-02-13 12:44:10 -06:00
methods. If the isothermal two-phase model is used, this includes for
example a \texttt { temperature()} method which returns the temperature
in \textsc { Kelvin} of the fluids and the rock matrix in the
domain. This temperature is then used by the model to calculate fluid
properties which possibly depend on it, e.g. density. The
\texttt { bboxMax()} (``\textbf { max} imum coordinated of the grid's
2012-02-23 08:48:40 -06:00
\textbf { b} ounding \textbf { b} ox'') method is used here to
determine the extend of the physical domain. It returns a vector with the
maximum values of each global coordinate of the grid. This method
2012-02-13 12:44:10 -06:00
and the analogous \texttt { bboxMin()} method are provided by the base
class \texttt { Dumux::BoxProblem<TypeTag>} .
\subsection { Defining Fluid Properties} \label { tutorial-coupled:description-fluid-class}
The \Dumux distribution includes some common substances which can be
used out of the box. The properties of the pure substances (such as
the components nitrogen, water, or the pseudo-component air) are
provided by header files located in the folder
\verb +dumux/material/components+.
Most often, when two or more components are considered, fluid
interactions such as solubility effects come into play and properties
of mixtures such as density or enthalpy are of interest. These
interactions are defined by { \em fluid systems} , which are located in
\verb +dumux/material/fluidsystems+. A more thorough overview of the
\Dumux fluid framework can be found in chapter~\ref { sec:fluidframework} .
2010-04-12 10:32:36 -05:00
2011-09-01 04:47:38 -05:00
% In this example, a class for the definition of a two-phase system is used. This allows for the choice
% of the two components oil and water and for access of the parameters that are relevant for the two-phase model.
2010-10-19 04:16:57 -05:00
2012-02-23 08:48:40 -06:00
\subsection { Defining Spatially Dependent Parameters} \label { tutorial-coupled:description-spatialParameters}
2010-04-12 10:32:36 -05:00
2012-02-13 12:44:10 -06:00
In \Dumux , many properties of the porous medium can depend on the
spatial location. Such properties are the \textit { intrinsic
permeability} , the parameters of the \textit { capillary pressure} and
the \textit { relative permeability} , the \textit { porosity} , the
\textit { heat capacity} as well as the \textit { heat conductivity} . Such
2012-02-23 08:48:40 -06:00
parameters are defined using a so-called \textit { spatial parameters}
2012-02-13 12:44:10 -06:00
class.
2010-04-12 10:32:36 -05:00
2012-02-23 08:48:40 -06:00
If the box discretization is to used, the spatial parameters class
2012-02-13 12:44:10 -06:00
should be derived from the base class
\texttt { Dumux::BoxSpatialParameters<TypeTag>} . Listing
2012-02-23 08:48:40 -06:00
\ref { tutorial-coupled:spatialparametersfile} shows the file \\
2010-04-12 10:32:36 -05:00
\verb +tutorialspatialparameters_ coupled.hh+:
2011-11-18 11:20:31 -06:00
%\begin{lst}[File tutorial/tutorialspatialparameters\_coupled.hh]\label{tutorial-coupled:spatialparametersfile} \mbox{}
%\lstinputlisting[style=DumuxCode, numbersep=5pt, firstline=28]{../../tutorial/tutorialspatialparameters_coupled.hh}
%\end{lst}
2008-09-25 11:55:15 -05:00
2012-02-13 12:44:10 -06:00
First, the spatial parameters type tag is created on line
\ref { tutorial-coupled:define-spatialparameters-typetag} . The type tag
2012-02-23 08:48:40 -06:00
for the problem is then derived from it. The \Dumux properties defined on
the type tag for the spatial parameters are, for example, the spatial
2012-02-13 12:44:10 -06:00
parameters class itself (line
\ref { tutorial-coupled:set-spatialparameters} ) or the capillary
2012-02-23 08:48:40 -06:00
pressure/relative permeability relations\footnote { Taken together, the
2012-02-13 12:44:10 -06:00
capillary pressure and the relative permeability relations are
called \textit { material law} .} which ought to be used by the
simulation (line
\ref { tutorial-coupled:rawlaw} \label { tutorial-coupled:materialLaw} ).
\Dumux provides several material laws in the folder
\verb +dumux/material/fluidmatrixinteractions+. The selected one --
here it is a relation according to a regularized version of
\textsc { Brooks} \& \textsc { Corey} -- is included in line
2012-02-23 08:48:40 -06:00
\ref { tutorial-coupled:rawLawInclude} .
After the selection, an adapter class is specified in line \ref { tutorial-coupled:eff2abs} to
translate between effective and absolute saturations. Like this,
residual saturations can be specified in a generic way. As only the employed
material law knows the names of the parameters which it
2012-02-13 12:44:10 -06:00
requires, it provides a parameter class
2012-02-23 08:48:40 -06:00
\texttt { RegularizedBrooksCoreyParams} which has the type
\texttt { Params} and which is defined in line
2012-02-13 12:44:10 -06:00
\ref { tutorial-coupled:matLawObjectType} . In this case, the spatial
parameters only require a single set of parameters which means that it
2012-02-23 08:48:40 -06:00
only requires a single material parameter object as can be seen in
2012-02-13 12:44:10 -06:00
line~\ref { tutorial-coupled:matParamsObject} .
In line \ref { tutorial-coupled:permeability} , a method returning the
intrinsic permeability is specified. As can be seen, the method has
2012-02-09 09:48:16 -06:00
to be called with three arguments:
2012-02-13 12:44:10 -06:00
\begin { description}
\item [\texttt{element}:] Just like for the problem itself, this
parameter describes the considered element by means of a \Dune
2012-02-23 08:48:40 -06:00
entity. Elements provide information about their geometry and
2012-02-13 12:44:10 -06:00
position and can be mapped to a global index.
2012-02-23 08:48:40 -06:00
\item [\texttt{fvElemGeom}:] It holds information about the finite-volume
geometry of the element induced by the box method.
\item [\texttt{scvIdx}:] This is the index of the sub-control volume of the
element which is considered. It is equivalent to the local index
of the vertex which corresponds to the considered control volume in
2012-02-13 12:44:10 -06:00
the element.
\end { description}
2012-02-23 08:48:40 -06:00
The intrinsic permeability is usually a tensor. Thus the method returns
a $ \texttt { dim } \times \texttt { dim } $ -matrix, where \texttt { dim} is the
2012-02-13 12:44:10 -06:00
dimension of the grid.
2010-12-10 09:05:12 -06:00
2012-02-09 09:48:16 -06:00
The method \texttt { porosity()} defined in line
2009-06-18 11:46:37 -05:00
\ref { tutorial-coupled:porosity} is called with the same arguments as
2012-02-13 12:44:10 -06:00
\texttt { intrinsicPermeability()} and returns a scalar value for
porosity dependent on the position in the domain.
2012-02-23 08:48:40 -06:00
Next, the method \texttt { materialLawParams()} , defined in line
\ref { tutorial-coupled:matLawParams} , returns the
\verb +materialLawParams+ object that is applied at the specified
2012-02-13 12:44:10 -06:00
position. Although in this case only one object is returned, in
general, the problem may be heterogeneous, which necessitates
returning different objects at different positions in space. While
the selection of the type of this object was already explained (line
\ref { tutorial-coupled:rawLawInclude} ), some specific parameter values
of the used material law, such as the \textsc { Brooks} \&
\textsc { Corey} parameters, are still needed. This is done in the
constructor at line \ref { tutorial-coupled:setLawParams} . Depending on
the type of the \texttt { materialLaw} object, the \texttt { set} -methods
might be different than those given in this example. The name of the
access / set functions as well as the rest of the implementation of
the material description can be found in
2011-02-04 09:11:02 -06:00
\verb +dumux/material/fluidmatrixinteractions/2p+.
2008-09-25 11:55:15 -05:00
2008-11-14 10:11:36 -06:00
\subsection { Exercises}
2008-11-26 02:29:57 -06:00
\label { tutorial-coupled:exercises}
2009-06-18 11:46:37 -05:00
The following exercises will give you the opportunity to learn how you
2012-02-13 12:44:10 -06:00
can change soil parameters, boundary conditions, run-time parameters
and fluid properties in \Dumux .
2008-11-26 01:56:50 -06:00
2008-11-14 10:11:36 -06:00
\subsubsection { Exercise 1}
2012-02-09 09:48:16 -06:00
\renewcommand { \labelenumi } { \alph { enumi} )} For Exercise 1 you have
to make only some small changes in the tutorial files.
2010-11-11 08:52:18 -06:00
2008-11-14 10:11:36 -06:00
\begin { enumerate}
2012-02-14 08:52:59 -06:00
\item \textbf { Running the Program} \\
2012-02-24 05:16:37 -06:00
To get an impression what the results should look like you can first run the original version of the coupled tutorial model by typing \texttt { ./tutorial\_ coupled} . Note, that the time-step size is automatically adapted during the simulation. For the visualization of the results using paraview please refer to section \ref { quick-start-guide} .
2010-11-11 08:52:18 -06:00
\item \textbf { Changing the Model Domain and the Boundary Conditions} \\
2009-06-18 11:46:37 -05:00
Change the size of the model domain so that you get a rectangle with
2012-02-14 11:11:38 -06:00
edge lengths of $ \text { x } = \unit [ 400 ] { m } $ and $ \text { y } = \unit [ 500 ] { m } $ and with
discretization lengths of $ \Delta \text { x } = \unit [ 20 ] { m } $ and $ \Delta
\text { y} = \unit [20] { m} $ .
2009-06-18 11:46:37 -05:00
Change the boundary conditions in the file
\texttt { tutorialproblem\_ coupled.hh} so that water enters from the
bottom and oil is extracted from the top boundary. The right and the
left boundary should be closed for water and oil fluxes.
Compile the main file by typing \texttt { make tutorial\_ coupled} and
2012-02-09 09:48:16 -06:00
run the model as explained above.
2008-11-14 10:11:36 -06:00
2012-02-23 08:48:40 -06:00
\item \textbf { Changing the Shape of the Discrete Elements} \\
2012-02-14 11:11:38 -06:00
Change the types of elements used for discretizing the domain. In line \ref { tutorial-coupled:set-gridcreator} of the problem file the type of gridcreator is chosen. By choosing a different grid creator you can discretize the domain with different elements. Hint: You can find gridcreators in \texttt { dumux/common/} . The shape of the employed elements can be visualized in paraview by choosing \texttt { Surface with Edges} .
2009-06-18 11:46:37 -05:00
\item \textbf { Changing Fluids} \\
2012-02-13 12:44:10 -06:00
Now you can change the fluids. Use DNAPL instead of Oil and Brine instead of Water. To do that, you have to select different components via the property system in the problem file:
2011-02-04 09:11:02 -06:00
\begin { enumerate}
2012-02-23 08:48:40 -06:00
\item Brine: Brine is thermodynamically very similar to pure water but also considers a fixed amount of salt in the liquid phase. Hence, the class \texttt { Dumux::Brine} uses a pure water class, such as \texttt { Dumux::H2O} , as a second template argument after the data type \texttt { <Scalar>} .
2012-02-13 12:44:10 -06:00
\item DNAPL: A standard set of chemical substances, such as Oil and Brine, is already included in the problem (via a list of \texttt { \# include ..} statements) and hence easily accessible by default. However, this is not the case for the class \texttt { Dumux::SimpleDNAPL} , which describes a simple \textbf { d} ense \textbf { n} on-\textbf { a} queous \textbf { p} hase \textbf { l} iquid and is located in the folder \texttt { dumux/material/components/} . Try to include the file and select the component as the non-wetting phase via the property system.
2010-11-11 08:52:18 -06:00
\end { enumerate}
2011-09-01 04:47:38 -05:00
If you want to take a closer look on how the fluid classes are defined and which substances are already available please browse through the files in the directory
2012-02-13 12:44:10 -06:00
\texttt { /dumux/material/components} and read chapter~\ref { sec:fluidframework} .
2009-06-18 11:46:37 -05:00
2012-02-13 13:16:29 -06:00
\item \textbf { Use a Full-Fledged Fluid System} \\
2012-02-13 12:44:10 -06:00
\Dumux usually describes fluid mixtures via \textit { fluid systems} , see also chapter \ref { sec:fluidframework} . In order to include a fluid system, you first have to comment out lines \ref { tutorial-coupled:2p-system-start} to \ref { tutorial-coupled:2p-system-end} in the problem file. If you use eclipse, this can easily be done by pressing \textit { Ctrl + Shift + 7} -- the same as to cancel the comment later on.\\
2012-02-23 08:48:40 -06:00
Now include the file \texttt { fluidsystems/h2oairfluidsystem.hh} in the material folder, and set a property \texttt { FluidSystem} with the appropriate type, i.e. \texttt { Dumux::H2OAirFluidSystem<TypeTag>} . However, this is a rather complicated fluid system which considers mixtures of components and also uses tabulated components that need to be initialized -- i.e. the tables need to be filled with values. The initialization of the fluid system is normally done in the constructor of the problem by calling \texttt { GET\_ PROP\_ TYPE(TypeTag, FluidSystem)::init();} . As water flow replacing a gas is much faster, test your simulation only until $ 2000 $ seconds and start with a time step of $ 1 $ second.\\
2012-02-13 12:44:10 -06:00
Please reverse the changes made in this part of the exercise, as we will continue to use immiscible phases from here on and hence do not need a complex fluid system.
2009-06-18 11:46:37 -05:00
\item \textbf { Changing Constitutive Relations} \\
2012-02-13 13:16:29 -06:00
Use an unregularized linear law with an entry pressure of $ p _ e = 0 . 0 \; \text { Pa } $ and maximal capillary pressure of e.g. $ p _ { c _ { max } } = 2000 . 0 \; \text { Pa } $ instead of using a
2010-12-10 09:05:12 -06:00
regularized Brooks-Corey law for the
2010-11-11 08:52:18 -06:00
relative permeability and for the capillary pressure saturation relationship. To do that you have
2010-04-12 10:32:36 -05:00
to change the file \texttt { tutorialspatialparameters\_ coupled.hh} .
You can find the material laws in the folder
2010-10-13 10:48:08 -05:00
\verb +dumux/material/fluidmatrixinteractions+. The necessary parameters
2010-11-11 08:52:18 -06:00
of the linear law and the respective \texttt { set} -functions can be found
in the file \\
\verb +dumux/material/fluidmatrixinteractions/2p/linearmaterialparams.hh+.
2008-11-14 10:11:36 -06:00
\item \textbf { Heterogeneities} \\
2009-06-18 11:46:37 -05:00
Set up a model domain with the soil properties given in Figure
\ref { tutorial-coupled:exercise1_ d} . Adjust the boundary conditions
2010-11-11 08:52:18 -06:00
so that water is again flowing from the left to the right of the
2012-02-07 11:53:55 -06:00
\begin { figure} [ht]
2012-02-13 13:16:29 -06:00
\psfrag { K1 =} { $ \mathbf { K } = 10 ^ { - 8 } \; \text { m } ^ 2 $ }
2008-11-14 10:11:36 -06:00
\psfrag { phi1 =} { $ \phi = 0 . 15 $ }
2012-02-13 13:16:29 -06:00
\psfrag { K2 =} { \textcolor { white} { $ \mathbf { K } = 10 ^ { - 9 } \; \text { m } ^ 2 $ } }
2008-11-14 10:11:36 -06:00
\psfrag { phi2 =} { \textcolor { white} { $ \phi = 0 . 3 $ } }
2012-02-13 13:16:29 -06:00
\psfrag { 600 m} { $ 600 \; \text { m } $ }
\psfrag { 300 m} { $ 300 \; \text { m } $ }
2008-11-14 10:11:36 -06:00
\centering
\includegraphics [width=0.5\linewidth,keepaspectratio] { EPS/exercise1_ c.eps}
2012-02-13 13:16:29 -06:00
\caption { Exercise 1f: Set-up of a model domain with a heterogeneity. $ \Delta x = 20 \; \text { m } $ $ \Delta y = 20 \; \text { m } $ .} \label { tutorial-coupled:exercise1_ d}
2008-11-14 10:11:36 -06:00
\end { figure}
2011-02-04 09:11:02 -06:00
domain. You can use the fluids of exercise 1c).\\
2012-02-13 13:16:29 -06:00
\textbf { Hint:} The current position of the control volume can be obtained using \texttt { element\allowbreak .geometry()\allowbreak .corner(scvIdx)} .\\
2012-02-13 12:44:10 -06:00
When does the front cross the material border? In paraview, the
2012-02-13 13:16:29 -06:00
animation view (\textit { View} $ \rightarrow $ \textit { Animation
2012-02-13 12:44:10 -06:00
View} ) is a convenient way to get a rough feeling of the time-step
sizes.
2008-11-14 10:11:36 -06:00
\end { enumerate}
\subsubsection { Exercise 2}
2011-02-25 08:01:32 -06:00
For this exercise you should create a new problem file analogous to
2012-02-13 12:44:10 -06:00
the file \texttt { tutorialproblem\_ coupled.hh} (e.g. with the name
\texttt { ex2\_ tutorialproblem\_ coupled.hh} and new spatial parameters
just like \texttt { tutorialspatialparameters\_ coupled.hh} . The new
problem file needs to
2012-02-23 08:48:40 -06:00
be included in the file \texttt { tutorial\_ coupled.cc} .
2012-02-13 12:44:10 -06:00
The new files should contain the definition of new classes with names
that relate to the file name, such as
\texttt { Ex2TutorialProblemCoupled} . Make sure that you also adjust the
guardian macros in lines \ref { tutorial-coupled:guardian1} and
\ref { tutorial-coupled:guardian1}
2012-02-23 08:48:40 -06:00
in the header files (e.g. change
\mbox { \texttt { DUMUX\_ TUTORIALPROBLEM\_ COUPLED\_ HH} } to\\
\mbox { \texttt { DUMUX\_ EX2\_ TUTORIALPROBLEM\_ COUPLED\_ HH} } ).
Besides adjusting the guardian macros, the new problem file should define and
2012-02-13 12:44:10 -06:00
use a new type tag for the problem as well as a new problem class
2012-02-23 08:48:40 -06:00
e.g. \mbox { \texttt { Ex2TutorialProblemCoupled} } . Make sure to assign your
2012-02-13 12:44:10 -06:00
newly defined spatial parameter class to the
\texttt { SpatialParameters} property for the new
2012-02-23 08:48:40 -06:00
type tag.
2012-02-13 12:44:10 -06:00
After this, change the run-time parameters so that they match the
domain described by figure \ref { tutorial-coupled:ex2_ Domain} . Adapt
the problem class so that the boundary conditions are consistent with
figure \ref { tutorial-coupled:ex2_ BC} . Initially, the domain is fully
saturated with water and the pressure is $ p _ w = 5 \times
10^ 5\; \text { Pa} $ . Oil infiltrates from the left side. Create a grid
with $ 20 $ cells in $ x $ -direction and $ 10 $ cells in $ y $ -direction. The
simulation time should be set to $ 10 ^ 6 \; \text { s } $ with an
initial time step size of $ 100 \; \text { s } $ .
2009-06-18 11:46:37 -05:00
Now include your new problem file in the main file and replace the
\texttt { TutorialProblemCoupled} type tag by the one you've created and
compile the program.
2008-11-14 10:11:36 -06:00
2012-02-07 11:53:55 -06:00
\begin { figure} [ht]
2012-02-13 12:44:10 -06:00
\psfrag { K1} { K $ = 10 ^ { - 7 } \; \text { m } ^ 2 $ }
2008-11-14 10:11:36 -06:00
\psfrag { phi1} { $ \phi = 0 . 2 $ }
2012-02-23 08:48:40 -06:00
\psfrag { Lin} { \textsc { Brooks} -\textsc { Corey} Law}
2012-02-13 12:44:10 -06:00
\psfrag { Lin2} { $ \lambda = 1 . 8 $ , $ p _ e = 1000 \; \text { Pa } $ }
\psfrag { K2} { K $ = 10 ^ { - 9 } \; \text { m } ^ 2 $ }
2008-11-14 10:11:36 -06:00
\psfrag { phi2} { $ \phi = 0 . 15 $ }
2012-02-13 12:44:10 -06:00
\psfrag { BC1} { \textsc { Brooks} -\textsc { Corey} Law}
\psfrag { BC2} { $ \lambda = 2 $ , $ p _ e = 1500 \; \text { Pa } $ }
\psfrag { H1y} { $ 50 \; \text { m } $ }
\psfrag { H2y} { $ 15 \; \text { m } $ }
\psfrag { H3y} { $ 20 \; \text { m } $ }
\psfrag { L1x} { $ 100 \; \text { m } $ }
\psfrag { L2x} { $ 50 \; \text { m } $ }
\psfrag { L3x} { $ 25 \; \text { m } $ }
2008-11-14 10:11:36 -06:00
\centering
\includegraphics [width=0.8\linewidth,keepaspectratio] { EPS/Ex2_ Domain.eps}
2008-11-26 02:29:57 -06:00
\caption { Set-up of the model domain and the soil parameters} \label { tutorial-coupled:ex2_ Domain}
2008-11-14 10:11:36 -06:00
\end { figure}
2012-02-07 11:53:55 -06:00
\begin { figure} [ht]
2012-02-13 12:44:10 -06:00
\psfrag { pw} { $ p _ w = 5 \times 10 ^ 5 \; \text { Pa } $ }
2008-11-14 10:11:36 -06:00
\psfrag { S} { $ S _ n = 1 . 0 $ }
2012-02-13 12:44:10 -06:00
\psfrag { qw} { $ q _ w = 2 \times 10 ^ { - 4 } \; \text { kg } / \text { m } ^ 2 \text { s } $ }
\psfrag { qo} { $ q _ n = 0 . 0 \; \text { kg } / \text { m } ^ 2 \text { s } $ }
2008-11-14 10:11:36 -06:00
\psfrag { no flow} { no flow}
\centering
\includegraphics [width=0.8\linewidth,keepaspectratio] { EPS/Ex2_ Boundary.eps}
2008-11-26 02:29:57 -06:00
\caption { Boundary Conditions} \label { tutorial-coupled:ex2_ BC}
2008-11-14 10:11:36 -06:00
\end { figure}
2008-09-25 03:11:11 -05:00
2010-11-11 08:52:18 -06:00
\begin { itemize}
2012-02-13 12:44:10 -06:00
\item Increase the simulation time to e.g. $ 4 \times 10 ^ 7 \; \text { s } $ . Investigate the saturation: Is the value range reasonable?
2010-11-11 08:52:18 -06:00
\item What happens if you increase the resolution of the grid?
\end { itemize}
2012-02-14 08:52:59 -06:00
\subsubsection { Exercise 3: Parameter File Input}
2012-02-13 12:44:10 -06:00
As you have experienced, compilation takes quite some time. Therefore,
\Dumux provides a simple method to read in parameters at run-time
2012-02-24 05:16:37 -06:00
via \textit { parameter input files} .
2012-02-12 06:26:04 -06:00
2012-02-13 12:44:10 -06:00
In the code, parameters can be read via the macro
\texttt { GET\_ RUNTIME\_ PARAM(TypeTag, Scalar,
MyWonderfulGroup.MyWonderfulParameter);} . At the end of the
simulation a list of parameters is printed if the command line option
\texttt { -printParams 1} is passed to the simulation. Add some (for
example \texttt { Newton.MaxSteps} and \texttt { EnableGravity} ) to the
parameter file \texttt { tutorial\_ coupled.input} and observe what
2012-02-14 08:52:59 -06:00
happens if they are modified. For more information about the input file please refer to section \ref { sec:inputFiles} .
2012-02-12 06:26:04 -06:00
2012-02-14 08:52:59 -06:00
\subsubsection { Exercise 4: Create a New Component}
2009-06-18 11:46:37 -05:00
2012-02-13 12:44:10 -06:00
Create a new file for the benzene component called \texttt { benzene.hh}
and implement a new component. (You may get a hint by looking at
2012-02-23 08:48:40 -06:00
existing components in the directory \verb +/dumux/material/components+). \\
2009-06-18 11:46:37 -05:00
Use benzene as a new fluid and run the model of Exercise 2 with water
2012-02-13 12:44:10 -06:00
and benzene. Benzene has a density of $ 889 . 51 \, \text { kg } /
\text { m} ^ 3$ and a viscosity of $ 0.00112 \, \text { Pa} \; \text { s} $ .
2009-06-18 11:46:37 -05:00
2011-01-19 10:31:28 -06:00
\clearpage \newpage
2010-11-10 04:15:37 -06:00
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "dumux-handbook"
%%% End: