The “guts” of the affinity calculations: compute affinities or other thermodynamic properties of formation reactions of species on multidimensional arrays with dimensions corresponding to the ranges of intesive variables requested by the user; calculate affinities of ionization reactions of proteins.

1 2 3 4 5 |

`what` |
character, name of property to calculate |

`vars` |
character, names of variables over which to calculate a property |

`vals` |
list of numeric, values for each variable |

`lims` |
list of numeric, limits of the values for each variable |

`T` |
numeric, temperature. Default is to take the temperature from |

`P` |
numeric, pressure, or character "Psat" (default), which denotes 1 bar or the saturation vapor pressure of |

`IS` |
numeric, ionic strength; default is 0 mol kg |

`sout` |
list, output from subcrt function |

`exceed.Ttr` |
logical, allow subcrt to compute properties for phases beyond their transition temperature? |

`transect` |
logical, perform calculations on a transect instead of a grid? |

`args` |
list, defines the variables over which to calculate properties |

`iprotein` |
numeric, rownumber in |

`pH` |
numeric, pH |

`energy`

is the engine for the calculations of chemical affinity. Given *n* (which can be zero, one, or more) names of basis species and/or T, P, or IS as the `var`

s, it calculates the property given in `what`

on an *n*-dimensional grid or transect for each of the values (`vals`

) of the corresponding variable. The limits for each variable given in `lims`

indicate the minimum and maximum value and, if a third value is supplied, the resolution, or number of points in the given dimension. If T, P, and/or IS are not among the `var`

s, their constant values can be supplied in `T`

(in Kelvin), `P`

(in bar, or Psat), and `IS`

(in mol kg*^-1*). `sout`

, if provided, replaces the call to `subcrt`

which can greatly speed up the calculations if this intermediate step is stored by other functions (e.g., `transfer`

). `exceed.Ttr`

is passed to `subcrt`

so that the properties of mineral phases beyond their transition temperatures can optionally be calculated.

The `what`

argument of `energy`

is analogous to the `property`

argument of `affinity`

.

`energy.args`

is used by `affinity`

to generate the argument list for `energy`

. `energy.args`

also has the job of converting Eh to pe as a function of temperature (see `convert`

), and converting pe and pH to logarithms of activities of the electron and protein, respectively (i.e., negating the values).

In CHNOSZ version 0.9, `energy`

gained a new argument transect which is set to TRUE by `energy.args`

when the length(s) of the variables is(are) greater than three. In this mode of operation, instead of performing the calculations on an *n*-dimensional grid, the affinities are calculated on an *n*-dimensional transect through chemical potential (possibly including T and/or P) space.

`A.ionization`

builds a list of values of A/2.303RT of the ionization reactions of proteins that are a function of `T`

, `P`

and `pH`

but are expanded to as many dimensions as defined in `vars`

in order to be included by the calculations by `energy`

. These calculations are invoked if proteins are in the species definition, and the basis species contain H+.

For `energy`

, a list the first element of which is `sout`

(the results from `subcrt`

) and the second element of which is `a`

, which contains the calculated properties. The latter itself is a list, one element for each species of interest, which have dimensions that are the number of `var`

iables passed to the function.

For `energy.args`

, a list with elements `what`

, `vars`

, `vals`

, `lims`

, `T`

, `P`

, `IS`

that are appropriate for the corresponding arguments in `energy`

.

In most cases, `affinity`

is used interactively instead of these functions.

1 2 3 4 |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.