TransWikia.com

How to solve system of PDE's with complicated initial and boundary conditions

Mathematica Asked by Mathematicain on June 19, 2021

I am trying to solve the Cavity problem given in [Paper by Mansour et al.][1] with a physical model [![physical model][2]][2].
System of PDE and B.C are [![enter image description here][3]][3].
How can I impose boundary conditions like this?

Code

Clear[M, Ha, Ec, pr,  pde1, pde2, pde3]
pde1[Pr_,Da_]=u[x,y]*D[u[x,y],x]+v[x,y]*D[u[x,y],y]==-D[P[x, y], x]+Pr*(D[u[x, y],x,x]+D[u[x,y],y,y]-u[x,y]/Da);
pde2[Pr_,Da_,Ra_,Ha_]=u[x, y]*D[v[x, y],x]+v[x, y]*D[v[x, y], y]==-D[P[x, y], y]+Pr*(D[v[x,y],x,x]+D[v[x,y],y,y]-v[x,y]/Da)-Ha^2*Pr*v[x,y]+Ra*Pr*T[x,y];
pde3[Q_]=u[x,y]*D[T[x,y],x]+v[x,y]*D[D[x,y],y]==Pr*(D[T[x,y],x,x]+D[T[x,y],y, y])-Q*T[x,y];


With[{lb=2},bcs = {u[x,0]==0, v[x,0]==0,T[x, 0]==0,{u[x, lb]==0,v[x, lb]==0,T[x, lb]==0}}];

