Skip to content
Snippets Groups Projects
To learn more about this project, read the wiki.

Exercise #1 (DuMuX course)


## Problem set-up

N_2 is injected in an aquifer previously saturated with water with an injection rate of 0.001 kg/(s*m^2). The aquifer is situated 2700 m below sea level and the domain size is 60 m x 40 m. It consists of two layers, a moderately permeable one (\Omega_1) and a lower permeable one (\Omega_2).

Preparing the exercise

  • Navigate to the directory dumux/tutorial/ex1

Exercise 1 deals with two problems: a two-phase immiscible problem (2p) and a two-phase compositional problem (2p2c). They both set up the same scenario with the difference that the 2p2c assumes a miscible fluid state for the two fluids (water and gaseous N_2) and the 2p model assumes an immiscible fluid state.



Task 1: Getting familiar with the code


Locate all the files you will need for this exercise

  • The main file for the 2p problem : exercise1_2p.cc
  • The main file for the 2p2c problem : exercise1_2p2c.cc
  • The problem file for the 2p problem: injection2pproblem.hh
  • The problem file for the 2p2c problem: injection2p2cproblem.hh
  • The shared spatial parameters file: injection2pspatialparams.hh
  • The shared input file: exercise1.input



### Task 2: Compiling and running an executable
  • Change to the build-directory
cd ../../build-cmake/tutorial/ex1
  • Compile both executables exercise1_2p and exercise1_2p2c
make exercise1_2p exercise1_2p2c
  • Execute the two problems and inspect the result
./exercise1_2p exercise1.input
./exercise1_2p2c exercise1.input
  • you can look at the results with paraview
paraview injection-2p2c.pvd



### Task 3: Changing input parameters

In the input file exercise1.input you can find the following section

[SpatialParams]
EntryPressureAquitard = 4.5e4
EntryPressureAquifer = 1e4
  • Change the values for the aquitard entry pressure in the input file to a lower value and compare the results with the previous solution. You don't need to recompile the executable.



### Task 4: Runtime parameters

The injection rate is currently hard-coded in injection2p2cproblem.hh to 1e-4 kg/(s m^2).

 // set the Neumann values for the Nitrogen component balance
 // convert from units kg/(s*m^2) to mole/(s*m^2)
values[Indices::contiNEqIdx] = -1e-4/FluidSystem::molarMass(FluidSystem::nCompIdx);
values[Indices::contiWEqIdx] = 0.0;

We want to be able to set it at runtime. To this end,

  • use the following DuMuX macro to read a runtime parameter from the input file
// read the injection rate from the input file at run time
totalAreaSpecificInflow_ = getParam<TYPE>("GROUPNAME.PARAMNAME");
  • Replace <TYPE>,<GROUPNAME>,<PARAMNAME> by what is appropriate for your case:
    • <TYPE> is the type of the parameter to read
    • <GROUPNAME> is the group in the input file
    • <PARAMNAME> is the name of the parameter in the input file

Note that due to the way the macro works, the names are specified as plain text within the "quotation marks".<GROUPNAME> and <PARAMNAME> need to be separated by a dot (.). Follow the instructions given as a

// TODO: dumux-course-task

in the injection2p2cproblem.hh file and also remember to also set the parameter totalAreaSpecificInflow in the input file.

  • Check the influence of that parameter on the simulation result by rerunning the simulation with different injection rates. Remember to also set the parameter totalAreaSpecificInflow in the input file.

Since you have changed your header file, you have to recompile the program.




### 5. Setting up a new executable (for a non-isothermal simulation)
  • Copy the main file exercise1_2p.cc and rename it to exercise1_2pni.cc
  • In exercise1_2pni.cc, include the header injection2pniproblem.hh instead of injection2pproblem.hh.
  • In exercise1_2pni.cc, change Injection2pCCTypeTag to Injection2pNICCTypeTag in the line using TypeTag = TTAG(Injection2pCCTypeTag);
  • Add a new executable in CMakeLists.txt by adding the lines
# the two-phase non-isothermal simulation program
dune_add_test(NAME exercise1_2pni
              SOURCES exercise1_2pni.cc
              CMD_ARGS exercise1.input)
  • Test that everything compiles without error
make # should rerun cmake
make exercise1_2pni # builds new executable



### 6. Setting up a non-isothermal __2pni__ test problem
  • Open the file injection2pniproblem.hh. It is a copy of the injection2pproblem.hh with some useful comments on how to implement a non-isothermal model. Look for comments containing
// TODO: dumux-course-task
  • The following set-up should be realized:

    Boundary conditions: Dirichlet conditions for the temperature with a temperature gradient of 0.03 K/m and a starting temperature of 283 K.

    Initial conditions: The same temperature gradient as in the boundary conditions with an additional lens (with position: 20 < x < 30, 5 < y < 35), which has an initial temperature of 380 K.

The non-isothermal model requires additional spatial parameters like the thermal conductivity. They are already implemented in injection2pspatialparams.hh, you just need to uncomment them.