Don't wanna be here? Send us removal request.
Text
How to simulate a pH titration curve: part 1, weak monoacid
When studying wet chemistry, pH titrations are impossible to avoid. But how to make custom pH titration curves for whichever compound we desire?
The curves for pH titrations are easy to predict with a simple Excel file... provided you make assumptions that can easily turn into a nightmare for weak acids, weak bases and/or polyacids/polybases.
The most accurate way to compute the pH of a solution being titrated is to solve an equation system. For instance, if you titrate a solution of acetic acid (AH) with NaOH, you can write, for any volume of NaOH added, the following equations :
AH = A- + H+ / ka H2O = H+ + OH- / kw
Since we have an equilibrium, we can write: 1> ka=cH*cA/cAH where c denotes the concentration of the species
Since we have a conservation of the quantity of the acetate radical, we can write: 2a> nAHtotal = nAH + nA where nAHtotal is the quantity of acid initially added to the solution, nAH (rsp nA) the quantity of AH (rsp A) in solution
Equation 2a can also be written: 2b> nAHtotal / (volini + voladded) = cA + cAH where volini is the initial volume
Since the solution is electrically neutral we can write: 3a> nNa + nH = nOH + nA
Like equation 2a, equation 2b can be written: 3b> cbase * voladded /(volini + voladded) + cH = cA + cOH since the quantity of Na is equal to the quantity of base added to the solution
Lastly, the water autoprotolysis equation yields: 4> kw = cH*cOH
Here, the assumption is made that the activity is equal to the concentration in mol/L divided by 1 mol/L. Given that such demonstrations are most useful in high school and undergrad labs where concentrated solutions (>1 mol/L) are not so common, I consider that this assumption is not so crazy.
The 4 equations (1, 2b, 3b and 4) all depend on 4 concentrations (cH, cOH, cAH, cA), the added volume (voladded) and the initial parameters (ka, ke, nAHtotal, volini and cbase).
The only interesting relation is that between cH and voladded, because we would like to plot cH versus voladded.
A good solution consists in using an algebra calculus programming language such as Maple or Mathematica. Since it is necessary to pay a fee to use them, the programming language Maxima can be used.
The code to setup the equations looks like this :
> eqpKa : ka = cH*cA/cAH; > eqsumAHA : nAHtotal / (volini + voladded) = cA + cAH; > eqsumcharges : cbase * voladded /(volini + voladded) + cH = cA + cOH; > eqpKw : kw = cH * cOH;
and the code to remove 3 variables to keep only 1 equations is as follows: > efinal : eliminate([eqpKa,eqsumAHA,eqsumcharges,eqpKw],[cOH,cA,cAH])[1];
This returns the following equation: -cH*(volini+voladded)*(((ka+cH)*kw-cH^2*ka-cH^3)*volini^2+ (((2*ka+2*cH)*kw+cbase*(-cH*ka-cH^2)-2*cH^2*ka-2*cH^3)*voladded+cH*ka*nAHtotal)*volini+ ((ka+cH)*kw+cbase*(-cH*ka-cH^2)-cH^2*ka-cH^3)*voladded^2+cH*ka*nAHtotal*voladded)
This expression is indeed an equation, because the equation is true when the value of the expression is equal to zero.
If all the values except the pH are fixed (i.e. when a known volume of base is added), solving for “cH” returns the possible values of the hydrogen concentration.
You may have noticed that this is a polynome of cH, so multiple values are theoretically possible, but only one will be 1/ positive and 2/ inferior to the amount of acid initially present in the solution.
Link to the code: https://github.com/zenito/titration-simulation-maxima
0 notes
Text
Welcome!
I have a PhD in chemistry and I like to teach and to fiddle with lines of code when it is convenient, welcome to my tumblr and I hope you enjoy the ride :)
0 notes