A General Program for ConcpH

advertisement
A General Program for pH-calculations in a Mixture of Acids and
Bases in Watersolutions.
By Stig Johansson Bräkne-Hoby, Sweden.
The Purpose. With the help of this program you will be able to caculate pH of a special
acid or base or a number of these substances in a watersolution. Both concentration pH
and activity pH may be calculated. Here only the ConcpH will be described.
If there are other reactions than hydrolysis the calculations may not be valid.
The Mathematical Part of the solving consists of two sections.
The first section consists of a complete algebraic solving with regard to the conditions of
mass balance, charge balance and equilibriums for water, acids and bases. With the help
of these conditions you will be able to get [H3O+] as the only unknown factor, if the
values of concentrations and dissociation constants are known. [H3O+] will not be solved
explicitly but exists in an implicit form.
The second section of the calculation is performed with the help of a dator program,
which is based on Newton-Raphson’s method. This method is iterative in according with
the following formula, where [H3O+] is represented by X, and the derived function by
F’(X):
Xn+1 = Xn – F(Xn)/F’ (Xn)
The iteration proceeds until ABS(Xn+1 - Xn) < ABS(Xn+1/1e10). From the formula we
conclude that also the derivative F’ (X) must be calculated.
The categories of acids and bases, which have been used as examples, have been
taken from chemical handbooks for instance Handbook of Chemistry and Physics. It is
always possible to discuss which categories and how many of each sort of acid and base
will be represented. It is, however, very simple for the programmer to change and
construct programs with different constituents.
Literature:
Handbook of Chemistry and Physics. 64th Edition. !983-84
G Christian: Analytical Chemistry. New York 2004.
A. Gordus: Analytical Chemistry. New York 1985.
G Hägg: Kemisk reaktionslära. Uppsala 1965.
E Lundqvist and A Sjöberg: Numeriska metoder. Uppsala 1970.
Acid-Base-functions in the pH-program.
In the functions, [H3O+] will be replaced by x and [OH-] by y.
Mathematical principle.
The final functions F(x) and F’(x) have been built by adding the partial functions fi(x)
respective fi’(x) , which represent the different sorts of substances where the function f1
represents the shared water and the other fi the special acids and bases. For each of the
acids and bases there is a complete solution, in which water is included, but in each of
their final functions the solitary terms of y and x have been taken away, as their watervalues must not be added to the shared water represented by f 1 , which participates in all
calculatioins.
Kw=1.00E-14 (pKw=14.00) is default but can be changed
Calculating ConcpH.
Pure water.
OH   H O 

H O  OH   K
1

3


3
y  x  f1 x   y  x  0
1
y  x  KW
KW
x0
x
K

f 1  x    W2  1  0
x
f1 x  
Strong 1-protic acid
C1
M
HA  H 2 O  H 3O   A 
HA
OH   A   H O 



3

y
yx
has
already
been
C1 
brought
x
and
 y  C1  x  0
f 2 x   C1  0

f 2 x   0
Strong 2-protic acid.
C1
M
H2 A
C2
M
NaHA
H 2 A  H 2O  H 3O   A
NaHA  Na  HA 
HA   H 2O  H 3O   A2 
C3
M
K 2 A  2 K   A2 
K2 A
OH  HA  2  A   Na  2  K  H O 
y  HA   2A   C
 2C
(1)
C  C  C  C  HA   A  (2)
K  HA   x  A  3


2



3

2
2

1
2
3
3
2
Tot

2
2
KW  x  y
y
4
x  CTot 2 K 2  CTot

 C2  2C3  x  0
x  K2
x  K2
f3 x  
x  CTot 2 K 2  CTot

 C2  2C3  0
x  K2
x  K2
f 3 x   
K 2  CTot
x  K 2 2
2
2
Weak 1-protic acid
HA  H 2 O  H 3 O   A 
C1
M
HA
C2
M
NaA
aq
NaA 
Na   A 
OH   A   Na   H O 
y  A   C
 x 1
C  C  C  HA  A  2
K  HA  x  A  3




3

2

1
2
Tot

4
KW  x  y
K  CTot
 C2  x  0
Kx
K  CTot
f 4 x  
 C2  0
Kx
K  CTot
f 4x   
0
 K  x 2
