next up previous
Next: basis Up: CHNOSZ examples Previous: [4] subcrt

makeup

## Don't show: data(thermo)
thermo$obigt: 1809 aqueous, 3368 total species
## End(Don't show) # the composition of a simple compound makeup("CO2") # 1 carbon, 2 oxygen
C O 1 2
# the formula of lawsonite, with a parenthetical part and a suffix makeup("CaAl2Si2O7(OH)2*H2O")
Al Ca H O Si 2 1 4 10 2
# fractional coefficients are ok redfield <- c(106, 16, 1) reddiv10 <- makeup("C10.6N1.6P0.1") stopifnot(10*reddiv10 == redfield) # the coefficient for charge is a number with a *preceding* sign # e.g., ferric iron, with a charge of +3 is expressed as makeup("Fe+3")
Fe Z 1 3
# transcribing the formula the way it appears in many # publications produces a likely unintended result: # 3 iron atoms and a charge of +1 makeup("Fe3+")
Fe Z 3 1
# these all represent a single negative charge, i.e., electron makeup("-1")
Z -1
makeup("Z0-1")
Z -1
makeup("Z-1+0")
Z -1
# hypothetical compounds with negative numbers of elements makeup("C-4(O-2)") # -4 carbon, -2 oxygen
C O -4 -2
makeup("C-4O-2") # -4 carbon, 1 oxygen, -2 charge
C O Z -4 1 -2
makeup("C-4O-2-2") # -4 carbon, -2 oxygen, -2 charge
C O Z -4 -2 -2
# the 'sum' argument can be used to check mass and charge # balance in a chemical reaction formula <- c("H2O", "H+", "Z0-1", "O2") (mf <- makeup(formula, c(-1, 2, 2, 0.5), sum=TRUE))
H O Z 0 0 0
stopifnot(all(mf==0))


next up previous
Next: basis Up: CHNOSZ examples Previous: [4] subcrt