species {CHNOSZ}R Documentation

Species of Interest

Description

Define the species of interest in a system; modify their physical states and logarithms of activities.

Usage

  species(species = NULL, state = NULL, delete = FALSE, add = FALSE,
    index.return = FALSE)

Arguments

species

character, names or formulas of species to add to the species definition; numeric, rownumbers of species to modify or delete

state

character, physical states; numeric, logarithms of activities or fugacities

delete

logical, delete the species identified by numeric values of species (or all species if that argument is missing)?

add

logical, delete a previous species definition instead of adding to it?

index.return

logical, return the affected rownumbers of thermo()$species instead of its contents?

Details

After defining the basis species of your system you can use species to identify the species of interest. A species is uniquely identified by a combination of a name and state, which are columns of the thermodynamic database in thermo()$OBIGT. For each match of species to the name, formula, or abbreviation of a species, and of state to the state (‘⁠aq⁠’, ‘⁠cr⁠’, ‘⁠gas⁠’, ‘⁠liq⁠’), the species is added to the current species definition in thermo()$species.

The state argument can be omitted, in which case the first matching species in any state is added (in many cases, this means the aqueous species). If there are multiple matches for a species, the one that is in the state given by thermo()$opt$state is chosen, otherwise the matching (or n'th matching duplicate) species is used. Note that the states of species representing phases of minerals that undergo polymorphic transitions are coded as ‘⁠cr⁠’ (lowest-T phase), ‘⁠cr2⁠’, ‘⁠cr3⁠’, ... (phases with increasing temperature). If state is ‘⁠cr⁠’ when one of these minerals is matched, all the polymorphs are added.

The data frame in thermo()$species holds the species names and indices as well as the stoichiometric reaction coefficients for the formation reaction from the basis species and the logarithms of activities or fugacities that are used by affinity. The default values for logarithms of activities are -3 for aqueous (‘⁠aq⁠’) species and 0 for others.

To modify the logarithms of activities of species (logarithms of fugacities for gases) provide one or more numeric values of species referring to the rownumbers of the species dataframe, or species NULL, to modify all currently defined species. The values in state, if numeric, are interpreted as the logarithms of activities, or if character are interpreted as new states for the species. If species is numeric and delete is TRUE, these species are deleted from the dataframe; if the only argument is delete and it is TRUE, all the species are removed.

By default, when identifying new species, any previous species definition is removed. Set add to TRUE to add species to an existing definition.

Value

With no arguments or when adding species, species returns the value of thermo()$species, unless index.return is TRUE, when the function returns the rownumbers of thermo()$species having the new species. With ‘⁠delete=TRUE⁠’, the value is the definition that existed prior the deletion; with ‘⁠delete=TRUE⁠’ and ‘⁠species⁠’ not NULL, the number of species remaining after the selected ones have been deleted, or NULL if no species remain.

See Also

Use info to search the thermodynamic database without adding species to the system. basis is a prerequisite for species.

Examples


# Set up the basis species
basis("CHNOS")
# Define some aqueous species
species(c("CO2", "NH3"))
# Add some gases
species(c("CO2", "NH3"), "gas", add = TRUE)
# Delete the aqueous species
species(1:2, delete = TRUE)
# Modify the "logact" value
# (log10 of activity for aqueous species;
#  log10 of fugacity for gases)
species(1:2, c(-2, -5))
# Change the state to aqueous
species(1:2, "aq")
# Load a new species definition (deletes the old one first)
species(c("glycine", "alanine"))
# Delete all the species
species(delete = TRUE)

# Changing the elements in the basis definition
# causes species to be deleted
basis(c("CaO", "CO2", "H2O", "SiO2", "MgO", "O2"))
species(c("dolomite", "quartz", "calcite", "forsterite"))
basis(c("CO2", "H2O", "O2"))
species()  # NULL

[Package CHNOSZ version 2.1.0 Index]