y
Weak 2-protic acid.
H 2 A  H 2 O  H 3 O   HA 
C1
M
H2 A
C2
M
NaHA
C3
M
K2 A
aq
NaHA 
Na   HA 
aq
K 2 A 
2 K   A 2
OH   HA   2  A   Na   2  K   H O 
1
y  HA   2  A   C
 2C  x
2
C  C  C  C  H A  HA   A 
3
K  H A  x  HA 
4
K  HA   x  A 


2



3

2
2
3

1
2
3
Tot
2
2

1
2

2
2
KW  x  y
y
5
K 1CTot x
2 K 1 K 2 CTot

 C 2  2C 3  x  0
2
K1 K 2  K1 x  x
K1 K 2  K1 x  x 2
f 5 x  
K 1CTot  x  2 K 2 
 C 2  2C 3  0
K1 K 2  K1 x  x 2
f 5x   

K 1CTot K 1 K 2  x 2  4 K 2 x
K K
1
2
 K1 x  x

2 2
0
Weak 3-protic acid.
C1
M
H3 A
H 3 A  H 2 O  H 3O   H 2 A 
C2
M
LiH 2 A
aq
LiH 2 A 
Li   H 2 A 
C3
M
Na2 HA
aq
Na2 HA 
2 Na   HA 
C4
M
K3 A
aq
K 3 A 
3 K   A 3
OH   H A   2  HA   3  A   Li   2  Na   3  K   H O 
y  H A   2  HA   3  A   C  2C  3C  x 1
C  C  C  C  C  H A  H A   HA   A  2 
K H A  x  H A  3
K H A   x  HA  4 
5
K HA   x  A 


2
3



2

2
3
2
2

1
2

3
3
4
Tot
3
3
2
4
3
2

1
2
3
2

2
2
2
3
3
KW  x  y
y
6
K 1CTot x 2 2 K 1 K 2 CTot x 3K 1 K 2 K 3 CTot


 C 2  2C 3  3C 4  x  0
N
N
N
N  K1 K 2 K 3  K1 K 2 x  K1 x 2  x 3
f 6 x  
K 1CTot x 2 2 K 1 K 2 CTot x 3K 1 K 2 K 3 CTot


 C 2  2C 3  3C 4  0
N
N
N
f 6 x  
2 K 1CTot x K 1CTot x 2  N  2 K 1 K 2 CTot 2 K 1 K 2 CTot x  N  3K 1 K 2 K 3 CTot  N 




0
N
N
N2
N2
N2
N   K1 K 2  2 K1 x  3x 2
Weak 4-protic acid
C1
M
H4A
H 4 A  H 2O  H 3O   H 3A 
C2
M
LiH 3 A
aq
Li   H 3 A 
LiH 3 A 
C3
M
Na 2 H 2 A
aq
2 Na   H 2 A 2 
Na 2 H 2 A 
C4
M
K 3 HA
aq
3K   HA 3
K 3 HA 
C5
M
Rb 4 A
aq
4Rb   A 4 
Rb 4 A 
OH   H A   2  H A   3  HA   4  A   Li   2  Na   3  K   4  Rb   H O 
x
 4C
 3C
y  H A   2H A   3HA   4A   C  2C
C  C  C  C  C  C  H A   H A   H A   HA   A 
K  H A   x  H A  3
K  H A   x  H A  4 
K  H A   x  HA  5
6
K  HA   x  A 
4
3
2

3
3
2
3
3
2
2

1





4
3
2


2
3
4
5
Tot
1
4
2
3
3
2
2
3
4
4
5
2
3
4
1
2

3
2

2
3
2
3
4
4
KW  x  y
7 
x 3 K 1 C Tot 2 x 2 K 1 K 2 C Tot 3xK 1 K 2 K 3 C Tot 4K 1 K 2 K 3 K 4 C Tot
 C 2  2C 3  3C 4  4C 5  x  0



N
N
N
N
x 3 K 1 C Tot 2 x 2 K 1 K 2 C Tot 3xK 1 K 2 K 3 C Tot 4K 1 K 2 K 3 K 4 C Tot
 C 2  2C 3  3C 4  4C 5  0



