Created
October 12, 2017 08:03
-
-
Save Ionizing/d89587ec8c8d6ff1e4440ce1f6bdfa9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.stats as ss | |
# Background Electric Potential, mV | |
Phi_0 = 318 | |
# Concentration of typical solution, mg/L | |
C = [0.2, 0.4, 0.8, 1.2, 1.6, 2.0] | |
# Potential of solution, mV | |
Phi_1 = [287, 257, 236, 224, 216, 209] | |
# Volume of sample solution, mg/L | |
V = [50, 50.5, 51, 51.5, 52, 52.5, 53] | |
# Potential of sample solution, mV | |
Phi_2 = [227, 209, 199, 191, 185, 181, 177] | |
# Plot the E-log10(c) figure | |
plt.figure() | |
X = np.log10([x / 1000.0 for x in C]) | |
Y = [x / 1000.0 for x in Phi_1] | |
slope, intercept, r_value, p_value, std_err = ss.linregress(X, Y) | |
# print(slope, intercept, r_value, p_value, std_err) | |
xp = np.linspace(np.min(X), np.max(X), 150) | |
yp = slope * xp + intercept | |
plt1, = plt.plot(X, Y, '*') | |
plt2, = plt.plot(xp, yp, '-') | |
plt.xlabel('$\lg c_{F^-}$') | |
plt.ylabel('$E/\mathrm{V}$') | |
plt.title('Working curve of flourine ion') | |
plt.legend([plt1, plt2], ['Original spots', 'Fitted Curve']) | |
# plt.savefig('fig1.png') | |
# Calculate the concentration in method 1 | |
y1 = Phi_2[0] / 1000 | |
x1 = (y1 - intercept) / slope | |
plt.plot([xp[0], x1, x1], [y1, y1, yp[-1]], '--') | |
txt = "$C_F^-$ = %f \n $E$ = %f" % (10 ** x1, y1) | |
plt.text(x1, y1, txt) | |
print(10**x1) | |
plt.savefig('fig1.png') | |
# Calculate in method 2 | |
cs = 0.1 | |
S = slope | |
DeltaE = (Phi_2[1] - Phi_2[0]) * 10**-3 | |
Vx = V[0] | |
Vs = V[1] - V[0] | |
cF = cs / (np.power(10, DeltaE/S) * (Vx/Vs + 1) - Vx/Vs) | |
print(cF) | |
plt.figure() | |
# Calculate in method 3 | |
X3 = V-V[0]*np.ones(np.size(V)) | |
Y3 = V * np.power(10, Phi_2/S*10**-3) | |
# print(Y3) | |
plt3 = plt.plot(X3, Y3, '*') | |
slope3, intercept3, r_value3, p_value3, std_err3 = ss.linregress(X3, Y3) | |
V0s = - intercept3 / slope3 | |
xp31 = np.linspace(X3[0], X3[-1], 100) | |
yp31 = xp31 * slope3 + intercept3 | |
xp30 = np.linspace(V0s, X3[0], 100) | |
yp30 = xp30 * slope3 + intercept3 | |
plt.plot(xp31, yp31, '-', xp30, yp30, '-') | |
txt3 = '$V_s^0 = %f$mL' % V0s * 10**3 | |
plt.xlabel('$V_{si}$') | |
plt.ylabel('$(V_s + V_si)10^{{E_i}/{S}}$') | |
cF3 = - cs * V0s / Vx | |
print(cF3) | |
plt.savefig('fig3.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment