Problem¶

Find solution for $\Phi(\rho, \theta)$ inside a circular region of radia $a$. The region is enclosed by a circle with the radius $a$, is maintained at potential $−V$ in the upper half circle and at potential $+V$ in the lower half circle as shown in the figure.

“”


The system is axially symmetric and $\rho < a$. Hence, the solution can be written as, \begin{equation} \Phi = \sum_{l=0}^{\infty}\, A_l \left(\frac{\rho}{a}\right)^l P_l \left(\cos\theta\right) \end{equation} We need to find $A_l$'s using the boundary condition on the circle. $$ \Phi(r=a, \theta) = \left\{ \begin{array}{cc} +1 & \left(\cos\theta<0\right)\\ -1 & \left(\cos\theta\geq0\right) \end{array}\right. $$ Using the result form step function expressed terms of Legendre Polynomials, $$ f(x) = \frac 32 P_1(x) - \frac 78 P_3(x) + \frac{11}{16} P_5(x) + \cdots $$ we get $$ \Phi \left(\rho, \theta \right) \, = \, V \left[ \frac 32 \left(\frac{\rho}{a}\right) P_1(\cos\theta) - \frac 78 \left(\frac{\rho}{a}\right)^3 P_3(\cos\theta) + \frac{11}{16} \left(\frac{\rho}{a}\right)^5 P_5(\cos\theta) + \cdots\right] $$

In [9]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
cmap = mpl.colormaps['hot']
import imageio
import os
from scipy.special import legendre
from IPython.display import Image

def Phi(r, theta, V, a):
    p1=legendre(1)
    p3=legendre(3)
    p5=legendre(5)
    r=r/a
    fx=np.zeros(r.shape)
    x=np.cos(theta)
    fx= V* ( 3/2*r*p1(x) - 7/8* (r**3)*p3(x) + 11/16*(r**5)*p5(x))
    return fx

a=1
Np=50
r1=np.linspace(0,a,2*Np)
theta1=np.linspace(0,np.pi, 2*Np)
[r,theta]=np.meshgrid(r1, theta1)
x=r*np.cos(theta-np.pi/2)
y=r*np.sin(theta-np.pi/2)
x1=r*np.cos(theta+np.pi/2)
y1=r*np.sin(theta+np.pi/2)
pot=Phi(r, theta, 1, a)
plt.pcolor(x,y, pot, vmin=-1.3, vmax=1.3)  
plt.pcolor(x1,y1, -pot, vmin=-1.3, vmax=1.3)  
plt.gca().set_aspect(1)
#plt.contour(x,y, pot,30, color='w')  
plt.xlabel('x-axis')
plt.ylabel('z-axis')
plt.xlim([-1.1, 1.1])
plt.ylim([-1.1, 1.1])
#plt.clim(-1.1,1.1)
plt.title('Potential on x-z plane')
plt.colorbar()
Out[9]:
<matplotlib.colorbar.Colorbar at 0x7ff0372dc850>
In [ ]: