I have code for solving the heat equation in polar coordinates. NDSolveValue gives a very clean result (with a mild warning.) I have plotted the solution with Revolution3D and with Plot3D, but I am not satisfied. Is there a better way to plot this or are these acceptable visualizations? (I have only shown one graph from each at t = 20).

s[r, \[Theta], t], {r, -2, 2}, {\[Theta], -2 \[Pi], 2 \[Pi]}, 
AxesLabel -> {r, \[Theta], T[r, \[Theta], t]}, 
PlotRange -> {{-2, 2}, {-2 \[Pi], 2 \[Pi]}, {0, 70}}, 
AspectRatio -> 1], {t, 0, 80, 20}]

enter image description here

s[r, \[Theta], t], {r, -2, 2}, {\[Theta], -2 \[Pi], 2 \[Pi]}, 
AxesLabel -> {r, \[Theta], T[r, \[Theta], t]}, 
PlotRange -> {{-2, 2}, {-2 \[Pi], 2 \[Pi]}, {-5, 70}}], {t, 0,80, 

enter image description here

Here is the code that generated these solutions along with a CountourPlot:

a = 1;
s = NDSolveValue[{D[u[r, theta, t], t] == 
a^2 D[u[r, theta, t], {r, 2}] + (a^2/r) D[u[r, theta, t], 
   r] + (a^2/r^2) D[u[r, theta, t], {theta, 2}], 
DirichletCondition[u[r, theta, t] == 0, True], 
u[r, theta, 0] == 250}, 
u, {r, -2, 2}, {theta, -2 Pi, 2 Pi}, {t, 0, 300}]

s1[r, \[Theta], t], {r, -2, 2}, {\[Theta], -2 \[Pi], 2 \[Pi]}, 
PlotLegends -> Automatic], {t, 2, 300, 50}]

I think there is a problem with the solution as r -> 0.

enter image description here

  • 3
    $\begingroup$ A better way in what sense? What aspect would you like to see refined/updated? Also, it would be better to also provide the code that generates the solutions to these equations. If for your own reasons you don't want to share the PDE solver you have, perhaps you can give us a MWE -a test function so we can try and plot and help! $\endgroup$
    – user49048
    Feb 17, 2022 at 22:06
  • $\begingroup$ I am happy to provide the code for the solution below. I am wondering if there is a convention for showing the result or if there is a clearly superior way to visualize the result. $\endgroup$
    – Hank Foley
    Feb 19, 2022 at 16:34
  • $\begingroup$ I just added the code for the solutions. $\endgroup$
    – Hank Foley
    Feb 19, 2022 at 16:43
  • 1
    $\begingroup$ the code you posted is wrong. Try copying it to new worksheet with clean kernel and run. You will see the errors. $\endgroup$
    – Nasser
    Feb 19, 2022 at 16:53
  • $\begingroup$ It was missing the numerical value for and there was a typo. It works fine now. $\endgroup$
    – Hank Foley
    Feb 20, 2022 at 17:53

1 Answer 1


You can not have radius $r$ from -2 to +2 in polar coordinates. $r$ is the length of the r coordinates which must be positive. In addition, the angle needs to be from either 0 to 2 Pi or -Pi to Pi. That is enpugh.

Another option to display the result is to use ParametricPlot3D

a = 1;
lengthOfRadius = 2;
pde = D[u[r, theta, t], t] == a^2*Laplacian[u[r, theta, t], {r, theta}, "Polar"]
ic = u[r, theta, 0] == 10;
s = NDSolveValue[{pde, DirichletCondition[u[r, theta, t] == 0, True], 
   ic}, u, {r, 0, lengthOfRadius}, {theta, -Pi, Pi}, {t, 0, 5}]

And now to display the solution after 1 second

ParametricPlot3D[{r Cos[theta], r Sin[theta], s[r, theta, time]}, {r, 0, 
  lengthOfRadius}, {theta, -Pi, Pi}, Boxed -> False, Axes -> False, 
 ImageSize -> 300]

Mathematica graphics

And at time=5 seconds all the heat seem to have been dissipated.

Mathematica graphics

Using your RevolutionPlot3D it now shows as after one second

 s[r, theta, 1], {r, 0, lengthOfRadius}, {theta, -Pi, Pi}, 
 AspectRatio -> 1]

Mathematica graphics

  • $\begingroup$ (+1) a great answer as always. Maybe you can, also, mention that there was a potentially harmful extrapolation before. The PDE was solved until $t=100$ and then there in the Table $t$ went all the way to $300$. $\endgroup$
    – user49048
    Feb 21, 2022 at 4:58
  • $\begingroup$ Thank you - very helpful! $\endgroup$
    – Hank Foley
    Feb 21, 2022 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.