util.formula {CHNOSZ} | R Documentation |
Calculate the standard molal entropy of elements in a compound; calculate the standard molal Gibbs energy or enthalpy of formation, or standard molal entropy, from the other two; list coefficients of selected elements in a chemical formula; calculate the average oxidation state of carbon. Create a stoichiometric matrix for selected species.
as.chemical.formula(makeup, drop.zero = TRUE)
mass(formula)
entropy(formula)
GHS(formula, G = NA, H = NA, S = NA, T = 298.15, E_units = "J")
ZC(formula)
i2A(formula)
makeup |
numeric, object returned by |
drop.zero |
logical, drop elements with a coefficient of zero? |
formula |
character, chemical formulas, or numeric, rownumbers in |
G |
numeric, standard molal Gibbs energy of formation from the elements |
H |
numeric, standard molal enthalpy of formation from the elements |
S |
numeric, standard molal molal entropy |
T |
numeric, temperature in Kelvin |
E_units |
character, energy units (J or cal) |
i2A
returns a stoichiometric matrix representing the elemental composition of the formula
s.
Each column corresponds to an element that is present in at least one of the formulas; some element counts will be zero if not all formula have the same elements.
If a matrix is passed to i2A
it is returned unchanged.
as.chemical.formula
makes a character string representing a chemical formula from a vector of coefficients with names corresponding to the elements (e.g., the output of makeup
) or from a stoichiometric matrix (output of i2A
).
Each elemental symbol is written followed by its coefficient; negative coefficients are signed.
Any coefficients equal to 1 are not explicitly written, and any charge (indicated by makeup
as ‘Z’) is shown as a signed number at the end of the formula.
If the formula is uncharged, and the last element has a negative coefficient, +0 is shown at the end of the formula to indicate a charge of zero.
The remaining functions documented here accept vectors of chemical formulas, species indices, or a mixture of both, or stoichiometric matrices with elements on the columns.
mass
and entropy
return the sums of masses or entropies of elements in each of the formula
s.
The masses are calculated using the masses of the elements in their natural isotopic distribution, and the entropies, in J K^{-1}
mol^{-1}
, are calculated using the entropies of the compounds of the pure elements in their stable states at 25 °C and 1 bar.
The properties of the elements used by this function are taken from thermo$element
.
GHS
computes one of the standard molal Gibbs energy or enthalpy of formation from the elements, or standard molal entropy, from values of the other two.
The formula
, G
, H
and S
arguments must all have the same length.
The entropies of the elements (Se
) in each formula
are calculated using entropy
, which gives values in Joules.
If E_units
is ‘cal’, the values are converted to calories.
The equation in effect can be written as {\Delta}G^{\circ}={\Delta}H^{\circ}-T{\Delta}S^{\circ}
, where {\Delta}S^{\circ}=S-S_e
and T
is the temperature given in T
(defaults to 298.15 K) (note that G
and H
in the arguments correspond respectively to {\Delta}G^{\circ}
and {\Delta}H^{\circ}
in the equation).
For each formula, if one of G
, H
, or S
is NA, its value is calculated from the other two.
Otherwise, the values are returned unchanged.
ZC
returns the average oxidation state of carbon (Z_{\mathrm{C}}
) calculated from ratios of the elements in the chemical formula
s.
The equation used is
Z_{\mathrm{C}}=\frac{Z-n_{\mathrm{H}}+2\left(n_{\mathrm{O}}+n_{\mathrm{S}}\right)+3n_{\mathrm{N}}}{n_{\mathrm{C}}}
, where the n
refer to the number of the indicated element in the formula and Z
is the charge (Dick and Shock, 2011).
The result is NaN
for any formula that does not contain carbon. Elements other than those shown in the equation are not included in the calculation, and produce a warning.
mass
, entropy
, and ZC
return numeric values.
as.chemical.formula
returns a character object.
GHS
returns a matrix with column names ‘G’, ‘H’ and ‘S’, and i2A
returns a matrix with column names corresponding to the elements in the formulas.
Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. PLOS One 6, e22782. doi:10.1371/journal.pone.0022782
makeup
, used by mass
and entropy
, and ZC
and i2A
for counting the elements in a formula (the latter two make use of the count.zero
argument).
## Mass and entropy from chemical formulas
mass("H2O")
entropy("H2O")
mass("-1") # electron
entropy("-1")
## Different ways to get the formula of alanine
iA <- info("alanine")
info(iA)$formula
as.chemical.formula(makeup(iA))
## Converting among Gibbs energy, enthalpy, entropy
# Calculate the value of G from H and S
GHS("H2O", H = water("H")$H, S = water("S")$S)
# The result is not exactly equal to the value from water("G"),
# probably because of different entropies of the elements
## Average oxidation states of carbon
ZC(c("CO2", "CH4", "CHNOSZ")) # 4, -4, 7
si <- info("LYSC_CHICK")
# Can use species index or formula
ZC(si)
ZC(info(si)$formula)
## Calculate the chemical formulas, then
## ZC of all of the proteins in CHNOSZ's database
pf <- protein.formula(thermo()$protein)
range(mass(pf))
# Use na.rm = TRUE because we have a "protein" with a formula of H2O
range(ZC(pf), na.rm = TRUE)