PhreeqcUsers Discussion Forum

Applications and Case Studies => Soil profile geochemistry => Topic started by: P.Merdy on June 18, 2020, 07:30:54 AM

Title: acid base titration with 2 binding sites in solution
Post by: P.Merdy on June 18, 2020, 07:30:54 AM
Hello.
I would like to simulate the acid-base titration of a lake containing natural organic matter in order to determine the pKa of two mean sites, called strong and weak, which will basically represent carboxylic and phenolic groups. I need to adjust the two pKa until the titration curve fits with the experimental one and this is why I used "selected output". I would like to draw pH=f(volume of titrant). Before the titration, I added NaOH to reach pH=12 and then I titrate with HNO3. The PhreeqC plot is showing only one initial volume point. The selected output is empy (I have the headings only). This is the script below and please if someone can help solving the problems, we will be very grateful. Thank you.     

SOLUTION_SPECIES   
     
#      strong site--Ha_s
   
      Ha_sOH = Ha_sOH
   log_k  0.0

      Ha_sOH = Ha_sO- + H+
   log_k  -4   

#   weak site--Ha_w

   Ha_wOH = Ha_wOH
   log_k  0.0

   Ha_wOH = Ha_wO- + H+
   log_k  -9   

END
SOLUTION 1   
   temp 25
   water 0.015 kg # volume of the lake sample that is titrated
        -units  mol/kgw   
        pH      9.1   
        N(5)      0.1   
        K      0.1    charge
   -units mg/kgw   
   Ha_s   637
   Ha_w   637

REACTION
KOH 0.1
1.067e-4 # initial NaOH added to raise the pH to 12 before acid titration
END
REACTION
HNO3 0.1 # concentration of acid titrant
1.5e-3 moles in 17 steps
H2O 0.8447
END 

USER_GRAPH 1
 -chart_title  "Titration Curve"
 -axis_titles "Acid Added (mL)", "pH"
 -axis_scale x_axis  0 15 1
 -axis_scale y_axis 0 12 1
 -start
10 VT=SOLN_VOL*1000 # volume of the acid titrant added
20 V=VT-15
30 pH = -LA("H+")
40 GRAPH_X V
50 GRAPH_Y pH
END

SELECTED_OUTPUT
-file titration_Ha
-reaction true
-step true
-molalities H+ Ha_wOH Ha_sOH Ha_wO- Ha_sO-


END
Title: Re: acid base titration with 2 binding sites in solution
Post by: dlparkhurst on June 18, 2020, 03:04:02 PM
Let's step back and consider your initial conditions. Ignoring the organic acids, the combination of solution volume and KOH addition generate a pH less than 11, rather than 12. Adding the organics would require additional base.

Code: [Select]
SOLUTION 1
    temp      25
    pH        9.1
    units     mol/kgw
    density   1
    K         0.1 charge
    N(5)      0.1
    -water    0.015 # kg
REACTION
KOH 0.1
1.067e-4 # initial NaOH added to raise the pH to 12 before acid titration
END

After you address the pH issue, the next question is what are the concentrations of Ha_s and Ha_w. You did not include SOLUTION_MASTER_SPECIES so I am not sure what you had in mind for molalities. Note that you cannot define -units twice in a SOLUTION definition; only the last definition will be used. If you want to mix mol/kgw and mg/kgw, you should define -units mol/kgw and then

Ha_s 637 mg/kgw gfw ???

Note that you are really defining the concentration of organic OH groups that can be deprotonated.
Title: Re: acid base titration with 2 binding sites in solution
Post by: John Mahoney on June 18, 2020, 03:59:07 PM
Once again This is another good application of PhreePlot and its fitting capabilities.  I have done this as an examples for a simple alkalinity titration to calculate the well known Ks for the the carbonate reactions. I have had troubles posting longer messages so send me a private message and I will provide more details. the posting issue might be relate to attaching PhreePlot input files not sure.

