This little program "Generate pH-pe-files for PHREEQC" is easing the creation of pe-pH-diagrams (predominance 
diagrams) with PhreeqC. The initial PhreeqC Input file for calculating predominance diagrams is simple, 
besides different species in solution it only contains pe and pH values which will be changed stepwise 
in order to cover the pe and pH range necessary for creating a whole pe-pH-diagram. From the Output file the 
predominant species (i.e. the species present in the highest concentration) will be determined for each pair of 
pe and pH value by means of a Excel Macro ("Predom_Spec.xls").

In order not to be obliged to change pe and pH manually (changing e.g. pH from 0 (acid) to 14 (alkaline) and 
pe from -10 (reducing) to +20 (oxidizing) only in steps of 1 this would be 
15 pH-values * 31 pe-values  = 465 combinations!) this program was written.

The program needs a PhreeqC Input file as master (to be opened with FILE / Input-File) with a SOLUTION 1 defining 
pH and EH (mandantory !) and a block SELECTED_OUTPUT. You may define within SOLUTION whatever you want and you may 
add EQUILIBRIUM_PHASES or REACTION blocks

SOLUTION 1		
units mmol/L		
pe 4			
pH 7
Fe 10
Cl 10

SELECTED_OUTPUT
-file            1_pepH_Fe.csv
-reset           false	
-pH
-pe
-molalities	Fe+2 Fe+3 FeCl+ FeOH+ Fe(OH)2 Fe(OH)3- Fe(OH)2+ Fe(OH)3 FeOH+2 Fe+3 Fe2(OH)2+4 Fe(OH)4- 
                Fe3(OH)4+5 FeCl+2 FeCl2+ FeCl3


The one job in this master will be copied by the program n-times. For the above mentioned example of 15 pH values 
and 31 pe values one would get 465 jobs. Solution number as well as pe and pH will be changed automatically for 
every new job. The solution number in the Input-master has to be 1, the program will automatically number the 
following solutions from 1 to n. Values for pe or pH in the master file are arbitrarily assumed. Instead of Fe 
and Cl any other species of interest might also be defined. 

The desired minimum and maximum pe and pH values have to be defined in the programs Input mask as well as the 
step size, e.g. 1. The smaller the step size is the more jobs will be in the Input file and the more points the 
resulting pe-pH-diagram will have. If there are any pe-pH combinations in your defined range which lay 
above (O2-H2O) or underneath (H2O-H2) the stability field of water, they will be automatically removed by the 
program and the resulting Output file will have n - x jobs, with n = total number of combinations resulting 
from defined pe-pH-range and x = number of combinations outside the stability field of water.

The result is written in an Output-file, for which a name has to be defined under FILE / Output-File before 
running the program. The so created Output-file with n-jobs can be used in PhreeqC as Input file for modelling 
the species distribution for each pair of pe-pH values. If you use PhreeqC for Windows you might experience the 
limits of the build in Editor (can not process files > 32 KB). If your output file is exceeding that size you
have to start PhreeqC on the DOS prompt with INPUT und OUTPUT-file as parameters.

In order to facilitate the search for the predominant species in the resulting PhreeqC Output file the keyword 
SELECTED_OUTPUT has to be used. Remember: The SELECTED_OUTPUT block has to be the last KEY-WORD block in the 
Input-File for this program.

The automatical reproduction of different pe-pH-combinations will paste all jobs before the key word 
SELECTED_OUTPUT. Since there is no END between the different Solutions, the results of all pe-pH-combinations will 
be written into the SELECTED_OUTPUT.

Have fun !