Beginners > SELECTED_OUTPUT

How to write pe and Eh to an external file?

(1/1)

puo:
Hello,

In the phreeqc output file pe and Eh values are written, e.g.:

Initial solution 1.   

----------------------------------User print-----------------------------------

  9.9731e-01 density kg/L at 25 ?C

---------------------------------Redox couples---------------------------------

   Redox couple             pe  Eh (volts)

   N(-3)/N(5)           6.2161      0.3677

Question: How to write the values pe and Eh to an external file?

Thanks in advance.

I tried several variants of the next code without succes:

USER_PRINT
-start
10 print RHO 'density', 'kg/L', 'at', TRIM(STR$(tc)), '?C'
20 print pe
30 print Eh
-end

calculate_values #Define variables for selected output
rho
-start
10 save rho #Calculate Density
-end

calculate_values #Define variables for selected output
pe_calc
-start
10 save pe #Calculate pe
-end

calculate_values #Define variables for selected output
Eh_calc
-start
10 save Eh #Calculate Eh
-end

PRINT
-reset false # 1
-eh # 2
-headings # 7
-user_print true # 19
-selected_output # 23 Default TRUE

SELECTED_OUTPUT
-file C:\phreeqc\xxx.csv #1
-reset false # 3
-solution TRUE # 6
-pH TRUE # 10
-pe TRUE # 11
-alkalinity TRUE # 14
-charge_balance TRUE # 17
-percent_error TRUE #18
-totals C #19
-molalities HCO3- CO3-2 #21
-saturation_indices CO2(g) Anhydrite Aragonite Calcite Fehydroxyphosphate Gypsum Rhodochrosite Hydroxyapatite FCO3Apatite #24
-calculate_values rho pe_calc Eh_calc # 29

END

dlparkhurst:
The pe is -LA("e-"), which can be printed easily.

The Eh can be calculated with the following expression and printed:


--- Code: ---Eh = LOG(10)*R_KJ_DEG_MOL * TK / F_KJ_V_EQ * pe

--- End code ---

To get the pe from a redox couple requires some work. There is no way to export the redox-couple pe's that are shown in the output file. The following shows the calculation of pe for the NO3-/NH4+ redox couple. Unfortunately, you must rearrange the reaction for each redox couple to isolate e- and make the calculation for each redox couple.


--- Code: ---SOLUTION
-units mmol/kgw
pe    10
N(-3) 0.1
N(5)  0.1
USER_PRINT
10 R_KJ_DEG_MOL = 0.0083147
20 F_KJ_V_EQ = 96.4935
30 pe = -LA("e-")
40 Eh = LOG(10)*R_KJ_DEG_MOL * TK / F_KJ_V_EQ * pe
50 PRINT "pe:           ", STR_F$(pe, 10, 2)
60 PRINT "Eh:            ", STR_F$(Eh, 10, 3), "V"
100 REM NO3- + 10 H+ + 8 e- = NH4+ + 3 H2O (phreeqc.dat)
110 pe_NO3_NH4 = -(LA("NH4+") + 3*LA("H2O") - LA("NO3-") - 10*LA("H+") - LK_SPECIES("NH4+")) / 8
120 Eh_NO3_NH4 = LOG(10)*R_KJ_DEG_MOL * TK / F_KJ_V_EQ * pe_NO3_NH4
130 PRINT "pe_NO3_NH4:   ", STR_F$(pe_NO3_NH4, 10, 2)
140 PRINT "Eh_NO3_NH4:    ", STR_F$(Eh_NO3_NH4, 10, 3), "V"
END

--- End code ---

puo:
Dear David,
Thank you for your clear answer. With the provided code, I created the input file below, which successfully writes the pe and Eh values in an output file.
Martin


--- Code: ---DATABASE c:\phreeqc\database\wateq4f.dat

SOLUTION_SPREAD
units mg/L
redox N(-3)/N(+5)
Number pH Ca Cl Fe K Mg Mn Na N(-3) N(+5) P S C
mg/L mg/L mg/L mg/L mg/L mg/L mg/L mg/L mg/L mg/L mg/L charge #mg/L as C
1 28.97 7.72 2.87 16.4 10.72 0.426 8.1 0.498 2.22 0.0065 26.99 27.88
2 32.42 14.56 11.97 23.1 9.68 1.382 17.2 1.365 0.22 0.026 24.70 41.67
3 44.92 12.2 13.42 22.7 15.3 1.76 11.2 1.200 9.84 0.029 21.36 44.00
4 36.19 29.31 18.44 14.4 14.36 1.039 8.7 2.343 4.17 0.059 34.53 33.44
5 25.96 15.86 6.44 18.4 11.38 1.053 9 2.005 1.65 0.0065 26.95 27.91

USER_PRINT
-start
10 R_KJ_DEG_MOL = 0.0083147
20 F_KJ_V_EQ = 96.4935
30 pe = -LA("e-")
40 Eh = LOG(10)*R_KJ_DEG_MOL * TK / F_KJ_V_EQ * pe
50 PRINT "pe:           ", STR_F$(pe, 10, 2)
60 PRINT "Eh:            ", STR_F$(Eh, 10, 3), "V"
70 REM NO3- + 10 H+ + 8 e- = NH4+ + 3 H2O (phreeqc.dat)
80 pe_NO3_NH4 = -(LA("NH4+") + 3*LA("H2O") - LA("NO3-") - 10*LA("H+") - LK_SPECIES("NH4+")) / 8
90 Eh_NO3_NH4 = LOG(10)*R_KJ_DEG_MOL * TK / F_KJ_V_EQ * pe_NO3_NH4
100 PRINT "pe_NO3_NH4:   ", STR_F$(pe_NO3_NH4, 10, 2)
110 PRINT "Eh_NO3_NH4:    ", STR_F$(Eh_NO3_NH4, 10, 3), "V"
-end

calculate_values #Define variables for selected output
pe_NO3_NH4 # pe_NO3_NH4 is the name, can be called elsewhere in BASIC statements.
-start
10 save -(LA("NH4+") + 3*LA("H2O") - LA("NO3-") - 10*LA("H+") - LK_SPECIES("NH4+")) / 8 # the definition of pe_NO3_NH4
-end

calculate_values #Define variables for selected output
Eh_NO3_NH4 # Eh_NO3_NH4 is the name, can be called elsewhere in BASIC statements.
-start
10 R_KJ_DEG_MOL = 0.0083147
20 F_KJ_V_EQ = 96.4935
30 pe_NO3_NH4 = -(LA("NH4+") + 3*LA("H2O") - LA("NO3-") - 10*LA("H+") - LK_SPECIES("NH4+")) / 8
40 save LOG(10)*R_KJ_DEG_MOL * TK / F_KJ_V_EQ * pe_NO3_NH4 # the definition of Eh_NO3_NH4
-end

PRINT
-reset true # 1
-headings # 7
-user_print true # 19
-selected_output # 23 Default TRUE

SELECTED_OUTPUT
-file C:\phreeqc\selected_output.csv #1
-reset false # 3
-solution TRUE # 6
-pe TRUE # 11
-calculate_values pe_NO3_NH4 Eh_NO3_NH4 # 29

END
--- End code ---

Navigation

[0] Message Index

Go to full version