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 3:   Sphere with an axially symmetric charge distribution

Conside a sphere with an axially symmetric charge distribution.  Assume that the sphere has a surface-charge density that is in powers of Cos^n[θ].

Part (a)   Find the potential outside and inside the sphere for an arbitrasry charge density.

potInA[s_]:= 
	Sum[(A[i] (r/a)^i) LegendreP[i,Cos[θ]],{i,0,s}]

potOutA[s_]:=
	Sum[(A[i] (a/r)^(i+1) ) LegendreP[i,Cos[θ]],{i,0,s}]

chargeDensity[s_]:=
	(1/(4π))(D[potInA[s],r]-D[potOutA[s],r])//.{r->a}

chargeDensity[2]

Aequation[s_,ρ_]:=
LogicalExpand[chargeDensity[s]==ρ + O[Cos[θ]]^(s+1)]

Aequation[2, Q Cos[θ]^2]

Arule[s_,ρ_]:=
	Solve[Aequation[s,ρ],Array[A,s+1,0]]//Flatten

Arule[4, Q Cos[θ]^2]

Part (b)  Let the surface charge density be Q/(a^2)  (Cos[θ] + (1/2)Cos[θ]^2).  Find the potential using the results derived in Part (a) .  Plot the potential in the {r,θ} plane.

σ=Q/a^2 (Cos[θ] + 1/2 Cos[θ]^2)//Expand

potOutQ=potOutA[2]//.Arule[2,σ]

potInQ=potInA[2]//.Arule[2,σ]

values={Q->1,a->1}

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

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

Show[p1,p2];

Part (c)  Plot the equipotential surfaces and electric field lines for the potential found in Pard (b).

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

eq1=potInQ/.r2xRule/.values/.x->0//ExpandAll//Together

eq2=potOutQ/.r2xRule/.values/.x->0//ExpandAll

((2 π)/(3 (Sqrt[(y^2) + (z^2)]))) + 
      ((4 π z)/(3 (y^2) (Sqrt[(y^2) + (z^2)]) + 
          3 (z^2) (Sqrt[(y^2) + (z^2)]))) - 
      ((2 π)/(15 (y^2) (Sqrt[(y^2) + (z^2)]) + 
          15 (z^2) (Sqrt[(y^2) + (z^2)]))) + 
      ((12 π (z^2))/((2 (y^2) + 2 (z^2)) 
          (15 (y^2) (Sqrt[(y^2) + (z^2)]) + 15 (z^2) (Sqrt[(y^2) + (z^2)]))
            ))

pot = If[y^2 + z^2 < 1
	, -(2/15)*(-5*Pi + Pi*y^2 - 10*Pi*z - 2*Pi*z^2)
	,  (2*Pi)/(3*Sqrt[y^2 + z^2]) + 
    	(4*Pi*z)/(3*y^2*Sqrt[y^2 + z^2] + 3*z^2*Sqrt[y^2 + z^2]) - 
    	(2*Pi)/(15*y^2*Sqrt[y^2 + z^2] + 15*z^2*Sqrt[y^2 + z^2]) + 
    	(12*Pi*z^2)/
     	((2*y^2 + 2*z^2)*(15*y^2*Sqrt[y^2 + z^2]
     	+ 15*z^2*Sqrt[y^2 + z^2]))];

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

Show[VEPlot[pot,{y,-2,2.1},{z,-2,2.1}],circle];