(*:Copyright:Ludovico Ruggeri Laderchi. *)
(*:Mathematica Version: 2.0 *)
(*:Package Version: 1.3 *)
(*:Name: pH` *)
(*:Title: Determination of pH *)
(*:Author:Ludovico Ruggeri Laderchi 1997 *)
(*:Keywords: pH, titrations *)
(*:Summary:
This packages computes the pH of a monoprotic acid solution, given its
concentration and its dissociation costant. pH computes
the exact pH values solving the equations of both
the water and the acid equilibria. For didactical purposes
an alternative rough method, using the simplified formula
pH=-Log[k*C], is implemented too. The latter can be
checked against the the exact value to show where the
approximations used to derive the simplified formula are
acceptable.
Both functions can be used also to compute the pOH
of basic solutions or the pH of poliprotic acids
(considering one dissociation step only) by using the
appropraite costants.
*)
BeginPackage["pH`"]
RoughpH::usage="RoughpH[k,c] computes the pH of an acid solution whose
concentration is c and k is the acid dissociation costant. The following
approximations are used: the ionic equilibrium of water is ignored and the ionic
concentration of the associated base is equal to the one of the acid"
pH::usage="pH[k,c] computes the pH of an acid solution whose
concentration is c and k is the acid dissociation constant."
Begin["pH`Private`"]
RoughpH[k_,c_]:= N[First[DeleteCases[ReplaceAll[-Log[H],
Solve[H^2/(c-H)==k,H]],x_Complex]/Log[10]]]
kw =10^-14 (* water dissociation costant *)
pH[k_,c_]:= N[First[
DeleteCases[ReplaceAll[-Log[H],
Solve[{OH*H==kw,(H*B)/HB==k,HB+B==c,OH+B==H},H,
{OH,HB,B}]],x_Complex]]/Log[10]]
End[ ]
Protect[RoughpH,pH]
EndPackage[] (* miscellaneous`pH` *)
(* Example : pH[1.8*10^(-5),.02] computes
the pH of 0.02 molar acetic acid solution (dissociation
costant (k)=1.8*10^-5] *)