geolysis 0.11.0__py3-none-any.whl → 0.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,46 @@
1
1
  from abc import ABC, abstractmethod
2
+ from dataclasses import dataclass
2
3
  from typing import Annotated
3
4
 
4
5
  from func_validator import (
5
- validate_func_args,
6
+ validate_params,
6
7
  MustBeNonNegative,
7
8
  MustBePositive,
8
9
  )
9
10
 
10
11
  from geolysis.foundation import Foundation
11
- from geolysis.utils import arctan, round_, tan
12
+ from geolysis.utils import arctandeg, round_, tandeg, isinf
13
+
14
+
15
+ @dataclass(frozen=True, slots=True)
16
+ class UltimateBearingCapacityResult:
17
+ ultimate_bearing_capacity: float
18
+ allowable_bearing_capacity: float
19
+ allowable_applied_load: float
20
+ n_c: float
21
+ n_q: float
22
+ n_gamma: float
23
+ s_c: float
24
+ s_q: float
25
+ s_gamma: float
26
+ d_c: float
27
+ d_q: float
28
+ d_gamma: float
29
+ i_c: float
30
+ i_q: float
31
+ i_gamma: float
12
32
 
13
33
 
14
34
  class UltimateBearingCapacity(ABC):
15
35
  def __init__(
16
- self,
17
- friction_angle: float,
18
- cohesion: float,
19
- moist_unit_wgt: float,
20
- foundation_size: Foundation,
21
- apply_local_shear: bool = False,
36
+ self,
37
+ friction_angle: float,
38
+ cohesion: float,
39
+ moist_unit_wgt: float,
40
+ foundation_size: Foundation,
41
+ saturated_unit_wgt: float = 20.5,
42
+ apply_local_shear: bool = False,
43
+ factor_of_safety: float = 3.0,
22
44
  ) -> None:
23
45
  r"""
24
46
  :param friction_angle: Internal angle of friction for general
@@ -26,6 +48,9 @@ class UltimateBearingCapacity(ABC):
26
48
  :param cohesion: Cohesion of soil ($kPa$).
27
49
  :param moist_unit_wgt: Moist unit weight of soil ($kN/m^3$).
28
50
  :param foundation_size: Size of the foundation.
51
+ :param saturated_unit_wgt: Saturated unit weight of soil ($kN/m^3$).
52
+ :param factor_of_safety: Factor of safety against bearing
53
+ capacity failure. Added in v0.12.0.
29
54
  :param apply_local_shear: Indicate whether bearing capacity
30
55
  failure is general shear or local
31
56
  shear failure.
@@ -34,6 +59,8 @@ class UltimateBearingCapacity(ABC):
34
59
  self.cohesion = cohesion
35
60
  self.moist_unit_wgt = moist_unit_wgt
36
61
  self.foundation_size = foundation_size
62
+ self.saturated_unit_wgt = saturated_unit_wgt
63
+ self.factor_of_safety = factor_of_safety
37
64
  self.apply_local_shear = apply_local_shear
38
65
 
39
66
  @property
@@ -49,33 +76,34 @@ class UltimateBearingCapacity(ABC):
49
76
 
50
77
  """
51
78
  if self.apply_local_shear:
52
- return arctan((2.0 / 3.0) * tan(self._friction_angle))
79
+ return arctandeg((2.0 / 3.0) * tandeg(self._friction_angle))
53
80
  return self._friction_angle
54
81
 
55
82
  @friction_angle.setter
56
- @validate_func_args
57
- def friction_angle(self, val: Annotated[float, MustBeNonNegative]):
58
- self._friction_angle = val
83
+ @validate_params
84
+ def friction_angle(
85
+ self,
86
+ friction_angle: Annotated[float, MustBeNonNegative],
87
+ ):
88
+ self._friction_angle = friction_angle
59
89
 
60
90
  @property
61
91
  def cohesion(self) -> float:
