]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/Documentation/numericalPage.ipynb
Salome HOME
Improved message display
[tools/solverlab.git] / CoreFlows / Documentation / numericalPage.ipynb
1 {
2  "cells": [
3   {
4    "cell_type": "code",
5    "execution_count": 5,
6    "metadata": {},
7    "outputs": [
8     {
9      "data": {
10       "text/markdown": [
11        "The numerical methods \n",
12        "=====================\n",
13        "\n",
14        "CoreFlows proposes a variety of finite volume methods (see \\ref leveque for an introduction). The method  can be explicit or implicit (enum \\ref TimeScheme), and the convection fluxes can be approximated using the  \\ref roe,  \\ref vfroe or \\ref vffc formulations (enum \\ref NonLinearFormulation).\n",
15        "\n",
16        "The basic method for fluid models is the \\ref roe scheme with entropic correction (see \\ref kieu) and source upwinding (see\\ref wbsourceterms). In order to increase precision it is possible to use centered, staggered, pressureCorrection or lowMach schemes through the enum \\ref SpaceScheme.\n",
17        "\n",
18        "The finite volume discretisation allows an easy handling of general geometries and meshes generated by \\ref salome .\n",
19        "\n",
20        "Explicit schemes are used in general for fast dynamics solved with small time steps while implicit schemes allow the use of large time step to quickly reach the stationary regime. The implicit schemes result in nonlinear systems that are solved using a Newton type method.\n",
21        "\n",
22        "The upwind scheme is the basic scheme but options are available to use a centered scheme (second order in space) or entropic corrections.\n",
23        "\n",
24        "Our models can be written in generic form as a nonlinear system of balance laws:\n",
25        "\n",
26        "$$\n",
27        "\\frac{\\partial U}{\\partial t} + \\nabla \\cdot \\left(\\mathcal{F}^{conv}(U)\\right)+\\nabla \\cdot \\left(\\mathcal{F}^{diff}(U)\\right) = 0, \n",
28        "$$\n",
29        "\n",
30        "where \n",
31        "- $U$ is the vector of conservative unknowns, \n",
32        "- $\\mathcal{F}^{conv}$ is the convective flux \n",
33        "- and $\\mathcal{F}^{diff}$ the diffusive flux.\n",
34        "\n",
35        "We decompose the computational domain into $N$ disjoint cells $C_i$ with volume $v_i$.\n",
36        "+ Two neighboring cells $C_i$ and $C_j$ have a common boundary $\\partial C_{ij}$ with area $s_{ij}$.\n",
37        "+ We denote $N(i)$ the set of neighbors of a given cell $C_i$ and $\\vec n_{ij}$ the exterior unit normal vector of $\\partial C_{ij}$ . \n",
38        "\n",
39        "Integrating the system (\\ref NStokesEq) over $C_{i}$ and setting $U_i(t)=  \\frac{1}{v_i} \\int_{C_i} U(x,t) dx$, the semi-discrete equations can be written:\n",
40        "\n",
41        "$$\n",
42        " \\frac{\\mathrm{d} U_i}{\\mathrm{d} t} + \\sum_{j \\in N(i)} \\frac{s_{ij}}{v_i}\\left(\\overrightarrow \\Phi^{conv}_{ij} +  \\overrightarrow{\\Phi}^{diff}_{ij}\\right)= S_i(U,x).\n",
43        "$$\n",
44        "with: \n",
45        "- $\\overrightarrow{\\Phi}^{con}_{ij}= \\frac{1}{s_{ij}}\\int_{\\partial C_{ij}}\\mathcal F^{conv}(U).\\vec n_{ij}ds $,\n",
46        "- $\\overrightarrow \\Phi^{diff}_{ij}= \\frac{1}{s_{ij}}\\int_{\\partial C_{ij}}\\mathcal {F}^{diff}(U).\\vec n_{ij}ds $\n",
47        "\n",
48        "To approximate the convection numerical flux $\\overrightarrow \\Phi^{conv}_{ij}$ we solve an  approximate Riemann problem at the interface $\\partial C_{ij}$. There are three possible formulations for the convection fluxes. \n",
49        "- Using the \\ref roe local linearisation of the fluxes, we obtain the following formula:\n",
50        "$$\n",
51        "\\begin{array}{lll}\n",
52        "\\overrightarrow{\\Phi}^{conv, Roe}_{ij}&= &\\frac{\\mathcal{F}^{conv}(U_i) + \\mathcal{F}^{conv}(U_j)}{2} \\vec{n}_{ij}- \\mathcal{D}(U_i,U_j) \\frac{U_j-U_i}{2}\\\\\n",
53        "&=&\\mathcal{F}^{conv}(U_i) \\vec{n}_{ij} + A^-(U_i,U_j) (U_j - U_i),\n",
54        "\\end{array}\n",
55        "$$\n",
56        "- Using the \\ref vfroe local linearisation of the fluxes, we obtain the following formula:\n",
57        "$$\n",
58        "\\overrightarrow{\\Phi}^{conv, VFRoe}_{ij}=\\mathcal{F}^{conv}\\left(\\frac{U_i + U_j}{2} - \\mathcal{D}(U_i,U_j) \\frac{U_j-U_i}{2}\\right)\\vec{n}_{ij},\n",
59        "$$\n",
60        "- Using the \\ref vffc local linearisation of the fluxes, we obtain the following formula:\n",
61        "$$\n",
62        "\\overrightarrow{\\Phi}^{conv, VFFC}_{ij}= \\frac{\\mathcal{F}^{conv}(U_i) + \\mathcal{F}^{conv}(U_j)}{2} \\vec{n}_{ij}- \\mathcal{D}(U_i,U_j) \\frac{\\mathcal{F}^{conv}(U_j)-\\mathcal{F}^{conv}(U_i)}{2} \\vec{n}_{ij},\n",
63        "$$\n",
64        "where \n",
65        "- $\\mathcal{D}$ is an upwinding matrix,\n",
66        "- $A(U_i,U_j)$ the Roe matrix\n",
67        "- and $A^-= \\frac{A - \\mathcal{D}}{2}$.\n",
68        "\n",
69        " The choice $\\mathcal{D}= 0$ gives the \\ref centered upwinding, $\\mathcal{D}= |A|$ for the \\ref roe formulation and  $\\mathcal{D}= sign(A)$ for the \\ref vfroe and \\ref vffc formulations give the full \\ref upwind upwinding. The \\ref lowMach, \\ref pressureCorrection and \\ref staggered upwindings allow more precision for  Mach number flows. \n",
70        "\n",
71        "The diffusion numerical flux $\\overrightarrow\\Phi_{ij}^{diff}$ is approximated on structured meshes using the formula:\n",
72        "$$\n",
73        "\\overrightarrow \\Phi_{ij}^{diff}= D (\\frac{U_i+U_j}{2},\\vec{n}_{ij})(U_j-U_i),\n",
74        "$$\n",
75        "\n",
76        "where \n",
77        "- $D(U,\\vec{n}_{ij})=\\nabla\\mathcal{F}^{diff}(U).\\vec{n}_{ij}$ is the matrix of the diffusion tensor.\n",
78        "$(\\ref{eq:flux diff})$ is not accurate for highly non structured or non conforming meshes. However, since we are mainly interested in convection driven flows, we do not ask for a very precise scheme.\n",
79        "\n",
80        "Finally, since $\\sum_{j \\in N(i)}\\mathcal {F}^{conv}(U_i). \\vec{n}_{ij}=0$, using $(\\ref{eq:flux roe})$ and $(\\ref{eq:flux diff})$ the equation $(\\ref{eq:numer scheme})$ of the semi-discrete scheme becomes:\n",
81        "$$\n",
82        "\\frac{\\mathrm{d} U_{i}}{\\mathrm{d} t} + \\sum_{j\\in N(i)} {\\frac{s_{ij}}{v_i}\\{(A^-+ D)(U_i,U_j)\\}(U_j-U_i)} = S_i(U,x), \n",
83        "$$\n",
84        "\n",
85        "The source term in $(\\ref{eq:reduced scheme})$ can be approximated using either a \n",
86        "$$\n",
87        " \\textrm{ Centered source } S_i=S(U_i)\\nonumber\n",
88        "$$\n",
89        "or an\n",
90        "$$\n",
91        "\\begin{array}{lll}\n",
92        " \\textrm{ Upwind source } S_i&=&\\frac{1}{2}(Id-signe(A^{Roe}_{i,i+1}))\\frac{S(U_i)+S(U_{i+1})}{2}\\\\\n",
93        "\t\t\t      &&+\\frac{1}{2}(Id+signe(A^{Roe}_{i-1,i}))\\frac{S(U_{i-1})+S(U_i)}{2}.\\nonumber\n",
94        "\\end{array}\n",
95        "$$\n",
96        "\n",
97        "\n",
98        "\n",
99        "Explicit schemes\n",
100        "----------------\n",
101        "\n",
102        "In explicit schemes, in order to compute the values $U_i^{n+1}$, the fluxes $\\Phi^{conv}_{ij}$, $\\Phi^{diff}_{ij}$ and the source term $S(U,x)$ in $(\\ref{eq:numer scheme})$ are evaluated at time $n$ :\n",
103        "$$\n",
104        "\\begin{array}{lll}\n",
105        "\\frac{U_{i}^{n+1} - U_{i}^{n}}{\\Delta t} &+& \\sum_{j\\in N(i)} \\frac{s_{ij}}{v_i}\\left(\\frac{1}{2}(\\mathcal{F}^{conv}(U_i^n) + \\mathcal{F}^{conv}(U_j^n)). \\vec{n}_{ij}- \\mathcal{D}(U_i^n,U_j^n,\\vec{n}_{ij}) \\frac{U_j^n-U_i^n}{2}\\right)\\\\\n",
106        "&+&\\frac{s_{ij}}{v_i} D (\\frac{U_i+U_j}{2},\\vec{n}_{ij})(U_j-U_i)= S(U^n,x_i), \\nonumber\n",
107        "\\end{array}\n",
108        "$$\n",
109        "or equivalently using $(\\ref{eq:flux roe})$ and $(\\ref{eq:flux diff})$\n",
110        "$$\n",
111        "\\frac{U_{i}^{n+1} - U_{i}^{n}}{\\Delta t} + \\sum_{j\\in N(i)} {\\frac{s_{ij}}{v_i}\\{(A^-+ D)(U_i^{n},U_j^{n},\\vec{n}_{ij})\\}(U^{n}_j-U^{n}_i)} =  S(U^n,x_i). \n",
112        "$$\n",
113        "\n",
114        "From the system $(\\ref{explicitscheme})$ we can obtain $U_i^{n+1}$ easily using matrix-vector products and vector sum. \n",
115        "However the time step of explicit methods is constrained by the CFL condition for stability reasons.\n",
116        "\n",
117        "Implicit schemes\n",
118        "----------------\n",
119        "\n",
120        "In implicit schemes, in order to compute the values $U_i^{n+1}$, the fluxes $\\Phi^{conv}_{ij}$, $\\Phi^{diff}_{ij}$ and the source term $S(U,x)$ in $(\\ref{eq:numer scheme})$ are evaluated at time $n+1$ :\n",
121        "$$\n",
122        "\\begin{array}{lll}\n",
123        "\\frac{U_{i}^{n+1} - U_{i}^{n}}{\\Delta t} &+& \\sum_{j\\in N(i)} \\frac{s_{ij}}{v_i}\\left(\\frac{1}{2}(\\mathcal{F}^{conv}(U_i^{n+1}) + \\mathcal{F}^{conv}(U_j^{n+1})). \\vec{n}_{ij}- \\mathcal{D}(U_i^{n+1},U_j^{n+1},\\vec{n}_{ij}) \\frac{U_j^{n+1}-U_i^{n+1}}{2}\\right)\\\\\n",
124        "&+&\\frac{s_{ij}}{v_i} D (\\frac{U_i+U_j}{2},\\vec{n}_{ij})(U_j-U_i) = S(U^{n+1},x_i),\n",
125        "\\end{array}\n",
126        "$$\n",
127        "or equivalently using $(\\ref{eq:flux roe})$ and $(\\ref{eq:flux diff})$\n",
128        "$$\n",
129        "\\frac{U_{i}^{n+1} - U_{i}^{n}}{\\Delta t} + \\sum_{j\\in N(i)} {\\frac{s_{ij}}{v_i}\\{(A^-+ D)(U_i^{n+1},U_j^{n+1},\\vec{n}_{ij})\\}(U^{n+1}_j-U^{n+1}_i)} =  S(U^{n+1},x_i). \n",
130        "$$\n",
131        "\n",
132        "The system $(\\ref{implicitscheme})$ is nonlinear. The computation of $U_i^n$ is more expensive but we can expect to use larger time steps than would be allowed with the explicit scheme.\n",
133        "\n",
134        "We use the following Newton iterative method to obtain the required solutions:\n",
135        "$$\n",
136        "\\begin{array}{lll}\n",
137        "\\frac{\\delta U_i^{k+1}}{\\Delta t}& + &\\sum_{j \\in N(i)} \\frac{s_{ij}}{v_i} \\left[( A^-+ D)(U_i^k,U_j^k) \\right] \\left(\\delta U_j^{k+1}- \\delta U_i^{k+1} \\right)\\\\\n",
138        "& = &- \\frac{U^k_i-U^n_i}{\\Delta t} - \\sum_{j \\in N(i)} \\frac{s_{ij}}{v_i} \\left[( A^-+ D)(U_i^k,U_j^k)\\right] (U^k_j-U^k_i),\n",
139        "\\end{array}\n",
140        "$$\n",
141        "where :\n",
142        "- $\\delta U_i^{k+1} = U_i^{k+1} - U_i^{k}$ is the variation of the $k$-th iterate that approximate the solution at time $n+1$. \n",
143        "\n",
144        "Defining the unknown vector $\\mathcal U = (U_1,\\dots,U_N)^t$, each Newton iteration for the computation of $\\mathcal U$ at time step $n+1$ requires the numerical solution of the following linear system:\n",
145        "$$\n",
146        " \\mathcal A(\\mathcal U^k)\\delta \\mathcal U^{k+1} =  b(\\mathcal U^n, \\mathcal U^{k}).\n",
147        "$$\n",
148        "\n",
149        "\n",
150        "\n",
151        "Numerical scheme for the Navier-Stokes equations\n",
152        "------------------------------------------------\n",
153        "\n",
154        "For the Navier-Stokes equations $U=(\\rho, \\vec q, \\rho E)^t$ and the fluxes in $(\\ref{Navierstokes})$ write\n",
155        "$$\n",
156        "\\mathcal{F}^{conv}(U)= \\left(\\begin{array}{c}\n",
157        "\\vec{q} \\\\\n",
158        "\\vec{q} \\otimes \\frac{\\vec{q}}{\\rho} + p {I}_d \\\\\n",
159        "\\left( \\rho E + p \\right) \\frac{\\vec{q}}{\\rho} \n",
160        "\\end{array}\n",
161        " \\right) ,\\;\n",
162        "\\mathcal{F}^{diff}(U)=\\left(\\begin{array}{c}\n",
163        "0\\\\\n",
164        "-\\nu \\vec \\nabla (\\frac{\\vec{q}}{\\rho}) \\\\\n",
165        "-\\lambda \\vec \\nabla T \n",
166        "\\end{array}\n",
167        " \\right).\n",
168        "$$\n",
169        "\n",
170        "For the Euler equations, we can build the \\ref roe matrix $A(U_i,U_j)$ explicitly using the Roe averaged state $U_{Roe}(U_i,U_j)=(\\tilde\\rho, \\tilde \\rho\\tilde u, \\tilde\\rho \\tilde E=\\tilde \\rho\\tilde H-\\tilde p)^t$ defined by\n",
171        " $$\n",
172        "\\begin{array}{lll}\n",
173        "\\tilde{\\rho}&=&\\sqrt{\\rho_{i}\\rho_{j}}\\\\\n",
174        "\\tilde{u}&=&\\frac{\\sqrt{\\rho_{i}}u_{i}+\\sqrt{\\rho_{j}}u_{j}}{\\sqrt{\\rho_{i}}+\\sqrt{\\rho_{j}}}\\\\\n",
175        "\\tilde{H}&=&\\frac{\\sqrt{\\rho_{i}}H_{i}+\\sqrt{\\rho_{j}}H_{j}}{\\sqrt{\\rho_{i}}+\\sqrt{\\rho_{j}}}.\n",
176        "\\end{array}\n",
177        "$$\n",
178        "The Roe matrix writes (see \\ref leveque)\n",
179        "$$\n",
180        "A_{Roe}(U_i,U_j)=\\nabla\\mathcal{F}^{conv}(U_{Roe}(U_i,U_j))\\vec{n}_{ij}=\n",
181        "\\left(\\begin{array}{ccc}\n",
182        "       0  & 1 & 0\\\\\n",
183        "       \\tilde{\\chi}+(\\frac{1}{2}\\tilde{\\kappa} -1)\\tilde{u}^2 & (2-\\tilde{\\kappa})\\tilde{u} & \\tilde{\\kappa}\\\\\n",
184        "       (\\tilde{\\chi}+\\frac{1}{2}\\tilde{\\kappa} \\tilde{u}^2- \\tilde{H})\\tilde{u} & \\tilde{H}-\\tilde{\\kappa} \\tilde{u}^2 & (\\tilde{\\kappa}+1)\\tilde{u}\n",
185        "      \\end{array}\\right)\n",
186        "$$\n",
187        "\n",
188        "The diffusion numerical flux $\\overrightarrow\\Phi_{ij}^{diff}$ is approximated with the formula:\n",
189        "$$\n",
190        "\\overrightarrow \\Phi_{ij}^{diff}= D (\\frac{U_i+U_j}{2})(U_j-U_i)\n",
191        "$$\n",
192        " with the matrix \n",
193        "$$\n",
194        "D(U)= \n",
195        "\\left(\n",
196        "\\begin{array}{ccc}\n",
197        " 0&\\vec 0& 0\\\\\n",
198        "\\frac{\\nu \\vec q}{\\rho^2}& \\frac{-\\nu}{\\rho} I_d&0\\\\\n",
199        "\\frac{\\lambda}{c_v}\\left(\\frac{c_vT}{\\rho}-\\frac{||\\vec q||^2}{2\\rho^3}\\right)&\\quad \\frac{{\\vec q}^{\\;t} \\lambda}{\\rho^2 c_v}&\\quad-\\frac{\\lambda}{c_v  \\rho}\n",
200        "\\end{array}\n",
201        "\\right) , $$ \n",
202        "where $c_v$ is the heat capacity at constant volume.\n",
203        "\n"
204       ],
205       "text/plain": [
206        "<IPython.core.display.Markdown object>"
207       ]
208      },
209      "metadata": {},
210      "output_type": "display_data"
211     }
212    ],
213    "source": [
214     "from IPython.display import display, Markdown\n",
215     "display(Markdown('numericalPage.md'))"
216    ]
217   }
218  ],
219  "metadata": {
220   "kernelspec": {
221    "display_name": "Python 2",
222    "language": "python",
223    "name": "python2"
224   },
225   "language_info": {
226    "codemirror_mode": {
227     "name": "ipython",
228     "version": 2
229    },
230    "file_extension": ".py",
231    "mimetype": "text/x-python",
232    "name": "python",
233    "nbconvert_exporter": "python",
234    "pygments_lexer": "ipython2",
235    "version": "2.7.12"
236   }
237  },
238  "nbformat": 4,
239  "nbformat_minor": 2
240 }