Skip to main content

finite element method - Solving Navier-Stokes equations for a steady-state compressible viscous flow in a 2D axisymmetric step


Note: you may apply or follow the edits on the code here in this GitHub Gist


I'm trying to follow this post to solve Navier-Stokes equations for a compressible viscous flow in a 2D axisymmetric step. The geometry is :


enter image description here



lc = 0.03;
rc = 0.01;
xp = 0.01;
c = 0.005;
rp = rc - c;
lp = lc - xp;
Subscript[T, 0] = 300;
Subscript[\[Eta], 0] = 1.846*10^-5;
Subscript[P, 1] = 6*10^5 ;
Subscript[P, 0] = 10^5;

Subscript[c, P] = 1004.9;
Subscript[c, \[Nu]] = 717.8;
Subscript[R, 0] = Subscript[c, P] - Subscript[c, \[Nu]];
\[CapitalOmega] = RegionDifference[
Rectangle[{0, 0}, {lc, rc}],
Rectangle[{xp, 0}, {xp + lp, rp}]];

And meshing:


Needs["NDSolve`FEM`"];
mesh = ToElementMesh[\[CapitalOmega],

"MaxBoundaryCellMeasure" -> 0.00001,
MaxCellMeasure -> {"Length" -> 0.0008},
"MeshElementConstraint" -> 20, MeshQualityGoal -> "Maximal"][
"Wireframe"]

enter image description here


Where the model is axisymmetric around the x axis, the governing equations including conservation equations of mass, momentum and heat can be written as:


$$ \frac{\partial}{\partial x}\left( \rho \nu_x \right)+\frac{1}{r}\frac{\partial }{\partial r}\left(r \rho \nu_r\right)=0 \tag{1}$$


$$\frac{\partial}{\partial x}\left( \rho \nu_x^2+\mathring{R} \rho T \right)+\frac{1}{r}\frac{\partial}{\partial r}\left( r \left( \rho \nu_r \nu_x + \eta \frac{\partial \nu_x}{\partial r} \right)\right) \tag{2}$$


$$ \frac{\partial}{\partial x}\left( \rho \nu_x \nu_r+\eta \frac{\partial \nu_r}{\partial x} \right)+ \frac{1}{r}\frac{\partial}{\partial r}\left( r \left( \rho \nu_r ^2 +\mathring{R} \rho T \right) \right)=0 \tag{3}$$



$$\rho c_\nu\left( \nu_x \frac{\partial T}{\partial x} + \nu_r \frac{\partial T}{\partial r} \right)+ \mathring{R} \rho T \left( \frac{1}{r}\frac{\partial}{\partial r} \left( r \nu_r \right)+ \frac{\partial \nu_x}{\partial x} \right)+ \eta \left( 2 \left( \frac{\partial \nu_x}{\partial x} \right)^2+ 2 \left( \frac{\partial \nu_r}{\partial r} \right)^2+ \left( \frac{\partial \nu_r}{\partial x}+ \frac{\partial \nu_x}{\partial r} \right)^2 \\ -\frac{2}{3}\left( \frac{1}{r} \frac{\partial}{\partial r}\left( r \nu_r \right) + \frac{\partial \nu_x}{\partial x} \right)^2 \right)=0 \tag{4}$$


