You are on page 1of 8
A Computer Program for a Trilinear Diagram Plot and Analysis of Water Mixing Systems by Michael D. Morris, Jeffrey A. Berk, Joseph W. Krul ABSTRACT ‘The Piper (1953) trilinear diagram has been widely used to graphically represent the dissolved constituents of natural waters and to test for apparent mixtures of waters from different sources. Because of the time required to plot points and calculate the proportional values of mixing, this treatment of data was often quite tedious, particulaely in studies involving large numbers of chemical analyses. The PIPER program was written in BASIC to be ran on @ Hewlett-Packard desktop computer with an X-¥ plotter. Data input isin ppm units. The program plots points in all three fields ofthe trilinear diagram, draws at each point within the central diamond field a circle with 2 radius correspondent to the concentrations exprested in meq/l, checks for points that fall on a straight line (or within « predetermined tolerance of a straight line) representing postulated mixtures with two end members, and/or within a triangle representing mixtures of three end members Finally, the program does a numerical analysis of the ‘mixing ratios of the constituents for postulated mixing systems according to the methodology as presented by Piper (1953), “Department of Geology, Kent State University Contribution No. 241 Department of Geology, Kent State University, Kent, Ohio 44242, Received April 1982, revised August 1982, accepced September 1982. Discussion open until July 1, 1983 Vol. 21, No. 1-GROUND WATER—January-February 1983 INTRODUCTION In a graphical treatment of chemical analyses of ground water developed by Piper (1953), the character of a ground water can be expressed by three points located in three different fields. The points represent: (1) percentage-reacting equiva- lents of three major cation constituents (Mg"", Na" and Ca’*) in a cation triangular field ; (2) percent- age-reacting equivalents of three major anion constituents (CI, SO; and HCO3) in an anion triangular field; and (3) the point in the diamond- shaped field representing the overall chemical character of the solution. The last point is plotted at the intersection of rays projected from the points in the anion and cation triangular fields into the diamond field (Figure 1). Piper's graphical treatment of the chemical analysis allows for an easy discrimination of distinct water types by their plottings in various subareas of the diamond field (Figure 2). Piper (1953) also suggested that water analysis repre- sented by points aligning along a straight line in all three fields should be tested for the possibility that they represent a part of a mixing system. A solution produced by a mixture of two end members is represented in each of the three fields as.a point which is located on a straight line in between the points representing the two end members. Moreover, the individual ionic constitu- ents in the mixture will all have been mixed in the same proportions. Similarly, in the case of a mixture from three sources, the solution will be 67 Fig. 1. Piper's (1953) tril represented in each of the three fields by a point located inside a triangle defined by the three end members, Again, all the ionic constituents will have been mixed in the same proportions. When only a few points are plotted on a tri- linear diagram, it is rather easy to discern and con- firm a binary mixing by “eyeballing” of three points aligned on a straight line in all three fields and to make the appropriate computations (Piper, 1953). To discern and confirm a ternary mixing system is more complex. When the number of chemical analyses involved is large, the task of YW) Fig. 2, Water types on a trilinear diagram: area 1 — (Ca"? + Mg") > (Na’ + K"); area 2 — (Ca"? + Mg") <(Na" + K*); area 3 — (HCO5 +03") > (er +803); 92 4 — (HCO; + COs") < (cI + S04); 125 — carbonate hardness (secondary alkalinity) > 60%: 12 6 — noncarbonate hardnoss (secondary salinity) > 50%: 22 7 — noncarbonate alkali (primary salinity) > 50%; 228 — carbonate alkali (primary alkalinity) > 50%; 12 9 — no dominant eation-anion pair. singling out all possible mixing systems and testing each for validity is extremely tedious, as well as is the mere task of production of a trilinear diagram for a large number of analyses. The follow- ing computer program is designed to plot up to 100 chemical analyses on a trilinear diagram and then scan simultaneously all the analyses, testing for all the possible combinations in binary and ternary mixing systems, ‘The program was designed to place points in all three fields and to calculate and test the pro- portions needed to postulate possible mixing relationships. Although this program produces reliable calculations for a wide variety of chemical compositions, the user is cautioned that the results can be significantly affected by the selec- tion of input values and certain user-specified options. The user is further cautioned that interpretations must reflect the specific field conditions and locations from which the water samples were collected. Our computer program is based on Piper's (1953) original assumptions 1, All of the major constituents have been included in the calculations, 2. All ions are assumed to remain in solution, 3. All the Fe, Al, and Si are present in the water in a colloidal state as oxides and are not in chemical equilibrium with the ionized constituents, ‘Therefore, these elements are not included in calculations of total concentration, 4. Minor constituents of ground water are summed with the six major constituents to which. they are respectively related in chemical properties. 5, Water consisting of substantial quantities of free acid cannot be fully represented on the diagram ‘The program was written in Hewlett-Packard enhanced BASIC for use on a HP 9845A desktop computer with an optional 9872B X-Y plotter. Options within the program allow graphics to be produced on the cathode-ray-tube (CRT) display, the thermal printer, or the X-Y plotter. Minor variations should allow this program to be adapted to other computers using BASIC, Due to memory limitations on the HP 9845A, the program is actually subdivided into two smaller routines linked together. “PIPER,” the first portion of the program, is used to input and store data, compute unit conversions and to plot the resulting percent- age values on the trilinear diagram. The mixing calculations may then be performed by the second portion of the program named “MIXING.” The transfer of control to the second routine is accom- plished in line 3680 of “PIPER” utilizing the LINK command in order to conserve all variables defined earlier, Depending on the computer capabilities that the program is going to be adapted to, it may be stored as one long program or several smaller routines. A flow diagram of the program is shown in Figure 3, Fig, 3. Flow chart of “PIPER” and “MIXING.” INPUT OF RAW DATA Input concentrations of various constituents must be in units of parts per million (ppm). The program will convert these units to meq/l, and further to percentage of total dissolved solids. ‘The program asks for the six major constitu- cents: (Ca"*, Mg’, Na’, CI, SO’ and HCO) and only K", CO3 and NO} as second-rank constitu- ents, Other second-rank constituents can be added with only minor changes in the program. In a single run of the program, data from a maximum, of 100 sources may be entered, stored, plotted and tested for mixing trends. Data input can come from keyboard or data previously stored on a data file. Creation of a data file after input from the keyboard is a user’s option. PLOTTING AND COMPUTATIONAL PROCEDURES ‘The plotting of points and the drawing of the outline of the triangles and diamond both are done in cartesian coordinates on the H-P graphics system. All trilinear coordinates must be converted to X-Y coordinates. The units used are millimeters for the CRT and will vary on the X-Y plotter depending on the size of the plot. The plotting field is 184.47 by 149.82 units. The primary trilinear diagram is an equilateral triangle with sides divided into 100 units. For ease in reading, cation and anion sub- triangles are offset from the upper diamond. The subtriangles are equilateral with sides of 50 units representing a range of 0 to 100% of a specified constituent. ‘The height of a triangle (Figure 4) is calcu- lated in the following manner: Fig. 4. Dimensional ri trilinear diagram, a tan 60° = AY/(50/2) AY = 25(tan 60°) AY = 43.30 units In similar fashion, the dimensions of the diamond field are found to be 50 units wide and 86.60 units in height. Points within the cation triangle, if plotted by hhand, are based on the percentage-reacting values of Ca’?, Mg"?, Na’ and K°; if plotted by this program, the points (Figure 5) are based on the percentage of Ca’? and Mg”? compared to the total cations, Points within the anion triangle are calcu- lated and plotted in a similar fashion based on the percentages of SO? and HCO3. The relevant equations are as follows: Fig. 5. Coordinate system in the triangular fields of a ‘eilinear diagram, y Mg? (%6) y" SOF (%6) 25(tan 60°) 100 25 (tan 60°) 100 100 ¥" = 25 tan 60° Mg’? (%) 100 Y" = 25 tan 60° SO;*0%) an 69° ME?) van 69" S02 0%) 4 tan 60° = Y'/X" tan 60° = Y"/X" X' = Y/tan 60° X" = Y"/tan 60° Recalling the conversion: 2% ion concentration = 1 unit on the plotting field 9 (99) EBB ys X,, = Xp HCOs (66) LEME “a 2% LAR 3 2% Ca’? (%) Yy" HCO} (%) Y" Xq=Xq - Be is a 2 tan 60° = 2 tan 60° Keg = Xpy — £42) _ tan 60" Mg 04 _ HCO3(%) _ tan 60° SOF (4/4 ee tan 60° 7 2 tan 60° Ca‘? (%) _— Mg*? (9%). HCO; (%) SO? (%) Xx = Xgi- Xi =Xpo as eee + ee 4 Yq 2¥q+¥" Yp+¥" Mg"? (%6) Oz (%6) Yq = Yo + tan 60° Y, = Ya + tan 60° 4 The location of points in the diamond is at the intersection of rays projected from points in the anion and cation triangles. In the computer program it is calculated and plotted based on the reacting percentages of HCO; and (Na") + (K*) (Figure 6). To plot the point in the diamond field as shown in Figure 6, the following equations were derived: Xp’ > Xp 00 units Lunit 2% Xz - Xp’ = (Nat + K"(%) an Lunit Xp’ Xy = HCO} (%) 2% (Xp ~ Xp) = (Ny ~ Xp) = 4 [OX — Xp) (Kye — Ky) ~ (Ny — Xp] HCO (%) _(Na’ + K")(06) Xp — Xs) = 50- Oer~ Xs) 4 + Xp = Xp! + (Xp — Xp!) = (Xpt~ Xy) ~ (Kp > Xs) Xp + 100-HE ay 10 Eco eoeins SKI) X= Xp + 50 HCO , (Nal + VC + + % TS] = 60° -¥. tan 60° =_1—1 Xr~ Xs Yy - Yy = tan 60° (Xy - Xs) HCO} (%) _ (Nat + KD) 4 4 1 = tan 60° [50~ _tan 60° [200 ~ HCO} (9%) ~ (Na” + K")(%6)} = 86.60 — 4330 [HCO5 (%) + (Na’ + K*)(%)] Yy = Yq" + 86.60 ~ 4330 [HCO (%) + (Na’ + K°)(%5)] Analyses may be plotted with a point, an symbols, There has not been a provision for over- identification number, or by choice of five other prints. Piper proposed using citcles, whose areas are proportional to the absolute concentrations of the sources, plotted around points in the central diamond field. Our program plots circles whose radii are based on the sum of meqj/l and are propor- tionally represented with cither an arithmetic scale at a user-defined proportion or a logarithmic scale. DETERMINATION OF MIXING BETWEEN ‘TWO END MEMBERS Primary criterion for ground-water mixing is that the flow directions must physically bring waters from two sources together. This criterion cannot be judged by the computer program and must not be overlooked by the operator. The second criterion for determination of a binary mixing system is based on the assumption that when two waters mix in any proportion and all products remain in solution, the mixture will plot somewhere on a straight line between the two end Fig. 6. Coordinate system in the diamond field ofa trilinear members in all three fields of the trilinear diagram. diagram. ‘The total concentration for the mixture in the diamond field must be intermediate between the total concentration of the two end members, whereas the concentration of the mixture (the absolute concentration and the concentration of the specific constituents) must all be in equal proportionate volumes (Figure 7; Piper, 1953). Our ‘computer program analyzes all the elements of this criterion and either confirms or disproves apparent mixtures. One of the most important decisions required from the user of this program is to determine the acceptable tolerance away from a straight line for a group of any three points being considered as a possible mixing combination. A user-specified Fig. 7. Binary mixing system in the diamond field of the trilinear afb = (Vp X E9)/(Vq X Ea) ValMy = (bX Eq i/la Ey) Em = [Ey X Ep X (a+ BI /LlaX Eq) + (6X Ep) Va (bX Ep)/lla X Ey) + (bX Eg] Vy = (aX Egi/lla X E4) + (bX Ey) Cry = (Cy X Va) + (Cy X Vo) — distances measured on the diagram; = concentrations of respective waters having compositions A, B and M: Vr, = proportionate volume in mixture M of water having composition Vp = proportionate volume in mixture M of water having composition B; Cm = calculated concentration of the mixture M. 2 tolerance away from a true straight line is incorpo- rated, Based on an acceptable analytical error, a five percent tolerance is normally used. Deviation allowed away from a straight line is a function of the length of that line and the user-specified tolerance. Possible mixing points must fit inside a tolerance window. If a point falls more than the preset percentage away from the straight line, the tested combination of three points is rejected as not a mixing system. For example, when 2 five percent tolerance has been specified, a mixing point on a line seven units long would be con- sidered if the point was within .35 units off the line. In clusters of points (ie., very short lines) even very small analytical errors would cause mix- tures to be disqualified, All points representing a postulated mixing system may deviate from theit plotted positions. The maximum amount they may deviate is assumed to be the same as the user-de- fined percent tolerance. If both end points in a binary mixing system have maximum variance in opposing directions, the line is either lengthened or shortened. The length of the line is compared to the maximum possible variation. If that amount of possible variance is greater than the length of the line, the program considers these points a cluster. ‘The allowed tolerance away from the cluster of points, representing similar percentage of reacting concentrations, is equal to the user-specified percentage To test for possible mixtures, all points are considered in all combinations of pairs as end members, and the remaining points are tested to see if they fit within a “tolerance window” around the line, The limits of the window are the maxi- mum plus the tolerance, and the minimum minus the tolerance for both the X and Y values of the end points (Figure 8), The window is further limited within two parallel lines on either side of, and at the specified tolerance away from the line under consideration, ‘The user should be cautioned that the mixing systems identified by the computer program con- form with the mathematical criteria only (Piper, 1953). THREE-WAY MIXING Piper also suggested a method to check for a ternary mixture resulting from three end members, ‘This technique treats the three end-member com: positions, when plotted, as apexes of a hypo- thetical triangle in each plotting field. The first criterion for a hypothetical mixture point for the program to consider is that it must plot within the TBE erin rae oe art om Yr Wt 49> 4 TTR ATR ara faspastasaessooses Tg Sa ns a eat | sag agRSRSS CRIES 75 APPENDIX I. PROGRAM LISTING* TRUE Fore * Copies of the program may be obrained on disc (single, or double density) or tape-cassette for a nominal fee by contacting Dr. Yoram Eckstein, Department of Geology, Kent State University, Kent, Ohio +4242, 74

You might also like