swap.basis {CHNOSZ}R Documentation

Swap Basis Species

Description

Swap the basis species defining a chemical system. One basis species is replaced by a new one with a different chemical formula.

Usage

  swap.basis(species, species2, T = 25)
  basis.elements(basis = thermo()$basis)
  element.mu(basis = thermo()$basis, T = 25)
  basis.logact(emu, basis = thermo()$basis, T = 25)
  ibasis(species)

Arguments

basis

dataframe, a basis definition

T

numeric, temperature in Kelvin

emu

numeric, chemical potentials of elements

species

character, names or formulas of species, or numeric, indices of species

species2

character or numeric, a species to swap in to the basis definition

Details

swap.basis allows to change the basis definition by swapping out a basis species for a new one. Specify the names or formulas of the old and replacement basis species in the first argument. When the basis definition is changed, any species of interest that were present are deleted, unless the new basis definition has exactly the same elements as before. In that case, the species are kept; also, the activities of the new basis species are set in order to maintain the chemical potentials of the elements at T °C and 1 bar.

The other functions are supporting functions: basis.elements returns the stoichiometric matrix for the current basis definition, element.mu calculates the chemical potentials of elements corresponding to the activities of the basis species, basis.logact does the inverse operation, and ibasis returns the index in the basis set for a given species index (in thermo$OBIGT), name or formula.

See Also

basis, and mosaic

Examples


## Swapping basis species
# Start with a preset basis definition
b1 <- basis("CHNOS+")
# Swap H2(aq) for O2(gas)
b2 <- swap.basis("O2", "H2")
# Put oxygen back in
b3 <- swap.basis("H2", "oxygen")

# Interconversion of chemical potentials of elements and
# logarithms of activities of basis species at high temperature
basis("CHNOS+")
bl1 <- basis()$logact
emu <- element.mu(T = 100)
bl2 <- basis.logact(emu, T = 100)
# There's no difference
round(bl2 - bl1, 10)

[Package CHNOSZ version 2.1.0 Index]