f 7 x  
N
N
N
N
N K 1 K 2 K 3 K 4  K 1 K 2 K 3 x  K 1 K 2 x 2  K 1 x 3  x 4
y
3K 1 x 2 C Tot K 1 x 3 C Tot N  4K 1 K 2 xC Tot 2K 1 K 2 x 2 C Tot N  3K 1 K 2 K 3 C Tot 3K 1 K 2 K 3 xC Tot N 





N
N
N
N2
N2
N2
4K 1 K 2 K 3 K 4 C Tot N 
0

N2
N   K 1 K 2 K 3  2K 1 K 2 x  3K 1 x 2  4 x 3
f 7 x  
Strong 1-protic base.
C
M

  
  H O 
OH   C
B  H 2 O  BH   OH 
B
OH   BH


y



3

C
x
y C  x  0
f 8  x   C  0
f 8 x   0
Strong 2-protic base.
B  H 2 O  BH   OH 
C1
M
B
C2
M
BHCl
C3
M
BH 2 Br2
aq
BHCl 
BH   Cl 
aq
BH 2 Br2 
BH 2  2 Br 
OH   Cl   Br   BH   2  BH  H O 
y C
 2C
 BH   2  BH   x
C  C  C  C  B   BH   BH 
3
K  BH   BH  y



2


2
3
2

2
3
2
2

1
2
3
Tot
2
2

b2
2
KW  x  y
y  C 2  2C 3 
CTot K W  2 K b 2 x 
0
K W  K b 2 x 
CTot K b 2 K W
K W
4
CTot K W  2 K b 2 x 
x0
K W  Kb2 x 
f 9  x   C 2  2C 3 
f 9 x   
dvs
 K b2 x
2
0
1
2
B  0
Weak 1-protic base.
B  H 2 O  BH   OH 
C1
M
B
C2
M
BHCl
aq
BHCl 
BH   Cl 
OH   Cl   BH   H O 
y  C  BH   x
C  C  C  B   BH 
K  B   BH  y




3
1

2
2

1
2
Tot
3

b
4
KW  x  y
y  C2 
K b CTot x
x0
K b x  KW
K b CTot x
0
K b x  KW
f10 x   C 2 
f10 x   
K b K W CTot
 K b x  K W 2
Weak 2-protic base.
B  H 2 O  BH   OH 
C1
M
B
C2
M
BHCl
C3
M
BH 2 Br2
aq
BHCl 
BH   Cl 
aq
BH 2 Br2 
BH 2
2
 2 Br 
OH  Cl  Br   BH  2  BH  H O 



2


2
y
 C2

3


 BH   2  BH 2
 2C3
2
 

C1  C 2  C3  CTot  B   BH   BH 2
B K b1  BH   y
BH  K

b2

 BH 2
2
y  C 2  2C3 
2
1
2
3
 y
KW  x  y
 x

4
5
K b1CTot K W x
K b1 K b 2 x  K b1 K W x  K W
2
2

2 K b1 K b 2 CTot x 2
K b1 K b 2 x 2  K b1 K W x  K W
K b1CTot K W x 2 K b1 K b 2 CTot x 2

0
N
N
2
2
K C 4 K b 2 x  K W  K b1 CTot x2 K b 2 x  K W 
f11 x    b1 Tot

0
2
N
N
f11 x   C 2  2C3 
N  K b1 K b 2 x 2  K b1 K W x  K W
2
2
x0
The calculated partial functions will be added as below
F(x)=f1(x) + f2(x) + .... +f11(x) = 0 och F´(x)=f´1(x) + f´2(x) + ..... + f´11(x) = 0
After that the iterative expression xn+1 = xn - F(xn)/F´(xn) is used until ABS(xn+1-xn)
<ABS(xn/1e10).
[H3O+] = x2, where 1. 10-15 <= x2 =<1.
At last the final concentrations can be calculated according to the following.
Calculation of the final concentrations at the calculated pH.
Strong 1-protic acid.
C
M
HA  0
HA  H 2 O  H 3 O   A 
HA
A   C

C1
M
H2A
Strong 2-protic acid.
H 2 A  H 2O  H 3O   A 
C2
M
HA 
H 2 A  0
C3
M
A
2

   1
  H O  A  2
C1  C 2  C 3  C Tot  HA   A 2 

K 2 HA
HA   KC