62
- r"""Return cohesion for local shear in the case of local shear failure
63
- or general shear in the case of general shear failure.
92
+ r"""Return cohesion for local shear in the case of local shear
93
+ failure or general shear in the case of general shear failure.
64
94
 
65
95
  In the case of local shear failure:
66
96
 
67
- $$
68
- C^{'} = \dfrac{2}{3} \cdot C
69
- $$
97
+ $$C^{'} = \dfrac{2}{3} \cdot C$$
70
98
  """
71
99
  if self.apply_local_shear:
72
100
  return (2.0 / 3.0) * self._cohesion
73
101
  return self._cohesion
74
102
 
75
103
  @cohesion.setter
76
- @validate_func_args
77
- def cohesion(self, val: Annotated[float, MustBeNonNegative]):
78
- self._cohesion = val
104
+ @validate_params
105
+ def cohesion(self, cohesion: Annotated[float, MustBeNonNegative]):
106
+ self._cohesion = cohesion
79
107
 
80
108
  @property
81
109
  def moist_unit_wgt(self) -> float:
@@ -83,9 +111,22 @@ class UltimateBearingCapacity(ABC):
83
111
  return self._moist_unit_wgt
84
112
 
85
113
  @moist_unit_wgt.setter
86
- @validate_func_args
87
- def moist_unit_wgt(self, val: Annotated[float, MustBePositive]):
88
- self._moist_unit_wgt = val
114
+ @validate_params
115
+ def moist_unit_wgt(self, moist_unit_wgt: Annotated[float, MustBePositive]):
116
+ self._moist_unit_wgt = moist_unit_wgt
117
+
118
+ @property
119
+ def saturated_unit_wgt(self) -> float:
120
+ """Saturated unit weight of soil ($kN/m^3$)."""
121
+ return self._saturated_unit_wgt
122
+
123
+ @saturated_unit_wgt.setter
124
+ @validate_params
125
+ def saturated_unit_wgt(
126
+ self,
127
+ saturated_unit_wgt: Annotated[float, MustBePositive],
128
+ ):
129
+ self._saturated_unit_wgt = saturated_unit_wgt
89
130
 
90
131
  @property
91
132
  def load_angle(self):
@@ -134,85 +175,107 @@ class UltimateBearingCapacity(ABC):
134
175
  def _surcharge_term(self) -> float:
135
176
  depth = self.foundation_size.depth
136
177
  water_level = self.foundation_size.ground_water_level
178
+ unit_wgt = self.moist_unit_wgt
179
+ eop = unit_wgt * depth
137
180
 
138
- if water_level is None:
139
- water_corr = 1.0 # water correction
140
- else:
141
- # water level above the base of the foundation
142
- a = max(depth - water_level, 0.0)
143
- water_corr = min(1 - 0.5 * a / depth, 1)
144
-
145
- # effective overburden pressure (surcharge)
146
- eop = self.moist_unit_wgt * depth
147
- return eop * self.n_q * self.s_q * self.d_q * self.i_q * water_corr
181
+ if not isinf(water_level):
182
+ if water_level < depth:
183
+ d_1 = water_level
184
+ d_2 = depth - d_1
185
+ unit_wgt = self.saturated_unit_wgt - 9.81
186
+ eop = self.moist_unit_wgt * d_1 + unit_wgt * d_2
187
+ return eop * self.n_q * self.s_q * self.d_q * self.i_q
148
188
 
149
189
  def _embedment_term(self, coef: float = 0.5) -> float:
150
190
  depth = self.foundation_size.depth
151
191
  width = self.foundation_size.effective_width
152
192
  water_level = self.foundation_size.ground_water_level
153
193
 
154
- if water_level is None:
155
- # water correction
156
- water_corr = 1.0
157
- else:
158
- #: b -> water level below the base of the foundation
159
- b = max(water_level - depth, 0)
160
- water_corr = min(0.5 + 0.5 * b / width, 1)
194
+ unit_wgt = self.moist_unit_wgt
195
+
196
+ if water_level is not None:
197
+ wgt = self.saturated_unit_wgt - 9.81
198
+ if water_level < depth:
199
+ unit_wgt = wgt
200
+ else:
201
+ d = water_level - depth
202
+ if d <= width:
203
+ unit_wgt = wgt + (d / width) * (self.moist_unit_wgt - wgt)
161
204
 
162
205
  return (
163
- coef
164
- * self.moist_unit_wgt
165
- * width
166
- * self.n_gamma
167
- * self.s_gamma
168
- * self.d_gamma
169
- * self.i_gamma
170
- * water_corr
206
+ coef
207
+ * unit_wgt
208
+ * width
209
+ * self.n_gamma
210
+ * self.s_gamma
211
+ * self.d_gamma
212
+ * self.i_gamma
171
213
  )
172
214
 
173
- @round_(ndigits=2)
174
- def bearing_capacity(self) -> float:
175
- """Calculates the ultimate bearing capacity."""
215
+ def _bearing_capacity(self) -> float:
176
216
  return (
177
- self._cohesion_term(1.0)
178
- + self._surcharge_term()
179
- + self._embedment_term(0.5)
217
+ self._cohesion_term(1.0)
218
+ + self._surcharge_term()
219
+ + self._embedment_term(0.5)
180
220
  )
181
221
 
182
- def bearing_capacity_results(self) -> dict:
222
+ def bearing_capacity_results(self) -> UltimateBearingCapacityResult:
183
223
  """Return a dictionary of bearing capacity results with
184
224
  intermediate calculations.
185
225
 
186
226
  !!! info "Added in v0.11.0"
227
+ """
228
+ return UltimateBearingCapacityResult(
229
+ ultimate_bearing_capacity=self.ultimate_bearing_capacity(),
230
+ allowable_bearing_capacity=self.allowable_bearing_capacity(),
231
+ allowable_applied_load=self.allowable_applied_load(),
232
+ n_c=self.n_c,
233
+ n_q=self.n_q,
234
+ n_gamma=self.n_gamma,
235
+ s_c=self.s_c,
236
+ s_q=self.s_q,
237
+ s_gamma=self.s_gamma,
238
+ d_c=self.d_c,
239
+ d_q=self.d_q,
240
+ d_gamma=self.d_gamma,
241
+ i_c=self.i_c,
242
+ i_q=self.i_q,
243
+ i_gamma=self.i_gamma,
244
+ )
245
+
246
+ @round_(ndigits=1)
247
+ def ultimate_bearing_capacity(self) -> float:
248
+ """Calculates the ultimate bearing capacity.
249
+
250
+ !!! info "Added in v0.12.0"
251
+ """
252
+ return self._bearing_capacity()
253
+
254
+ @round_(ndigits=1)
255
+ def allowable_bearing_capacity(self) -> float:
256
+ """Calculates the allowable bearing capacity.
257
+
258
+ !!! info "Added in v0.12.0"
259
+ """
260
+ return self._bearing_capacity() / self.factor_of_safety
261
+
262
+ @round_(ndigits=1)
263
+ def allowable_applied_load(self) -> float:
264
+ """Calculates the allowable applied load.
187
265
 
266
+ !!! info "Added in v0.12.0"
188
267
  """
189
- return {
190
- "bearing_capacity": self.bearing_capacity(),
191
- "n_c": self.n_c,
192
- "n_q": self.n_q,
193
- "n_gamma": self.n_gamma,
194
- "s_c": self.s_c,
195
- "s_q": self.s_q,
196
- "s_gamma": self.s_gamma,
197
- "d_c": self.d_c,
198
- "d_q": self.d_q,
199
- "d_gamma": self.d_gamma,
200
- "i_c": self.i_c,
201
- "i_q": self.i_q,
202
- "i_gamma": self.i_gamma,
203
- }
268
+ area = self.foundation_size.foundation_area()
269
+ return self.allowable_bearing_capacity() * area
204
270
 
205
271
  @property
206
272
  @abstractmethod
207
- def n_c(self) -> float:
208
- ...
273
+ def n_c(self) -> float: ...
209
274
 
210
275
  @property
211
276
  @abstractmethod
212
- def n_q(self) -> float:
213
- ...
277
+ def n_q(self) -> float: ...
214
278
 
215
279
  @property
216
280
  @abstractmethod
217
- def n_gamma(self) -> float:
218
- ...
281
+ def n_gamma(self) -> float: ...
@@ -1,6 +1,14 @@
1
- from abc import ABC
2
-
3
- from geolysis.utils import cos, cot, deg2rad, exp, isclose, pi, round_, tan
1
+ from geolysis.utils import (
2
+ cosdeg,
3
+ cotdeg,
4
+ deg2rad,
5
+ exp,
6
+ isclose,
7
+ pi,
8
+ round_,
9
+ tandeg,
10
+ add_repr,
11
+ )
4
12
  from ._core import UltimateBearingCapacity
5
13
 
6
14
  __all__ = [
@@ -10,8 +18,6 @@ __all__ = [
10
18
  "TerzaghiUBC4RectangularFooting",
11
19
  ]
12
20
 
13
- from geolysis.foundation import Foundation
14
-
15
21
 
16
22
  class TerzaghiBearingCapacityFactors:
17
23
 
@@ -20,54 +26,27 @@ class TerzaghiBearingCapacityFactors:
20
26
  def n_c(friction_angle: float) -> float:
21
27
  if isclose(friction_angle, 0.0):
22
28
  return 5.7
23
- return cot(friction_angle) * (
24
- TerzaghiBearingCapacityFactors.n_q(friction_angle) - 1.0
29
+ return cotdeg(friction_angle) * (
30
+ TerzaghiBearingCapacityFactors.n_q(friction_angle) - 1.0
25
31
  )
26
32
 
27
33
  @staticmethod
28
34
  @round_(ndigits=2)
29
35
  def n_q(friction_angle: float) -> float:
30
- return exp((3.0 * pi / 2.0 - deg2rad(friction_angle)) * tan(
31
- friction_angle)) / (
32
- 2.0 * (cos(45.0 + friction_angle / 2.0)) ** 2.0
33
- )
36
+ return exp(
37
+ (3.0 * pi / 2.0 - deg2rad(friction_angle)) * tandeg(friction_angle)
38
+ ) / (2.0 * (cosdeg(45.0 + friction_angle / 2.0)) ** 2.0)
34
39
 
35
40
  @staticmethod
36
41
  @round_(ndigits=2)
37
42
  def n_gamma(friction_angle: float) -> float:
38
- return (TerzaghiBearingCapacityFactors.n_q(
39
- friction_angle) - 1.0) * tan(
43
+ return (TerzaghiBearingCapacityFactors.n_q(friction_angle) - 1.0) * tandeg(
40
44
  1.4 * friction_angle
41
45
  )
42
46
 
43
47
 
44
- class TerzaghiUltimateBearingCapacity(UltimateBearingCapacity, ABC):
45
-
46
- def __init__(
47
- self,
48
- friction_angle: float,
49
- cohesion: float,
50
- moist_unit_wgt: float,
51
- foundation_size: Foundation,
52
- apply_local_shear: bool = False,
53
- ) -> None:
54
- r"""
55
- :param friction_angle: Internal angle of friction for general
56
- shear failure (degrees).
57
- :param cohesion: Cohesion of soil ($kPa$).
58
- :param moist_unit_wgt: Moist unit weight of soil ($kN/m^3$).
59
- :param foundation_size: Size of the foundation.
60
- :param apply_local_shear: Indicate whether bearing capacity
61
- failure is general shear or local
62
- shear failure.
63
- """
64
- super().__init__(
65
- friction_angle=friction_angle,
66
- cohesion=cohesion,
67
- moist_unit_wgt=moist_unit_wgt,
68
- foundation_size=foundation_size,
69
- apply_local_shear=apply_local_shear,
70
- )
48
+ @add_repr
49
+ class TerzaghiUltimateBearingCapacity(UltimateBearingCapacity):
71
50
 
72
51
  @property
73
52
  def n_c(self) -> float:
@@ -94,12 +73,12 @@ class TerzaghiUBC4StripFooting(TerzaghiUltimateBearingCapacity):
94
73
  """
95
74
 
96
75
  @round_(ndigits=2)
97
- def bearing_capacity(self) -> float:
76
+ def _bearing_capacity(self) -> float:
98
77
  """Calculates ultimate bearing capacity for strip footing."""
99
78
  return (
100
- self._cohesion_term(1.0)
101
- + self._surcharge_term()
102
- + self._embedment_term(0.5)
79
+ self._cohesion_term(1.0)
80
+ + self._surcharge_term()
81
+ + self._embedment_term(0.5)
103
82
  )
104
83
 
105
84
 
@@ -112,12 +91,29 @@ class TerzaghiUBC4CircularFooting(TerzaghiUltimateBearingCapacity):
112
91
  """
113
92
 
114
93
  @round_(ndigits=2)
115
- def bearing_capacity(self) -> float:
94
+ def _bearing_capacity(self) -> float:
116
95
  """Calculates ultimate bearing capacity for circular footing."""
117
96
  return (
118
- self._cohesion_term(1.3)
119
- + self._surcharge_term()
120
- + self._embedment_term(0.3)
97
+ self._cohesion_term(1.3)
98
+ + self._surcharge_term()
99
+ + self._embedment_term(0.3)
100
+ )
101
+
102
+
103
+ class TerzaghiUBC4SquareFooting(TerzaghiUltimateBearingCapacity):
104
+ """Ultimate bearing capacity for square footing according to
105
+ `Terzaghi 1943``.
106
+
107
+ See [implementation](../formulas/ultimate-bearing-capacity.md/#terzaghi-bearing-capacity-for-square-footing)
108
+ for more details on bearing capacity equation used.
109
+ """
110
+
111
+ def _bearing_capacity(self):
112
+ """Calcalates ultimate bearing capacity for square footing."""
113
+ return (
114
+ self._cohesion_term(1.3)
115
+ + self._surcharge_term()
116
+ + self._embedment_term(0.4)
121
117
  )
122
118
 
123
119
 
@@ -130,7 +126,7 @@ class TerzaghiUBC4RectangularFooting(TerzaghiUltimateBearingCapacity):
130
126
  """
131
127
 
132
128
  @round_(ndigits=2)
133
- def bearing_capacity(self) -> float:
129
+ def _bearing_capacity(self) -> float:
134
130
  """Calculates ultimate bearing capacity for rectangular footing."""
135
131
  width = self.foundation_size.width
136
132
  length = self.foundation_size.length
@@ -138,20 +134,7 @@ class TerzaghiUBC4RectangularFooting(TerzaghiUltimateBearingCapacity):
138
134
  emb_coef = (1.0 - 0.2 * (width / length)) / 2.0
139
135
 
140
136
  return (
141
- self._cohesion_term(coh_coef)
142
- + self._surcharge_term()
143
- + self._embedment_term(emb_coef)
137
+ self._cohesion_term(coh_coef)
138
+ + self._surcharge_term()
139
+ + self._embedment_term(emb_coef)
144
140
  )
145
-
146
-
147
- class TerzaghiUBC4SquareFooting(TerzaghiUBC4RectangularFooting):
148
- """Ultimate bearing capacity for square footing according to
149
- `Terzaghi 1943``.
150
-
151
- See [implementation](../formulas/ultimate-bearing-capacity.md/#terzaghi-bearing-capacity-for-square-footing)
152
- for more details on bearing capacity equation used.
153
- """
154
-
155
- def bearing_capacity(self):
156
- """Calcalates ultimate bearing capacity for square footing."""
157
- return super().bearing_capacity()