geolysis 0.9.0__py3-none-any.whl → 0.10.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.
Files changed (32) hide show
  1. geolysis/__init__.py +3 -3
  2. geolysis/bearing_capacity/abc/__init__.py +21 -0
  3. geolysis/bearing_capacity/abc/_cohl/__init__.py +109 -0
  4. geolysis/bearing_capacity/abc/{cohl → _cohl}/_core.py +19 -8
  5. geolysis/bearing_capacity/abc/_cohl/bowles_abc.py +103 -0
  6. geolysis/bearing_capacity/abc/_cohl/meyerhof_abc.py +100 -0
  7. geolysis/bearing_capacity/abc/_cohl/terzaghi_abc.py +143 -0
  8. geolysis/bearing_capacity/ubc/__init__.py +107 -128
  9. geolysis/bearing_capacity/ubc/_core.py +65 -52
  10. geolysis/bearing_capacity/ubc/_hansen_ubc.py +271 -0
  11. geolysis/bearing_capacity/ubc/_terzaghi_ubc.py +178 -0
  12. geolysis/bearing_capacity/ubc/_vesic_ubc.py +253 -0
  13. geolysis/foundation.py +146 -136
  14. geolysis/soil_classifier.py +379 -283
  15. geolysis/spt.py +323 -257
  16. geolysis/{utils/__init__.py → utils.py} +44 -33
  17. geolysis-0.10.0.dist-info/METADATA +181 -0
  18. geolysis-0.10.0.dist-info/RECORD +22 -0
  19. {geolysis-0.9.0.dist-info → geolysis-0.10.0.dist-info}/WHEEL +1 -1
  20. geolysis/bearing_capacity/abc/cohl/__init__.py +0 -137
  21. geolysis/bearing_capacity/abc/cohl/bowles_abc.py +0 -96
  22. geolysis/bearing_capacity/abc/cohl/meyerhof_abc.py +0 -96
  23. geolysis/bearing_capacity/abc/cohl/terzaghi_abc.py +0 -131
  24. geolysis/bearing_capacity/ubc/hansen_ubc.py +0 -287
  25. geolysis/bearing_capacity/ubc/terzaghi_ubc.py +0 -246
  26. geolysis/bearing_capacity/ubc/vesic_ubc.py +0 -293
  27. geolysis/utils/exceptions.py +0 -65
  28. geolysis/utils/validators.py +0 -119
  29. geolysis-0.9.0.dist-info/METADATA +0 -206
  30. geolysis-0.9.0.dist-info/RECORD +0 -24
  31. {geolysis-0.9.0.dist-info → geolysis-0.10.0.dist-info}/licenses/LICENSE.txt +0 -0
  32. {geolysis-0.9.0.dist-info → geolysis-0.10.0.dist-info}/top_level.txt +0 -0
@@ -1,152 +1,131 @@
1
- """
2
- This package provides a factory function and utilities for creating ultimate
3
- bearing capacity calculations using methods like Hansen, Terzaghi, and Vesic
4
- for various foundation shapes.
5
- """
6
1
  import enum
7
- from typing import Optional
2
+ from typing import Optional, Annotated
8
3
 
9
- from geolysis.foundation import Shape, create_foundation
10
- from geolysis.utils import enum_repr
11
- from geolysis.utils.exceptions import ErrorMsg, ValidationError
4
+ from func_validator import MustBeMemberOf, validate_func_args
12
5
 
6
+ from geolysis.foundation import Shape, create_foundation
7
+ from geolysis.utils import AbstractStrEnum
13
8
  from ._core import UltimateBearingCapacity
