isorel.ppi

# simple example of fitting to a Langmuir isotherm using unit weighting
#   plot of fit to Langmuir isotherm - using relative error weighting, w_i = abs(1/calc_i)
#   see iso.ppi and other \fit files

SPECIATION
  jobTitle                             "Test fitting: relative error weighting"
  calculationType                      fit
  calculationMethod                    1

FIT
  dataFile                             iso.dat 
  onepass                              FALSE
  dependentVariableColumnObs           1
  dependentVariableColumnCalc          1
  fitWeightingMethod                   1                             # 1 = relative error weighting
  fitFiniteDiffStepSize                1.0E-3
  blockRangeColumn                  5
  numberOfFitParameters                2
  fitParameterNames                    log_k  M1
  fitLogParameters                     0 0
  fitAdjustableParameters              1 1
  fitParameterValues                   3.0 1.0

PLOT
  plotTitle                            "Zn sorption on Hfo<br>(with relative error weighting<br>fitWeightingMethod = 1)"
  xtitle                               "Zn concn (mmol/L)"
  ytitle                               "Zn sorbed (mmol Zn/mol Fe)"
  lineWidth                            0.4
  lines                                calculated                    # y (line) = calculated from the out file
  points                               observed                      # y (points) = observed from the out file
  lineColor                            red
  labelSize                            0.0                           # suppress labelling
  legendTextSize                       0.0                           # suppress the legend (key)
  pointSize                            4.0
  customXcolumn                        Znconcn                       # x = Znconcn from out file
  extraText                            "extratextiso.dat"


CHEMISTRY

PRINT
    -reset false
PHASES
Fix_H+
  H+ = H+
  log_k 0.0
SELECTED_OUTPUT
 -high_precision true
 -reset false
SURFACE_MASTER_SPECIES
  Surf Surf
SURFACE_SPECIES
  Surf = Surf
  log_k  0.0

  Surf + Zn+2 = SurfZn+2
  log_K <log_k>
SURFACE
    Surf <M1>
    -equil 1
    -no_edl

USER_PUNCH
# fit Langmuir isotherm
-headings  sorbZn pH mmolZn step_no                                  # this the output pH not the input pH
10 sorbedZn=SURF("Zn","Surf")
20 if sorbedZn>0 THEN punch sorbedZn, -la("H+"),  tot("Zn")*1e3, step_no

SOLUTION 1
    -pH <pHobs>
    -units mmol/L
    Na   1000
    N(5) 1000
    Zn   <Znconcn>                                                   # <Znconcn> from iso.dat
EQUILIBRIUM_PHASES
  Fix_H+ -<pHobs>  NaOH
  -force_equality true
END