PhreePlot (001 025)
PhreePlot (001 025)
!
PhreePlot
David G Kinniburgh
http://www.phreeplot.org
David M Cooper
Centre for Ecology and Hydrology, Deiniol Road, Bangor, Gwynedd, LL57 2UW, UK
June 2011
Table of contents
1 INTRODUCTION ............................................................................................. 1
1.1 What does PhreePlot do?............................................................................ 1
1.2 What PhreePlot does not do....................................................................... 2
1.3 What you need to know before using PhreePlot ......................................... 2
1.4 Navigating this document .......................................................................... 3
2 INSTALLATION ................................................................................................ 5
2.1 Installing PhreePlot.................................................................................... 5
2.1.1 Windows .............................................................................................. 5
2.1.2 Mac OS X machines ............................................................................. 7
2.2 Checking for updates ................................................................................. 7
2.3 Changing the console appearance............................................................... 7
2.4 Installing Ghostscript and GSview ............................................................. 8
2.4.1 Launching PhreePlot from Windows Explorer or similar ...................... 8
2.4.2 Specifying the input file name on the command line ............................ 8
2.4.3 Specifying input and output filenames in PhreePlot input files ............. 8
2.4.4 Setting the PhreePlot environment variable .......................................... 9
2.4.5 Adding the path to PhreePlot to the Windows PATH setting .............. 9
2.4.6 Search path for files .............................................................................. 9
2.4.7 Ensuring that the correct databases are found ....................................... 9
2.5 Other useful software ................................................................................. 9
2.6 Trouble-shooting ..................................................................................... 10
File conversions ................................................................................. 10
Problem and bug reporting................................................................ 10
legendTitle...................................................................................................220
lineColor, lineColor2y .................................................................................221
lineColorDictionary.....................................................................................221
lines, lines2y ................................................................................................222
lineType, lineType2y ...................................................................................222
lineWidth, lineWidth2y...............................................................................223
log................................................................................................................223
logDepVariable ............................................................................................223
logVariableIn ...............................................................................................224
loopFile........................................................................................................225
loopIndexStartNumber ................................................................................227
loopInt.........................................................................................................227
loopLogVar..................................................................................................227
loopMax ......................................................................................................228
loopMin.......................................................................................................228
mainLoop ....................................................................................................228
mainLoopColumn .......................................................................................230
mainspecies..................................................................................................230
minimumAreaForLabeling...........................................................................231
minimumYValueForPlotting .......................................................................231
missingValue................................................................................................232
multipageFile ...............................................................................................232
nameSpeciationProgram ..............................................................................233
nudge...........................................................................................................233
nudgeFile.....................................................................................................235
numberOfFitParameters ..............................................................................236
numericTags ................................................................................................236
omitAccumulate...........................................................................................237
onePass ........................................................................................................237
out ...............................................................................................................238
overlay .........................................................................................................239
pageOrientation...........................................................................................241
paperSize......................................................................................................241
pdf ...............................................................................................................242
pdfMaker.....................................................................................................243
IPhreePlotVersion........................................................................................244
Phreeqc.0.out...............................................................................................244
PLOT ..........................................................................................................244
plotFactor ....................................................................................................244
plotFrequency ..............................................................................................245
plotOrder.....................................................................................................245
plotTitle.......................................................................................................245
plotTitleColor..............................................................................................246
plotTitleSize ................................................................................................246
png ..............................................................................................................246
pointColor, pointColor2y............................................................................247
points, points2y ...........................................................................................248
pointsSameColor .........................................................................................248
pointSize, pointSize2y..................................................................................248
pointType, pointType2y..............................................................................249
pol ...............................................................................................................249
xii PhreePlot Guide
xtitle ............................................................................................................275
yaxisLength..................................................................................................275
ymax ............................................................................................................276
ymin ............................................................................................................276
yoffset ..........................................................................................................276
yscale ...........................................................................................................276
ytitle, 2ytitle.................................................................................................277
1 Introduction
PhreePlot makes it possible to produce certain types of high quality geochemical plots using
Phreeqc (Parkhurst and Appelo, 2013). Phreeqc is a popular and freely-available program for
calculating geochemical speciation and mass transport. It has a very flexible input structure
that makes it easy to customise the type of calculations performed. This includes the ability to
modify the thermodynamic database used. It also has a very flexible mechanism for outputting
the results of these calculations which makes it straightforward for programs such as
PhreePlot to interface with it. In short, it is an excellent geochemical calculator.
Phreeqc originally did not include any charting options or any mechanism for repeating
blocks of calculations with a DO ... ENDDO-type structure. It was these two missing features
that led to the development of PhreePlot.
An early fork of Phreeqc, Phreeqc for Windows (Post, 2011) incorporated some simple
charting and this has been extended and is now fully incorporated in the latest Windows ver-
sion of Phreeqc (Version 3). Phreeqc is also now available as a modular version as iPhreeqc
(Charlton and Parkhurst, 2011). This includes most of the functionality of the batch version
and means that Phreeqc can be incorporated into programs written in C++, Fortran as well as
in interpreted languages such as Python and R (there is a ‘phreeqc’ package). It is also availa-
ble as a Windows COM server and so can be linked to spreadsheets and databases. These
options allow fine-grained programming giving the developer a large degree of control over
the calculations made. These programming languages also usually have access to libraries of
other useful functions to facilitate programming.
So what does PhreePlot do? PhreePlot sits on top of Phreeqc and makes it relatively straight-
forward to do certain kinds of repetitive Phreeqc calculations, the type of calculations that are
often needed to make a plot. It does this while maintaining the basic structure of Phreeqc
input files. PhreePlot uses tags placed within the Phreeqc input files to identify places where
substitutions are to be made and has several mechanisms to control the values substituted and
the looping done. It also contains software for generating Postscript plot files. If Ghostscript
is installed then automatic conversion to pdf, png, jpg, ai, eps and epsi formats is possible.
With this basic functionality, PhreePlot can be used to generate predominance diagrams, con-
tour plots, and to fit observations to Phreeqc models.
One of the motivations for developing PhreePlot was to develop the ability to calculate pre-
dominance and mineral stability diagrams, often known as Eh-pH or pe-pH diagrams, based
on a full chemical speciation. This numerical approach is different from the ‘equation-based’
approach typically found in textbooks and employed in software such as the Geochemist’s
Workbench (Bethke, 2005). One of the advantages of the numerical approach is that reactions
that do not obey the classical speciation model can also be included in the diagrams. This
includes adsorption, ion exchange and co-precipitation reactions. Since a full speciation is
undertaken, the impact of all interactions are automatically taken into account and the results
are fully consistent with those of other speciation and reaction path calculations undertaken
using the same database.
The intellectual ‘penalty’ with this approach is that realistic and solvable reaction paths have to
be devised to map the whole of the activity space of interest. The practical penalty is that the
large number of computations required means that the numerical approach is significantly
slower than the analytical approach.
2 PhreePlot Guide
We have developed two ways of constructing predominance diagrams: the ‘grid’ approach sim-
ply calculates the speciation at all points on a grid and while the ‘hunt and track’ attempts to
track the boundaries between predominant fields. This approach usually requires considerably
fewer speciation calculations than the ‘grid’ approach to produce a diagram of equivalent qual-
ity but it makes the assumption that all fields are interconnected and can be reached in some
way by tracking along their boundaries. This is not necessarily the case and so fields can be
missed1. This appears to be relatively uncommon in practice but is nevertheless an important
limitation of the ‘hunt and track’ approach. The ‘grid’ approach makes no such assumption
and so should always be the final arbiter.
A somewhat different way of looking at predominance diagrams is to ‘contour’ the data for
some diagnostic variable such as the total dissolved amount or concentration of some element.
Phreeqc is very flexible in the way that it can define its output and this is translated into a
great flexibility in the variables that can be contoured.
PhreePlot also makes use of its looping capability to fit chemical models to data. This can be
used, for example, to derive log K values from experimental data.
PhreePlot makes use of the PSPLOT Postscript library (Kohler, 2005) to produce high qual-
ity Postscript plot files. These can be edited, printed or converted to other graphical formats
using various software packages, e.g. GPL Ghostscript/GSview, Adobe Illustrator, Inkscape,
CorelDRAW, GIMP, etc. As of February 2018, Ghostscript is optionally included in the
PhreePlot distribution and if selected to be installed, does not need to be separately installed.
Inkscape is currently probably the best free vector graphics editor capable of editing native
Postscript text.
The iteration scheme available in PhreePlot is quite limited and follows a fixed format: once
through zero or more ‘initialization’ or pre-loop simulations and then a four-loop iteration
scheme (x, y, z and character). If something else is wanted, then this will have to be pro-
grammed specifically using the iPhreeqc module as mentioned above (Müller et al., 2011).
PhreePlot leaves getting the geochemistry right and the necessary output produced up to the
user. You will have to be reasonably proficient with Phreeqc before attempting to use
PhreePlot. We provide many demos to help get you started.
The plotting is hopefully of a high quality but the types of plots produced are rather limited. If
more sophisticated plots are wanted, then some other plotting program must be used. There
are many. Some of these such as R, Python, Matlab and Mathematica allow external pro-
grams to be run and so could still use PhreePlot to generate the data with all the communica-
tions being done via files.
The interface to PhreePlot is via a console or command prompt. There is no GUI. You will
need to use a text editor to edit the input files.
PhreePlot currently runs on the Windows operating system. It contains iPhreeqc, an embed-
ded version of Phreeqc, and so does not need another copy of Phreeqc. However, it will be
necessary to have an up-to-date version of Phreeqc available for the documentation, release
notes, licence conditions and other information.
The plotting part of PhreePlot uses as input the output from Phreeqc, as communicated
through its main ‘selected output’ file (number 0). Phreeqc provides very versatile facilities for
writing these files. Therefore it is necessary to be fairly competent at running Phreeqc in the
normal way and of manipulating the selected output file(s). If you are not, follow the docu-
mentation provided with Phreeqc and study the examples included in that manual carefully,
initially choosing the one closest to your needs as a template. The demos included with
PhreePlot also provide examples and templates for many types of plot.
Since Phreeqc includes a BASIC interpreter for customising output to the selected output
file(s), some knowledge of BASIC programming is useful. A careful study of the demo exam-
ples provided here should give an introduction to this and will provide example of the link to
PhreePlot.
This Guide is primarily intended for online browsing not for printing. There are several aids
to help navigate around the document using Adobe Reader. Some tips for navigating the doc-
ument are given below though these may vary slightly depending on the version of Adobe
Reader used.
A roadmap to the documentation can be seen by enabling the bookmarks for this document
in Adobe Reader. If these bookmarks cannot be seen, toggle them on by clicking the book-
mark icon or on the left-hand side of the Reader window or go through the menu
system and tick the View|Navigation Panels|bookmarks item.
Various hyperlinks are available within the Guide including links to all of the keywords used
in the text. These link to the corresponding description in the Keywords section (Section 14).
All links appear in blue text and are underlined. Hyperlinks are indicated by the cursor chang-
ing to a pointed finger when hovering over the link.
You can navigate over your navigation history in one of three ways: (i) use the or
toolbar icons; (ii) use the Alt+Left arrow. to go backwards; Alt+Right arrow navigates
forward again, or to go backwards (iii) use the Previous View item from the right click (con-
text) menu. If the toolbar icons are not already visible in Adobe Reader, activate them with the
Tools|Customize Toolbars|Page Navigation Toolbar dialog or similar.
4 PhreePlot Guide
Installation 5
2 Installation
The latest version of PhreePlot can be downloaded from http://www.phreeplot.org. The file-
name for the Windows installer should have the format, setup-pp-xxxxx-yymmdd-zzzz.exe
where xxxxx is the target system (Win32 or x64), yymmdd is the date of the PhreePlot build and
zzzz is the Phreeqc build number.
2.1.1 Windows
PhreePlot is available in both 32-bit (Win32) and 64-bit Windows (x64) versions. The Win32
version will run in both 32- and 64-bit versions of Windows whereas the 64-bit version will
only run in native 64-bit versions of Windows. The 32-bit and 64-bit executables both have
the same file name, pp.exe, so that the batch files will work for both versions in a straightfor-
ward manner. The banner sent to the screen and log file will indicate the version of PhreePlot
actually being used.
The installer should be executed and PhreePlot installed to your preferred directory (called a
‘folder’ in Windows parlance). The default directory is a PhreePlot sub-directory in your
application data directory. This can be changed during the initial installation (but not when
PhreePlot is updated on top of an existing installation).
There are also options during installation to (i) Associate ppi files with PhreePlot; (ii) Install
Ghostscript, and (iii) Add path to the PATH variable. All three options are recommended but
can be skipped here and manually selected later if desired.
The installation will create a series of sub-directories in which the PhreePlot files will be
installed. However, the program executable (pp.exe) will always be installed in the Program
Files directory, e.g. C:\Program Files\PhreePlot\ (or in C:\Program Files
(x86)\PhreePlot\ when installing the 32-bit version of PhreePlot on a 64-bit system). You
have no control over this.
6 PhreePlot Guide
Each of the demo sub-directories contains a specific example, or collection of related examples.
These include a PhreePlot input file and any other input files required. Input filenames gen-
erally have the extension .ppi though this is not necessary.
However, if ppi is associated with the PhreePlot executable during installation, as recom-
Installation 7
mended, then double clicking a ppi file in Windows Explorer or similar will automatically
execute it with PhreePlot. This is the easiest way to run PhreePlot as there is no GUI.
Spaces in input filenames should work but if in doubt, enclose the filename in quotes (or pref-
erably, avoid!). The search path for the input file follows the normal operating system conven-
tions although as with most PhreePlot searches, PhreePlot will also search the system
directory. In batch files, the current working directory is the directory from which the batch
file originated. Use the ‘change directory’ (cd ...) command in a batch file to change to a
new working directory if required.
If PhreePlot is having trouble finding the input file, use the full path name including the
drive.
Output files are automatically put in the same directory as the input file using the input file
name minus the extension as the root.
PhreePlot also needs to know where to find certain files such as Ghostscript files. It does not
use the Windows registry for this and so some file paths need to be set explicitly. The steps
outlined below should be taken to ensure that PhreePlot knows where to find the necessary
files.
Installing PhreePlot under Windows requires Administrator rights. You will be asked to
accept the installation.
The installer should be executed and PhreePlot installed to your preferred directory.
The PhreePlot executable, pp.exe, does not require Administrator privileges to run. If set,
these should be turned off by opening the Properties dialog for the pp.exe file (right-click the
file), opening the Compatibility tab and unticking the ‘Run this program as an administrator’
tick box. The same should be done for all users by clicking the ‘Show settings for all users’ but-
ton. This should prevent UAC prompts when running PhreePlot.
Batch files such as demo.bat also do not need Administrator privileges to run but will need
permission to ‘Read & execute’ (set under the Security tab of the file’s properties).
PhreePlot has been reported to work on Apple Mac’s with Windows emulators such as Wine
and Parallels.
The latest version will always be available for download from the PhreePlot website,
www.phreeplot.org. If the keyword, checkForUpdate is set to TRUE, then PhreePlot will auto-
matically check the server to see if a more recent version is available. This uses the wget pro-
gram. The second parameter for the checkForUpdate keyword sets the minimum time gap (in
days) between checking. Setting this to 1 means that the server will be checked once every day
whereas setting it to 0 will mean that the server will be checked every time PhreePlot is exe-
cuted.
The default appearance of the console is white text on a black background. If you want to
change this, right click on an existing console and select Defaults. This gives the option of
changing the default window size and position, the text font and the foreground and back-
ground colours, e.g. to black text on a white background.
These settings should become the default for all new console windows. If only a temporary
change is required, use the console Properties dialogs instead.