14
- from .hansen_ubc import HansenUltimateBearingCapacity
15
- from .terzaghi_ubc import (TerzaghiUBC4CircularFooting,
16
- TerzaghiUBC4RectangularFooting,
17
- TerzaghiUBC4SquareFooting, TerzaghiUBC4StripFooting)
18
- from .vesic_ubc import VesicUltimateBearingCapacity
19
-
20
- __all__ = ["UBCType",
21
- "TerzaghiUBC4StripFooting",
22
- "TerzaghiUBC4CircularFooting",
23
- "TerzaghiUBC4RectangularFooting",
24
- "TerzaghiUBC4SquareFooting",
25
- "HansenUltimateBearingCapacity",
26
- "VesicUltimateBearingCapacity",
27
- "create_ultimate_bearing_capacity"]
28
-
29
-
30
- @enum_repr
31
- class UBCType(enum.StrEnum):
32
- """Enumeration of available ultimate bearing capacity types."""
9
+ from ._hansen_ubc import HansenUltimateBearingCapacity
10
+ from ._terzaghi_ubc import (
11
+ TerzaghiUBC4CircularFooting,
12
+ TerzaghiUBC4RectangularFooting,
13
+ TerzaghiUBC4SquareFooting,
14
+ TerzaghiUBC4StripFooting,
15
+ )
16
+ from ._vesic_ubc import VesicUltimateBearingCapacity
17
+
18
+ __all__ = [
19
+ "UBCType",
20
+ "TerzaghiUBC4StripFooting",
21
+ "TerzaghiUBC4CircularFooting",
22
+ "TerzaghiUBC4RectangularFooting",
23
+ "TerzaghiUBC4SquareFooting",
24
+ "HansenUltimateBearingCapacity",
25
+ "VesicUltimateBearingCapacity",
26
+ "create_ubc_4_all_soil_types",
27
+ ]
28
+
29
+
30
+ class UBCType(AbstractStrEnum):
31
+ """Enumeration of available ultimate bearing capacity methods.
32
+
33
+ Each member represents a different method for determining
34
+ the ultimate bearing capacity of soil.
35
+ """
36
+
33
37
  HANSEN = enum.auto()
34
- TERZAGHI = enum.auto()
35
- VESIC = enum.auto()
38
+ """Hansen's method for calculating ultimate bearing capacity."""
36
39
 
40
+ TERZAGHI = enum.auto()
41
+ """Terzaghi's method for calculating ultimate bearing capacity."""
37
42
 
38
- ubc_classes = {
39
- UBCType.HANSEN: HansenUltimateBearingCapacity,
40
- UBCType.TERZAGHI: {Shape.STRIP: TerzaghiUBC4StripFooting,
41
- Shape.CIRCLE: TerzaghiUBC4CircularFooting,
42
- Shape.SQUARE: TerzaghiUBC4SquareFooting,
43
- Shape.RECTANGLE: TerzaghiUBC4RectangularFooting},
44
- UBCType.VESIC: VesicUltimateBearingCapacity,
45
- }
46
-
47
-
48
- def create_ultimate_bearing_capacity(friction_angle: float,
49
- cohesion: float,
50
- moist_unit_wgt: float,
51
- depth: float,
52
- width: float,
53
- length: Optional[float] = None,
54
- eccentricity: float = 0.0,
55
- ground_water_level: Optional[
56
- float] = None,
57
- load_angle: float = 0.0,
58
- apply_local_shear: bool = False,
59
- shape: Shape | str = Shape.SQUARE,
60
- ubc_type: Optional[UBCType | str] = None,
61
- ) -> UltimateBearingCapacity:
62
- r"""A factory function that encapsulate the creation of ultimate bearing
63
- capacity.
43
+ VESIC = enum.auto()
44
+ """Vesic's method for calculating ultimate bearing capacity."""
45
+
46
+
47
+ @validate_func_args
48
+ def create_ubc_4_all_soil_types(
49
+ friction_angle: float,
50
+ cohesion: float,
51
+ moist_unit_wgt: float,
52
+ depth: float,
53
+ width: float,
54
+ length: Optional[float] = None,
55
+ eccentricity: float = 0.0,
56
+ ground_water_level: Optional[float] = None,
57
+ load_angle: float = 0.0,
58
+ apply_local_shear: bool = False,
59
+ shape: Shape | str = "square",
60
+ ubc_type: Annotated[UBCType | str, MustBeMemberOf(UBCType)] = "hansen",
61
+ ) -> UltimateBearingCapacity:
62
+ r"""A factory function that encapsulate the creation of ultimate
63
+ bearing capacity.
64
64
 
65
65
  :param friction_angle: Internal angle of friction for general shear
66
66
  failure (degree).
67
- :type friction_angle: float
68
-
69
- :param cohesion: Cohesion of soil (:math:`kPa`).
70
- :type cohesion: float
71
-
72
- :param moist_unit_wgt: Moist unit weight of soil (:math:`kN/m^3`).
73
- :type moist_unit_wgt: float
74
67
 
68
+ :param cohesion: Cohesion of soil ($kPa$).
69
+ :param moist_unit_wgt: Moist unit weight of soil ($kN/m^3$).
75
70
  :param depth: Depth of foundation (m).
76
- :type depth: float
77
-
78
71
  :param width: Width of foundation footing (m).
79
- :type width: float
80
-
81
72
  :param length: Length of foundation footing (m).
82
- :type length: float, optional
83
-
84
73
  :param eccentricity: The deviation of the foundation load from the
85
- center of gravity of the foundation footing,
86
- defaults to 0.0 (m). This means that the foundation
87
- load aligns with the center of gravity of the
88
- foundation footing.
89
- :type eccentricity: float, optional
90
-
74
+ center of gravity of the foundation footing.
91
75
  :param ground_water_level: Depth of water below ground level (m).
92
- :type ground_water_level: float, optional
93
-
94
76
  :param load_angle: Inclination of the applied load with the vertical
95
- (:math:`\alpha^{\circ}`), defaults to 0.0.
96
- :type load_angle: float, optional
97
-
98
- :param apply_local_shear: Indicate whether bearing capacity failure is
99
- general or local shear failure, defaults to
100
- False.
101
- :type apply_local_shear: bool, optional
102
-
103
- :param shape: Shape of foundation footing, defaults to
104
- :attr:`~geolysis.foundation.Shape.SQUARE`.
105
- :type shape: Shape | str, optional
106
-
107
- :param ubc_type: Type of allowable bearing capacity calculation to apply.
108
- Available values are: :attr:`~UBCType.HANSEN`,
109
- :attr:`~UBCType.TERZAGHI`, and :attr:`~UBCType.VESIC`
110
- defaults to None.
111
- :type ubc_type: UBCType | str, optional
112
-
113
- :raises ValueError: Raised if ubc_type is not supported.
114
- :raises ValueError: Raised when length is not provided for a rectangular
115
- footing.
116
- :raises ValueError: Raised if an invalid footing shape is provided.
77
+ ($\alpha^{\circ}$).
78
+ :param apply_local_shear: Indicate whether bearing capacity failure
79
+ is general or local shear failure.
80
+ :param shape: Shape of foundation footing.
81
+ :param ubc_type: Type of allowable bearing capacity calculation to
82
+ apply.
83
+
84
+ :raises ValidationError: Raised if ubc_type is not supported.
85
+ :raises ValidationError: Raised if an invalid footing shape is
86
+ provided.
87
+ :raises ValueError: Raised when length is not provided for a
88
+ rectangular footing.
117
89
  """
