I'm trying to solve the heat equation on a torus and am running into a problem... Mathematica keeps running, but never finishes/ends. Even after leaving it running overnight, I still got nada.
Thoughts?
Here is my code(I also tried "DSolveValue"):
ClearAll
eqs = {D[[u][t, x, y], {t, 1}] ==
D[[u][t, x, y], {x, 2}] + D[[u][t, x, y], {y, 2}]};
torusBC = {[u][t, 0, y] == [u][t, 2*Pi, y], [u][t, x, 0] == [u][t, x, 2*Pi]};
iv = {[u][0, x, y] ==
DiracDelta[0, x - 0, y - 0] + DiracDelta[0, x - Pi/3, y - 0] +
DiracDelta[0, x - 2*Pi/3, y - 0] +
DiracDelta[0, x - Pi/6, y - Pi/2] +
DiracDelta[0, x - 3*Pi/6, y - Pi/2]};
sol = NDSolveValue[{eqs, torusBC, iv}, [u][t, x, y], {t, x, y}] //
FullSimplify
Plot3D[sol[x, y, t], {0, 2*Pi}, {0, 2*Pi}]
So, I've gone through and made the corrections... And reverted back to DSolveValue because of the dirac deltas. This is the code now:
eqs = D[u[t, x, y], {t, 1}] == D[u[t, x, y], {x, 2}] + D[u[t, x, y], {y, 2}];
torusBC = {u[t, 0, y] == u[t, 2 Pi, y], u[t, x, 0] == u[t, x, 2 Pi]};
iv = {u[0, x, y] ==
DiracDelta[x - (Pi/4), y] + DiracDelta[x - (2 Pi/3), y] +
DiracDelta[x - (4 Pi/3), y - (Pi/4)] +
DiracDelta[x - (Pi/3), y - (3 Pi/4)] +
DiracDelta[x - (5 Pi/3), y - (3 Pi/4)]};
sol = DSolveValue[{eqs, torusBC, iv}, u[t, x, y], {t, x, y}]
Manipulate[
Plot3D[sol, {x, 0, (2 Pi)}, {y, 0, (2 Pi)}, PlotRange -> Full,
AxesLabel -> {x, y, h}], {t, 0.00001, 1, Appearance -> "Labeled"}]
Now it's giving me a whole host of errors, but it at least looks like it's trying to compute something.
Thoughts?
For w/e it's worth... I'm doing this so I can spit out a contour graph at some random time, to turn into a .stl to 3D print for a demonstration. My use of 3D plot is really just to help me determine what time to choose.
ClearAll
at the beginning doesn't do anything, please check the document ofClearAll
carefully. 2.[u]
is clearly wrong, actually when I try executing your code, Mathematica immediately givesSyntax::sntxb
warning and stop, I won't why your code runs overnight. 3. The{t, x, y}
is wrong,NDSolveValue
is a numeric solver, you need to specify a domain for it. Please read the document ofNDSolveValue
carefully. 4.DiracDelta
won't work in numeric solver likeNDSolveValue
, you need to approximate it with smooth function... $\endgroup$NDSolve
is the better choice. You just need to approximateDiracDelta
with a smooth function. Though improved these days,DSolve
is still not that good at PDE solving. $\endgroup$