util.affinity: Functions to Work With Chemical Affinities


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.


  energy(what, vars, vals, lims, T=get("thermo")$opt$Tr, P="Psat", IS=0, 
    sout=NULL, exceed.Ttr=FALSE, transect = FALSE)
  A.ionization(iprotein, vars, vals, T=get("thermo")$opt$Tr,
    P="Psat", pH=7, transect=FALSE)



character, name of property to calculate


character, names of variables over which to calculate a property


list of numeric, values for each variable


list of numeric, limits of the values for each variable


numeric, temperature. Default is to take the temperature from thermo$opt$Tr, which corresponds to 25 °C


numeric, pressure, or character "Psat" (default), which denotes 1 bar or the saturation vapor pressure of H2O above 100 °C (see water)


numeric, ionic strength; default is 0 mol kg^-1


list, output from subcrt function


logical, allow subcrt to compute properties for phases beyond their transition temperature?


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


list, defines the variables over which to calculate properties


numeric, rownumber in thermo$protein


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 vars, 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 vars, 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 variables 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.

See Also

In most cases, affinity is used interactively instead of these functions.


species("acetic acid")
eargs <- energy.args(list(O2=c(-90, -60, 5), T=c(0, 100, 5)))
ea <- do.call(energy, eargs)

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

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