eqn1 = D[\[Rho][x, r]*Subscript[\[Nu], x][x, r], x] + 
D[r*\[Rho][x, r]*Subscript[\[Nu], r][x, r], r]/r == 0 ;
eqn2 = D[\[Rho][x, r]*Subscript[\[Nu], x][x, r]^2 +
Subscript[R, 0] \[Rho][x, r]*T[x, r], x] +
D[r*(\[Rho][x, r]*Subscript[\[Nu], x][x, r]*
Subscript[\[Nu], r][x, r] +
Subscript[\[Eta], 0]*D[Subscript[\[Nu], x][x, r], r]), r]/
r == 0 ;
eqn3 = D[\[Rho][x, r]*Subscript[\[Nu], x][x, r]*

Subscript[\[Nu], r][x, r] +
Subscript[\[Eta], 0]*D[Subscript[\[Nu], r][x, r], x], x] +
D[r*(\[Rho][x, r]*Subscript[\[Nu], r][x, r]^2 +
Subscript[R, 0] \[Rho][x, r]*T[x, r]), r]/r == 0;
eqn4 = Subscript[
c, \[Nu]]*\[Rho][x,
r]*(Subscript[\[Nu], x][x, r]*D[T[x, r], x] +
Subscript[\[Nu], r][x, r]*D[T[x, r], r]) +
Subscript[R, 0]*\[Rho][x, r]*
T[x, r]*(D[Subscript[\[Nu], x][x, r], x] +

D[r*Subscript[\[Nu], r][x, r], x]/r) + (2*
D[Subscript[\[Nu], x][x, r], x]^2 +
2*D[Subscript[\[Nu], r][x, r],
r]^2 + (D[Subscript[\[Nu], x][x, r], r] +

D[Subscript[\[Nu], r][x, r],
x])^2 - ((D[Subscript[\[Nu], x][x, r], x] +
D[r*Subscript[\[Nu], r][x, r], x]/r)^2)*2/3)*
Subscript[\[Eta], 0] == 0;
eqns = {eqn1, eqn2, eqn3, eqn4};


And the boundary conditions are:



  1. constant pressure at inlet

  2. constant pressure at outlet

  3. axis of symmetry

  4. no slip


Implemented as


bc1 = Subscript[R, 0] \[Rho][0, r]*Subscript[T, 0] == Subscript[P, 1] 

bc2 = Subscript[R, 0] \[Rho][lc, r]*Subscript[T, 0] == Subscript[P, 0]
bc3 = DirichletCondition[{Subscript[\[Nu], r][x, 0] == 0,
D[Subscript[\[Nu], r][x, r], r] == 0,
D[Subscript[\[Nu], x][x, r], r] == 0, D[\[Rho][x, r], r] == 0,
D[T[x, r], r] == 0}, r == 0 && (0 <= x <= xp )]
bc4 = DirichletCondition[{Subscript[\[Nu], r][x, r] == 0,
Subscript[\[Nu], x][x, r] ==
0}, (0 <= r <= rp && x == xp ) || (r == rp &&
xp <= x <= xp + lp) || (r == rc && 0 <= x <= lc) ] == 0
bcs = {bc1, bc2, bc3, bc4};


When I try to solve the equations:


{\[Nu]xsol, \[Nu]rsol, \[Rho]sol, Tsol} = 
NDSolveValue[{eqns, , bcs}, {Subscript[\[Nu], x], Subscript[\[Nu],
r], \[Rho], T}, {x, r} \[Element] mesh,
Method -> {"FiniteElement",
"InterpolationOrder" -> {Subscript[\[Nu], x] -> 2,
Subscript[\[Nu], r] -> 2, \[Rho] -> 1, T -> 1},
"IntegrationOrder" -> 5}];


I get the errors:



NDSolveValue::femnr: {x,r}[Element] is not a valid region specification.



and



Set::shape: Lists {[Nu]xsol,[Nu]rsol,Tsol,[Rho]sol} and NDSolveValue[<<1>>] are not the same shape.



Googling the errors does not offer that much of help (e.g. here). I would appreciate if you could help me know What is the issue and how I can solve it.


P.S.1. The NDSolveValue femnr error was caused by [ "Wireframe"] term at the end of meshing command changing it to



mesh = ToElementMesh[\[CapitalOmega], 
"MaxBoundaryCellMeasure" -> 0.00001,
MaxCellMeasure -> {"Length" -> 0.0008},
"MeshElementConstraint" -> 20, MeshQualityGoal -> "Maximal"];
mesh["Wireframe"]

resolves the issue.


