/
example_chemical_potentials.py
204 lines (164 loc) · 6.49 KB
/
example_chemical_potentials.py
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# This file is part of BurnMan - a thermoelastic and thermodynamic toolkit for the Earth and Planetary Sciences
# Copyright (C) 2012 - 2015 by the BurnMan team, released under the GNU
# GPL v2 or later.
"""
example_chemical_potentials
---------------------------
This example shows how to use the chemical potentials library of functions.
*Demonstrates:*
* How to calculate chemical potentials
* How to compute fugacities and relative fugacities
"""
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import burnman_path # adds the local burnman directory to the path
import burnman
import burnman.constants as constants
from burnman.tools import chemistry
import burnman.minerals as minerals
assert burnman_path # silence pyflakes warning
if __name__ == "__main__":
'''
Here we initialise the minerals we'll be using
'''
P = 1.e9
T = 1000.
fa = minerals.HP_2011_ds62.fa()
mt = minerals.HP_2011_ds62.mt()
qtz = minerals.HP_2011_ds62.q()
FMQ = [fa, mt, qtz]
for mineral in FMQ:
mineral.set_state(P, T)
'''
Here we find chemical potentials of FeO, SiO2 and O2 for
an assemblage containing fayalite, magnetite and quartz,
and a second assemblage of magnetite and wustite
at 1 GPa, 1000 K
'''
component_formulae = ['FeO', 'SiO2', 'O2']
component_formulae_dict = [chemistry.dictionarize_formula(f)
for f in component_formulae]
chem_potentials = chemistry.chemical_potentials(FMQ, component_formulae_dict)
oxygen = minerals.HP_2011_fluids.O2()
oxygen.set_state(P, T)
hem = minerals.HP_2011_ds62.hem()
MH = [mt, hem]
for mineral in MH:
mineral.set_state(P, T)
print('log10(fO2) at the FMQ buffer:', np.log10(chemistry.fugacity(oxygen, FMQ)))
print('log10(fO2) at the mt-hem buffer:', np.log10(chemistry.fugacity(oxygen, MH)))
print('Relative log10(fO2):', np.log10(chemistry.relative_fugacity(oxygen, FMQ, MH)))
'''
Here we find the oxygen fugacity of the
FMQ buffer, and compare it to published values.
Fugacity is often defined relative to a material at
some fixed reference pressure (in this case, O2)
Here we use room pressure, 100 kPa
'''
# Set up arrays
temperatures = np.linspace(900., 1420., 100)
log10fO2_FMQ_ONeill1987 = np.empty_like(temperatures)
log10fO2_FMQ = np.empty_like(temperatures)
invT = np.empty_like(temperatures)
# Reference and assemblage pressure
Pr = 1.e5
P = 1.e5
for i, T in enumerate(temperatures):
# Set states
oxygen.set_state(Pr, T)
for mineral in FMQ:
mineral.set_state(P, T)
# The chemical potential and fugacity of O2 at the FMQ buffer
# according to O'Neill, 1987
muO2_FMQ_ONeill1987 = -587474. + 1584.427 * \
T - 203.3164 * T * np.log(T) + 0.092710 * T * T
log10fO2_FMQ_ONeill1987[i] = np.log10(
np.exp((muO2_FMQ_ONeill1987) / (constants.gas_constant * T)))
invT[i] = 10000. / (T)
# The calculated chemical potential and fugacity of O2 at the FMQ
# buffer
log10fO2_FMQ[i] = np.log10(chemistry.fugacity(oxygen, FMQ))
# Plot the FMQ log10(fO2) values
plt.plot(temperatures, log10fO2_FMQ_ONeill1987,
'k', linewidth=1., label='FMQ (O\'Neill (1987)')
plt.plot(temperatures, log10fO2_FMQ, 'b--',
linewidth=2., label='FMQ (HP 2011 ds62)')
# Do the same for Re-ReO2
'''
Here we define two minerals, Re (rhenium) and
ReO2 (tugarinovite)
'''
class Re (burnman.Mineral):
def __init__(self):
formula = 'Re1.0'
formula = chemistry.dictionarize_formula(formula)
self.params = {
'name': 'Re',
'formula': formula,
'equation_of_state': 'hp_tmt',
'H_0': 0.0,
'S_0': 36.53,
'V_0': 8.862e-06,
'Cp': [23.7, 0.005448, 68.0, 0.0],
'a_0': 1.9e-05,
'K_0': 3.6e+11,
'Kprime_0': 4.05,
'Kdprime_0': -1.1e-11,
'n': sum(formula.values()),
'molar_mass': chemistry.formula_mass(formula)}
burnman.Mineral.__init__(self)
class ReO2 (burnman.Mineral):
def __init__(self):
formula = 'Re1.0O2.0'
formula = chemistry.dictionarize_formula(formula)
self.params = {
'name': 'ReO2',
'formula': formula,
'equation_of_state': 'hp_tmt',
'H_0': -445140.0,
'S_0': 47.82,
'V_0': 1.8779e-05,
'Cp': [76.89, 0.00993, -1207130.0, -208.0],
'a_0': 4.4e-05,
'K_0': 1.8e+11,
'Kprime_0': 4.05,
'Kdprime_0': -2.25e-11,
'n': sum(formula.values()),
'molar_mass': chemistry.formula_mass(formula)}
burnman.Mineral.__init__(self)
'''
Here we find the oxygen fugacity of the Re-ReO2
buffer, and again compare it to published values.
'''
# Mineral and assemblage definitions
rhenium = Re()
rheniumIVoxide = ReO2()
ReReO2buffer = [rhenium, rheniumIVoxide]
# Set up arrays
temperatures = np.linspace(850., 1250., 100)
log10fO2_Re_PO1994 = np.empty_like(temperatures)
log10fO2_ReReO2buffer = np.empty_like(temperatures)
for i, T in enumerate(temperatures):
# Set states
oxygen.set_state(Pr, T)
for mineral in ReReO2buffer:
mineral.set_state(P, T)
# The chemical potential and fugacity of O2 at the Re-ReO2 buffer
# according to Powncesby and O'Neill, 1994
muO2_Re_PO1994 = -451020 + 297.595 * T - 14.6585 * T * np.log(T)
log10fO2_Re_PO1994[i] = np.log10(
np.exp((muO2_Re_PO1994) / (constants.gas_constant * T)))
invT[i] = 10000. / (T)
# The chemical potential and fugacity of O2 at the Re-ReO2 buffer
log10fO2_ReReO2buffer[i] = np.log10(chemistry.fugacity(oxygen, ReReO2buffer))
# Plot the Re-ReO2 log10(fO2) values
plt.plot(temperatures, log10fO2_Re_PO1994, 'k',
linewidth=1., label='Re-ReO2 (Pownceby and O\'Neill (1994)')
plt.plot(temperatures, log10fO2_ReReO2buffer,
'r--', linewidth=2., label='Re-ReO2 (HP 2011 ds62)')
plt.ylabel("log_10 (fO2)")
plt.xlabel("T (K)")
plt.legend(loc='lower right')
plt.show()