-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeology.py
40 lines (31 loc) · 1.07 KB
/
geology.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
#!/usr/bin/env
"""geology.py: tools for modeling geology."""
import bisect
class Rock():
""" Stores rock parameters for Detournay bit-rock interaction model. """
def __init__(self, Sstar, wstar, xieps, mugam, betaw, xi):
self.Sstar = Sstar
self.wstar = wstar
self.xieps = xieps
self.mugam = mugam
self.betaw = betaw
self.xi = xi
class Geology():
""" Stores geology as a list of rock types. """
def __init__(self, data):
self.data = data
self.transitions = list(data.keys())
self.transitions.sort()
def lookup(self, x):
""" Look up rock parameters at depth/length x. """
key = max(key for key in self.data.keys() if x - key >= 0)
return self.data[key]
def __call__(self, x):
return self.lookup(x)
def segment(self, x):
return bisect.bisect_left(self.transitions, x) - 1
def midpoint(self, i, xfin):
trans = self.transitions + [xfin]
return (trans[i+1] + trans[i])/2
def start(self, i):
return self.transitions[i]