44 Energy in planetary processes
Software Box 1.1 Continued
capacity, i.e., of function (S1.1.1). The second procedure is named intcp_sh and
calculates the definite integral of the heat capacity equation, i.e., function (S1.1.2). The
fourth procedure, named HT_sh, calculates the enthalpy at the temperature of interest
by adding the heat capacity integral to the enthalpy at 298.15 K (e.g. equation (1.100)).
Each of these procedures receives from the calling procedure an array that contains
the values of the thermodynamic properties, and a separate variable that contains the
temperature in K. The remaining procedures work in the same way but calculate other
thermodynamic functions. They will be introduced in later chapters. The procedures in
th_shomate.mw are placed in a table (one of the many Maple data structures – we
won’t get into that here), and this table is saved into a package, which is an executable
file that other Maple procedures can call. The last line in th_shomate.mw takes care
of this, and here is a very important point: packages must be saved in a directory, or
library, that must be known by the calling procedure. The name of this directory can
be anything you want. I have chosen c:/thcalc, so you should create a directory
(or “folder”) with this name before attempting to run any of the Maple procedures
from the website. When you download th_shomate.mw you can put it in this or any
directory you wish. Then open the file and execute it (you can do this in the “Edit”
pull down menu). Execution of the file places the th_shomate executable package
in c:/thcalc, and the package is ready to be used by other procedures.
The file th_template_1.mw contains a number of commands and procedures that
are used by many of the thermodynamic calculation worksheets that we will discuss in
this and subsequent chapters. It is important to understand what each of these commands
does. I describe them in the order in which they appear in the Maple worksheet.
libname := ... tells Maple the location of the library where the packages are
stored. It must match the name used when the package was created (see above).
with (th_shomate) tells Maple to load the th_shomate package.
with (spread) tells Maple to load a standard package that enables spreadsheet
functions.
RefStateData := CreateSpreadsheet() creates a spreadsheet named
RefStateData, that is used to store standard state thermodynamic properties at
the reference conditions, 298.15 K and 1 bar. Each row in the spreadsheet contains
data for one chemical species. For now we will only use the first nine columns, but
more data columns will be occupied in later chapters. The first column contains
correlative numbers that will serve to identify the species (more on this below).
The second column stores the name of the species. Each additional column after the
second one corresponds to a thermodynamic property, generally at 298K and 1 bar.
Successive columns store the values of
f
H
0
1,298
, S
0
1,298
f
G
0
1,298
(the functions S
and G will be defined in later chapters) and the a
i
coefficients of the C
P
function.
Enthalpy and Gibbs free energy must be entered in kJoules, all other quantities
in Joules. The data can be entered directly in Maple, but I find it easier to store
the data (e.g. from Holland & Powell, 1998, or some other data base) in a regu-
lar spreadsheet such as QuattroPro and then copy whatever is needed to Maple.
Once you have all of the data that you will need for the calculations in the Maple
spreadsheet it is best to save it in Tab Delimited format by right-clicking anywhere
in the spreadsheet and then Export Data. It can then be imported directly into
Maple by performing the inverse operation. The data for this example are stored
in tab-delimited format in a file named spgrt.