The following transient problem is essentially the reciprocating (i.e., fully reversing) flow of a fluid over a thick heated block until the system reaches a cyclic steady-state (i.e., the system temperature oscillates around a mean when this point is reached). The following code simulates the system for a fluid velocity boundary condition $u=3*\sin(2*\pi*0.5*t)$, i.e., a frequency of $0.5Hz$ and a heat flux input of $1000 W/m^2$. tflow
refers to the total time till which the flow oscillation occurs and t0
is the time-step. The code uses the flow solver developed by Alex Trounev and described in this page.
Needs["NDSolve`FEM`"]
{f = 0.5; L = 0.040, d = 0.003, e = 0.005, kf = 0.026499, ks = 16,
rho = 1.1492, rhos = 7860, mu = 18.923*10^-6, cp = 1.0069*10^3,
cps = 502.4}; u0 = 3; nu = mu/rho; om = 2 Pi f;
tflow = 400;
t0 = .3;
NV = 2 f tflow;
nn = Round[NV \[Pi]/(om t0)]
Ti = 307; q = 1000/Ti;
reg1 = ImplicitRegion[0 <= x <= L && 0 <= y <= d, {x, y}]; reg2 =
ImplicitRegion[0 <= x <= L && -e <= y <= d, {x, y}];
UX[0][x_, y_] := 0;
VY[0][x_, y_] := 0;
P[0][x_, y_] := 0;
Tfs[0][x_, y_] := 307/Ti; appro =
With[{k = 2. 10^6}, ArcTan[k #]/Pi + 1/2 &];
ade[y_] := (ks + (kf - ks) appro[y])
rde[y_] := (cps rhos + (cp rho - cps rhos) appro[y]);
Monitor[Do[{UX[i], VY[i], P[i]} =
NDSolveValue[{{Inactive[
Div][({{-\[Mu], 0}, {0, -\[Mu]}}.Inactive[Grad][
u[x, y], {x, y}]), {x, y}] + D[p[x, y], x] +
UX[i - 1][x, y]*D[u[x, y], x] +
VY[i - 1][x, y]*D[u[x, y], y] + (u[x, y] - UX[i - 1][x, y])/
t0, Inactive[
Div][({{-\[Mu], 0}, {0, -\[Mu]}}.Inactive[Grad][
v[x, y], {x, y}]), {x, y}] + D[p[x, y], y] +
UX[i - 1][x, y]*D[v[x, y], x] +
VY[i - 1][x, y]*D[v[x, y], y] + (v[x, y] - VY[i - 1][x, y])/
t0, D[u[x, y], x] + D[v[x, y], y]} == {0, 0, 0} /. \[Mu] ->
nu, {DirichletCondition[{u[x, y] == u0*Sin[om*i*t0],
v[x, y] == 0},
x == L (1 - Sign[Sin[om*i*t0]])/2 && 0 < y < d],
DirichletCondition[{u[x, y] == 0, v[x, y] == 0},
y == 0 || y == d]},
DirichletCondition[p[x, y] == 0,
x == L (1 + Sign[Sin[om*i*t0]])/2 && 0 < y < d]}, {u, v,
p}, {x, y} \[Element] reg1,
Method -> {"FiniteElement",
"InterpolationOrder" -> {u -> 2, v -> 2, p -> 1},
"MeshOptions" -> {"MaxCellMeasure" -> 0.0000005}}];
ux = If[y <= 0, 0, UX[i][x, y]]; vy = If[y <= 0, 0, VY[i][x, y]];
Tfs[i] =
NDSolveValue[{rde[
y] ((ux*D[T[x, y], x] +
vy*D[T[x, y], y]) + (T[x, y] - Tfs[i - 1][x, y])/t0) -
Inactive[Div][
ade[y]*Inactive[Grad][T[x, y], {x, y}], {x, y}] ==
NeumannValue[q, y == -e],
DirichletCondition[{T[x, y] == 1},
x == L (1 - Sign[Sin[om*i*t0]])/2 && 0 <= y <= d]},
T, {x, y} \[Element] reg2,
Method -> {"FiniteElement", "InterpolationOrder" -> {T -> 2},
"MeshOptions" -> {"MaxCellMeasure" -> 0.0000001}}] //
Quiet;, {i, 1, nn}],ProgressIndicator[i,{1,nn}]]; // AbsoluteTiming
ListLinePlot[
Table[{i t0, Tfs[i][0.5*L, -e/2]*Ti - 273.16}, {i, 0, nn}],
AxesLabel -> {"t(s)", "T(in deg. C)"}, PlotRange -> Full]
If one plots the temperature profile at a point $(0.5L,-e/2)$ in the solid with time, it turns out to be:
As can be seen, the temperature of the system initially increases fast to gradually slow down and reach a cyclic steady-state (marked with red), where it oscillates around a mean.
However, keeping all other parameters same, if I increase the frequency to say f=2
Hz, I need to give a smaller time-step which should be at-least $<\frac{1}{2*2}=0.25s$, to resolve the flow reversal in each half-period correctly. In this scenario, the tflow
required to reach a cyclic steady-state increases.
When I run the above code with f=2, t0=0.1,tflow=800
, it crashes each and every time with the error Wolfram Kernel has stopped working
. My question is:
- Can this code be improved so that it does not crash for high
f
, which require smallt0
? For example:f=2, t0=0.1