Week 5: Laplace Equations: Aravind EE1 6B131 Electrical Dept
Week 5: Laplace Equations: Aravind EE1 6B131 Electrical Dept
Week 5: Laplace Equations: Aravind EE1 6B131 Electrical Dept
Aravind
EE16B131
Electrical Dept.
1 Introduction
This report contains the solutions of the week-5 assignment of EE2307. The answers to the questions, the python code, and
the plots obtained are entered below.
k = arange(Niter)
1
#....... Getting best-fit line
#..... y = mx+c ==> x(m)+ 1(c) = y
#M c = b form, where M = [x 1], b = y
# So, c = lstsq(M,b)
b = arange(Niter)
M1 = zeros((Niter,2))
M1[:,0] = 1 M1[:,1] = b
b = log(errors)
c = lstsq(M1,b)[0]
M2 = zeros((Niter-500,2))
b2=arange(500,Niter)
M2[:,0]=1
M2[:,1]=b2
b2=log(errors[500:])
c2=lstsq(M2,b2)[0]
x=linspace(0,Niter-1,Niter)
#.... Error v/s iterations plot .....
fig1 = figure()
semilogy(k,errors,’ro’,markevery=50)
semilogy(x, exp(c[0]+c[1]*x), ’r’)
semilogy(x[500:],exp((c2[0]+c2[1]*x[500:])),’g’)
suptitle("Evolution of error with iteration", fontsize=20)
xlabel("iteration", fontsize=16)
ylabel("error (log scale)", fontsize=16)
savefig("fig_err.pdf")
#.... Surface plot of potential ......
fig2 = figure(4)
ax = p3.Axes3D(fig2) #... Axes3D is used to do the surface plot
x = arange(1,Nx+1)
y = arange(1,Ny+1)
X,Y = meshgrid(x,y) #... creates arrays out of x and y
title("3-D surface plot of the potential")
surf = ax.plot_surface(Y, X, phi, rstride=1, cstride=1, cmap=cm.jet, linewidth=0)
savefig("fig_surf.pdf")
#.... Contour plot of potential ......
fig3 = figure()
title("Contour plot of potential (Equipotential lines)")
cp = contour(Y, X, phi)
clabel(cp, inline=True, fontsize=10)
savefig("fig_cont.pdf")
#..... Evaluating current .....
fig4 = figure() Jx = zeros((Nx,Ny))
Jy = zeros((Nx,Ny))
Jx[1:-1,1:-1] = 0.5*(phi[1:-1,0:-2]-phi[1:-1,2:])
Jy[1:-1,1:-1] = 0.5*(phi[0:-2,1:-1]-phi[2:,1:-1])
quiver(y,x,Jy.transpose(),Jx.transpose())
title("Vector plot of the current flow")
savefig("fig_cur.pdf")
show()
return phi
phi = potential(Nx,Ny)
E=zeros(Nx)
for i in range(Ny):
E[i]=sum(pow((phi[:,i]-1*(Ny-i)/Ny),2))
E1=sum(E)/(Nx*Ny)
print E1
2
1.2 Theory
The potential distribution inside resistor is found by solving Laplace equation:
∇2 φ = 0
0.6
10 -2
0.4
10 -3 0.2
0.0
30
10 -4 25
20
0 15
5
10 -5 10 10
0 500 1000 1500 2000 15
20 5
iteration 25
30 0
30 Contour plot of potential (Equipotential lines) 30 Vector plot of the current flow
25 25
20 20
0.600
0.300
15 15
0.450
0.900
0.750
0.150
10 10
5
5
0
5 10 15 20 25 30 0 5 10 15 20 25 30
3
2. For Nx = 30, Ny =30, Nxbegin = 0, Nend = 30 (electrode covering surfaces)
0.6
10 -3 0.4
0.2
10 -4
0.0
30
10 -5 25
20
0 15
5
10 -6 0 10 10
500 1000 1500 2000 15
20 5
iteration 25
30 0
30 Contour plot of potential (Equipotential lines) 30 Vector plot of the current flow
25 25
20 20
15 15
0.900
0.750
0.600
0.450
0.300
0.150
10 10
5
5
0
5 10 15 20 25 30 0 5 10 15 20 25 30
1 X L − yi 2
2 = (φi,j − V0 )
Nx Ny i,j L
For Nx = 30, Ny = 30, with electrodes covering the entire top and bottom surfaces, we get 2 = 0.338
Similarly, for Nx = 60, Ny = 60, 2 = 0.254, and for Nx = 150, Ny = 150, 2 = 0.106.
We observe that2 decreases as the electrode size increases. It is because as the electrode size increases, the fringing effect
involed in the field distribution becomes insignificant. This enables the computed values to resemble the physical values to a
greater extent. The value of 2 doesn’t approach zero in reasonable time, since the algorithm used is not so good.