P.S.2. There is an extra ==0 at the end of boundary condition 4 it was edited to:


bc4 = DirichletCondition[{Subscript[\[Nu], r][x, r] == 0, 
Subscript[\[Nu], x][x, r] ==

0}, (0 <= r <= rp && x == xp) || (r == rp &&
xp <= x <= xp + lp) || (r == rc && 0 <= x <= lc)];

at this moment the second error still persists and a new error was added:



NDSolveValue::deqn Equation or list of equations expected instead of Null in the first argument ...



P.S.3 There were multiple issues. So I decided to use this Github Gist to further edit the code.




Comments

Popular posts from this blog

calculus and analysis - Integral of the Sinc product

Let us consider the following integral $$ B_n = \int_0^\infty \prod_{k=1,3,5,\dots}^n\frac{\sin (x/k)}{x/k}dx $$ By definition, Sinc[x] == Sin[x]/x , therefore B[n_?OddQ] := Integrate[Product[Sinc[x/k], {k, 1, n, 2}], {x, 0, Infinity}] B /@ Range[1, 13, 2] {Pi/2, Pi/2, Pi/2, Pi/2, Pi/2, Pi/2, Pi/2} OK, everything is fine. But... B[15] 467807924713440738696537864469 Pi/935615849440640907310521750000 What's going on? Answer As Eckhard wrote in comments B[n] is the n-th Borwein integral . (The letter B was not accidental :) ) This funny properties of Borwein integrals is related to the Fourier transform of Sinc function FourierTransform[Sinc[x], x, k] 1/2 Sqrt[Pi/2] (Sign[1 - k] + Sign[1 + k]) Plot[%, {k, -2, 2}, Filling -> 0] which is the box function. The result is $\pi/2$ while the sum $$ 1/3+1/5+\dots+1/n $$ B_n = \frac{\pi}{2} - \pi \bigg(\sum_{k=3,5,\ldots}^n\frac{1}{k} -1\biggr)^\frac{n-1}{2}\prod_{k=3,5,\dots}^n\frac{k}{k-1}. $$ For $n=15$ it is equal to $$ \frac{46780...

list manipulation - Solving word search puzzles

I am trying to create a code that can identify the following terms in a grid of letters: MATHEMATICA, STACK, EXCHANGE and USERS. list1={"M","S","T","A","S","I","S","X","X","T","R","X"}; list2={"A ","T ","H ","X ","R ","X ","G ","R ","S ","H ","X ","A"}; list3={"M","A","T","H","E","M","A","T","I","C","A","I"}; list4={"A","X","S","G","S","X","A","I","R","T","X","T"}; list5={"T","I","T","G","U","C","C","I","R","N",...

implicit - Plotting a function with implicitly defined variable

I have a question about plotting a function with an implicitly defined variable. I think the solution should be something similar like here: Define a function with variables linked implicitly but I quite can't get it to work. I apologize if this has been asked for, I tried doing a thorough search before asking. Anyway, I am trying to plot the following function: $$ u(x,y,t)=\text{sgn}(x+y-t+r(t))\big(e^{-\vert x+y-t+r(t) \vert }-1\big)+r(t)e^{-\vert x+y+r(t)+\ln(\frac{1}{9}r(t)^2-\frac{1}{2}r(t)+1)\vert} $$ where $r(t)$ is implicitly defined with the following equation $$ \ln\vert r(t)\vert-\frac{1}{2}\ln\vert r(t)^2-\frac{9}{2}r(t)+9\vert+\frac{3\sqrt{}{7}}{7}\tan^{-1}\big(\frac{4r(t)-9}{3\sqrt{}{7}}\big)=2t. $$ Ultimately, I would like to use Plot3D for $u(x,y)$ and use Manipulate to see the function at different time steps of $t$. Thank you in advance for your time and help. It's greatly appreciated. Edit: Here is some mathematica format to make life easier: Sign[x + y - t ...