Professional Documents
Culture Documents
A. Exact Solution
A. Exact Solution
A. Exact Solution
a. Exact solution
ϕs
⎡ 1 + exp (−kx) tanh ( ) ⎤
4
ϕ = 2ln ⎢
⎢
⎥
⎥
ϕs
⎣ 1 − exp (−kx) tanh ( ) ⎦
4
b. Approximate solution
1 + 0.25ϕs exp (−kx)
ϕ = 2ln [ ]
1 − 0.25ϕs exp (−kx)
c. Debye-Huckle approximation
ϕ = ϕs exp (−kx)
# Arrange the 'kx' from 0 to 2 and write the all input data
kx = np.linspace(0, 2, 20)
l = len(kx)
phi_s1 = 0.5
phi_s2 = 1
phi_s3 = 2
Exact solution
In [5]: # Define the 'phi_e'
phi_e1 = np.zeros(kx.shape)
phi_e2 = np.zeros(kx.shape)
phi_e3 = np.zeros(kx.shape)
Approximate solution
In [6]: # Define the 'phi_a'
phi_a1 = np.zeros(kx.shape)
phi_a2 = np.zeros(kx.shape)
phi_a3 = np.zeros(kx.shape)
Debye-Huckle approximation
In [7]: # Define the 'phi_D'
phi_D1 = np.zeros(kx.shape)
phi_D2 = np.zeros(kx.shape)
phi_D3 = np.zeros(kx.shape)
for i in range(0, l, 1):
# Write the equation of 'phi' for Debye-Huckle approximation.
phi_D1[i] = phi_s1*np.exp(-kx[i])
phi_D2[i] = phi_s2*np.exp(-kx[i])
phi_D3[i] = phi_s3*np.exp(-kx[i])
# phi_s=0.5
axis[0, 0].plot(kx, phi_e1, label ='Exact solution', linestyle='--');
axis[0, 0].plot(kx, phi_a1, label ='Approximate solution', alpha=0.6)
axis[0, 0].set_title("phi_s=0.5")
axis[0, 0].grid()
axis[0, 0].legend()
# phi_s=1
axis[1, 0].plot(kx, phi_e2, label ='Exact solution', linestyle='--');
axis[1, 0].plot(kx, phi_a2, label ='Approximate solution', alpha=0.6)
axis[1, 0].set_title("phi_s=1")
axis[1, 0].grid()
axis[1, 0].legend()
# phi_s=2
axis[2, 0].plot(kx, phi_e3, label ='Exact solution', linestyle='--');
axis[2, 0].plot(kx, phi_a3, label ='Approximate solution', alpha=0.6)
axis[2, 0].set_title("phi_s=2")
axis[2, 0].grid()
axis[2, 0].legend()
# phi_s=0.5
axis[0, 1].plot(kx, phi_e1, label ='Exact solution', linestyle='--');
axis[0, 1].plot(kx, phi_D1, label ='Debye-Huckle approximation', alpha=0.6)
axis[0, 1].set_title("phi_s=0.5")
axis[0, 1].grid()
axis[0, 1].legend()
# phi_s=1
axis[1, 1].plot(kx, phi_e2, label ='Exact solution', linestyle='--');
axis[1, 1].plot(kx, phi_D2, label ='Debye-Huckle approximation', alpha=0.6)
axis[1, 1].set_title("phi_s=1")
axis[1, 1].grid()
axis[1, 1].legend()
# phi_s=2
axis[2, 1].plot(kx, phi_e3, label ='Exact solution', linestyle='--');
axis[2, 1].plot(kx, phi_D3, label ='Debye-Huckle approximation', alpha=0.6)
axis[2, 1].set_title("phi_s=2")
axis[2, 1].grid()
axis[2, 1].legend()