mol[n_Integer, o_: "Pseudospectral"] := {"MethodOfLines","SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n,"MinPoints" -> n, "DifferenceOrder" -> o}}mol[tf : False | True, sf_: Automatic] := {"MethodOfLines", "DifferentiateBoundaryConditions" -> {tf,"ScaleFactor" -> sf}}
Clear@solfuncWith[{pts = 20, lb = 2}, solfunc[Ha_, Pr_: 6.2, Da_: 2, Ra_: 1, Q_ 1, tend1_: 5] := NDSolveValue[{pde1[Pr, Da], pde2[Pr, Da, Ra, Ha], pde3[Q], bcs}, {u, v,T}, {y, 0, lb}, {x, 0, tend1},Method -> Union[mol[pts, 4], mol[True, 100]]]]

(sollst[#] = solfunc[#]) & /@ {1, 3, 6, 9}; // Quiet

One Answer

We can use FEM as it is to solve this problem in versions 12-12.1.1

 Needs["NDSolve`FEM`"]; 
k = 2; Pr0 = 1; Ra = 10^4; R = Ra*Pr0; a = 0; d = 1/2; b = 1/3; Da = 1; Ha = 1; Q = 1; 
reg = Rectangle[{0., 0.}, {1., 1.}]; 
{UX, VY, PK, TK} = NDSolveValue[
    {{Inactive[Div][{{-[Mu], 0}, {0, -[Mu]}} . Inactive[Grad][u[x, y], {x, y}], {x, y}] + 
         Pr0*(u[x, y]/Da) + D[p[x, y], x] + u[x, y]*D[u[x, y], x] + v[x, y]*D[u[x, y], y] - 
         R*T[x, y]*Sin[a], Inactive[Div][{{-[Mu], 0}, {0, -[Mu]}} . Inactive[Grad][v[x, y], {x, y}], 
          {x, y}] + Pr0*(v[x, y]/Da) + Ha^2*Pr0*v[x, y] + D[p[x, y], y] + u[x, y]*D[v[x, y], x] + 
         v[x, y]*D[v[x, y], y] - R*T[x, y]*Cos[a], D[u[x, y], x] + D[v[x, y], y]} == {0, 0, 0} /. 
      [Mu] -> Pr0, u[x, y]*D[T[x, y], x] + v[x, y]*D[T[x, y], y] - (D[T[x, y], x, x] + 
        D[T[x, y], y, y]) - Q*T[x, y] == 0, DirichletCondition[{u[x, y] == 0, v[x, y] == 0}, 
      x == 0. || y == 0. || x == 1 || y == 1], DirichletCondition[p[x, y] == 0., 
      y == 1. && x == 1.], DirichletCondition[T[x, y] == -0.5, (x == 0 || x == 1.) && 
       d - b/2 <= y <= d + b/2], DirichletCondition[T[x, y] == 0.5, 
      (y == 0 || y == 1.) && d - b/2 <= x <= d + b/2]}, {u, v, p, T}, Element[{x, y}, reg], 
    Method -> {"FiniteElement", "InterpolationOrder" -> {u -> 2, v -> 2, p -> 1, T -> 2}, 
      "MeshOptions" -> {"MaxCellMeasure" -> 0.001}}];

Visualization of temperature and flow

{ContourPlot[TK[x, y], {x, y} [Element] reg, 
  PlotLegends -> Automatic, Contours -> 20, PlotPoints -> 25, 
  ColorFunction -> "Rainbow", AxesLabel -> {"x", "y"}, 
  PlotLabel -> T], 
 StreamDensityPlot[{UX[x, y], VY[x, y]}, {x, y} [Element] reg, 
  StreamPoints -> Fine, StreamStyle -> LightGray, 
  PlotLegends -> Automatic, VectorPoints -> Fine, 
  ColorFunction -> "Rainbow", PlotLabel -> Row[{"Ra=", Ra}]]}

Figure 1

To calculate Nusselt number we use

Nu = -Evaluate[Grad[TK[x, y], {x, y}]];

Now we can visualize Nu as follows

{Plot[Nu[[1]] /. x -> 0, {y, 0, 1}, PlotRange -> All, Frame -> True, 
  Axes -> False, FrameLabel -> {"y", "Nu"}], 
 Plot[Nu[[1]] /. x -> 1, {y, 0, 1}, PlotRange -> All, Frame -> True, 
  Axes -> False, FrameLabel -> {"y", "Nu"}], 
 Plot[Nu[[2]] /. y -> 0, {x, 0, 1}, PlotRange -> All, Frame -> True, 
  Axes -> False, FrameLabel -> {"x", "Nu"}], 
 Plot[Nu[[2]] /. y -> 1, {x, 0, 1}, PlotRange -> All, Frame -> True, 
  Axes -> False, FrameLabel -> {"x", "Nu"}]} 

Figure 2

To plot Nu over reg we exclude extremum points on a border

{ContourPlot[Nu[[1]], {x, y} [Element] reg, PlotLegends -> Automatic,
   Contours -> 40, ColorFunction -> Hue, FrameLabel -> {"x", "y"}, 
  PlotLabel -> "!(*SubscriptBox[(Nu), (x)])", 
  PlotRange -> {-5, 5}, PlotPoints -> 50], 
 ContourPlot[Nu[[2]], {x, y} [Element] reg, PlotLegends -> Automatic,
   Contours -> 40, ColorFunction -> Hue, FrameLabel -> {"x", "y"}, 
  PlotLabel -> "!(*SubscriptBox[(Nu), (y)])", 
  PlotRange -> {-5, 5}, PlotPoints -> 50]}

Figure 3

Code to compute flow for the case of region and temperature distribution as it shown in Figure 4 Figure 4

Needs["NDSolve`FEM`"];
k = 2; Pr0 = 1; Ra = 10^4; R = Ra*Pr0; a = 0; d = 1/2; b = 
 1/3; Da = 1; Ha = 1; Q = 1;
reg = RegionDifference[Rectangle[{0., 0.}, {1., 1.}], 
   Rectangle[{d - b/2, 0.}, {d + b/2, b}]];
mesh = ToElementMesh[reg, MaxCellMeasure -> .001]

{UX, VY, PK, TK} = 
  NDSolveValue[{{Inactive[Div][{{-[Mu], 0}, {0, -[Mu]}} . 
          Inactive[Grad][u[x, y], {x, y}], {x, y}] + 
        Pr0*(u[x, y]/Da) + D[p[x, y], x] + u[x, y]*D[u[x, y], x] + 
        v[x, y]*D[u[x, y], y] - R*T[x, y]*Sin[a], 
       Inactive[Div][{{-[Mu], 0}, {0, -[Mu]}} . 
          Inactive[Grad][v[x, y], {x, y}], {x, y}] + 
        Pr0*(v[x, y]/Da) + Ha^2*Pr0*v[x, y] + D[p[x, y], y] + 
        u[x, y]*D[v[x, y], x] + v[x, y]*D[v[x, y], y] - 
        R*T[x, y]*Cos[a], D[u[x, y], x] + D[v[x, y], y]} == {0, 0, 
       0} /. [Mu] -> Pr0, 
    u[x, y]*D[T[x, y], x] + 
      v[x, y]*D[T[x, y], y] - (D[T[x, y], x, x] + D[T[x, y], y, y]) - 
      Q*T[x, y] == 0, 
    DirichletCondition[{u[x, y] == 0, v[x, y] == 0}, True], 
    DirichletCondition[p[x, y] == 0., y == 1. && x == 1.], 
    DirichletCondition[
     T[x, y] == -0.5, (x == 0 || x == 1.) && d - b/2 <= y <= d + b/2],
     DirichletCondition[
     T[x, y] == -0.5, (x == d - b/2 || x == d + b/2) && 0 <= y <= b], 
    DirichletCondition[
     T[x, y] == 0.5, (y == b || y == 1.) && 
      d - b/2 <= x <= d + b/2]}, {u, v, p, T}, Element[{x, y}, mesh], 
   Method -> {"FiniteElement", 
     "InterpolationOrder" -> {u -> 2, v -> 2, p -> 1, T -> 2}}]; 

Visualization of numerical solution Figure 5

Correct answer by Alex Trounev on June 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP