HpH:

--------------------------------------------------------------------------
   pH measurement of a pH process. The process consists of an acid
   (HNO3) stream, buffer (NaHCO3) stream, and base (NaOH) stream that are 
   mixed in a stirred tank. The chemical equilibria is modeled by 
   introducting two reaction invariants for each inlet stream.

           +        -         -         =
   wAi = [H ]i - [OH ]i - [HCO3]i - 2[CO3]i
                        -         =
   wBi = [H2CO3]i + [HCO3]i + 2[CO3]i

--------------------------------------------------------------------------
   Form:
   y = HpH( pH, x, d )
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   pH          (1,1) Measurement 
   x           (3,1) State [wA4;wB4;h]
   d           (1,1) Structure
                     .wA1       (1,1) See above
                     .wA2       (1,1)
                     .wA3       (1,1)
                     .wB1       (1,1)
                     .wB2       (1,1)
                     .wB3       (1,1)
                     .pK1       (1,1) Base 10 log of equilibrium constant
                     .pK2       (1,1) Base 10 log of equilibrium constant
                     .a         (1,1) Crossectional area of mixing tank
                     .cV        (1,1) Valve coefficient
                     .n         (1,1) Valve exponent
                     .z         (1,1) Vertical distance between bottom of
                                      tank and outlet of effluent
                     .q1        (1,1) Volumetric flow of HNO3
                     .q2        (1,1) Volumetric flow of NaHCO3
                     .q3        (1,1) Volumetric flow of NaOH

   -------
   Outputs
   -------
   y           (1,1) Quantity to be zeroed

--------------------------------------------------------------------------
   Reference: Henson, M. A. and D. E. Seborg. (1997.) Nonlinear Process
              Control Prentice-Hall. pp. 207-210.
--------------------------------------------------------------------------