Conceptual Models > Design of conceptual models

Calculating pH from H+ concentration input

(1/2) > >>

MarkFP:
Hi all,

I'm not sure I'm posting this question in the correct sub-forum, but here goes:

I'm working on coupling PHREEQC (currently just speciation calculations) with an external model that predicts microbial growth and metabolic dynamics. The external model produces H+ concentrations as an output, and I want to use these values as an input for PHREEQC for speciation and pH calculation.

However, I run into convergence issues whenever H is defined as an input within with the SOLUTION block, presumably because the program requires a pH input which is incompatible with the H concentration input...

Is there something simple I'm overlooking here? Any help would be gratefully received!

Thanks

dlparkhurst:
I need to know a bit more about your calculation.

So you want to define a SOLUTION that has a given H+ concentration.

What are the constituents in the solution? If you have HCO3- in the solution, the solution will be buffered, and it requires quite a bit of acid or base to attain a given H+ concentration.

What do you want to do about charge balance? You can't just add H+. Your reactions may be microbial, but they still require a charge balanced reaction. If you are pumping out H+, presumably you are also removing a cation or adding an anion to the solution.

What reaction are you going to run with the solution after you fix H+ concentration?

The only difference between 10^-pH and H+ concentration is the activity coefficient for H+. So, you can iteratively set the pH, determine the activity coefficient, and adjust the pH until you get the H+ concentration that you want. If your solution is fairly constant composition, the activity coefficient will not vary much, so you may be able to get away with simply determining the activity coefficient for you medium and assuming it is constant.

MarkFP:
Thanks for the reply.

For the simplest conception of my question, we could ignore the microbial model and just focus on a simple speciation calculation. Is it possible to input a defined H+ and have pH calculated as an output? When I try this, I always get convergence issues (example pasted in below).

However, I'll work through your questions in sequence:

We would like to apply this to a range of solution compositions, some of which will include HCO3-/CO32-. These will have high pH (low [H+]), somewhere in the pH ~9 range. Others will be ~neutral and will not contain HCO3-/CO32-.

Charge balance: indeed, we will adjust other ions to achieve charge balance. In the example below, this is set to Cl.

Downstream calculations: The activities of individual solution species output by PHREEQC are used to calculate delta G for various metabolic reactions that define the next iteration of the microbial model. Concentrations of solution species that may have changed following precipitation/dissolution of solid phases are also fed into the microbial model to define substrate availability, etc.

I appreciate I any input, thanks.


Example (using pitzer.dat)

TITLE H_trials_01

SOLUTION 1
    temp      25
    units     mol/kgw
    Na       2.89E-01
    Mg       2.45E-07
    K          4.52E-02
    S(6)     1.11E-02
    Cl          1.80E-01 charge
    C(4)     1.20E-01
    Ca       7.81E-06
    H         1e-9
    -water    1 # kg


END

dlparkhurst:
There is not a simple way to input H+ concentration, only pH. I attach a script to perform the calculation, which hopefully is not too cumbersome for your uses.

The following script is a bit obscure, but it assumes the pH that you define for a solution is -log10(H+), where H+ is moles per kilogram water. The script actually writes another script to a file named adjust_pH.pqi (twice). It uses an equilibrium phase that allows you to specify the pH of the solution by addition/removal of HCl. Since the desired pH is unknown, it iteratively calculates a pH from the specified H+ concentration and the current activity coefficient of H+. The calculated H+ concentration at the estimated pH may still not be exactly the specified H+ concentration because the activity coefficient may change by the addition/removal of HCl, but after a couple of iterations it should converge to the specified H+ concentration.

If you look at the output, the first iteration gives 1.01e-9 and the second iteration 1.000e-9 for the concentration of H+.


--- Code: ---PHASES
Fix_H+
  H+ = H+
  log_k 0
END
SOLUTION 1
    pH        9  # log10 H+ mol/kgw
    temp      25
    units     mol/kgw
    Na       2.89E-01
    Mg       2.45E-07
    K          4.52E-02
    S(6)     1.11E-02
    Cl          1.80E-01 charge
    C(4)     1.20E-01
    Ca       7.81E-06
    -water    1 # kg
SELECTED_OUTPUT 2
-file adjust_pH.pqi
USER_PUNCH 2
-start
5 IF GET(1) = 0 THEN PUT(LA("H+"), 1)
10 target_h = 10^GET(1)
20 gamma_h = GAMMA("H+")
30 new_ph = LOG10(target_h * gamma_h)
40 s$ = "USE solution 1" + EOL$
50 s$ = s$ + "EQUILIBRIUM_PHASES 1" + EOL$
60 s$ = s$ + "Fix_H+" + STR_F$(new_pH, 15, 10) + " HCl 10 " + EOL$
70 s$ = s$ + "SAVE solution 1" + EOL$
90 PUNCH s$
100 END
-end
END
# Iterate 2 times to adjust to specified H+ concentration
SELECTED_OUTPUT 2
-file adjust_pH.pqi
INCLUDE$ adjust_pH.pqi
END
SELECTED_OUTPUT 2
-file adjust_pH.pqi
INCLUDE$ adjust_pH.pqi
END

--- End code ---

MarkFP:
Thanks David- I would never have thought of taking this approach, so thanks for the pointers. We're exploring now whether it is feasible to build into our model, and will report back if we get it working.

Navigation

[0] Message Index

[#] Next page

Go to full version