From 96f354391952c9a7d5dde8f6fac573f5e91a5d05 Mon Sep 17 00:00:00 2001 From: Martin Schneider <martin.schneider@iws.uni-stuttgart.de> Date: Wed, 10 Jul 2024 14:46:13 +0200 Subject: [PATCH] [ex][model][slides] Update Model Exercise Slides [ex][model][slides] Replace discrete eq from first model slide [ex][model][slides] move area in fluxes [slides] fix typo [ex][model][slides] Change discrete eq [ex][model][slides] Proposel for new property instructions --- slides/model.md | 87 ++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/slides/model.md b/slides/model.md index fc9fb5ad..1b84b164 100644 --- a/slides/model.md +++ b/slides/model.md @@ -9,29 +9,27 @@ A DuMu^x^ model is an implementation of a discretized **mathematical model**, ge ## What is a DuMu^x^ model Mathematical model (PDE): -$\begin{equation*} -\small +$$ +\begin{aligned} \frac{\partial S(u)}{\partial t} + \nabla \cdot \mathbf{F}(u) = q, \quad \forall (t,\mathbf{x}) \in (0,T] \times \Omega -\end{equation*}$ +\end{aligned} +$$ <img src=img/model_domain_discretization.png width="100%"> -Discrete model, e.g. using finite volumes: -$\begin{equation*} -\small -|B| \frac{S_h(\mathbf{u}^{n+1}_h) - S_h(\mathbf{u}^{n}_h)}{\Delta t} + \sum_{\sigma \in \Sigma_B} F_{B,\sigma}(\mathbf{u}^{n+1}_h) = \int_{B} q^{n+1} \, dx, \quad \forall t_{n+1}\leq T, \; \forall B -\end{equation*}$ - ## What is a DuMu^x^ model -Discrete model, e.g. using finite volumes: -$\begin{equation*} +Discrete model using finite volumes: +$$ +\begin{aligned} \small -|B| \frac{S_h(\mathbf{u}^{n+1}_h) - S_h(\mathbf{u}^{n}_h)}{\Delta t} + \sum_{\sigma \in \Sigma_B} F_{B,\sigma}(\mathbf{u}^{n+1}_h) = \int_{B} q \, dx, \quad \forall t_{n+1}\leq T, \; \forall B -\end{equation*}$ +|B| \frac{S_B(\mathbf{u}^{n+1}_h) - S_B(\mathbf{u}^{n}_h)}{\Delta t} + \sum_{\sigma \in \Sigma_B} F_{B,\sigma}(\mathbf{u}^{n+1}_h) = |B| q_B(\mathbf{u}^{n+1}_h), \quad \forall t_{n+1}\leq T, \; \forall B +\end{aligned} +$$ -* $S_h:$ storage term +* $B:$ control volume +* $S_B:$ storage term * $F_{B,\sigma}:$ flux term over sub control volume face (scvf) -* $q:$ source term +* $q_B:$ source term Where to implement these terms in DuMu^x^? @@ -51,9 +49,11 @@ Implements terms of a PDE in the functions ## Example: Diffusion equation Mathematical model (PDE): -$\begin{equation} -\frac{\partial c}{\partial t} - \nabla \cdot (D \nabla c) = 0 \:\: \mathrm{in}\; \Omega \times (0,T] \\ -\end{equation}$ +$$ +\begin{aligned} +\frac{\partial c}{\partial t} - \nabla \cdot (D \nabla c) = 0 \:\: \mathrm{in}\; \Omega \times (0,T] +\end{aligned} +$$ with @@ -65,9 +65,11 @@ with ## Example: Diffusion equation Discrete model using the Box discretization: -$\begin{equation} -\vert B \vert \frac{c_B^{n+1}-c_B^{n}}{\Delta t} - \sum_{\sigma \in \Sigma_{B}} \left[ D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma \vert \right] = 0, -\end{equation}$ +$$ +\begin{aligned} +\vert B \vert \frac{c_B^{n+1}-c_B^{n}}{\Delta t} - \sum_{\sigma \in \Sigma_{B}} \vert \sigma \vert \left[ D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \right] = 0, +\end{aligned} +$$ with @@ -79,11 +81,13 @@ with ## Example: Diffusion equation Discrete model using the Box discretization: -$\begin{equation} -\vert B \vert \frac{c_B^{n+1}-c_B^{n}}{\Delta t} - \sum_{\sigma \in \Sigma_{B}} \left[ D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma \vert \right] = 0, -\end{equation}$ +$$ +\begin{aligned} +\vert B \vert \frac{c_B^{n+1}-c_B^{n}}{\Delta t} - \sum_{\sigma \in \Sigma_{B}} \vert \sigma \vert \left[ D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \right] = 0, +\end{aligned} +$$ -<img src=img/box_scv_scvf.png width="90%"> +<img src=img/box_scv_scvf.png width="80%"> ## `LocalResidual` The local residual of the diffusion model: @@ -112,9 +116,11 @@ NumEqVector computeStorage(const Problem& problem, ## Flux term -$\begin{equation} -F_{B,\sigma} = -D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma \vert -\end{equation}$ +$$ +\begin{aligned} +F_{B,\sigma} = - \vert \sigma \vert D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} +\end{aligned} +$$ with @@ -182,9 +188,19 @@ For its implementation different model-specific properties have to be set # Model properties +## Model properties + +All properties are defined within the namespace `Dumux::Properties`. + +```cpp +namespace Dumux::Properties { + //define all properties +} // end namespace Dumux::Properties +``` ## Model type tag -The property tag is an empty struct with the respective name, e.g. `DiffusionModel` +The property type tag is an empty struct with the respective name, e.g. `DiffusionModel`. +All properties related to the desired model can be attributed using the property type tag. ```cpp namespace Dumux::Properties::TTag { @@ -192,18 +208,11 @@ namespace Dumux::Properties::TTag { struct DiffusionModel {}; } // end namespace Dumux::Properties::TTag ``` -## Model properties -We can set nodel properties for the `DiffusionModel` type tag - -All properties are defined within the namespace `Dumux::Properties` -```cpp -namespace Dumux::Properties { - //define all properties -} // end namespace Dumux::Properties -``` ## Defining model properties + The type of the local residual is the class `DiffusionModelLocalResidual` defined from earlier + ```cpp template<class TypeTag> struct LocalResidual<TypeTag, TTag::DiffusionModel> @@ -211,7 +220,9 @@ struct LocalResidual<TypeTag, TTag::DiffusionModel> ``` ## Defining model properties + The model traits specify information about the model: + ```cpp template<class TypeTag> struct ModelTraits<TypeTag, TTag::DiffusionModel> -- GitLab