118
-
119
- msg = ErrorMsg(param_name="ubc_type",
120
- param_value=ubc_type,
121
- symbol="in",
122
- param_value_bound=list(UBCType))
123
-
124
- if ubc_type is None:
125
- raise ValidationError(msg)
126
-
127
- try:
128
- ubc_type = UBCType(str(ubc_type).casefold())
129
- except ValueError as e:
130
- raise ValidationError(msg) from e
90
+ ubc_type = UBCType(ubc_type)
131
91
 
132
92
  # exception from create_foundation will automatically propagate
133
93
  # no need to catch and handle it.
134
- fnd_size = create_foundation(depth=depth,
135
- width=width,
136
- length=length,
137
- eccentricity=eccentricity,
138
- load_angle=load_angle,
139
- ground_water_level=ground_water_level,
140
- shape=shape)
141
-
94
+ fnd_size = create_foundation(
95
+ depth=depth,
96
+ width=width,
97
+ length=length,
98
+ eccentricity=eccentricity,
99
+ load_angle=load_angle,
100
+ ground_water_level=ground_water_level,
101
+ shape=shape,
102
+ )
103
+
104
+ ubc_class = _get_ultimate_bearing_capacity(ubc_type,
105
+ fnd_size.footing_shape)
106
+
107
+ return ubc_class(
108
+ friction_angle=friction_angle,
109
+ cohesion=cohesion,
110
+ moist_unit_wgt=moist_unit_wgt,
111
+ foundation_size=fnd_size,
112
+ apply_local_shear=apply_local_shear,
113
+ )
114
+
115
+
116
+ def _get_ultimate_bearing_capacity(ubc_type: UBCType, foundation_shape: Shape):
117
+ ubc_classes = {
118
+ UBCType.HANSEN: HansenUltimateBearingCapacity,
119
+ UBCType.TERZAGHI: {
120
+ Shape.STRIP: TerzaghiUBC4StripFooting,
121
+ Shape.CIRCLE: TerzaghiUBC4CircularFooting,
122
+ Shape.SQUARE: TerzaghiUBC4SquareFooting,
123
+ Shape.RECTANGLE: TerzaghiUBC4RectangularFooting,
124
+ },
125
+ UBCType.VESIC: VesicUltimateBearingCapacity,
126
+ }
142
127
  if ubc_type == UBCType.TERZAGHI:
