5. Lagrangians and Hamiltonians

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.1  Point Charges, Multipoles, and Image Problems

Problem 5:  Multiopole Expansions of Charge Distributions

Consider the charge densities:
		ρ1 = q0 (a - r) / a^4  (Sin[θ] - π/4)
		ρ2 = q0 (a - r) / a^4  Exp[(a - r)/a] Cos[θ]
		ρ3 = q0 (a - r)^2 / a^5  Sin[θ]^2 Sin[2 ϕ]
	for r ≺ a snd ρi = 0 for r ≥ a.

Part (a)  Use ContourPlot to make a two dimensional plot of the charge densities.

ρ1  =  
      q0 (a  -  r) / a^4  (Sin[θ]  -  π/4)

ρ2  =  
      q0 (a  -  r) / a^4  Exp[(a  -  r)/a] 
        Cos[θ]

ρ3  =  
      q0 (a  -  r)^2 / a^5  Sin[θ]^2 Sin[2 ϕ]

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

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

\(\(ContourPlot[\(\(ρ1 /. r2xRule\) //. values\) /. {y -> 0}

      	, {x, \(-1\), 1}, {z, \(-1\), 1}
\ \ , PlotPoints -> 20
	, 
      ColorFunction -> Hue]; \)\)

\(\(ContourPlot[\(\(ρ2 /. r2xRule\) //. values\) /. {y -> 0}

      	, {x, \(-1\), 1}, {z, \(-1\), 1}
\ \ , PlotPoints -> 20
	, 
      ColorFunction -> Hue]; \)\)

\(\(ContourPlot[\(\(ρ3 /. r2xRule\) //. values\) /. {z -> 0}

      	, {x, \(-1\), 1}, {y, \(-1\), 1}
\ \ , PlotPoints -> 20
	, 
      ColorFunction -> Hue]; \)\)

Part (b)   Find the multipole expansion for the potentials.

multi1 = MultipoleP[ρ1, a, 2]

multiCheck = MultipoleSH[ρ1, a, 2]

multi1 == multiCheck //. {P -> LegendreP, Y -> SphericalHarmonicY} // 
      Simplify

multi2 = MultipoleP[ρ2, a, 2]

multi3 = MultipoleSH[ρ3, a, 2] // Simplify

Part (c)  Find the electric fields for the multipole expansion for the potentials.

eField1 = -Grad[multi1, Spherical[r, θ, ϕ]]

eField1 //. {P -> LegendreP} // Simplify

eField2 = 
      -Grad[multi2, Spherical[r, θ, ϕ]] //. {
            P -> LegendreP} // Simplify

eField3 = 
      -Grad[multi3 //. {Y -> SphericalHarmonicY, P -> LegendreP}, 
              Spherical[r, θ, ϕ]] // ExpToTrig // Simplify

Part (d)   Plot the potential contours and electric field lines of the multipole expansions using VEPlot.

\(pot1 = 
      \((\(\(\(multi1 /. r2xRule\)

                				 //. {Y -> SphericalHarmonicY, P -> LegendreP}\)

              				 //. values\) /. {y -> 0, z -> y})\) // Simplify\)

VEPlot[pot1];

\(pot2 = 
      \((\(\(\(multi2 /. r2xRule\)

                				 //. {Y -> SphericalHarmonicY, P -> LegendreP}\)

              				 //. values\) /. {y -> 0, z -> y})\) // Simplify\)

VEPlot[pot2];

\(pot3 = 
      \(\(\((\(\(\(multi3 /. r2xRule\)

                    				 //. {Y -> SphericalHarmonicY, P -> LegendreP}\)

                  				 //. values\) /. {z -> 0})\) // ExpToTrig\) // 
          ExpandAll\) // Simplify\)

VEPlot[pot3];