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.2  Cartesian and Cylindrical Coordinates

Problem 4:  Potential inside a Rectangular Box with Five Sides at zero potential

Consider a rectangular enclosure with sides at: x=0, x=a, y=0,  y=b, z=0 and z=c.  The side at z=c has the potential V[x,y,c]=V0 and the other five sides have zero potential.

Part (a)   Express the potential for general V[x,y,z] as an expansion of functions expresses in Cartesian coordinates.  Find the expansion coefficients.

Clear[A, pot, term, mz,  val1, val2]

\(term[mx_, my_] := 
      \((A[mx, my]\ Sin[mx\ π\ x/a]

          		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ Sin[my\ π\ y/b]

          			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ Sinh[mz\ π\ z/c])\)\)

pot[nx_,ny_]:=Sum[term[mx,my]//Evaluate,{mx,1,nx},{my,1,ny}]

pot[nx, ny]

val1 = {{x -> 0}, {y -> 0}, {z -> 0}, {x -> a}, {y -> b}}

val2 = {Sin[mx π] -> 0, Sin[my π] -> 0}

(pot[nx, xy] //. val1) //. val2

mzSol = 
      Solve[(π mx/a)^2  +  (π my/b)^2  + 
              (π I mz/c)^2  == 0, mz][[2]]

eq1 = V0 == term[mx, my] //. {z -> c}

\(trigRules = {Sin[2\ mx\ π] -> 0, \ Sin[2\ my\ π] -> 0, 

        	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        Sin[mx\ π] -> 0, Cos[mx\ π] -> \((\(-1\))\)^mx, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        Sin[my\ π] -> 0, Cos[my\ π] -> \((\(-1\))\)^my, 

        	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        Sin[mx\ π/2] -> \((1 - \((\(-1\))\)^mx)\)/2, 

        				\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        Sin[my\ π/2] -> \((1 - \((\(-1\))\)^my)\)/2}\)

\(rhs = 
      \((Integrate[eq1[\([2]\)]\ Sin[mx\ π\ x/a]\ Sin[my\ π\ y/b]

            			, {x, 0, a}, {y, 0, b}])\) //. trigRules\)

\(lhs = 
      \((\((Integrate[eq1[\([1]\)]\ Sin[mx\ π\ x/a]\ Sin[my\ π\ y/b]

                			, {x, 0, a}, {y, 0, b}])\) //. trigRules)\) // Simplify
        \)

aSol = Solve[rhs == lhs, A[mx, my]] // Flatten // Simplify

A[mx_, my_] = A[mx, my] /. aSol

pot[nx, ny]

Part (b)   Find the first few terms of the potential expansion when V[x,y,c] ≡ V0 = 1.  Illustrate the accuracy of the solutionby comparing the results with the boundary potential on the wall z=c.

vals = {a -> 1, b -> 1, c -> 1, V0 -> 1}

mz = mz /. mzSol

pot[3, 3] /. vals

\(\(Plot[
      Table[\(pot[n, n] //. vals\) //. {x -> 1/2, z -> 1}

          		, {n, 2, 8, 2}] // Evaluate
	, {y, 0, 1}]; \)\)

\(\(Plot3D[\(pot[8, 8] //. vals\) //. {z -> 1} // Evaluate

      	, {y, 0, 1}, {x, 0, 1}]; \)\)

\(\(Plot3D[\(pot[4, 4] //. vals\) //. {z -> 1} // Evaluate

      	, {y, 0, 1}, {x, 0, 1}
	, ColorFunction -> Hue]; \)\)

\(\(ContourPlot[\(pot[8, 8] //. vals\) //. {z -> 1} // Evaluate

      	, {x, 0, 1}, {y, 0, 1}
\ \ , ContourSmoothing -> True]; \)\)

\(\(ContourPlot[\(pot[4, 4] //. vals\) //. {z -> 1} // Evaluate

      	, {x, 0, 1}, {y, 0, 1}
\ \ , ContourSmoothing -> True
\ \ , 
      ColorFunction -> Hue]; \)\)

Part (c)   Let x=1/2 and plot the potential in the {y,z} plane.  Let x=1/2 and use VEPlot to plot the equipotential surfaces and the electric field in the {y,z} plane.

\(\(Plot3D[\(pot[4, 4] //. vals\) //. {x -> 1/2} // Evaluate

      	, {y, 0, 1}, {z, 0, 1}]; \)\)

\(\(Plot3D[\(pot[60, 60] //. vals\) //. {x -> 1/2} // Evaluate

      	, {y, 0, 1}, {z, 0, 1}]; \)\)

\(\(VEPlot[\(pot[8, 8] //. vals\) //. {x -> 1/2} // Evaluate

      	, {y, 0, 1}, {z, 0, 1}]; \)\)