Title: Re: acid base titration with 2 binding sites in solution
Post by: John Mahoney on June 18, 2020, 05:05:11 PM
There is a little more discussion about this fitting application on my website Mahoney Geochemical,  go to philosophy page and scroll down.  In this case I ran a titration using PHREEQC and it produced a file of pH values for each step.  That became the observation file . I then set up a PhreePlot model to calculate the two log K values for the carbonate/bicarbonate reaction and the H2CO3/bicarbonate reaction.  the toughest part I see in your titration is getting the steps from the actual titration to match the acid additions in the model.  I assume you used an automatic titrator so that should be easy. 
Because there is a potential issue with PPI files, although Tom says he corrected it I have entered the file as a code block.
 
here is the input file for my titration.   I suppose you could also add the site concentrations as additional fitting parameters , but you would need to have good data and enough of if for some confidence in the fits.


Code: [Select]
# Example of fitting speciation reactions
SPECIATION
  jobtitle                             "Fitting Carbonate equilibrium using alkalinity titration"
  calculationType                      fit
  calculationMethod                    1
  database                             "Wateq4f.DAT"
  #debug      1
 
 FIT
  fitMethod           nlls
  dataFile                            "titrations.dat"  # file containing observations and independent variables
  onepass                              true
  mainLoop                             1            # main (iterating) loop starts at first simulation (relative to start of block)
  dependentVariableColumnObs           pH   # column in onepoint.dat
  dependentVariableColumnCalc          calc_pH      # column in selected output
    fitMaxStepSize                       .1
  fitFiniteDiffStepSize                1.0E-03      # initial step size for parameter adjustment
  numberOfFitParameters            2
    fitParameterNames                    "k1fit"  "k2fit"
  fitLogParameters                     0   0
  fitAdjustableParameters              1  1        # 1 .= adjustable, 0 = fixed
  fitParameterValues                  10.0  11.0     # initial values
  fitConvergenceCriterion              1e-7
 
PLOT
  plotfactor 1  # 0 turns off Plotting
  plotTitle                            "Alkalinity titration fit <br> log K values 10.329 16.681 <br> fitted values <k1fit>  <k2fit>"
  xtitle                            step
    ytitle                               "pH"
    lines                                calculated                              # the 'calculated' column in the 'out' file is plotted as a line
    points                               observed                                # the 'observed' column in the 'out' file is plotted as points
    convertLabels                        F                                       # prevents the labels being interpreted as species
    changeColor                          T                                       # give subsets a sequence of difft colours
   lineColor  "blue"
   useLineColorDictionary                 0                                       # 0 = do NOT use the line colour dictionary for colours
    pointSize                            1.5      # 3.0                               # symbols will be 1.5  3 mm (nominal)
      plotFactor                           1.0                                     # can use this to scale whole plot
    png t
   pdf t
 
  trackSymbolColor   black
pointsSamecolor true
  gridLines true
CHEMISTRY
PRINT
    -reset     t

SOLUTION_SPECIES

#CO2     could be used instead of H2CO3
CO3-2 + 2 H+ = CO2 + H2O
log_k <k2fit>

#HCO3-               27
H+ + CO3-2 = HCO3-
log_k <k1fit>


SELECTED_OUTPUT 1
    -file                 titrations.dat
    -high_precision       true
    -reset                false

USER_PUNCH
-headings  calc_pH
-start
10 PUNCH -LA("H+")
-end

SOLUTION
units mg/L
Alkalinity 200
Ca 80
pH 11.3
REACTION
H2SO4
.005 moles in 50 steps
END
   
Title: Re: acid base titration with 2 binding sites in solution
Post by: John Mahoney on June 18, 2020, 06:16:22 PM
I did not include the data from the original PHREEQC model, but you should be able to work that out from the chemistry portion of the PhreePlot input file. 
Title: Re: acid base titration with 2 binding sites in solution
Post by: P.Merdy on June 19, 2020, 07:42:55 AM
Thank you so much for your very useful advices, David and John.
I will take into consideration and work out the scipt.
Title: Re: acid base titration with 2 binding sites in solution
Post by: John Mahoney on June 20, 2020, 02:10:10 AM
the tricky part will to get the right amount of titrant added in each step and to assure that all that titrant in each step has been consumed. In my simple example that is easy.

 David Kinniburgh suggested you look at some examples  he stated:   
