thermo data object, as well as modify the object. This help topic should help users understand the major side effects, but does not contain a comprehensive description of these interactions (the code is the ultimate reference).sys.source is used to create a list object named thermo that is placed in an environment named CHNOSZ:thermo. Because that environment is attached, the thermo object, including all of its components, is accessible in the search path. Some functions in CHNOSZ have side effects that modify the contents of thermo; all such changes can be reverted, and the object restored to its original state, by calling data(thermo). In the functions in the package, the greatest number of accessions are to the thermodynamic database (thermo$obigt), followed by the basis and species definitions (thermo$basis and thermo$species). For example, info can be used to look up thermodynamic data in thermo$obigt by the name or chemical formula of a species. As another example, subcrt attempts to balance unbalanced chemical reactions with the user-defined basis species in thermo$basis.
Some functions modify the thermodynamic database or system definition in thermo. These are examples of <<-< a=""><-<>.
Side effects are not highly desirable in functional programming languages such as R. The reason this design is adopted in CHNOSZ is that interactive use of basis and species appeared to the author, in the early stages of developing the package and of learning R, to be facilitated by not requiring users to assign the results of these functions to objects. Instead, using side effects, the program
The two major side effects, that most users will encounter, are the basis and species definitions. These functions and a few other modifications (writing) and accessions (reading) of data objects are listed below. The names of objects in this table refer to the components of the thermo object; for example, one can type thermo$opt at the command line to access all of the contents of the opt component, including those not listed in the table.
obigt mod.obigt info thermodynamic database
basis basis species, subcrt basis definition
species species affinity species definition
opt$T.units T.units convert units
opt$water -- water formulation for properties of water
opt$Tr, Pr -- GHS reference temperature and pressure
opt$state -- info physical state
opar thermo.plot.new -- graphical parameters
}
Beginning with CHNOSZ version 0.9-9, instances of <<-< a=""><-<> in the code have the effect of thermo, you also should use the <<-< a=""><-<> operator; examples of changing thermo$opt$water in this manner can found in the help page for water.
data(thermo) # side effect: reset the system definition
basis() # NULL
basis("CHNOS") # side effect: define the basis species
basis() # not NULL
data(thermo) # side effect: reset the system definition
basis() # NULLRun the code above in your browser using DataLab