/
averaging_schemes.py
604 lines (482 loc) · 21.7 KB
/
averaging_schemes.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# This file is part of BurnMan - a thermoelastic and thermodynamic toolkit for the Earth and Planetary Sciences
# Copyright (C) 2012 - 2017 by the BurnMan team, released under the GNU
# GPL v2 or later.
from __future__ import absolute_import
import numpy as np
import warnings
class AveragingScheme(object):
"""
Base class defining an interface for determining average
elastic properties of a rock. Given a list of volume
fractions for the different mineral phases in a rock,
as well as their bulk and shear moduli, an averaging
will give back a single scalar values for the averages.
New averaging schemes should define the functions
average_bulk_moduli and average_shear_moduli, as
specified here.
"""
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli :math:`K` for a composite. This defines the interface
for this method, and is not implemented in the base class.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli of each phase in the composite. :math:`[Pa]`
Returns
-------
K : float
The average bulk modulus :math:`K`. :math:`[Pa]`
"""
raise NotImplementedError("")
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the shear moduli :math:`G` for a composite. This defines the interface
for this method, and is not implemented in the base class.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli of each phase in the composite. :math:`[Pa]`
Returns
-------
G : float
The average shear modulus :math:`G`. :math:`[Pa]`
"""
raise NotImplementedError("")
def average_density(self, volumes, densities):
"""
Average the densities of a composite, given a list of volume
fractions and densitites. This is implemented in the base class,
as how to calculate it is not dependent on the geometry of the rock.
The formula for density is given by
.. math::
\\rho = \\frac{\\Sigma_i \\rho_i V_i }{\\Sigma_i V_i}
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
densities : list of floats
List of densities of each phase in the composite. :math:`[kg/m^3]`
Returns
-------
rho : float
Density :math:`\\rho`. :math:`[kg/m^3]`
"""
total_mass = np.sum(np.array(densities) * np.array(volumes))
total_vol = np.sum(np.array(volumes)) # should sum to one
density = total_mass / total_vol
return density
def average_thermal_expansivity(self, volumes, alphas):
"""
thermal expansion coefficient of the mineral :math:`\\alpha`. :math:`[1/K]`
"""
total_vol = np.sum(np.array(volumes))
return np.sum(np.array(alphas) * np.array(volumes)) / total_vol
def average_heat_capacity_v(self, fractions, c_v):
# TODO: double-check that the formula we use is appropriate here.
"""
Averages the heat capacities at constant volume :math:`C_V` by molar fractions
as in eqn. (16) in :cite:`Ita1992`.
Parameters
----------
fractions : list of floats
List of molar fractions of each phase in the composite (should sum to 1.0).
c_v : list of floats
List of heat capacities at constant volume :math:`C_V` of each phase in the composite. :math:`[J/K/mol]`
Returns
-------
c_v : float
heat capacity at constant volume of the composite :math:`C_V`. :math:`[J/K/mol]`
"""
return np.sum(np.array(fractions) * np.array(c_v))
def average_heat_capacity_p(self, fractions, c_p):
# TODO: double-check that the formula we use is correct.
"""
Averages the heat capacities at constant pressure :math:`C_P` by molar fractions.
Parameters
----------
fractions : list of floats
List of molar fractions of each phase in the composite (should sum to 1.0).
c_p : list of floats
List of heat capacities at constant pressure :math:`C_P` of each phase in the composite. :math:`[J/K/mol]`
Returns
-------
c_p : float
heat capacity at constant pressure :math:`C_P` of the composite. :math:`[J/K/mol]`
"""
return np.sum(np.array(fractions) * np.array(c_p))
class VoigtReussHill(AveragingScheme):
"""
Class for computing the Voigt-Reuss-Hill average for elastic properties.
This derives from :class:`burnman.averaging_schemes.averaging_scheme`, and implements
the :func:`burnman.averaging_schemes.averaging_scheme.average_bulk_moduli` and
:func:`burnman.averaging_schemes.averaging_scheme.average_shear_moduli` functions.
"""
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite with the Voigt-Reuss-Hill average, given by:
.. math::
K_{VRH} = \\frac{K_V + K_R}{2}
This is simply a shorthand for an arithmetic average of the bounds given
by :class:`burnman.averaging_schemes.voigt` and :class:`burnman.averaging_schemes.reuss`.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite.
Not used in this average. :math:`[Pa]`
Returns
-------
K : float
The Voigt-Reuss-Hill average bulk modulus :math:`K_{VRH}`. :math:`[Pa]`
"""
return voigt_reuss_hill_function(volumes, bulk_moduli)
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the shear moduli :math:`G` of a composite with the Voigt-Reuss-Hill average, given by:
.. math::
G_{VRH} = \\frac{G_V + G_R}{2}
This is simply a shorthand for an arithmetic average of the bounds given
by :class:`burnman.averaging_schemes.voigt` and :class:`burnman.averaging_schemes.reuss`.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite
Not used in this average. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite :math:`[Pa]`
Returns
-------
G : float
The Voigt-Reuss-Hill average shear modulus :math:`G_{VRH}`. :math:`[Pa]`
"""
return voigt_reuss_hill_function(volumes, shear_moduli)
class Voigt(AveragingScheme):
"""
Class for computing the Voigt (iso-strain) bound for elastic properties.
This derives from :class:`burnman.averaging_schemes.averaging_scheme`, and implements
the :func:`burnman.averaging_schemes.averaging_scheme.average_bulk_moduli` and
:func:`burnman.averaging_schemes.averaging_scheme.average_shear_moduli` functions.
"""
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite :math:`K` with the Voigt (iso-strain)
bound, given by:
.. math::
K_V = \\Sigma_i V_i K_i
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite.
Not used in this average. :math:`[Pa]`
Returns
-------
K : float
The Voigt average bulk modulus :math:`K_V`. :math:`[Pa]`
"""
return voigt_average_function(volumes, bulk_moduli)
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the shear moduli of a composite with the Voigt (iso-strain)
bound, given by:
.. math::
G_V = \\Sigma_i V_i G_i
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite.
Not used in this average. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
G : float
The Voigt average shear modulus :math:`G_V`. :math:`[Pa]`
"""
return voigt_average_function(volumes, shear_moduli)
class Reuss(AveragingScheme):
"""
Class for computing the Reuss (iso-stress) bound for elastic properties.
This derives from :class:`burnman.averaging_schemes.averaging_scheme`, and implements
the :func:`burnman.averaging_schemes.averaging_scheme.average_bulk_moduli` and
:func:`burnman.averaging_schemes.averaging_scheme.average_shear_moduli` functions.
"""
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite with the Reuss (iso-stress)
bound, given by:
.. math::
K_R = \\left(\\Sigma_i \\frac{V_i}{K_i} \\right)^{-1}
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite.
Not used in this average. :math:`[Pa]`
Returns
-------
K : float
The Reuss average bulk modulus :math:`K_R`. :math:`[Pa]`
"""
return reuss_average_function(volumes, bulk_moduli)
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the shear moduli of a composite with the Reuss (iso-stress)
bound, given by:
.. math::
G_R = \\left( \\Sigma_i \\frac{V_i}{G_i} \\right)^{-1}
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite.
Not used in this average. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
G : float
The Reuss average shear modulus :math:`G_R`. :math:`[Pa]`
"""
return reuss_average_function(volumes, shear_moduli)
class HashinShtrikmanUpper(AveragingScheme):
"""
Class for computing the upper Hashin-Shtrikman bound for elastic properties.
This derives from :class:`burnman.averaging_schemes.averaging_scheme`, and implements
the :func:`burnman.averaging_schemes.averaging_scheme.average_bulk_moduli`
and :func:`burnman.averaging_schemes.averaging_scheme.average_shear_moduli` functions.
Implements formulas from :cite:`Watt1976`. The Hashin-Shtrikman bounds
are tighter than the Voigt and Reuss bounds because they make the
additional assumption that the orientation of the phases are statistically
isotropic. In some cases this may be a good assumption, and in others it
may not be.
"""
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite with the upper Hashin-Shtrikman bound.
Implements Formulas from :cite:`Watt1976`, which are too lengthy to reproduce here.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
K : float
The upper Hashin-Shtrikman average bulk modulus :math:`K`. :math:`[Pa]`
"""
K_n = max(bulk_moduli)
G_n = max(shear_moduli)
vol_frac = volumes / sum(volumes)
alpha_n = -3. / (3. * K_n + 4. * G_n)
A_n = 0
for i in range(len(vol_frac)):
if bulk_moduli[i] != K_n:
A_n += vol_frac[i] / (1. / (bulk_moduli[i] - K_n) - alpha_n)
K_upper = K_n + A_n / (1. + alpha_n * A_n)
return K_upper
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the shear moduli of a composite with the upper Hashin-Shtrikman bound.
Implements Formulas from :cite:`Watt1976`, which are too lengthy to reproduce here.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
G : float
The upper Hashin-Shtrikman average shear modulus :math:`G`. :math:`[Pa]`
"""
K_n = max(bulk_moduli)
G_n = max(shear_moduli)
vol_frac = volumes / sum(volumes)
beta_n = -3. * (K_n + 2. * G_n) / (5. * G_n * (3. * K_n + 4. * G_n))
B_n = 0
for i in range(len(vol_frac)):
if shear_moduli[i] != G_n:
B_n += vol_frac[i] / (
1. / (2. * (shear_moduli[i] - G_n)) - beta_n)
G_upper = G_n + (0.5) * B_n / (1. + beta_n * B_n)
return G_upper
class HashinShtrikmanLower(AveragingScheme):
"""
Class for computing the lower Hashin-Shtrikman bound for elastic properties.
This derives from :class:`burnman.averaging_schemes.averaging_scheme`, and implements
the :func:`burnman.averaging_schemes.averaging_scheme.average_bulk_moduli`
and :func:`burnman.averaging_schemes.averaging_scheme.average_shear_moduli` functions.
Implements Formulas from :cite:`Watt1976`. The Hashin-Shtrikman bounds
are tighter than the Voigt and Reuss bounds because they make the
additional assumption that the orientation of the phases are statistically
isotropic. In some cases this may be a good assumption, and in others it
may not be.
"""
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite with the lower Hashin-Shtrikman bound.
Implements Formulas from :cite:`Watt1976`, which are too lengthy to reproduce here.
Parameters
----------
volumes : list of floats
List of the volume of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
K : float
The lower Hashin-Shtrikman average bulk modulus :math:`K`. :math:`[Pa]`
"""
K_1 = min(bulk_moduli)
G_1 = min(shear_moduli)
vol_frac = volumes / sum(volumes)
alpha_1 = -3. / (3. * K_1 + 4. * G_1)
A_1 = 0
for i in range(len(vol_frac)):
if bulk_moduli[i] != K_1:
A_1 += vol_frac[i] / (1. / (bulk_moduli[i] - K_1) - alpha_1)
K_lower = K_1 + A_1 / (1. + alpha_1 * A_1)
return K_lower
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the shear moduli of a composite with the lower Hashin-Shtrikman bound.
Implements Formulas from :cite:`Watt1976`, which are too lengthy to reproduce here.
Parameters
----------
volumes : list of floats
List of volumes of each phase in the composite. :math:`[m^3]`.
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`.
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
G : float
The lower Hashin-Shtrikman average shear modulus :math:`G`. :math:`[Pa]`
"""
K_1 = min(bulk_moduli)
G_1 = min(shear_moduli)
vol_frac = volumes / sum(volumes)
beta_1 = -3. * (K_1 + 2. * G_1) / (5. * G_1 * (3. * K_1 + 4. * G_1))
B_1 = 0
for i in range(len(vol_frac)):
if shear_moduli[i] != G_1:
B_1 += vol_frac[i] / (
1. / (2. * (shear_moduli[i] - G_1)) - beta_1)
G_lower = G_1 + (0.5) * B_1 / (1. + beta_1 * B_1)
return G_lower
class HashinShtrikmanAverage(AveragingScheme):
"""
Class for computing arithmetic mean of the Hashin-Shtrikman bounds on elastic properties.
This derives from :class:`burnman.averaging_schemes.averaging_scheme`, and implements
the :func:`burnman.averaging_schemes.averaging_scheme.average_bulk_moduli`
and :func:`burnman.averaging_schemes.averaging_scheme.average_shear_moduli` functions.
"""
def __init__(self):
self.upper = HashinShtrikmanUpper()
self.lower = HashinShtrikmanLower()
def average_bulk_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite with the arithmetic mean of the upper
and lower Hashin-Shtrikman bounds.
Parameters
----------
volumes : list of floats
List of the volumes of each phase in the composite. :math:`[m^3]`
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite.
Not used in this average. :math:`[Pa]`
Returns
-------
K : float
The arithmetic mean of the Hashin-Shtrikman bounds on bulk modulus :math:`K`. :math:`[Pa]`
"""
return (self.upper.average_bulk_moduli(volumes, bulk_moduli, shear_moduli)
+ self.lower.average_bulk_moduli(volumes, bulk_moduli, shear_moduli)) / 2.0
def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
"""
Average the bulk moduli of a composite with the arithmetic mean of the upper
and lower Hashin-Shtrikman bounds.
Parameters
----------
volumes : list of floats
List of the volumes of each phase in the composite. [m^3].
bulk_moduli : list of floats
List of bulk moduli :math:`K` of each phase in the composite.
Not used in this average. :math:`[Pa]`
shear_moduli : list of floats
List of shear moduli :math:`G` of each phase in the composite. :math:`[Pa]`
Returns
-------
G : float
The arithmetic mean of the Hashin-Shtrikman bounds on shear modulus :math:`G`. :math:`[Pa]`
"""
return (self.upper.average_shear_moduli(volumes, bulk_moduli, shear_moduli)
+ self.lower.average_shear_moduli(volumes, bulk_moduli, shear_moduli)) / 2.0
def voigt_average_function(phase_volume, X):
"""
Do Voigt (iso-strain) average. Rather like
resistors in series. Called by voigt and
voigt_reuss_hill classes, takes a list of
volumes and moduli, returns a modulus.
"""
vol_frac = phase_volume / np.sum(phase_volume)
X_voigt = sum(f * x for f, x in zip(vol_frac, X))
return X_voigt
def reuss_average_function(phase_volume, X):
"""
Do Reuss (iso-stress) average. Rather like
resistors in parallel. Called by reuss and
voigt_reuss_hill classes, takes a list of
volumes and moduli, returns a modulus.
"""
vol_frac = phase_volume / np.sum(phase_volume)
for f, x in zip(vol_frac, X):
if x <= 0 and np.abs(f) > np.finfo(float).eps:
warnings.warn("Oops, called reuss_average with Xi<=0!")
return 0.0
X_reuss = 1. / sum(f / x for f, x in zip(vol_frac, X))
return X_reuss
def voigt_reuss_hill_function(phase_volume, X):
"""
Do Voigt-Reuss-Hill average (arithmetic mean
of Voigt and Reuss bounds). Called by
voigt_reuss_hill class, takes a list of
volumes and moduli, returns a modulus.
"""
X_vrh = (voigt_average_function(phase_volume, X)
+ reuss_average_function(phase_volume, X)) / 2.0
return X_vrh