5. Electrostatics

Legal Notice, Disclaimer, and Book Ordering Information:

Null

Setup

\(Clear["Global`*"]; 
Off[General::spell]; 
Off[General::spell1]; 
    \)

Needs["Calculus`VectorAnalysis`"]

Needs["Graphics`PlotField`"]

Needs["Graphics`PlotField3D`"]

<< "D:\Mma\Inits\ch5init.m"

Clear["Global`*"];

5.2 Problems

5.2.3  Legendre Polynomials and Spherical Harmonics

Problem 5:   Sphere with upper hemisphere V0 and lower hemisphere -V0.

Conside a sphere with a surface potential that is a discontinuous function.  The upper hemisphere has a potential +V0 and the lower hemisphere has a potential -V0.

Part (a)   Find the potential outside and inside the sphere.  Plot the potential as a function of {r,θ}.

potIn[s_]:= 
	Sum[(B[n] (r/r0)^n) P[n,Cos[θ]],{n,0,s}]

potOut[s_]:=
	Sum[(B[n] (r0/r)^(n+1) ) P[n,Cos[θ]],{n,0,s}]

B[n_]:=
	(2 n+1)/2 (
	+Integrate[+V0 LegendreP[n,Cos[θ]] Sin[θ],{θ,0,π/2}]
	+Integrate[-V0 LegendreP[n,Cos[θ]] Sin[θ],{θ,π/2,π}])

pOut=potOut[5]

pIn=potIn[5]

values={r0->1,V0->1,P->LegendreP}

Plot[Table[(pIn//.values),{r,0,1,0.2}]//Evaluate,{θ,0,2π}];

p1 = CylindricalPlot3D[
	pIn//.values//Evaluate
	,{r,0,1},{θ,0,2π}
	,BoxRatios->{1,1,1}
	,ViewPoint->{-1.5,-2,2}];

p2 = CylindricalPlot3D[
	pOut//.values//Evaluate
	,{r,1,3},{θ,0,2π}
	,BoxRatios->{1,1,1}
	,ViewPoint->{-1.5,-2,2}];

Show[p1,p2];

Part (b) Plot the equipotential surfaces in the x=0 plane.

r2xRule=({r,θ,ϕ}->CoordinatesFromCartesian[{x,y,z},Spherical]//Thread)

allRules=Join[{x->0},values,r2xRule]

potTot=If[y^2+z^2<=1,pIn//.allRules,pOut//.allRules]

circle=ParametricPlot[{Cos[t],Sin[t]},{t,0,2π}
		,Axes->False
		,PlotStyle->{Thickness[0.020]}];

Show[{
	ContourPlot[potTot//Evaluate
		,{y,-2,2},{z,-2,2}
		,ContourSmoothing->True]
	,circle
	}];

con=ContourPlot[potTot//Evaluate
		,{y,-2,2},{z,-2,2}
		,PlotPoints->30
		,ColorFunction->Hue
		,Contours->20
		,ContourSmoothing->True];

Show[{con,circle}];