Selveste
- 7
- 0
Homework Statement
Solve the Laplace equation in 2D by the method of separation of variables. The problem is to determine the potential in a long, square, hollow tube, where four walls have different potential. The boundary conditions are as follows:
V(x=0, y) = 0
V(x=L, y) = 0
V(x, y=0) = 0
V(x, y=L) = V_0(x)
Formulate a solution in terms of the Fourier coefficients, in a way suitable for numerical calculation. Write a computer program that takes any function V_0(x) and calculates V(x,y) inside the square tube.
Homework Equations
\nabla^2 V = 0
The Attempt at a Solution
\frac{\partial^2V}{\partial x^2} + \frac{\partial^2V}{\partial y^2} = 0
Separation of variables
V(x, y) = A(x)B(y)
Laplace becomes
\frac{1}{A(x)}\frac{\partial^2A(x)}{\partial x^2}+\frac{1}{B(y)}\frac{\partial^2B(y)}{\partial y^2}=0
which gives
\frac{\partial^2A(x)}{\partial x^2}= k^2A(x); \frac{\partial^2B(y)}{\partial y^2}= -k^2B(y)
solving the ODE's gives
A(x)=A\sin{kx}+B\cos{kx}
B(y)=Ce^{ky}+De^{-ky}
V(x,y) = [A\sin{kx}+B\cos{kx}][Ce^{ky}+De^{-ky}]
Boundary conditions
V=0 when x=0 \implies B=0.
V=0 when x=L \implies k=n\pi/L : n\in\mathbb{R}
V=0 when y=0 \implies C=-D.
which gives
V(x,y) = A\sin{(\frac{n\pi x}{L})}[e^{\frac{n\pi y}{L}}-e^{-\frac{n\pi y}{L}}]
Here I think the term with the exponentials look a little fishy, but can't see a mistake so I move on. Laplace equation is linear, so we have
V(x,y) = \sum_{n=1}^{\infty}C_n\sin{(\frac{n\pi x}{L})}[e^{\frac{n\pi y}{L}}-e^{-\frac{n\pi y}{L}}]
V(x,L) = \sum_{n=1}^{\infty}C_n\sin{(\frac{n\pi x}{L})} = V_0(x)
To find the Fourier coefficients we multiply both sides by \sin{(n'\pi x/L)} and integrate from 0 to L:
\sum_{n=1}^{\infty}C_n \int_0^L \sin{(\frac{n'\pi x}{L})}\sin{(\frac{n\pi x}{L})}dx = \int_0^LV_0(x)\sin{(\frac{n'\pi x}{L})}dx
Solution to the integral on the left side is
0, if n \ne n'
L/2, if n = n'
so the left side reduces to (L/2)C_{n'}, which implies
C_n = \frac{2}{L}\int_0^LV_0(x)\sin{(\frac{n\pi x}{L})}dx
So the solution to the problem is
V(x,y) = \sum_{n=1}^{\infty}C_n\sin{(\frac{n\pi x}{L})}[e^{\frac{n\pi y}{L}}-e^{-\frac{n\pi y}{L}}]
with C_n as above. Correct?
I now want to write a python program that takes any function V_0(x) and calculates V inside the square tube. I first make it dimensionless by introducing \xi =x/L and \gamma= y/L as variables instead of x, y.
V(\xi,\gamma) = \sum_{n=1}^{\infty}C_n\sin{(n\pi \xi)}[e^{n\pi \gamma}-e^{-n\pi \gamma}]
C_n = \frac{2}{L}\int_0^1V_0(\xi)\sin{(n\pi \xi)}d\xi
Is this correct? Otherwise, where did it all go wrong? And what should I do with the 2/L term in C_n? Maybe I ought to have introduced the new variables at the very beginning? Thanks.