-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmoduli.py
406 lines (276 loc) · 10.2 KB
/
moduli.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
# -*- coding: utf-8 -*-
'''
===================
moduli.py
===================
Converts between various acoustic/eslatic parameters,
and provides a way to calculate all the elastic moduli
from Vp, Vs, and rho
Created June 2014
@author: Matt Hall
Using equations http://www.subsurfwiki.org/wiki/Elastic_modulus
from Mavko, G, T Mukerji and J Dvorkin (2003), The Rock Physics Handbook,
Cambridge University Press
'''
import numpy as np
def youngs(vp=None, vs=None, rho=None, mu=None, lam=None, bulk=None, pr=None,
pmod=None):
'''
Computes Young's modulus given either Vp, Vs, and rho, or
any two elastic moduli (e.g. lambda and mu, or bulk and P
moduli).
SI units only.
Args:
vp, vs, and rho
or any 2 from lam, mu, bulk, pr, and pmod
Returns:
Young's modulus in pascals, Pa
'''
if (vp is not None) and (vs is not None) and (rho is not None):
return rho * vs**2 * (3.*vp**2 - 4.*vs**2) / (vp**2 - vs**2)
elif (mu is not None) and (lam is not None):
return mu * (3.*lam + 2*mu) / (lam + mu)
elif (bulk is not None) and (lam is not None):
return 9.*bulk * (bulk - lam) / (3.*bulk - lam)
elif (bulk is not None) and (mu is not None):
return 9.*bulk*mu / (3.*bulk + mu)
elif (lam is not None) and (pr is not None):
return lam * (1+pr) * (1 - 2*pr) / pr
elif (pr is not None) and (mu is not None):
return 2. * mu * (1+pr)
elif (pr is not None) and (bulk is not None):
return 3. * bulk * (1 - 2*pr)
else:
return None
def bulk(vp=None, vs=None, rho=None, mu=None, lam=None, youngs=None, pr=None,
pmod=None):
'''
Computes bulk modulus given either Vp, Vs, and rho, or
any two elastic moduli (e.g. lambda and mu, or Young's
and P moduli).
SI units only.
Args:
vp, vs, and rho
or any 2 from lam, mu, youngs, pr, and pmod
Returns:
Bulk modulus in pascals, Pa
'''
if (vp is not None) and (vs is not None) and (rho is not None):
return rho * (vp**2 - (4./3.)*(vs**2))
elif (mu is not None) and (lam is not None):
return lam + 2*mu/3.
elif (mu is not None) and (youngs is not None):
return youngs * mu / (9.*mu - 3.*youngs)
elif (lam is not None) and (pr is not None):
return lam * (1+pr) / 3.*pr
elif (pr is not None) and (mu is not None):
return 2. * mu * (1+pr) / (3. - 6.*pr)
elif (pr is not None) and (youngs is not None):
return youngs / (3. - 6.*pr)
elif (lam is not None) and (youngs is not None):
# Note that this returns a tuple.
x = np.sqrt(9*lam**2 + 2*youngs*lam + youngs**2)
def b(y): return 1/6. * (3*lam + youngs + y)
# Strictly, we should return b(x), b(-x)
# But actually, the answer is:
return b(x)
else:
return None
def pr(vp=None, vs=None, rho=None, mu=None, lam=None, youngs=None, bulk=None,
pmod=None):
'''
Computes Poisson ratio given either Vp, Vs, and rho, or
any two elastic moduli (e.g. lambda and mu, or Young's
and P moduli).
SI units only.
Args:
vp, vs, and rho
or any 2 from lam, mu, youngs, bulk, and pmod
Returns:
Poisson's ratio, dimensionless
'''
if (vp is not None) and (vs is not None):
return (vp**2. - 2.*vs**2) / (2. * (vp**2 - vs**2))
elif (mu is not None) and (lam is not None):
return lam / (2. * (lam+mu))
elif (mu is not None) and (youngs is not None):
return (youngs / (2.*mu)) - 1
elif (lam is not None) and (bulk is not None):
return lam / (3.*bulk - lam)
elif (bulk is not None) and (mu is not None):
return (3.*bulk - 2*mu) / (6.*bulk + 2*mu)
elif (bulk is not None) and (youngs is not None):
return (3.*bulk - youngs) / (6.*bulk)
elif (lam is not None) and (youngs is not None):
# Note that this returns a tuple.
x = np.sqrt(9*lam**2 + 2*youngs*lam + youngs**2)
def b(y): return (1/(4*lam)) * (-1*lam - youngs + y)
# Strictly, we should return b(x), b(-x)
# But actually, the answer is:
return b(x)
else:
return None
def mu(vp=None, vs=None, rho=None, pr=None, lam=None, youngs=None, bulk=None,
pmod=None):
'''
Computes shear modulus given either Vp, Vs, and rho, or
any two elastic moduli (e.g. lambda and bulk, or Young's
and P moduli).
SI units only.
Args:
vp, vs, and rho
or any 2 from lam, bulk, youngs, pr, and pmod
Returns:
Shear modulus in pascals, Pa
'''
if (vs is not None) and (rho is not None):
return rho * vs**2
elif (bulk is not None) and (lam is not None):
return 3. * (bulk - lam) / 2.
elif (bulk is not None) and (youngs is not None):
return 3. * bulk * youngs / (9.*bulk - youngs)
elif (lam is not None) and (pr is not None):
return lam * (1 - 2.*pr) / (2.*pr)
elif (pr is not None) and (youngs is not None):
return youngs / (2. * (1 + pr))
elif (pr is not None) and (bulk is not None):
return 3. * bulk * (1 - 2*pr) / (2. * (1 + pr))
elif (lam is not None) and (youngs is not None):
# Note that this returns a tuple.
x = np.sqrt(9*lam**2 + 2*youngs*lam + youngs**2)
def b(y): return 1/4. * (-3*lam + youngs + y)
# Strictly, we should return b(x), b(-x)
# But actually, the answer is:
return b(x)
else:
return None
def lam(vp=None, vs=None, rho=None, pr=None, mu=None, youngs=None, bulk=None,
pmod=None):
'''
Computes lambda given either Vp, Vs, and rho, or
any two elastic moduli (e.g. bulk and mu, or Young's
and P moduli).
SI units only.
Args:
vp, vs, and rho
or any 2 from bulk, mu, youngs, pr, and pmod
Returns:
Lambda in pascals, Pa
'''
if (vp is not None) and (vs is not None) and (rho is not None):
return rho * (vp**2 - 2.*vs**2.)
elif (youngs is not None) and (mu is not None):
return mu * (youngs - 2.*mu) / (3.*mu - youngs)
elif (bulk is not None) and (mu is not None):
return bulk - (2.*mu/3.)
elif (bulk is not None) and (youngs is not None):
return 3. * bulk * (3*bulk - youngs) / (9*bulk - youngs)
elif (pr is not None) and (mu is not None):
return 2. * pr * mu / (1 - 2.*pr)
elif (pr is not None) and (youngs is not None):
return pr * youngs / ((1+pr) * (1-2*pr))
elif (pr is not None) and (bulk is not None):
return 3. * bulk * pr / (1+pr)
else:
return None
def pmod(vp=None, vs=None, rho=None, pr=None, mu=None, lam=None, youngs=None,
bulk=None):
'''
Computes P-wave modulus given either Vp, Vs, and rho, or
any two elastic moduli (e.g. lambda and mu, or Young's
and bulk moduli).
SI units only.
Args:
vp, vs, and rho
or any 2 from lam, mu, youngs, pr, and bulk
Returns:
P-wave modulus in pascals, Pa
'''
if (vp is not None) and (rho is not None):
return rho * vp**2
elif (lam is not None) and (mu is not None):
return lam + 2*mu
elif (youngs is not None) and (mu is not None):
return mu * (4.*mu - youngs) / (3.*mu - youngs)
elif (bulk is not None) and (lam is not None):
return 3*bulk - 2.*lam
elif (bulk is not None) and (mu is not None):
return bulk + (4.*mu/3.)
elif (bulk is not None) and (youngs is not None):
return 3. * bulk * (3*bulk + youngs) / (9*bulk - youngs)
elif (lam is not None) and (pr is not None):
return lam * (1 - pr) / pr
elif (pr is not None) and (mu is not None):
return 2. * pr * mu * (1-pr) / (1 - 2.*pr)
elif (pr is not None) and (youngs is not None):
return (1-pr) * youngs / ((1+pr) * (1 - 2.*pr))
elif (pr is not None) and (bulk is not None):
return 3. * bulk * (1-pr) / (1+pr)
elif (lam is not None) and (youngs is not None):
# Note that this returns a tuple.
x = np.sqrt(9*lam**2 + 2*youngs*lam + youngs**2)
def b(y): return 1/2. * (-1*lam + youngs + y)
# Strictly, we should return b(x), b(-x)
# But actually, the answer is:
return b(x)
else:
return None
def vp(youngs=None, vs=None, rho=None, mu=None, lam=None, bulk=None, pr=None,
pmod=None):
'''
Computes Vp given bulk density and any two elastic moduli
(e.g. lambda and mu, or Young's and P moduli).
SI units only.
Args:
Any 2 from lam, mu, youngs, pr, pmod, bulk
Rho
Returns:
Vp in m/s
'''
if (mu is not None) and (lam is not None) and (rho is not None):
return np.sqrt((lam + 2.*mu) / rho)
elif (youngs is not None) and (mu and rho is not None):
return np.sqrt(mu * (youngs - 4.*mu) / (rho * (youngs - 3.*mu)))
elif (youngs is not None) and (pr and rho is not None):
return np.sqrt(youngs * (1 - pr) / (rho * (1+pr) * (1 - 2.*pr)))
elif (bulk is not None) and (lam and rho is not None):
return np.sqrt((9.*bulk - 2.*lam) / rho)
elif (bulk is not None) and (mu and rho is not None):
return np.sqrt((bulk + 4.*mu/3.) / rho)
elif (lam is not None) and (pr and rho is not None):
return np.sqrt(lam * (1. - pr) / (pr*rho))
else:
return None
def vs(youngs=None, vp=None, rho=None, mu=None, lam=None, bulk=None, pr=None,
pmod=None):
'''
Computes Vs given bulk density and shear modulus.
SI units only.
Args:
Mu
Rho
Returns:
Vs in m/s
'''
if (mu is not None) and (rho is not None):
return np.sqrt(mu / rho)
else:
return None
def moduli_dict(vp, vs, rho):
'''
Computes elastic moduli given Vp, Vs, and rho.
SI units only.
Args:
Vp, Vs, and rho
Returns:
A dict of elastic moduli, plus P-wave impedance.
'''
mod = {}
mod['imp'] = vp * rho
mod['mu'] = mu(vs=vs, rho=rho)
mod['pr'] = pr(vp=vp, vs=vs, rho=rho)
mod['lam'] = lam(vp=vp, vs=vs, rho=rho)
mod['bulk'] = bulk(vp=vp, vs=vs, rho=rho)
mod['pmod'] = pmod(vp=vp, rho=rho)
mod['youngs'] = youngs(vp=vp, vs=vs, rho=rho)
return mod