diff --git a/slides/materialsystem.md b/slides/materialsystem.md index 22021f03eb3b82cb26e973caca96983322cf65f3..ac0c8bd944b246194b6f2d33ce9e9797bcb9427f 100644 --- a/slides/materialsystem.md +++ b/slides/materialsystem.md @@ -1,27 +1,38 @@ --- -title: The DuMuX Material System +title: The DuMu^x^ Material System --- +# Challenge -## Challenges in simulating porous media +## Flow in porous media * Highly heterogeneous distribution of parameters and complex nonlinear material laws - * Strong interconnection of properties $\rightarrow$ difficult to achieve __modularity__ +$\rightarrow$ this also applies to other complex nonlinear equation systems. + +# How to achieve modularity? + ## How to achieve modularity? -- User-defined parameters and relationships: +* User-defined parameters and functional relationships: - Components / Fluid system / Binary coefficients - Solid system - Fluid-matrix interactions - Chemistry -- Dumux-specific containers and solvers: - - Fluid states - - Solid states - - Constraint solvers +* State representations and solvers: + - Fluid states (data) + - Solid states (data) + - Constraint solvers / "flash" (algorithm) + +## How to achieve modularity? +There is a library of `Components`, +`FluidSystems`, `BinaryCoefficients` +available in DuMu^x^. Can be used as is or can +be a good start for a user implementation. +More resources can be found [in the code documentation](https://dumux.org/docs/doxygen/master/group___material.html). # Components @@ -29,14 +40,41 @@ title: The DuMuX Material System * Define **Thermodynamic relations** (e.g. molar mass, vapor pressure, density) of a **single chemical species** or a fixed mixture of species * Provide a convenient way to access these quantities -* Not supposed to be used by models directly ## Example implementations -* _H2O_ : pure water, properties by IAPWS-97 or simplified - +* _H2O_ : pure water properties by IAPWS-97 +* _SimpleH2O_ : A simple water implementation at standard conditions * _Brine_ : water with a given salt concentration +* Many more, see [DuMu^x^ components docs](https://dumux.org/docs/doxygen/master/namespace_dumux_1_1_components.html) + +## Example interfaces + +```cpp +static Scalar gasDensity(Scalar temperature, Scalar pressure) +{ + // Assume an ideal gas + return IdealGas::density(molarMass(), temperature, pressure); +} +``` +## Example interfaces + +```cpp +static Scalar gasHeatCapacity(Scalar temperature, Scalar pressure) +{ + constexpr Scalar cpVapA = 19.25; + constexpr Scalar cpVapB = 0.05213; + constexpr Scalar cpVapC = 1.197e-5; + constexpr Scalar cpVapD = -1.132e-8; + + return 1/molarMass()*( + cpVapA + temperature*( + cpVapB/2 + temperature*(cpVapC/3 + temperature*(cpVapD/4)) + ) + ); +} +``` # Fluid systems @@ -50,9 +88,27 @@ Express the **thermodynamic relations between fluid quantities** (e.g. calculati ## Example implementations * _TwoPImmiscible_ : two immiscible fluid phases - * _H2OAir_ : gas and liquid phase with components water and air +* Many more, see [DuMu^x^ fluid systems docs](https://dumux.org/docs/doxygen/master/namespace_dumux_1_1_fluid_systems.html) +## Example interface + +```cpp +template <class FluidState> +static Scalar heatCapacity(const FluidState& fluidState, int phaseIdx) +{ + const Scalar temperature = fluidState.temperature(phaseIdx); + const Scalar pressure = fluidState.pressure(phaseIdx); + if (phaseIdx == liquidPhaseIdx) + return H2O::liquidHeatCapacity(temperature, pressure); // neglect air + else if (phaseIdx == gasPhaseIdx) + return Air::gasHeatCapacity(temperature, pressure) + * fluidState.moleFraction(gasPhaseIdx, AirIdx) + + H2O::gasHeatCapacity(temperature, pressure) + * fluidState.moleFraction(gasPhaseIdx, H2OIdx); + ... +} +``` # Binary coefficients @@ -66,6 +122,23 @@ Express the **thermodynamic relations between fluid quantities** (e.g. calculati ## Example implementations * _H2O_Air_ : Henry coefficient, gas diffusion coefficient, liquid diffusion coefficent for water and air +* More, see [DuMu^x^ binary coefficients docs](https://dumux.org/docs/doxygen/master/namespace_dumux_1_1_binary_coeff.html) + +## Example interface + +```cpp +template <class Scalar> +static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure) +{ + // _H2O_Air_ + constexpr Scalar theta = 1.8; + constexpr Scalar Daw = 2.13e-5; /* reference value */ + constexpr Scalar pg0 = 1.e5; /* reference pressure */ + constexpr Scalar T0 = 273.15; /* reference temperature */ + using std::pow; + return Daw*(pg0/pressure)*pow((temperature/T0), theta); +} +``` # Solid systems @@ -122,51 +195,33 @@ p_c = p_d S_e^{-1/\lambda} $\rightarrow$ the empirical parameters $p_d$ and $\lambda$ have to be specified -# Chemistry - -## Chemistry - -Reactions between different components. They are extra models or are incoporated via the introduction of a source term. - -<img src="img/chemistry.png" width="350"/> - - -## Example implementations - -Expresses the **electrochemical models for a fuel cell application**: - -* _Electrochemistry_ : for isothermal system -* _Electrochemistryni_ : for non-isothermal system - - # Fluid states ## Fluid states - * **Store** the complete thermodynamic configuration of a system at a given spatial and temporal position (e.g. saturation, mole fraction, enthalpy) - * **Provide access** methods to all thermodynamic quantities (e.g. saturation, mole fraction, enthalpy) +* **Store** the complete thermodynamic configuration of a system at a given spatial and temporal position (e.g. saturation, mole fraction, enthalpy) +* **Provide access** methods to all thermodynamic quantities (e.g. saturation, mole fraction, enthalpy) <img src="img/fluidstate.png" width="800"/> ## Example implementations - * _ImmiscibleFluidState_ : assumes immiscibility of the fluid phases. Phase compositions and fugacity coefficients do not need to be stored explicitly. - * _CompositionalFluidState_ : assumes thermodynamic equilibrium, only a single temperature needs to be stored. +* _ImmiscibleFluidState_ : assumes immiscibility of the fluid phases. Phase compositions and fugacity coefficients do not need to be stored explicitly. +* _CompositionalFluidState_ : assumes thermodynamic equilibrium, only a single temperature needs to be stored. # Solid states ## Solid states - * **Store** the complete solid configuration of a system at a given spatial and temporal position (e.g. solid volume fractions, solid heat capacity) - * **Provide** access methods to all solid quantities (e.g. porosity, density, temperature) +* **Store** the complete solid configuration of a system at a given spatial and temporal position (e.g. solid volume fractions, solid heat capacity) +* **Provide** access methods to all solid quantities (e.g. porosity, density, temperature) <img src="img/solidstate.png" width="800"/> ## Example implementations * _InertSolidState_ : assumes an inert solid phase. Solid volume fractions do not change. This is the **default**. - * _CompositionalSolidState_ : assumes a solid matrix composed out of two components. The volume fractions can change and properties such as heat capacity are adapted. # Constraint Solvers @@ -191,8 +246,8 @@ _CompositionFromFugacities_ : takes all component fugacities, the temperature an ## Example: 2 phases, miscible - * Components: _H2O_, _Air_ - * Fluid system: _TwoPTwoC_ +* Components: _H2O_, _Air_ +* Fluid system: _TwoPTwoC_ ## Relevant headers @@ -230,8 +285,8 @@ public: ## Example: 2 phases, miscible - * Components: _CaO_, _CaO2H2_ (slaked lime) - * Solid system: _OnePNCMin_ +* Components: _CaO_, _CaO2H2_ (slaked lime) +* Solid system: _OnePNCMin_ ## Specify solid system in properties file: @@ -262,4 +317,4 @@ struct SolidSystem<TypeTag, TTag::ThermoChem> ## First step: -Go to <https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-fluidsystem> and check out the README +Go to [Fluidsystem exercise](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/-/tree/master/exercises/exercise-fluidsystem#exercise-fluidsystem-dumux-course)