part 2 (problems using cylindrical and spherical coords)

Mathematica appendix to lectures on PDEs:
part 2 (problems using cylindrical and spherical coords)
Sec. 13.5 #2(b)
Semi-infinite cylinder of radius a (taken to be 1 here) with T=0 on rounded
surface and at infinity and T=r sin ΞΈπœƒ on bottom (z=0)
Use tables to speed up computation:
first the first 100 zeroes of J_1
In[38]:=
zeroJ1 = Table[BesselJZero[1, n], {n, 1, 100}] /βˆ•/βˆ• N;
Here is the sum of the first 100 terms contributing to the r and z dependence (with the overall sin ΞΈπœƒ
factor pulled out)
Total just adds up the entries of the array:
In[39]:=
tt1352[r_, z_] =
Total[(2 /βˆ• zeroJ1) (BesselJ[1, zeroJ1 r] /βˆ• BesselJ[2, zeroJ1]) Exp[-βˆ’ zeroJ1 z]];
In[40]:=
Plot[{tt1352[r, 0], tt1352[r, 0.05], tt1352[r, 0.1], tt1352[r, 0.5]}, {r, 0, 1},
AxesLabel β†’ο·οŠο”’ {r, T}, PlotRange β†’ο·οŠο”’ {{0, 1}, {0, 1}}, PlotStyle β†’ο·οŠο”’ {Thick},
PlotLabel β†’ο·οŠο”’ "Radial Temp distribution at z=0, 0.05, 0.1 and 0.5",
PlotLegends β†’ο·οŠο”’ {0, 0.05, 0.1, 0.05}]
T
Radial Temp distribution at z=0, 0.05, 0.1 and 0.5
1.0
0.8
0
0.05
0.6
Out[40]=
0.1
0.4
0.05
0.2
0.0
0.0
0.2
0.4
0.6
0.8
1.0
r
3D plot of T vs (x,y), using ParametricPlot3D to restrict plot to the region of the cylinder.
2
RevisedPDE2.nb
In[41]:=
ParametricPlot3D[{r Cos[theta], r Sin[theta], tt1352[r, 0.5] Sin[theta]},
{r, 0, 1}, {theta, 0, 2 Pi}, AxesLabel β†’ο·οŠο”’ {"x", "y", "T"},
PlotLabel β†’ο·οŠο”’ "T at z=0.5", BoxRatios β†’ο·οŠο”’ {1, 1, 1}]
Out[41]=
Lets see how this changes with z. Each plot takes a non-trivial amount of time to generate, lets prerender them. I’m making sure to specify PlotRange here so they are all scaled the same. I’m also using
β€œParallelTable” so that each core of my computer is making plots. This sped it up on my personal laptop
by a factor of 2, this won’t always make things faster depending on your individual machine. If you are
curious, try running it both ways (using Table and ParallelTable) inside the function AbsoluteTiming[ ].
In[42]:=
VaryZFrames = ParallelTable[ParametricPlot3D[
{r Cos[theta], r Sin[theta], tt1352[r, z] Sin[theta]}, {r, 0, 1}, {theta, 0, 2 Pi},
AxesLabel β†’ο·οŠο”’ {"x", "y", "T"}, PlotLabel β†’ο·οŠο”’ StringForm["T at z=``", z],
BoxRatios β†’ο·οŠο”’ {1, 1, 1}, PlotRange β†’ο·οŠο”’ {{-βˆ’ 1, 1}, {-βˆ’ 1, 1}, {-βˆ’ 1, 1}}], {z, 0, 1, .1}];
StringForm is a function that makes the second argument into a string and puts it where the ``s are.
RevisedPDE2.nb
In[43]:=
Manipulate[VaryZFrames[[i]], {i, 1, 10, 1}]
i
7
Out[43]=
This is how you plot just a β€œwedge” of the solution, which is useful for HW10 plots
3
4
RevisedPDE2.nb
In[44]:=
ParametricPlot3D{r Cos[theta], r Sin[theta], tt1352[r, 0.5] Sin[theta]},
{r, 0, 1}, ο€œtheta, Pi ο€Œ 3, 2 Pi ο€Œ 3ο€§, AxesLabel β†’ο·οŠο”’ {x, y, "T"},
PlotLabel β†’ο·οŠο”’ "T at z=0.5", BoxRatios β†’ο·οŠο”’ {1, 1, 1}
Out[44]=
β–  Sec. 13.7 #1
Steady state temp in a sphere of radius 1 if surface temp is 35 cos^4 ΞΈπœƒ
Here's the solution
In[45]:=
tt1371[r_, theta_] =
7 + 20 r ^ 2 LegendreP[2, Cos[theta]] + 8 r ^ 4 LegendreP[4, Cos[theta]];
Checking the BC
In[46]:=
Out[46]=
Expand[tt1371[1, theta]]
35 Cos[theta]4
Plotting T vs ΞΈπœƒ at various radii:
RevisedPDE2.nb
In[47]:=
5
Plot[{tt1371[0, th], tt1371[0.25, th], tt1371[0.5, th],
tt1371[0.75, th], tt1371[1, th]}, {th, 0, Pi}, PlotRange β†’ο·οŠο”’ {-βˆ’ 5, 35},
Ticks β†’ο·οŠο”’ {Table[n *⋆ Ο€ /βˆ• 8, {n, 0, 16}], Automatic}, AxesLabel β†’ο·οŠο”’ {"ΞΈ", "T"},
PlotLabel -βˆ’> "T vs ΞΈ (r=0, 1/βˆ•4, 1/βˆ•2, 3/βˆ•4 & 1)",
PlotStyle β†’ο·οŠο”’ {Thick}, PlotLegends β†’ο·οŠο”’ {0, .25, .5, .75, 1}]
T vs ΞΈπœƒ (r=0, 1/βˆ•4, 1/βˆ•2, 3/βˆ•4 & 1)
T
30
0
0.25
20
0.5
Out[47]=
0.75
10
1
Ο€πœ‹
Ο€πœ‹
3 Ο€πœ‹
Ο€πœ‹
5 Ο€πœ‹
3 Ο€πœ‹
7 Ο€πœ‹
8
4
8
2
8
4
8
ΞΈπœƒ
Ο€πœ‹
A fancier way of plotting (here for r=0.5 and 1):
In[48]:=
SphericalPlot3D{tt1371[0.5, th], tt1371[1, th]}, {th, 0, Pi}, ο€œΟ•, 0, 3 Pi ο€Œ 2
Out[48]=
Here we can vary r to look at the the angular distribution. The β€œradius” in the plot represents the temperature at a given {ΞΈπœƒ,Ο•πœ‘} point, not the actual radius.
6
RevisedPDE2.nb
In[49]:=
ManipulateSphericalPlot3Dtt1371[r, th], {th, 0, Pi},
ο€œΟ•, 0, 3 Pi ο€Œ 2ο€§, PlotRange β†’ο·οŠο”’ {{-βˆ’ 10, 10}, {-βˆ’ 10, 10}, Automatic}, {r, 1, 0}
r
0.0923346
Out[49]=