2
3
A   CK
x
x
2
Tot
2

Tot
2
K2
x
Weak 1-protic acid.
C1
M
HA
HA  H 2 O  H 3O   A 
C2
M
A
C1  C 2  CTot  HA   A 

 
 
K  HA   H 3O   A 
A   Kx CK

Tot
1
2
HA  CTot  x
xK
Weak 2-protic acid.
C1
M
H2A
H 2 A  H 2 O  H 3 O   HA 
C2
M
HA 
HA   H 2 O  H 3 O   A 2 
C3
M
A 2
   
2
K H A  x  HA 
3
K HA   x  A 
C1  C 2  C 3  C Tot  H 2 A  HA   A 2 
1

1
2

2
2
A   x
K 1 K 2 C Tot
2
2
 K1 x  K1 K 2
HA   x
K 1C Tot x

2
 K1 x  K1 K 2
H 2 A 
C Tot x 2
x 2  K1 x  K1 K 2
Weak 3-protic acid.
M
H3A
C2
M
H 2 A
C3
M
HA 2 
C4
M
A 3
A   K K
H



2A

K 1 H 3 A  x  H 2 A 
  
K HA   x  A 
K 2 H 2 A   x  HA 2 
2


  
HA   K K
K 1 K 2 C Tot x
2
K 3  K1 K 2 x  K1 x  x
2
3
1
K 1C Tot x 2
2
K 3  K1 K 2 x  K1 x 2  x 3
C Tot x 3
H 3 A 
K1 K 2 K 3  K1 K 2 x  K1 x 2  x 3
1
2
3
4
3
K 1 K 2 K 3 C Tot
2
 
3
3
1

C1  C 2  C 3  C 4  C Tot  H 3 A  H 2 A   HA 2   A 3
C1
K1 K 2 K 3  K1 K 2 x  K1 x 2  x 3
Weak 4-protic acid.
M
H4A
C2
M
H 3 A
C3
M
H 2 A 2
C4
M
HA
C5
M
A 4
A   K K
4
1
2

K 1 H 4 A  x  H 3 A 
 

3

K3 H 2 A


HA   K K
3
1
2
3
4
H
K 3 C Tot x
N

2

2A
N  K1 K 2 K 3 K 4  K1 K 2 K 3 x  K1 K 2 x 2  K1 x 3  x 4
B  H 2 O  BH   OH 
B  0
BH   C

Strong 2-protic base.
B  H 2 O  BH   OH 
C1
M
B
C2
M
BH 
C3
M
B H2

 
2

2
b2
C Tot
b2
y
2
B  0
C1  C 2  C 3  C Tot  BH   BH 2
 
K b 2 BH   BH 2
2

K b 2 C Tot x
K b2 x  KW
3
Tot
b2

2
BH   KC x KK

2
 y
KW  x  y
BH   KK
K 1 K 2 C Tot x 2
N
4
B
1
2
Strong 1-protic base.
M
  
 
 3
  x  HA  4
  x  A  5
2
K 4 HA 3
N
C
 
K 2 H 3 A   x  H 2 A 2
K 3 K 4 C Tot
N
H 4 A  CTot x

C1  C 2  C 3  C 4  C Tot  H 4 A  H 3 A   H 2 A 2   HA 3  A 4 
C1
W
W
1
H



3A
K 1C Tot x 3
N
Weak 1-protic base.
B  H 2 O  BH   OH 
C1
M
B
C2
M
BH 

C1  C 2  C Tot  B   BH 



K b B   BH   y
2
3
KW  x  y
BH   KK C y  KK xC Kx

b
Tot
b
b
B 
Tot
b
W
1
C Tot y
C Tot K W

K b  y K b x  KW
Weak 2-protic base.
B  H 2 O  BH   OH 
C1
M
B
C2
M
BH 
C3
M
BH 2


 

K W  xy
2

K b1 B   BH   y
2
K b 2 BH   BH 2
B  CTot K W
 
C1  C 2  C 3  C Tot  B   BH   BH 2
BH   K

N
2
N  K b1 K b 2 x 2  K b1 K W x  K W
b1
C Tot K W x
N
2
 y
2

1
2
3
4
BH   K
2
2
b1
K b 2 C Tot x 2
N
Download