1
$\begingroup$

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.

$\endgroup$
11
  • 1
    $\begingroup$ Your code is full of simple mistakes. 1. ClearAll at the beginning doesn't do anything, please check the document of ClearAll carefully. 2. [u] is clearly wrong, actually when I try executing your code, Mathematica immediately gives Syntax::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 of NDSolveValue carefully. 4. DiracDelta won't work in numeric solver like NDSolveValue, you need to approximate it with smooth function... $\endgroup$
    – xzczd
    Jul 3, 2020 at 2:16
  • 1
    $\begingroup$ ...5. Boundary conditions are missing. In a word, please calm down, learn the basics of Mathematica first. When you encounter problem, check the document by pressing F1. Coding blindly won't help. $\endgroup$
    – xzczd
    Jul 3, 2020 at 2:18
  • $\begingroup$ @xzczd Thanks for pointing those out to me, I just corrected them and updated my question to reflect the corrections. Having said that, I'm still getting errors. $\endgroup$ Jul 3, 2020 at 4:01
  • $\begingroup$ Now the equation looks suspicious, you mentioned you're solving on a torus, then usually we need laplacian in polar coordinates, but you're using that in Cartesian; the b.c. is also suspicious. Can you show us the problem in traditional math notation? $\endgroup$
    – xzczd
    Jul 3, 2020 at 4:11
  • 1
    $\begingroup$ I'd say finding a numeric solution with NDSolve is the better choice. You just need to approximate DiracDelta with a smooth function. Though improved these days, DSolve is still not that good at PDE solving. $\endgroup$
    – xzczd
    Jul 3, 2020 at 8:34

0