Update
Recently I revisited the obscure tutorial for "MethodOfLines"
and figured out how to fix your problem i.e. make NDSolve
use (D[u[x, y, t], y] /. y -> 0) == mu1[x]
and (D[u[x, y, t], y] /. y -> 1) == mu2[x]
for solving the equation rather than ignore them. What you need to do is:
(1) Add Method -> {"MethodOfLines",
"DifferentiateBoundaryConditions" ->{True, "ScaleFactor" -> 1}}
to NDSolve
.
This manual option adjustment is necessary because NDSolve
will automatically set "ScaleFactor" -> 0
for non-Dirichlet boundary condition, when i.c. and b.c. are inconsistent, this will make the Neumann inconsistent b.c. that's not a function of t
be completely ignored.
(2) Use UnitStep
instead of Piecewise
or If
to define mu1
and mu2
.
It's probably a bug, luckily we have Simplify`PWToUnitStep
and PiecewiseExpand
so don't need to reconstruct the function by hand.
The following is the fixed code:
c1 = -200.0; c2 = -200.0;
T0 = 500;
a = 0.002;
phi[x_, y_] = 300;
mu1[x_] = Simplify`PWToUnitStep@PiecewiseExpand@If[Abs[x - 0.5] <= 0.25, c1, 0]
mu2[x_] = Simplify`PWToUnitStep@PiecewiseExpand@If[Abs[x - 0.5] <= 0.25, c2, 0]
mu3[y_] := T0;
mu4[y_] := T0;
sol = u /. First@
NDSolve[{D[u[x, y, t], t] == a (D[u[x, y, t], x, x] + D[u[x, y, t], y, y]),
u[x, y, 0] == phi[x, y], (D[u[x, y, t], y] /. y -> 0) ==
mu1[x], (D[u[x, y, t], y] /. y -> 1) == mu2[x], u[0, y, t] == mu3[y],
u[1, y, t] == mu4[y]}, u, {x, 0, 1}, {y, 0, 1}, {t, 0, 100},
Method -> {"MethodOfLines",
"DifferentiateBoundaryConditions" ->{True, "ScaleFactor" -> 1}}]
Manipulate[ContourPlot[sol[x, y, time], {x, 0, 1}, {y, 0, 1}, Contours -> 15,
ColorFunction -> "TemperatureMap", PlotLabel -> "Temperature profile",
ContourLabels -> True, ImageSize -> Large]
, {{time, 5, "Time (t)"}, 5, 100, 0.5}
]
Now mu1
and mu2
apparently plays roles in the solution.
Original Answer
Well, this answer is quite incomplete because I can't fix the problem. I post this answer just to point out that the true reason for the changeless sol
is the BCs (D[u[x, y, t], y] /. y -> 0) == mu1[x]
and (D[u[x, y, t], y] /. y -> 1) == mu2[x]
are largely ignored by NDSolve
. If you try:
Clear["`*"]
T0 = 500; a = 0.002; phi[x_, y_] = 300;
(* I changed your definitions for mu1[x] and mu2[x] a little
since it doesn't work at least for version 8. *)
mu1[x_] := Piecewise[{{c1, Abs[x - 0.5] <= 0.25}}];
mu2[x_] := Piecewise[{{c2, Abs[x - 0.5] <= 0.25}}];
mu3[y_] := T0;
mu4[y_] := T0;
sol[c1_, c2_] := NDSolve[{D[u[x, y, t], t] == a (D[u[x, y, t], x, x] + D[u[x, y, t], y, y]),
u[x, y, 0] == phi[x, y],
(D[u[x, y, t], y] /. y -> 0) == mu1[x],
(D[u[x, y, t], y] /. y -> 1) == mu2[x],
u[0, y, t] == mu3[y],
u[1, y, t] == mu4[y]},
u[x, y, t], {x, 0, 1}, {y, 0, 1}, {t, 0, 100}];
Plot3D[Evaluate[D[u[x, y, t] /. sol[100, -500], y] /. y -> 1],
{x, 0, 1}, {t, 0, 100}, PlotRange -> All]
Plot3D[Evaluate[D[u[x, y, t] /. sol[100, -500], y] /. y -> 0],
{x, 0, 1}, {t, 0, 100}, PlotRange -> All]
you'll see:
Apparently mu1[x]
and mu2[x]
are almostly (maybe essentially…) not used. You can try several other c1
and c2
or even take off the BCs for $y=0$ and $y=1$ to confirm.
I guess some changes for the Method
will help but haven't succeeded until now… Look forward to someone who's more experienced in solving PDEs!
NDSolve
is returning as a solution with those conflicting boundary conditions. Did you come up with the numbers yourself? Otherwise, where do they come from? $\endgroup$