CASE STUDY GREENHOUSE GASES AND RAINWATER CASE STUDY continued

5.6 CASE STUDY 145 K 2 = [H + ][CO −2 3 ] [HCO − 3 ] 5.10 K w = [H + ][OH − ] 5.11 c T = K H p CO 2 10 6 + [HCO − 3 ] + [CO −2 3 ] 5.12 0 = [HCO − 3 ] + 2[CO −2 3 ] + [OH − ] − [H + ] 5.13 where K H = Henry’s constant, and K 1 , K 2 , and K w are equilibrium coefficients. The five unknowns are c T = total inorganic carbon, [HCO − 3 ] = bicarbonate, [CO −2 3 ] = carbonate, [H + ] = hydrogen ion, and [OH − ] = hydroxyl ion. Notice how the partial pressure of CO 2 shows up in Eqs. 5.9 and 5.12. Use these equations to compute the pH of rainwater given that K H = 10 −1.46 , K 1 = 10 −6.3 , K 2 = 10 −10.3 , and K w = 10 −14 . Compare the results in 1958 when the p CO 2 was 315 and in 2008 when it was 386 ppm. When selecting a numerical method for your computation, consider the following: • You know with certainty that the pH of rain in pristine areas always falls between 2 and 12. • You also know that pH can only be measured to two places of decimal precision. Solution. There are a variety of ways to solve this system of five equations. One way is to eliminate unknowns by combining them to produce a single function that only de- pends on [H + ]. To do this, first solve Eqs. 5.9 and 5.10 for [HCO − 3 ] = K 1 10 6 [H + ] K H p CO 2 5.14 [CO −2 3 ] = K 2 [HCO − 3 ] [H + ] 5.15 Substitute Eq. 5.14 into 5.15 [CO −2 3 ] = K 2 K 1 10 6 [H + ] 2 K H p CO 2 5.16 Equations 5.14 and 5.16 can be substituted along with Eq. 5.11 into Eq. 5.13 to give 0 = K 1 10 6 [H + ] K H p CO 2 + 2 K 2 K 1 10 6 [H + ] 2 K H p CO 2 + K w [H + ] − [H + ] 5.17 Although it might not be immediately apparent, this result is a third-order polynomial in [H + ]. Thus, its root can be used to compute the pH of the rainwater. Now we must decide which numerical method to employ to obtain the solution. There are two reasons why bisection would be a good choice. First, the fact that the pH always falls within the range from 2 to 12, provides us with two good initial guesses. Second, be- cause the pH can only be measured to two decimal places of precision, we will be satisfied

5.6 CASE STUDY continued

5.6 CASE STUDY continued

with an absolute error of E a,d = ±0.005. Remember that given an initial bracket and the desired error, we can compute the number of iteration a priori. Substituting the present val- ues into Eq. 5.6 gives dx=12-2; Ead=0.005; n=log2dxEad n = 10.9658 Eleven iterations of bisection will produce the desired precision. Before implementing bisection, we must first express Eq. 5.17 as a function. Be- cause it is relatively complicated, we will store it as an M-file: function f = fpHpH,pCO2 K1=10-6.3;K2=10-10.3;Kw=10-14; KH=10-1.46; H=10-pH; f=K11e6HKHpCO2+2K2K11e6HKHpCO2+KwH-H; We can then use the M-file from Fig. 5.7 to obtain the solution. Notice how we have set the value of the desired relative error ε a = 1 × 10 −8 at a very low level so that the it- eration limit maxit is reached first so that exactly 11 iterations are implemented [pH1958 fx ea iter]=bisectfpH,2,12,1e-8,11,315 pH1958 = 5.6279 fx = -2.7163e-008 ea = 0.08676 iter = 11 Thus, the pH is computed as 5.6279 with a relative error of 0.0868. We can be confident that the rounded result of 5.63 is correct to two decimal places. This can be verified by per- forming another run with more iterations. For example, setting maxit to 50 yields [pH1958 fx ea iter] = bisectfpH,2,12,1e-8,50,315 pH1958 = 5.6304 fx = 1.615e-015 ea = 5.169e-009 iter = 35 For 2008, the result is [pH2008 ea iter]=bisectfpH,2,12,1e-8,50,386 PROBLEMS 147 CASE STUDY 5.6 continued