dumux issueshttps://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/issues2024-03-25T10:31:55Zhttps://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/issues/1256[porousmedia] Energy balance implementation2024-03-25T10:31:55ZTimo Kochtimokoch@math.uio.no[porousmedia] Energy balance implementationWe currently have some inconsistencies in the energy balance for porous media. For thermal equilibrium models, we implement
```math
\frac{\partial \left( n_s \rho_s u_s + n_f \rho_f u_f \right)}{\partial t} =
- \nabla\cdot{\left( \rho...We currently have some inconsistencies in the energy balance for porous media. For thermal equilibrium models, we implement
```math
\frac{\partial \left( n_s \rho_s u_s + n_f \rho_f u_f \right)}{\partial t} =
- \nabla\cdot{\left( \rho_f h_f \boldsymbol{v}_f \right)} + \nabla\cdot{\left( \left\lbrace n_f \lambda_f + n_s \lambda_s \right\rbrace \nabla T \right)}.
```
but the correct balance would be
```math
\frac{\partial \left( n_s \rho_s u_s + n_f \rho_f \left\lbrace u_f - g z \right\rbrace \right)}{\partial t} =
- \nabla\cdot{\left( \left\lbrace \rho_f h_f - \rho_f g z\right\rbrace \boldsymbol{v}_f \right)} + \nabla\cdot{\left( \left\lbrace n_f \lambda_f + n_s \lambda_s \right\rbrace \nabla T \right)}.
```
This might seem like a small change but the difference actually shows some inconsistency. It's not just an omitted term.
Only looking at the fluid balance, the gravity term can also be written like this
```math
\frac{\partial \left( n_f \rho_f u_f \right)}{\partial t} = - \nabla\cdot{\left( \rho_f h_f \boldsymbol{v}_f \right)} + \nabla\cdot{\left(n_f \lambda_f \nabla T \right)} + \rho_f \boldsymbol{v}_f \cdot \boldsymbol{g} = - \nabla\cdot{\left( (\rho_f u_f + p) \boldsymbol{v}_f \right)} + \nabla\cdot{\left(n_f \lambda_f \nabla T \right)} + \rho_f \boldsymbol{v}_f \cdot \boldsymbol{g}.
```
Essentially, if we consider gravity in Darcy's law, we should also consider the corresponding term in the energy balance for consistency.
Subtracting the momentum balance multiplied by the velocity gives the balance of internal energy (non-conservative because only total energy is conserved):
```math
\frac{\partial \left( n_f \rho_f u_f \right)}{\partial t} = - \nabla\cdot{\left( \rho_f u_f \boldsymbol{v}_f \right)} + \nabla\cdot{\left(n_f \lambda_f \nabla T \right)} \underbrace{- p \left(\nabla\cdot{\boldsymbol{v}_f}\right)}_{\text{volume work}} \underbrace{+ \mu_f \boldsymbol{K}^{-1} \boldsymbol{v}_f \cdot \boldsymbol{v}_f}_{\text{viscous dissipation}}
```
This shows that there are conversion terms resulting in modification of the internal energy. Even if we assume that one of these is small, or both of these are small, we don't arrive at the implemented equation. If we don't have the gravity/potential energy term in the original balance, there would be an additional gravity term popping up here that mingles with the other energy conversion terms.
The gravity term vanishes if the fluid only moves perpendicular to the gravity field. However, for scenarios with strong upward/downward movement, this should have an effect.3.9Tufan GhoshTufan Ghoshhttps://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/issues/1160Prototypical math models for testing and as examples2023-09-23T18:14:28ZTimo Kochtimokoch@math.uio.noPrototypical math models for testing and as examples__Proposed feature__:
Many models in Dumux are relatively general and support many variations. This can also often be distracting both when understanding the code and when thinking about general concepts and structure. I propose (someth...__Proposed feature__:
Many models in Dumux are relatively general and support many variations. This can also often be distracting both when understanding the code and when thinking about general concepts and structure. I propose (something similar has been proposed in dumux-repositories/dumux-course#17) to add some models with simple structure. For example:
* Poisson's equation
* Heat equation / Diffusion equation
* Wave equation
* Burger's equation
* Cahn-Hillard equation(s)
* (Multidomain) Incompressible Stokes equations
These prototypical models have the advantage that we can mostly assume scalar constant parameters (no need for fluid systems and so on), a small number of primary variables (e.g. 1 scalar), and simple local residual. Parameter names could be generic and not imply specific physics.
__The goal would be to use such models__
* to demonstrate (to users and developers) what the essential and minimal ingredients of a new model are
* to use them as starting point for new models
* to test if our software components work well in isolation and are small enough (testing). If they turn out not to be these models should be good candidates to think about better abstractions (development).
* to have simple demonstrators for teaching/outreach
* to use them directly as tools/components
__Open questions:__
* In which folder would such models go?
* Do we even want to hard-code some models for one spatial discretization scheme to further simplify?
_Examples where a procedure like this helped to improve the code:_
* #867https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/issues/1000[freeflow] Properly include the volume work term in the energy balance2023-07-24T13:11:04ZKilian Weishaupt[freeflow] Properly include the volume work term in the energy balanceWe currently implement
$`\frac{\partial}{\partial t}(\rho u) = - \nabla \cdot (\rho \mathbf{v}h) + \nabla \cdot (\lambda \nabla T)`$
with $`h = u + \frac{p}{\rho}`$
However, the a correct form of the energy balance equation is (see ...We currently implement
$`\frac{\partial}{\partial t}(\rho u) = - \nabla \cdot (\rho \mathbf{v}h) + \nabla \cdot (\lambda \nabla T)`$
with $`h = u + \frac{p}{\rho}`$
However, the a correct form of the energy balance equation is (see !2473, !2471)
$`\frac{\partial}{\partial t}(\rho u) = - \nabla \cdot (\rho \boldsymbol{v}u) + \nabla \cdot (\lambda \nabla T) \underbrace{- p \left(\nabla\cdot{\boldsymbol{v}}\right)}_{\text{volume work}} + \underbrace{2\mu\boldsymbol{D}(\boldsymbol{v}) : \boldsymbol{D}(\boldsymbol{v})}_{\text{viscous dissipation}} `$
where $`\vec{D}(\vec{v}) = \frac{1}{2}\left( \nabla{\vec{v}} + \nabla{\vec{v}}^T \right)`$.
Viscous dissipation can often be neglected. Replacing enthalpy with internal energy in the first divergence term is simple but
the discretization of
$`p \nabla \cdot \mathbf{v}`$
is not straight-forward.
A possible simple solution would be:
Include in calculation of flux terms, i.e., evaluate $`\nabla \cdot \mathbf{v}`$
and assume a cell-constant $`p`$ which is just multiplied to the term. This gives a first-order scheme but should be ok since the term is often small. For incompressible flow the term also vanishes discretely since $`\nabla \cdot \mathbf{v} = 0`$.
This seems to work for cell-centered schemes without much additional effort (!2494).
For the box method it seems more difficult since the code assumes that fluxes on scvfs are symmetric. However the energy contribution (assembled on the scvfs) is different depending on the control volume (different control volume pressure).
Another solution is to implement the full conservative form of the energy equation
```math
\frac{\partial}{\partial t}\left( \frac{1}{2}\rho ||{\boldsymbol{v}}||^2 + \rho u \right) =
- \nabla\cdot{\left( \left[\frac{1}{2}\rho ||{\boldsymbol{v}}||^2 + \rho u \right] \boldsymbol{v}\right)}
+ \nabla\cdot{\left( \boldsymbol{T} \boldsymbol{v} + \lambda \nabla T\right)}
+ \rho \boldsymbol{v}\cdot \vec{g},
```
where $`\boldsymbol{T} = 2\mu\boldsymbol{D}(\boldsymbol{v}) - p\boldsymbol{I}`$.
__Edit 24 Jul 23 (@timok):__ included viscous dissipation term, annotations and conservative energy balance.