me 201/mth 281/me400/che400 contours for laplace equation

9
ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation 1.Introduction In this notebook, we construct contour plots of various solutions of Laplace's equation in a rectangle. The problem considered in section 2 has zero boundary conditions on three edges, and a parabolic distribution on the fourth edge. In section 3, we consider zero boundary conditions on three edges and a constant potential on the fourth edge. In section 4, a movie is constructed which shows in a particular case how the interior solution changes as the boundary conditions are changed. 2. Parabolic Distribution on One Boundary In this section, we look at the solution of the boundary value problem given below. 2 F x 2 + 2 F y 2 = 0, 0 < x < a,0 < y < b, with F H0, yL =F Hx,0L = F Ha, yL = 0, and F Hx, bL = F 0 x a 1 - x a . Here F 0 is a constant. This problem was solved in class by separation of variables. The result is F Hx, yL = n=1 c n sinh Hnpy ê aL sinh Hnpb ê aL sin Hnpx ê aL, where c n = 0 for n even, 8 F 0 n 3 p 3 for n odd. We define this series for Mathematica. We call the boundary function fbound[x], and its Fourier sine coefficients are called c[n]. The nth term in the series is called term[x,y,n], and the kth partial sum of the series is called phisum[x,y,k]. ü Definition of the Series fbound@x_D :=F 0 * Hx ê aL * H1 - x ê aL c@n_D := If@OddQ@nD, H8 *F 0 LêHn^3 * Pi^3L,0D term@x_, y_, n_D := N@c@nD * HSinh@Hn *p* yaSinh@Hn *p* baDL * Sin@Hn *p* xaDD phisum@x_, y_, k_D := Sum@term@x, y, nD, 8n, 1, k<D ü Parameter Values Now we specify the values of the parameters in the boundary function, and the size of the rectangle. All units are SI. a = 2; H** m **L b = 1; H** m **L F 0 = 40; H** volts **L

Upload: others

Post on 10-Apr-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

ME 201/MTH 281/ME400/CHE400Contours for Laplace Equation

1.Introduction

In this notebook, we construct contour plots of various solutions of Laplace's equation in a rectangle. The problemconsidered in section 2 has zero boundary conditions on three edges, and a parabolic distribution on the fourth edge. In section 3,we consider zero boundary conditions on three edges and a constant potential on the fourth edge. In section 4, a movie isconstructed which shows in a particular case how the interior solution changes as the boundary conditions are changed.

2. Parabolic Distribution on One Boundary

In this section, we look at the solution of the boundary value problem given below.

∂2F

∂x2+

∂2F

∂y2= 0 , 0 < x < a, 0 < y < b,

with F H0, yL = F Hx, 0L= F Ha, yL= 0, and F Hx, bL= F0x

a1 -

x

a.

Here F0is a constant. This problem was solved in class by separation of variables. The result is

F Hx, yL =‚n=1

cnsinh Hnpy êaL

sinh Hnpb êaLsin Hnpx êaL, where cn = 0 for n even,

8 F0

n3 p3for n odd.

We define this series for Mathematica. We call the boundary function fbound[x], and its Fourier sine coefficients arecalled c[n]. The nth term in the series is called term[x,y,n], and the kth partial sum of the series is called phisum[x,y,k].

ü Definition of the Series

fbound@x_D := F0 * Hx ê aL * H1 - x ê aL

c@n_D := If@OddQ@nD, H8 * F0L ê Hn^3 * Pi^3L, 0D

term@x_, y_, n_D := N@c@nD * HSinh@Hn * p * yL ê aD ê Sinh@Hn * p * bL ê aDL * Sin@Hn * p * xL ê aDD

phisum@x_, y_, k_D := Sum@term@x, y, nD, 8n, 1, k<D

ü Parameter Values

Now we specify the values of the parameters in the boundary function, and the size of the rectangle. All units are SI.

a = 2; H** m **L

b = 1; H** m **L

F0 = 40; H** volts **L

It is useful for plotting purposes to have information on the range of the functions. We specify here the minimum andmaximum value of the boundary function. They are called boundmin and boundmax.

Page 2: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

It is useful for plotting purposes to have information on the range of the functions. We specify here the minimum andmaximum value of the boundary function. They are called boundmin and boundmax.

boundmin := 0;

boundmax := F0 ê 4;

ü Graphical Check of Sine Series for Boundary Function

We now check that the series correctly represents the boundary function, by plotting both the exact boundary functionand the series representation. We use 20 terms in the series, which should be ample given that the convergence is like 1/n3 on theboundary. We plot the exact boundary function in red, the series approximation in blue. We first calculate a plot range, whichwe call plrange.