143
- ubc_class = ubc_classes[ubc_type][fnd_size.footing_shape]
128
+ ubc_class = ubc_classes[ubc_type][foundation_shape]
144
129
  else:
145
130
  ubc_class = ubc_classes[ubc_type]
146
-
147
- ubc = ubc_class(friction_angle=friction_angle,
148
- cohesion=cohesion,
149
- moist_unit_wgt=moist_unit_wgt,
150
- foundation_size=fnd_size,
151
- apply_local_shear=apply_local_shear)
152
- return ubc
131
+ return ubc_class
@@ -1,34 +1,50 @@
1
1
  from abc import ABC, abstractmethod
2
+ from typing import Annotated
3
+
4
+ from func_validator import (
5
+ validate_func_args,
6
+ MustBeNonNegative,
7
+ MustBePositive,
8
+ )
2
9
 
3
10
  from geolysis.foundation import Foundation
4
- from geolysis.utils import arctan, round_, tan, validators
11
+ from geolysis.utils import arctan, round_, tan
5
12
 
6
13
 
7
14
  class UltimateBearingCapacity(ABC):
8
- def __init__(self, friction_angle: float,
9
- cohesion: float,
10
- moist_unit_wgt: float,
11
- foundation_size: Foundation,
12
- # load_angle: float = 0.0,
13
- apply_local_shear: bool = False) -> None:
15
+ 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,
22
+ ) -> None:
14
23
  r"""
15
- :param friction_angle: Internal angle of friction for general shear
16
- failure (degrees).
17
- :type friction_angle: float
18
-
19
- :param cohesion: Cohesion of soil (:math:`kPa`).
20
- :type cohesion: float
21
-
22
- :param moist_unit_wgt: Moist unit weight of soil (:math:`kN/m^3`).
23
- :type moist_unit_wgt: float
24
24
 
25
+ $$
26
+ q_u = cN_c s_c d_c i_c + qN_q s_q d_q i_q
27
+ + 0.5 \gamma B N_{\gamma} s_{\gamma} d_{\gamma} i_{\gamma}
28
+ $$
29
+
30
+ - $q_u$ (kPa): Ultimate bearing capacity
31
+ - $c$ (kPa): Cohesion of soil
32
+ - $q$ (kPa): Overburden pressure of soil
33
+ - $\gamma$ (kN/m³): Unit weight of soil
34
+ - $B$ (m): Width of foundation footing
35
+ - $N_c$, $N_q$, $N_{\gamma}$: Bearing capacity factors
36
+ - $s_c$, $s_q$, $s_{\gamma}$: Shape factors
37
+ - $d_c$, $d_q$, $d_{\gamma}$: Depth factors
38
+ - $i_c$, $i_q$, $i_{\gamma}$: Inclination factors
39
+
40
+ :param friction_angle: Internal angle of friction for general
41
+ shear failure (degrees).
42
+ :param cohesion: Cohesion of soil ($kPa$).
43
+ :param moist_unit_wgt: Moist unit weight of soil ($kN/m^3$).
25
44
  :param foundation_size: Size of the foundation.
26
- :type foundation_size: Foundation
27
-
28
- :param apply_local_shear: Indicate whether bearing capacity failure is
29
- general shear or local shear failure,
30
- defaults to False.
31
- :type apply_local_shear: bool, optional
45
+ :param apply_local_shear: Indicate whether bearing capacity
46
+ failure is general shear or local
47
+ shear failure.
32
48
  """
33
49
  self.friction_angle = friction_angle
34
50
  self.cohesion = cohesion
@@ -41,13 +57,11 @@ class UltimateBearingCapacity(ABC):
41
57
  r"""Return friction angle for local shear in the case of local shear
42
58
  failure or general shear in the case of general shear failure.
43
59
 
44
- :Equation:
45
-
46
60
  In the case of local shear failure:
47
61
 
48
- .. math::
49
-
50
- \phi' = \tan^{-1} \left(\frac{2}{3} \tan \phi\right)
62
+ $$
63
+ \phi' = \tan^{-1} \left(\frac{2}{3} \tan \phi\right)
64
+ $$
51
65
 
52
66
  """
53
67
  if self.apply_local_shear:
@@ -55,8 +69,8 @@ class UltimateBearingCapacity(ABC):
55
69
  return self._friction_angle
56
70
 
57
71
  @friction_angle.setter
58
- @validators.ge(0.0)
59
- def friction_angle(self, val: float):
72
+ @validate_func_args
73
+ def friction_angle(self, val: Annotated[float, MustBeNonNegative]):
60
74
  self._friction_angle = val
