It looks you need to use other NDSolve
options to control the spatial grid size to help NDSolve
a little.
Trying things, found that by increasing the grid size, now this effect you showed goes away.
Grid size needs to be much smaller when the diffusion coefficient is very small since you are effectively in $\lim{k \to 0}$ now solving $\frac{\partial u}{\partial t} = k \left( \frac{\partial^2 u}{\partial x^2} \right)$ as $ \frac{\partial u(x,t)}{\partial t}=0$.
Using NDSolve
with "MethodOfLines"
options and increasing the "MaxPoints"
helped get rid of this problem. There might be other and better options to try.
This function below takes the number of spatial grid points you want to use. The smaller $k$ is, the larger the number of grid points need to be (i.e smaller grid size) to get rid of that kink near the left boundary you had.
Manipulate[
fun[k, lim, grid],
{{k, 1, "k"}, 0.000001, 1, 0.000001, Appearance -> "Labeled"},
{{grid, 39, "grid points"}, 39, 999, 2, Appearance -> "Labeled"},
{{lim, 1, "plot x limit"}, 0.01, 1, 0.01, Appearance -> "Labeled"},
SynchronousUpdating -> False,
ContinuousAction -> False,
SynchronousInitialization -> True,
Initialization :>
{
fun[k_, lim_, nPoints_] := Module[{u, t, x, sol, ic, bc},
bc = {u[t, 0] == t, u[t, 1] == 0};
ic = u[0, x] == 0;
sol =
First@NDSolve[
Flatten[{D[u[t, x], t] == k D[u[t, x], x, x], ic, bc}],
{u[t, x]}, {t, 0, 1}, {x, 0, lim},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"MaxPoints" -> nPoints, "MinPoints" -> nPoints},
Method -> "Adams"}, MaxSteps -> Infinity];
Plot[(u[t, x] /. sol) /. t -> 1, {x, 0, lim},
PlotRange -> All, ImageSize -> 300, Frame -> True,
ImageMargins -> {{30, 10}, {20, 20}}]
]
}
]
which gives