plrange := 8boundmin - 0.1 * Hboundmax - boundminL, boundmax + 0.1 * Hboundmax - boundminL<

graphbound = Plot@8phisum@x, b, 20D, fbound@xD<, 8x, 0, a<, PlotRange Ø plrange, ImageSize Ø 250,AxesLabel Ø 8"x", "boundary function"<, PlotStyle Ø 8RGBColor@0, 0, 1D, RGBColor@1, 0, 0D<D

0.5 1.0 1.5 2.0x

2

4

6

8

10

boundary function

The curves coincide, verifying the accuracy of the solution series on the boundary.

ü Contour Plots

We use Mathematica's contour plot routine to construct a contour plot of the solution. We use 20 terms in the seriessolution to construct the plot. The list countrange is a calculated set of contour values. We get 11 contours from the minimumboundmin to the maximum boundmax, at equal intervals of potential.

countrange := Module@8rng, inc, ans<, rng = boundmax - boundmin; inc = rng ê 10;ans = 8boundmin<; Do@ans = Append@ans, boundmin + j * incD, 8j, 1, 10<D; ansD

We check this for the present parameter values.

countrange

80, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10<

Now we construct the contour plot. We use the contour list constructed above, and we set the aspect ratio to b/a, to keep thepicture true to the geometry.

2 lapcon.nb

Page 3: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

topgraph = ContourPlotBphisum@x, y, 20D, 8x, 0, a<, 8y, 0, b<, Contours Ø countrange,

AspectRatio Øb

a, ImageSize Ø 250, PlotLabel Ø "Contours for Solution

of LaPlace Equation"F

The 10-volt contour is just a point -- the midpoint of the top boundary -- and doesn't show.

If you use the mouse to pass the cursor over the contour plot, you will see the numerical value of the potential displayedas you cross each contour.

We can eliminate the shading by using the option ContourShading set to False.

topgraph2 = ContourPlotBphisum@x, y, 20D, 8x, 0, a<, 8y, 0, b<, Contours Ø countrange,

AspectRatio Øb

a, ImageSize Ø 250, ContourShading Ø False, PlotLabel Ø "Contours for Solution

of LaPlace Equation"F

This gives a clearer view of the lower voltage contours, including the zero contour, which made up of the two sides and thebottom of the box.

3. Constant Potential on One Boundary

We reconsider the above boundary-value problem with the boundary condition now being a constant potential on theupper boundary. The other three sides are still held at zero potential. The new boundary function is

fbound@x_D := F0

Very few changes are required in what we have defined above. We must redefine the range functions boundmin and boundmax,and we must redefine the Fourier sine coefficients c[n]. We do that now.

lapcon.nb 3

Page 4: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

boundmin := 0; boundmax := F0;

c@n_D := If@OddQ@nD, H4 * F0L ê Hn * PiL, 0D

We choose the boundary potential to be 10 volts. Then the maximum in this problem is the same as in the previous problem.

F0 = 10.0;

ü Graphical Check of Sine Series for Boundary Function

We now check that the series correctly represents the boundary function, by plotting both the exact boundary funcitonand the series representation. Because the convergence on the boundary is only like 1/n, we will need many terms. We use 100terms. We plot the exact boundary function in red, the series approximation in blue. The plot range is the same as before.

graphbound2 =Plot@8phisum@x, b, 100D, fbound@xD<, 8x, 0, a<, PlotRange Ø plrange, ImageSize Ø 250,AxesLabel Ø 8"x", "boundary function"<, PlotStyle Ø 8RGBColor@0, 0, 1D, RGBColor@1, 0, 0D<D

0.5 1.0 1.5 2.0x

2

4

6

8

10

boundary function

Because the function represented by the Fourier sine series on the boundary is discontinuous, we see the usual struggle forconvergence with the Gibbs overshoot. The situation is much better in the interior of the rectangle, where the hyperbolic func-tions give us exponential convergence, so that only a modest number of terms are needed.

ü Contour Plots

We use Mathematica's contour plot routine to construct a contour plot of the solution. We use 20 terms in the seriessolution to construct the plot. The list countrange is a calculated set of contour values. We get 11 contours with equal incre-ments of potential from the minimum, boundmin, to the maximum, boundmax.

countrange := Module@8rng, inc, ans<, rng = boundmax - boundmin; inc = rng ê 10;ans = 8boundmin<; Do@ans = Append@ans, boundmin + j * incD, 8j, 1, 10<D; ansD

We check this for the present parameter values.

countrange

80, 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.<

Now we construct the contour plot. We use the contour list constructed above, and we set the aspect ratio to b/a, to keep thepicture true to the geometry. We use turn off shading.

4 lapcon.nb

