-
Notifications
You must be signed in to change notification settings - Fork 5
/
PHREEQC_Frz.txt
179 lines (149 loc) · 6.47 KB
/
PHREEQC_Frz.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# ----------------------------------------------------------
# Marc Neveu - 2020 - Freezing routine written as PHREEQC input file and emulating the capabilities of FREZCHEM
#
# Many thanks to Jonathan Toner for helpful suggestions that make the routine run more smoothly:
# - KNOBS settings below
# - Use of a dummy element, Bah, that keeps a bit of solution unfrozen and allows the program to proceed
# even when a lot of water starts to freeze near the eutectic.
#
# The routine works by:
#
# 1. First, describing a solution in the Ca, Mg, Na, K, Cl, S system (SOLUTION block), as well as salt species allowed
# to precipitate upon freezing (EQUILIBRIUM PHASES block).
#
# 2. Setting up a loop on temperature, water mass, or pressure by writing an intermediate SELECTED OUTPUT file,
# ./frzloopsetup.txt, using the USER_PUNCH block. In this loop, the temperature, water mass, and/or pressure of the
# SOLUTION are modified as specified, the post-step solution is saved (and so are the equilibrium phases for an
# equilibrium crystallization), and the step simulation results are written to a custom-named selected output file
# in the ./Out folder.
#
# 3. Executing ./frzloopsetup.txt via the INCLUDE$ keyword.
# ----------------------------------------------------------
DATABASE ./je7b00265_si_001_vm.txt
TITLE Set up temperature loop for freezing simulation
KNOBS
-iterations 1000
-step_size 1.1
-pe_step_size 1
SOLUTION 1 Ocean water
pH 7.0 charge
temp 0
pressure 1 # atm, *1.01325 for bars
# pe 4.5
water 1 kg
units mol/kgw
Ca 0.0064
Mg 2.929
Na 1.630
K 0
Cl 0.308
S 3.5964
Bah 1.0e-5 # Abundance must be negligible so as not to affect the chemistry
EQUILIBRIUM_PHASES 1 Minerals allowed to precipitate
# precipitate_only for fractional Xtal?
# Commented out species with no solubility data temperature below 273 K
# Phase name # Target SI # mol # precipitate_only # Formula
Ice(s) 0 0 # H2O
# Chlorides
Halite 0 0 # NaCl
Hydrohalite 0 0 # NaCl:2H2O
Sylvite 0 0 # KCl
Antarcticite 0 0 # CaCl2:6H2O
Bischofite 0 0 # MgCl2:6H2O
MgCl2:8H2O 0 0 # MgCl2:8H2O
MgCl2:12H2O 0 0 # MgCl2:12H2O
Carnallite 0 0 # KMgCl3:6H2O
# Tachyhydrite 0 0 # CaCl2:(MgCl2)2:12H2O
# Sulfates
Anhydrite 0 0 # CaSO4
Arcanite 0 0 # K2SO4
Epsomite 0 0 # MgSO4:7H2O
Gypsum 0 0 # CaSO4:2H2O
Meridianiite 0 0 # MgSO4:11H2O
Mirabilite 0 0 # Na2SO4:10H2O
Picromerite 0 0 # MgSO4:K2SO4:6H2O
# Bloedite 0 0 # Na2Mg(SO4)2:4H2O
# Hexahydrite 0 0 # MgSO4:6H2O
# Kieserite 0 0 # MgSO4:H2O
# Thenardite 0 0 # Na2SO4
# Na2SO4:7H2O 0 0 # Na2SO4:7H2O
# Starkeyite 0 0 # MgSO4:4H2O
# Pentahydrite 0 0 # MgSO4:5H2O
# Hexahydrite 0 0 # MgSO4:6H2O
# Bassanite 0 0 # CaSO4:0.5H2O
Glaserite 0 0 # Na2SO4:3K2SO4
# Glauberite 0 0 # Na2SO4:CaSO4
# Labile_Salt 0 0 # Na4(SO4)2:CaSO4:2H2O
# Leonite 0 0 # K2SO4:MgSO4:4H2O
# Langbeinite 0 0 # K2SO4:2MgSO4
# Syngenite 0 0 # K2SO4:CaSO4:H2O
# Polyhalite 0 0 # K2SO4:MgSO4:Ca2(SO4)2:2H2O
# Mixed chloride-sulfate
# Kainite 0 0 # KCl:MgSO4:2.75H2O
SAVE solution 1
# SAVE equilibrium_phases 1 # Only if equilibrium Xtal. Comment out for fractional Xtal.
SELECTED_OUTPUT
-file ./frzloopsetup.txt
-reset true
USER_PUNCH
-headings
-start
10 FOR i= 25.4 TO -60 STEP -0.5
# Lines 11-15: attempted to redefine water to account for density (i.e., Vm) change with temperature
# from Pruppacher and Klett (1997) but this seems to be ignored by PHREEQC.
# 11 a$ = EOL$ + "PHASES" + EOL$
# 12 a$ = a$ + "Ice(s)" + EOL$
# 13 a$ = a$ + "H2O = H2O" + EOL$
# 14 a$ = a$ + "-analytic -1.10976341E+01 5.11995404E-03 3.48880086E+02 3.65409383E+00 -7.51772938E+03 -5.09587694E-06" + EOL$
# 15 a$ = a$ + "-Vm " + STR$((1.008*2+15.999)/(916.7-0.175*i-0.0005*i*i)*1000) + EOL$
# 20 a$ = a$ + "SOLUTION_MODIFY 1" + EOL$
20 a$ = EOL$ + "SOLUTION_MODIFY 1" + EOL$
# Temperature stepping (freezing simulation):
21 a$ = a$ + "temp " + STR$(i) + EOL$
# Water stepping (evaporation simulation):
# 22 a$ = a$ + "water " + STR$(i) + EOL$
# Pressure stepping (e.g. along geotherm):
# 23 a$ = a$ + "pressure " + STR$((i+273.15-100)/(260-100)*240) + EOL$
25 a$ = a$ + "USE solution 1" + EOL$
30 a$ = a$ + "USE equilibrium_phases 1" + EOL$
40 a$ = a$ + "SAVE solution 1" + EOL$
# Only if equilibrium Xtal. Comment out for fractional Xtal.
# 50 a$ = a$ + "SAVE equilibrium_phases 1" + EOL$
# Write selected outputs as individual files that then have to be concatenated in terminal using:
# "find . -type f -name "*.txt" | while read file; do sed -n '2{p;q;}' $file >> z.out; done"
# Adjust command depending on i's min max step so that the titles are unique and have no space, +, -, or . characters.
60 a$ = a$ + "SELECTED_OUTPUT" + EOL$
# i in scientific notation: sign and digit before decimal decimal digits e exponent symbol exponent digit
61 a$ = a$ + "-file ./Out/" + MID$(STR$(i),2,2) + MID$(STR$(i),5,4) + MID$(STR$(i),9,1) + MID$(STR$(i),12,1) + ".txt" + EOL$
# Important so as to get pH right if need to restart at the end of a crashed simulation
62 a$ = a$ + "-high_precision true" + EOL$
63 a$ = a$ + "-reset false" + EOL$
64 a$ = a$ + "-simulation true" + EOL$
65 a$ = a$ + "-state false" + EOL$
66 a$ = a$ + "-temperature true" + EOL$
67 a$ = a$ + "-pH true" + EOL$
68 a$ = a$ + "-pe true" + EOL$
69 a$ = a$ + "-ionic_strength true" + EOL$
70 a$ = a$ + "-water true" + EOL$
71 a$ = a$ + "-charge_balance true" + EOL$
72 a$ = a$ + "-percent_error true" + EOL$
73 a$ = a$ + "-totals Ca Mg Na K Cl S Bah" + EOL$
74 a$ = a$ + "-activities H2O" + EOL$
75 a$ = a$ + "-equilibrium_phases Ice(s) Halite Hydrohalite Sylvite Antarcticite Bischofite MgCl2:8H2O MgCl2:12H2O Carnallite Anhydrite Arcanite Epsomite Gypsum Meridianiite Mirabilite Picromerite Glaserite" + EOL$
# Add solution density, volume, pressure, and specific conductance to selected output (not default options)
80 a$ = a$ + "USER_PUNCH" + EOL$
81 a$ = a$ + "-headings Solution_density Solution_volume Pressure Specific_conductance" + EOL$
82 a$ = a$ + "-start" + EOL$
83 a$ = a$ + "PUNCH RHO" + EOL$ # kg/L
84 a$ = a$ + "PUNCH SOLN_VOL" + EOL$ # L
85 a$ = a$ + "PUNCH PRESSURE" + EOL$ # atm
86 a$ = a$ + "PUNCH SC" + EOL$ # uS/cm, need to have -dw values in database for nonzero output
89 a$ = a$ + "-end" + EOL$
140 a$ = a$ + "END" + EOL$
150 PUNCH a$
160 NEXT i
-end
END
TITLE Loop freezing simulation
INCLUDE$ ./frzloopsetup.txt
END