You are on page 1of 3

//Potentiometric analysis. Nernst theory basis.

clear; clc;
//================================FUNCTIONS=====================================
function y=Nernst(a,b,c,d,e,f,x)//Nernst reduction potential [A,B,Vo -sample-,Vo
lt^0,n,T (K),V] (V).
F=96485.3415;//Faraday's electrochemical constant.
R=8.314472;//Ideal gas constant.
nfrf=e*F/(R*f);
y=d+log(a*(c+x).^-1+b.*x.*(c+x).^-1)/nfrf;
endfunction
function y=dNernst(a,b,c,d,e,f,x)//Nernst potential derivative (V/ml).
del=1e-7;
y=(Nernst(a,b,c,d,e,f,x+del)-Nernst(a,b,c,d,e,f,x))/del;
endfunction
function place(x,y)
for i=1:y
printf('\n');
end
for i=1:x
printf(' ');
end
endfunction
function ligne(x)
for i=1:x
printf('-');
end
endfunction
//================================FUNCTIONS=====================================
//==================================DATA========================================
Far=96485.3415;//Faraday's electrochemical constant.
Rg=8.314472;//Ideal gas constant.
en=1;
eh=25+273.15;//Room temperature 25 C.
e0=10;//Sample volume (ml).
ec=0.2415;//Cell point potential (V).
nfrt=en*Far/(Rg*eh);//Operational electrochemical constant.
sp=0.8;//Silver ion electrochemical potential (V).
e=[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17
.0,18.0;//Titrating solution volume -NaCl- (ml).
0.402,0.394,0.385,0.382,0.374,0.364,0.355,0.342,0.311,0.154,0.129,0.120,0.114,0.
110,0.106,0.104,0.102,0.101,0.100]';//Titrated solution potential -AgNO3- (V).
//But potential is measured with a "calomel cell" which intrinsec potential of m
easurement
//is 0.2415 V, so it us necessary to describe the real potential value:
//Before the equivalence point. The potential is added because a reduction inter
action occurs.
t=1;
u=9;

e(t:u,2)=e(t:u,2)+ec;
//After the equivalence point. The potential is substracted because an oxidation
interaction occur.
t=10;
u=length(e(:,2));
e(t:u,2)=e(t:u,2)-ec;
//==================================DATA========================================
//================================CALCULUS======================================
//Data adjust.
t2=1;
u2=9;
v1=(e0+e(t2:u2,1)).^-1;//First variable.
v2=e(t2:u2,1).*(e0+e(t2:u2,1)).^-1;//Second variable.
v3=exp(nfrt*(e(t2:u2,2)-sp));//Third variable (dependent variable).
//======Matrix and vectors======
A=[sum(v1.^2),sum(v1.*v2);
sum(v1.*v2),sum(v2.^2)];
b=[sum(v1.*v3) sum(v2.*v3)]';
c=A\b;
//======Matrix and vectors======
//================================CALCULUS======================================
//================================GRAPHICS======================================
plot(e(:,1),e(:,2),'.');
peq=-c(1)/c(2)-1e-8;//Immediately before the equivalence point.
M=[min(e(t2:u2,1)):(peq-min(e(t2:u2,1)))/5000:peq;
min(e(t2:u2,1)):(peq-min(e(t2:u2,1)))/5000:peq]';
M(:,2)=Nernst(c(1),c(2),e0,sp,en,eh,M(:,1));
plot(M(:,1),M(:,2),'red');
peq2=peq+2e-8;//Immediately after the equivalence point.
M2=[peq2:(max(e(t:u,1))-peq2)/5000:max(e(t:u,1));
peq2:(max(e(t:u,1))-peq2)/5000:max(e(t:u,1))]';
bal=-c(2)*(M2(:,1)-peq).*(e0+M2(:,1)).^-1;//Chloride ions respective balance equ
ation.
M2(:,2)=-Nernst(0,bal,0,sp-2*ec,en,eh,M2(:,1));
//The calomel cell potential is substracted twice due to the effect of the
//titration, first, and then due to the effect of the cloride ions adition.
plot(M2(:,1),M2(:,2),'red');
clear M;
clear M2;
clear bal;
//================================GRAPHICS======================================
//================================RESULTS=======================================
place(5,2);
printf('Potentiometric analysis. Nernst theory basis.');
place(3,1);
ligne(49);
place(7,1);
printf('Silver nitrate solution titration.');

place(7,1);
printf('Sodium chloride titrating solution.');
place(7,2);
printf('Calomel cell potential: %0.4f V',ec);
place(7,1);
printf('Titrating solution concentration: %0.4fe-3 N',-c(2)*1e3);
place(7,1);
printf('Titrated solution concentration: %0.4fe-3 N',c(1)/e0*1e3');
place(7,1);
printf('Equivalence point at: %0.4f ml',peq);
place(7,2);
ligne(3);
printf('Vol. (ml)');
ligne(3);
printf('E exp. (V)');
ligne(3);
printf('E thr. (V)');
ligne(3);
printf('Error')
ligne(3);
//Before equivalence point.
e(t2:u2,3)=Nernst(c(1),c(2),e0,sp,en,eh,e(t2:u2,1));
e(t2:u2,4)=100*abs(e(t2:u2,3)-e(t2:u2,2)).*e(t2:u2,3).^-1;
for i=1:length(e(t2:u2,1))
place(12,1);
printf('%0.1f',e(i,1));
place(9,0);
printf('%0.4f',e(i,2));
place(7,0);
printf('%0.4f',e(i,3));
place(5,0);
printf('%0.4f',e(i,4));
end
bal2=-c(2)*(e(t:u,1)-peq).*(e0+e(t:u,1)).^-1;
e(t:u,3)=-Nernst(0,bal2,0,sp-2*ec,en,eh,e(t:u,1));
e(t:u,4)=100*abs((e(t:u,3)-e(t:u,2)).*e(t:u,3).^-1);
//After equivalence point.
for i=t:length(e(:,1))
place(11,1);
if i==10
place(1,0);
end
printf('%0.1f',e(i,1));
place(8,0);
printf('%0.4f',e(i,2));
place(6,0);
printf('%0.4f',e(i,3));
place(5,0);
printf('%0.4f',e(i,4));
end
//================================RESULTS=======================================

You might also like