Commit 36aa1820 authored by Ned Coltman's avatar Ned Coltman
Browse files

Merge branch 'feature/propertiesheader_ex-fluidsystem' into 'master'

Fluidsystem Exercise with separate properties header

See merge request !96
parents 05735f09 f1febd5d
Pipeline #1826 passed with stage
in 32 seconds
......@@ -24,65 +24,11 @@
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_B_PROBLEM_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_B_PROBLEM_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p2c/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// The base porous media box problem
#include <dumux/porousmediumflow/problem.hh>
#include <dumux/common/properties.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
// The fluid system that is created in this exercise
#include "fluidsystems/h2omycompressiblecomponent.hh"
namespace Dumux{
// Forward declaration of the problem class
template <class TypeTag> class ExerciseFluidsystemProblemTwoPTwoC;
namespace Properties {
// Create a new type tag for the problem
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoPTwoC { using InheritsFrom = std::tuple<TwoPTwoC, BoxModel>; };
} // end namespace TTag
// Set the "Problem" property
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = ExerciseFluidsystemProblemTwoPTwoC<TypeTag>; };
// Set the spatial parameters
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = ExerciseFluidsystemSpatialParams<FVGridGeometry, Scalar>;
};
// Set grid and the grid creator to be used
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = Dune::YaspGrid<2>; };
// The fluid system property
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::H2OMyCompressibleComponent<Scalar>;
};
}
namespace Dumux {
/*!
* \ingroup TwoPBoxModel
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief The properties file for two phase-two component exercise-fluidsystem.
*/
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_B_PROPERTIES_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_B_PROPERTIES_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p2c/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
// The fluid system that is created in this exercise
#include "fluidsystems/h2omycompressiblecomponent.hh"
// The problem file, where setup-specific boundary and initial conditions are defined.
#include"2p2cproblem.hh"
namespace Dumux::Properties {
// Create a new type tag for the problem
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoPTwoC { using InheritsFrom = std::tuple<TwoPTwoC, BoxModel>; };
} // end namespace TTag
// Set the "Problem" property
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = ExerciseFluidsystemProblemTwoPTwoC<TypeTag>; };
// Set the spatial parameters
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = ExerciseFluidsystemSpatialParams<FVGridGeometry, Scalar>;
};
// Set grid and the grid creator to be used
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = Dune::YaspGrid<2>; };
// The fluid system property
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::H2OMyCompressibleComponent<Scalar>;
};
} // end namespace Dumux::Properties
#endif
......@@ -24,90 +24,18 @@
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_A_PROBLEM_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_A_PROBLEM_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// The porous media base problem
#include <dumux/porousmediumflow/problem.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
#include <dumux/common/properties.hh>
// The water component
#include <dumux/material/components/tabulatedcomponent.hh>
#include <dumux/material/components/h2o.hh>
// The components that will be created in this exercise
// TODO: dumux-course-task 2.2
//****** Include the corresponding header for the task *****//
#include "components/myincompressiblecomponent.hh"
// #include "components/mycompressiblecomponent.hh"
// We will only have liquid phases here
#include <dumux/material/fluidsystems/1pliquid.hh>
// The two-phase immiscible fluid system
#include <dumux/material/fluidsystems/2pimmiscible.hh>
// The interface to create plots during simulation
#include <dumux/io/gnuplotinterface.hh>
namespace Dumux{
// Forward declaration of the problem class
template <class TypeTag> class ExerciseFluidsystemProblemTwoP;
namespace Properties {
// Create a new type tag for the problem
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoP { using InheritsFrom = std::tuple<TwoP, BoxModel>; };
} // end namespace TTag
// Set the "Problem" property
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoP> { using type = ExerciseFluidsystemProblemTwoP<TypeTag>; };
// Set the spatial parameters
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::ExerciseFluidsystemTwoP>
{
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = ExerciseFluidsystemSpatialParams<FVGridGeometry, Scalar>;
};
// Set grid to be used
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoP> { using type = Dune::YaspGrid<2>; };
// we use the immiscible fluid system here
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoP>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using TabulatedH2O = Components::TabulatedComponent<Components::H2O<Scalar>>;
using LiquidWaterPhase = typename FluidSystems::OnePLiquid<Scalar, TabulatedH2O>;
// TODO: dumux-course-task 2.2
//****** Select the corresponding component for the task *****//
// Uncomment first line and comment second line for using the compressible component
using LiquidMyComponentPhase = typename FluidSystems::OnePLiquid<Scalar, MyIncompressibleComponent<Scalar> >;
// using LiquidMyComponentPhase = typename FluidSystems::OnePLiquid<Scalar, MyCompressibleComponent<Scalar> >;
public:
using type = typename FluidSystems::TwoPImmiscible<Scalar, LiquidWaterPhase, LiquidMyComponentPhase>;
};
}
namespace Dumux {
/*!
* \ingroup TwoPBoxModel
......@@ -317,6 +245,7 @@ private:
Scalar depthBOR_; //! depth at the bottom of the reservoir
Dumux::GnuplotInterface<double> gnuplot_; //! collects data for plotting
};
}
} // end namespace Dumux
#endif
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief The properties file for two phase exercise-fluidsystem.
*/
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_A_PROPERTIES_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_A_PROPERTIES_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
// The components that will be created in this exercise
// TODO: dumux-course-task 2.2
//****** Include the corresponding header for the task *****//
#include "components/myincompressiblecomponent.hh"
// #include "components/mycompressiblecomponent.hh"
// We will only have liquid phases here
#include <dumux/material/fluidsystems/1pliquid.hh>
// The two-phase immiscible fluid system
#include <dumux/material/fluidsystems/2pimmiscible.hh>
// The interface to create plots during simulation
#include <dumux/io/gnuplotinterface.hh>
// The problem file, where setup-specific boundary and initial conditions are defined.
#include"2pproblem.hh"
namespace Dumux::Properties {
// Create a new type tag for the problem
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoP { using InheritsFrom = std::tuple<TwoP, BoxModel>; };
} // end namespace TTag
// Set the "Problem" property
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoP> { using type = ExerciseFluidsystemProblemTwoP<TypeTag>; };
// Set the spatial parameters
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::ExerciseFluidsystemTwoP>
{
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = ExerciseFluidsystemSpatialParams<FVGridGeometry, Scalar>;
};
// Set grid to be used
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoP> { using type = Dune::YaspGrid<2>; };
// we use the immiscible fluid system here
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoP>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using TabulatedH2O = Components::TabulatedComponent<Components::H2O<Scalar>>;
using LiquidWaterPhase = typename FluidSystems::OnePLiquid<Scalar, TabulatedH2O>;
// TODO: dumux-course-task 2.2
//****** Select the corresponding component for the task *****//
// Uncomment first line and comment second line for using the compressible component
using LiquidMyComponentPhase = typename FluidSystems::OnePLiquid<Scalar, MyIncompressibleComponent<Scalar> >;
// using LiquidMyComponentPhase = typename FluidSystems::OnePLiquid<Scalar, MyCompressibleComponent<Scalar> >;
public:
using type = typename FluidSystems::TwoPImmiscible<Scalar, LiquidWaterPhase, LiquidMyComponentPhase>;
};
} // end namespace Dumux::Properties
#endif
......@@ -19,8 +19,10 @@ Locate all the files you will need for this exercise
* The shared __main file__ : `main.cc`
* The __input file__ for part a: `aparams.input`
* The __problem file__ for part a: `2pproblem.hh`
* The __properties file__ for part a: `2pproperties.hh`
* The __input file__ for part b: `bparams.input`
* The __problem file__ for part b: `2p2cproblem.hh`
* The __properties file__ for part b: `2p2cproperties.hh`
* The __spatial parameters file__: `spatialparams.hh`
Furthermore you will find the following folders:
......@@ -32,7 +34,7 @@ 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 __properties file__, i.e. for this part of the exercise the codes shown below is taken from the `2pproperties.hh` file.
In this part of the exercise we will consider a system consisting of two immiscible phases. Therefore, the _TypeTag_ for this problem (`ExerciseFluidsystemTwoP`) derives from
the `TwoP` _TypeTag_ (immiscible two-phase model properties) and the `BoxModel` _TypeTag_ (specifies properties of the discretization scheme).
......@@ -61,7 +63,7 @@ while the `BoxModel` _TypeTag_ can be found in the `discretization/box.hh` heade
For a cell-centered scheme, you could derive from `CCTpfaModel` or `CCMpfaModel` instead (and, of course, include the right headers).
As one of the two phases 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:
As one of the two phases we want to use water and we want to precompute tables on which the properties are then interpolated in order to save computational time. Since we need this part in both problem file and properties file, we have to include the following two headers in our problem file, i.e. `2pproblem.hh` file, and the properties file has access to them through problem file.
```c++
// The water component
......@@ -162,7 +164,7 @@ We now want to implement a pressure-dependent density for our component. Open th
$`\displaystyle \rho_{MyComp} = \rho_{min} + \frac{ \rho_{max} - \rho_{min} }{ 1 + \rho_{min}*e^{-1.0*k*(\rho_{max} - \rho_{min})*p} } `$
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 the corresponding line. Furthermore, the new component has to be set as a liquid phase in the fluid system. To do so, search for `TODO: dumux-course-task 2.2`. Comment out the corresponding line and uncomment the other. The density distribution of this phase (rhoN) 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 `2pproperties.hh` file by uncommenting the corresponding line. Furthermore, the new component has to be set as a liquid phase in the fluid system. To do so, search for `TODO: dumux-course-task 2.2`. Comment out the corresponding line and uncomment the other. The density distribution of this phase (rhoN) at the final simulation time should look like this:
![](../extradoc/exercise-fluidsystem_a_solution2.png)
......@@ -173,8 +175,9 @@ Compare the gnuplot output to the following plot of the density function from ab
### 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_ (`ExerciseFluidsystemTwoPTwoC`) from a _TypeTag_ (`TwoPTwoC`) that holds the miscible two-phase
two-component model properties:
The problem file and properties file for this part of the exercise are `2p2cproblem.hh` and `2p2cproperties.hh`, respectively.
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_ (`ExerciseFluidsystemTwoPTwoC`) from a _TypeTag_ (`TwoPTwoC`) that holds the miscible two-phase
two-component model properties:
```c++
// The numerical model
......
......@@ -32,8 +32,8 @@
#include <dune/grid/io/file/vtk.hh>
#include <dune/istl/io.hh>
#include "2pproblem.hh"
#include "2p2cproblem.hh"
#include "2pproperties.hh"
#include "2p2cproperties.hh"
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
......
......@@ -24,65 +24,11 @@
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_B_PROBLEM_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_B_PROBLEM_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p2c/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// The base porous media box problem
#include <dumux/porousmediumflow/problem.hh>
#include <dumux/common/properties.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
// The fluid system that is created in this exercise
#include "fluidsystems/h2omycompressiblecomponent.hh"
namespace Dumux{
// Forward declaration of the problem class
template <class TypeTag> class ExerciseFluidsystemProblemTwoPTwoC;
namespace Properties {
// Create a new type tag for the problem
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoPTwoC { using InheritsFrom = std::tuple<TwoPTwoC, BoxModel>; };
} // end namespace TTag
// Set the "Problem" property
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = ExerciseFluidsystemProblemTwoPTwoC<TypeTag>; };
// Set the spatial parameters
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = ExerciseFluidsystemSpatialParams<FVGridGeometry, Scalar>;
};
// Set grid and the grid creator to be used
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = Dune::YaspGrid<2>; };
// The fluid system property
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::H2OMyCompressibleComponent<Scalar>;
};
}
namespace Dumux {
/*!
* \ingroup TwoPBoxModel
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief The properties file for two phase-two component exercise-fluidsystem.
*/
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_B_PROPERTIES_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_B_PROPERTIES_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p2c/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
// The fluid system that is created in this exercise
#include "fluidsystems/h2omycompressiblecomponent.hh"
// The problem file, where setup-specific boundary and initial conditions are defined.
#include"2p2cproblem.hh"
namespace Dumux::Properties {
// Create a new type tag for the problem
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoPTwoC { using InheritsFrom = std::tuple<TwoPTwoC, BoxModel>; };
} // end namespace TTag
// Set the "Problem" property
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = ExerciseFluidsystemProblemTwoPTwoC<TypeTag>; };
// Set the spatial parameters
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = ExerciseFluidsystemSpatialParams<FVGridGeometry, Scalar>;
};
// Set grid and the grid creator to be used
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC> { using type = Dune::YaspGrid<2>; };
// The fluid system property
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoC>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::H2OMyCompressibleComponent<Scalar>;
};
} // end namespace Dumux::Properties
#endif
......@@ -24,88 +24,18 @@
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_A_PROBLEM_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_A_PROBLEM_HH
// The grid manager
#include <dune/grid/yaspgrid.hh>
// The numerical model
#include <dumux/porousmediumflow/2p/model.hh>
// The box discretization
#include <dumux/discretization/box.hh>
// The porous media base problem
#include <dumux/porousmediumflow/problem.hh>
// Spatially dependent parameters
#include "spatialparams.hh"
#include <dumux/common/properties.hh>
// The water component
#include <dumux/material/components/tabulatedcomponent.hh>
#include <dumux/material/components/h2o.hh>
// The components that will be created in this exercise
#include "components/myincompressiblecomponent.hh"
#include "components/mycompressiblecomponent.hh"
// We will only have liquid phases here