Page 5: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

topgraph2 = ContourPlotBphisum@x, y, 20D, 8x, 0, a<, 8y, 0, b<, Contours Ø countrange,

AspectRatio Øb

a, ImageSize Ø 250, ContourShading Ø False, PlotLabel Ø "Contours for Solution

of LaPlace Equation"F

We get the interesting result that all of the contours originate in the discontinuities at the upper corners. We also see the contourroutine struggling with the 10 volt contour, which is just the upper boundary. We can get a cleaner plot by omitting both the 0and 10 volt contours.

countrange = Take@countrange, 82, 10<D

81., 2., 3., 4., 5., 6., 7., 8., 9.<

topgraph3 = ContourPlotBphisum@x, y, 20D, 8x, 0, a<, 8y, 0, b<, Contours Ø countrange,

AspectRatio Øb

a, ImageSize Ø 250, ContourShading Ø False, PlotLabel Ø "Contours for Solution

of LaPlace Equation"F

We still can see glitches in the 9-volt contour. Near the boundary, we probably need more than 20 terms in the series. We repeatthe graph with 100 terms.

lapcon.nb 5

Page 6: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

topgraph4 = ContourPlotBphisum@x, y, 100D, 8x, 0, a<,

8y, 0, b<, Contours Ø countrange, AspectRatio Øb

a, PlotPoints Ø 30,

ImageSize Ø 250, ContourShading Ø False, PlotLabel Ø "Contours for Solution

of LaPlace Equation"F

There is considerable improvement in the 9-volt contour.

4. An Example of Dependence on Boundary Conditions

The primary concept associated with Laplace's equation is equilibrium. In some contexts, the concept is called steadystate. The point is that solutions of the Laplace equation depend at every interior point on every value specified on the boundary.This is in sharp contrast to the wave equation, for which there are well-defined domains of dependence, and in sharp contrastwith the heat equation, for which solutions at a given time depend on boundary conditions for past times, but not on futureboundary conditions. We illustrate the concept here for the Laplace equation by looking at a sequence of contour plots ofsolutions of the Laplace equation in a rectangle, as we morph smoothly from one boundary condition to another. The problem isspecified below.

∂2F

∂x2+

∂2F

∂y2= 0 , 0 < x < 1, 0 < y < 1,

with F H0, yL = F Hx, 0L= 0, F H1, yL= asin HpyL and F Hx, 1L= H1 - aL sin HpxL .

The potential is always zero on the left side and the bottom. When a = 0, the potential is also zero on the right side, and isnonzero on the top. When a = 1, the potential is nonzero on the right side and zero on the top. In the movie to be created below,we vary a continuously between 0 and 1, and observe the change of the contours in the interior of the rectangle associated withthe changes in the boundary condition.

We start with a solution in which F is zero on every boundary but the top, where it takes on the value Sin[p*x]. We endwith a solution in which F is zero on every boundary but the right, on which it takes on the value Sin[p*y]. We morph smoothlybetween these two and watch the contours change. The solution in this case is simple to obtain -- the normal series solutionreduces to a single term for each nonzero boundary condition. The solution is given below.

F[x_,y_,a_] := ((1.0-a)*Sin[p*x]*Sinh[p*y])/Sinh[N[p]] + (a*Sin[p*y]*Sinh[p*x])/Sinh[N[p]]

Now we define a funtion which produces contour plots shaded by colors.

con[a_] := ContourPlot[F[x,y,a],{x,0,1},{y,0,1},ImageSize->250, ColorFunction->Hue]

Now we make a movie with 101 graphs making the transition from a = 0 to a = 1. In the printed version of the notebook, onlythe first graph in the 101 graph sequence is shown. To see the movie, select the cell containing the graph group (the cell justbelow this text) and then go to the menu Graphics->Rendering->Animate Selected Graphics.

6 lapcon.nb

Page 7: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

Now we make a movie with 101 graphs making the transition from a = 0 to a = 1. In the printed version of the notebook, onlythe first graph in the 101 graph sequence is shown. To see the movie, select the cell containing the graph group (the cell justbelow this text) and then go to the menu Graphics->Rendering->Animate Selected Graphics.

Do[Print[con[n*0.01]],{n,0,100}];

As we change the boundary condition continuously, we see that the all of the contours in the interior change. This givesan example of the dependence of the interior solution on the boundary conditions.

For visualization in the printed version of this notebook, we construct an abbreviated sequence of 6 graphs.

Do[Print[con[n*0.2]],{n,0,5}];

lapcon.nb 7

Page 8: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

8 lapcon.nb

Page 9: ME 201/MTH 281/ME400/CHE400 Contours for Laplace Equation

lapcon.nb 9