61
75
 
62
76
  @property
@@ -64,31 +78,29 @@ class UltimateBearingCapacity(ABC):
64
78
  r"""Return cohesion for local shear in the case of local shear failure
65
79
  or general shear in the case of general shear failure.
66
80
 
67
- :Equation:
68
-
69
81
  In the case of local shear failure:
70
82
 
71
- .. math::
72
-
73
- C^{'} = \dfrac{2}{3} \cdot C
83
+ $$
84
+ C^{'} = \dfrac{2}{3} \cdot C
85
+ $$
74
86
  """
75
87
  if self.apply_local_shear:
76
88
  return (2.0 / 3.0) * self._cohesion
77
89
  return self._cohesion
78
90
 
79
91
  @cohesion.setter
80
- @validators.ge(0.0)
81
- def cohesion(self, val: float):
92
+ @validate_func_args
93
+ def cohesion(self, val: Annotated[float, MustBeNonNegative]):
82
94
  self._cohesion = val
83
95
 
84
96
  @property
85
97
  def moist_unit_wgt(self) -> float:
86
- """Moist unit weight of soil (:math:`kN/m^3`)."""
98
+ """Moist unit weight of soil ($kN/m^3$)."""
87
99
  return self._moist_unit_wgt
88
100
 
89
101
  @moist_unit_wgt.setter
90
- @validators.gt(0.0)
91
- def moist_unit_wgt(self, val: float):
102
+ @validate_func_args
103
+ def moist_unit_wgt(self, val: Annotated[float, MustBePositive]):
92
104
  self._moist_unit_wgt = val
93
105
 
94
106
  @property
@@ -98,47 +110,38 @@ class UltimateBearingCapacity(ABC):
98
110
 
99
111
  @property
100
112
  def s_c(self) -> float:
101
- """Shape factor :math:`S_c`"""
102
113
  return 1.0
103
114
 
104
115
  @property
105
116
  def s_q(self) -> float:
106
- """Shape factor :math:`S_q`"""
107
117
  return 1.0
108
118
 
109
119
  @property
110
120
  def s_gamma(self) -> float:
111
- r"""Shape factor :math:`S_{\gamma}`"""
112
121
  return 1.0
113
122
 
114
123
  @property
115
124
  def d_c(self) -> float:
116
- """Depth factor :math:`d_c`"""
117
125
  return 1.0
118
126
 
119
127
  @property
120
128
  def d_q(self) -> float:
121
- """Depth factor :math:`d_q`"""
122
129
  return 1.0
123
130
 
124
131
  @property
125
132
  def d_gamma(self) -> float:
126
- r"""Depth factor :math:`d_{\gamma}`"""
127
133
  return 1.0
128
134
 
129
135
  @property
130
136
  def i_c(self) -> float:
131
- """Inclination factor :math:`i_c`"""
132
137
  return 1.0
133
138
 
134
139
  @property
135
140
  def i_q(self) -> float:
136
- """Inclination factor :math:`i_q`"""
137
141
  return 1.0
138
142
 
139
143
  @property
140
144
  def i_gamma(self) -> float:
141
- r"""Inclination factor :math:`i_{\gamma}`"""
142
145
  return 1.0
143
146
 
144
147
  def _cohesion_term(self, coef: float = 1.0) -> float:
@@ -172,15 +175,25 @@ class UltimateBearingCapacity(ABC):
172
175
  b = max(water_level - depth, 0)
173
176
  water_corr = min(0.5 + 0.5 * b / width, 1)
174
177
 
175
- return (coef * self.moist_unit_wgt * width * self.n_gamma
176
- * self.s_gamma * self.d_gamma * self.i_gamma * water_corr)
178
+ return (
179
+ coef
180
+ * self.moist_unit_wgt
181
+ * width
182
+ * self.n_gamma
183
+ * self.s_gamma
184
+ * self.d_gamma
185
+ * self.i_gamma
186
+ * water_corr
187
+ )
177
188
 
178
189
  @round_(ndigits=2)
179
190
  def bearing_capacity(self) -> float:
180
191
  """Calculates the ultimate bearing capacity."""
181
- return (self._cohesion_term(1.0)
192
+ return (
193
+ self._cohesion_term(1.0)
182
194
  + self._surcharge_term()
183
- + self._embedment_term(0.5))
195
+ + self._embedment_term(0.5)
196
+ )
184
197
 
185
198
  @property
186
199
  @abstractmethod