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

Problem 3:  Potential with a Rectangular Conduit

Consider a rectangular conduit that runs from z=+∞ to -∞ and is  bounded by four located at: x=0, x=a, y=0, and y=b.  The potential is  zero on the sides y=0, and y=b.  On the side x=a the potential is V[a,y]=V0 and on the side x=0 the potential satisfies the equation v'[x]=0.

Part (a)   Express the potewntial as an expansion in Cartesian coordinates.  Determine the expansion coefficients.

term[m_] = A[m] Cosh[m π x/b] Sin[m π y/b]

pot[n_]:=Sum[term[m]//Evaluate,{m,1,n}]

pot[n]

D[pot[n], x] //. {x -> 0}

D[pot[100], x] //. {x -> 0}

pot[n] //. {x -> a}

eq1 = V0 == term[m] /. {x -> a}

\(rhs = 
      \((\((Integrate[eq1[\([2]\)]\ Sin[m\ π\ y/b], {y, 0, b}]
			 // 
              Simplify
		)\) //. {Sin[2\ m\ π] -> 0}
		)\)\)

\(lhs = 
      \((\((Integrate[eq1[\([1]\)]\ Sin[m\ π\ y/b], {y, 0, b}]
		)
              \) //. {Cos[m\ π] -> \((\(-1\))\)^m}
		)\) // Simplify
        \)

\(aSol = \(Solve[rhs == lhs, A[m]] // Flatten\) // Simplify; 

    A[m_] = A[m] /. aSol\)

pot[n]

Part (b)   Plot the potential on wall x=a and compare the results with the boundary condition potential.  Experiment by keeping more terms in the expression for the potential.  Make a three dimensional plot of the potential.

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

\(\(Plot[
      \(Table[pot[n], {n, 2, 8, 2}]
	 //. {x -> a}\) //. vals // Evaluate

      	, {y, 0, 1}
, PlotRange -> {0, 2}]; \)\)

\(\(Plot[
      \(Table[pot[n], {n, 10, 20, 2}]
	 //. {x -> a}\) //. vals // Evaluate
        
	, {y, 0, 1}
, PlotRange -> {0, 2}]; \)\)

\(\(Plot[
      \(Table[pot[n], {n, 20, 100, 20}]
	 //. {x -> a}\) //. vals // 
        Evaluate
	, {y, 0, 1}
, PlotRange -> {0, 2}]; \)\)

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

\(\(Plot3D[pot[10] //. vals // Evaluate
	, {y, 0, 1}, {x, 0, 1}
, 
      ViewPoint -> {2, 2, 1}]; \)\)

\(\(Plot3D[pot[100] //. vals // Evaluate
	, {y, 0, 1}, {x, 0, 1}
, 
      ViewPoint -> {2, 2, 1}]; \)\)

Part (c)   Plot the equipotential surfaces and the electric field in the {x,y} plane.

VEPlot[pot[4] //. vals, {x, 0, 1}, {y, 0, 1}];

VEPlot[pot[10] //. vals, {x, 0, 1}, {y, 0, 1}];

VEPlot[pot[100] //. vals, {x, 0, 1}, {y, 0, 1}];