When you fit an irregular set of data you have to calculate
each point separately, eg see \demo\kineticsSi\kineticsSifit1.ppi vs
demo\kineticsSi\kineticsSifit.ppi.

This is after you install PhreePlot. 
Title: Re: acid base titration with 2 binding sites in solution
Post by: P.Merdy on June 21, 2020, 03:45:39 PM
Thank you for the additional advices. I'm still trying tu use PhreeqC to generate the graph and data (I downloaded PhreePlot but I will need to get familiar to it) since I am more used to it. I have taken into account the previous comments of David and really moved forward with the script. Still, the graph does not show and the selected ouput does not contain any data (just the titles). I need help because at this stage, I do not progress anymore. Thank you very much. Here is my script:

SOLUTION_MASTER_SPECIES   # 2 sites are considered

        Ha_s       Ha_sOH       0.0   COO-   2000 # 2000 is the molecular molar mass in average for natural organic matter
        Ha_w       Ha_wOH       0.0   O-     2000 #
      
SOLUTION_SPECIES   
     
#      strong site--Ha_s
   
      Ha_sOH = Ha_sOH
   log_k  0.0

      Ha_sOH = Ha_sO- + H+
   log_k  -4   

#   weak site--Ha_w

   Ha_wOH = Ha_wOH
   log_k  0.0

   Ha_wOH = Ha_wO- + H+
   log_k  -9   

END
SOLUTION 1   
   temp 25
   water 0.015 kg # lagoon water to be titrated
        -units  mol/L   
        pH      9.1   
        N(5)      0.1   
        K      0.1    charge
   Ha_s   0,0046 # in mol/L. calculated based on dissolved organic carbon measurement
   Ha_w   0,0046

REACTION # on ajoute les titrants   
KOH 1
1.067e-4 # initial addition to raise the pH at  10
END
Save Solution 1
Use Solution 1
REACTION
H2O 1
HNO3 0.0018
0.833 moles in 50 steps
END 

USER_PRINT
10 PRINT SOLN_VOL * 1000

USER_GRAPH 1
 -chart_title  "Titration Curve"
 -axis_titles "Acid Added (mL)", "pH"
 -axis_scale x_axis  0 15 1
 -axis_scale y_axis 0 12 1
 -start
10 VT = SOLN_VOL*1000
20 V = VT-15 # volume of titrant added
30 pH = -LA("H+")
110 GRAPH_X V
120 GRAPH_Y pH
END

SELECTED_OUTPUT
-file titration_Ha
-reaction true
-step true
-molalities H+ Ha_wOH Ha_sOH Ha_wO- Ha_sO-
#-SOLN_VOL # PhreeqC does not seem to recognize this keyword so I had to remove it. But I would like a graph V(HNO3)added=f(pH)

END

 
Thank you in advance for your help
Title: Re: acid base titration with 2 binding sites in solution
Post by: dlparkhurst on June 21, 2020, 04:18:01 PM
You need to remove the END after REACTION (and before USER_PRINT), and remove the END after USER_GRAPH (and before SELECTED_OUTPUT). USER_GRAPH and SELECTED_OUTPUT must be defined before or in the same simulation (END-to-END) as the reaction you want to plot or write to selected output.

The set of options for SELECTED_OUTPUT is given in the manual and -soln_vol is not one of them. SOLN_VOL is a Basic function, so you will need to add USER_PUNCH to print it to the selected output file. You can add this code to augment SELECTED_OUTPUT 1:

Code: [Select]
USER_PUNCH 1
-heading Vol
-start
10 PUNCH SOLN_VOL
-end
Title: Re: acid base titration with 2 binding sites in solution
Post by: P.Merdy on June 21, 2020, 04:54:46 PM
Thank you so much for your help. I have learnt more about PhreeqC with your explanations and the script is running. :-)