Mathematica FEM method can be used to calculate unsteady viscous compressible flows around aerofoil in subsonic, transonic and supersonic modes. Here an example is given for the wing profile NACA2415 for the Mach number
$M = 0.55$, Reynolds number
$Re = 1000$, angle of attack
$\alpha =\pi/16$ .
myNACA[{m_, p_, t_}, x_] :=
Module[{},
yc = Piecewise[{{m/p^2 (2 p x - x^2),
0 <= x < p}, {m/(1 - p)^2 ((1 - 2 p) + 2 p x - x^2),
p <= x <= 1}}];
yt = 5 t (0.2969 Sqrt[x] - 0.1260 x - 0.3516 x^2 + 0.2843 x^3 -
0.1015 x^4);
\[Theta] =
ArcTan@Piecewise[{{(m*(2*p - 2*x))/p^2,
0 <= x < p}, {(m*(2*p - 2*x))/(1 - p)^2, p <= x <= 1}}];
{{x - yt Sin[\[Theta]],
yc + yt Cos[\[Theta]]}, {x + yt Sin[\[Theta]],
yc - yt Cos[\[Theta]]}}];
m = 0.04;
p = 0.4;
tk = 0.15;
pe = myNACA[{m, p, tk}, x];
ParametricPlot[pe, {x, 0, 1}, ImageSize -> Large, Exclusions -> None]
ClearAll[myLoop];
myLoop[n1_, n2_] :=
Join[Table[{n, n + 1}, {n, n1, n2 - 1, 1}], {{n2, n1}}]
Needs["NDSolve`FEM`"];
rt = RotationTransform[-\[Pi]/16];(*angle of attack*)a =
Table[pe, {x, 0, 1,
0.01}];
p0 = {p,
tk/2};
x1 = -2; x2 = 3;
y1 = -2; y2 = 2;
coords =
Join[{{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}}, rt@a[[All, 2]],
rt@Reverse[a[[All, 1]]]];
nn = Length@coords;
bmesh = ToBoundaryMesh["Coordinates" -> coords,
"BoundaryElements" -> {LineElement[myLoop[1, 4]],
LineElement[myLoop[5, nn]]}, "RegionHoles" -> {rt@p0}];
mesh = ToElementMesh[bmesh, MaxCellMeasure -> 0.001];
Show[mesh["Wireframe"], Frame -> True]
q = 1.4;
k = 40; Re0 = 1; U0 = 1; M0 = 0.55; Re1 = Re0/M0^2; Pin = 1;
t0 = 1/20; alpha = 0;
UX[0][x_, y_] := Cos[alpha];
VY[0][x_, y_] := Sin[alpha];
\[CapitalRho][0][x_, y_] := Pin;
yU = Interpolation[rt@a[[All, 1]], InterpolationOrder -> 2];
yL = Interpolation[rt@a[[All, 2]], InterpolationOrder -> 2];
Do[
{UX[i], VY[i], \[CapitalRho][i]} =
NDSolveValue[{{Inactive[
Div][({{-\[Mu], 0}, {0, -\[Mu]}}.Inactive[Grad][
u[x, y], {x, y}]), {x, y}] +
Re1*(Abs[\[CapitalRho][i - 1][x, y]]^q)*
\!\(\*SuperscriptBox[\(\[Rho]\),
TagBox[
RowBox[{"(",
RowBox[{"1", ",", "0"}], ")"}],
Derivative],
MultilineFunction->None]\)[x, y]/\[CapitalRho][i - 1][x, y] +
Re0*UX[i - 1][x, y]*D[u[x, y], x] +
Re0*VY[i - 1][x, y]*D[u[x, y], y] +
Re0*(u[x, y] - UX[i - 1][x, y])/t0,
Inactive[
Div][({{-\[Mu], 0}, {0, -\[Mu]}}.Inactive[Grad][
v[x, y], {x, y}]), {x, y}] +
Re1*(Abs[\[CapitalRho][i - 1][x, y]^q])*
\!\(\*SuperscriptBox[\(\[Rho]\),
TagBox[
RowBox[{"(",
RowBox[{"0", ",", "1"}], ")"}],
Derivative],
MultilineFunction->None]\)[x, y]/\[CapitalRho][i - 1][x, y] +
Re0*UX[i - 1][x, y]*D[v[x, y], x] +
Re0*VY[i - 1][x, y]*D[v[x, y], y] +
Re0*(v[x, y] - VY[i - 1][x, y])/t0,
D[\[CapitalRho][i - 1][x, y]*u[x, y], x] +
D[\[CapitalRho][i - 1][x, y]*v[x, y],
y] + (\[Rho][x, y] - \[CapitalRho][i - 1][x, y])/t0} == {0,
0, 0} /. \[Mu] -> 1/1000, {
DirichletCondition[{u[x, y] == U0*Cos[alpha],
v[x, y] == U0*Sin[alpha]}, x == x1 && y1 < y < y2],
DirichletCondition[{u[x, y] == 0., v[x, y] == 0.},
y == yU[x] && 0 <= x <= Cos[Pi/16]],
DirichletCondition[{u[x, y] == 0., v[x, y] == 0.},
y == yL[x] && 0 <= x <= Cos[Pi/16]],
DirichletCondition[\[Rho][x, y] == 1, x == x2]}}, {u,
v, \[Rho]}, {x, y} \[Element] mesh,
Method -> {"FiniteElement",
"InterpolationOrder" -> {u -> 2, v -> 2, \[Rho] -> 1}}], {i, 1,
k}];
ContourPlot[
Norm[{UX[i][x, y], VY[i][x, y]}] /. i -> 32, {x, x1, x2}, {y, y1,
y2}, PlotLegends -> Automatic, Contours -> 20,
ColorFunction -> "TemperatureMap", FrameLabel -> {"x", "y"},
PlotLabel -> V, PlotRange -> All, PlotPoints -> 50, MaxRecursion -> 2]
sp = StreamPlot[{UX[i][x, y], VY[i][x, y]} /. i -> 32, {x, -0.5,
1.5}, {y, -.5, .5}, PlotLegends -> Automatic,
ColorFunction -> "TemperatureMap", FrameLabel -> {"x", "y"},
PlotLabel -> V, PlotRange -> All, MaxRecursion -> 2,
StreamStyle -> LightGray, StreamPoints -> Fine,
AspectRatio -> Automatic];
cp = ContourPlot[
Norm[{UX[i][x, y], VY[i][x, y]}] /. i -> 32, {x, -0.5,
1.5}, {y, -.5, .5}, PlotLegends -> Automatic,
ColorFunction -> "BlueGreenYellow", FrameLabel -> {"x", "y"},
PlotLabel -> V, PlotRange -> All, MaxRecursion -> 2,
Contours -> 40, AspectRatio -> Automatic, PlotPoints -> 50];
Show[cp, sp]
StreamPlot[{UX[i][x, y], VY[i][x, y]} /. i -> 32, {x, 0.9,
1.05}, {y, -0.22, -0.12}, Epilog -> {Line[coords[[5 ;; nn]]]},
AspectRatio -> Automatic, StreamPoints -> Fine]
