geolysis 0.8.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 +20 -10
  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 +68 -66
  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 +160 -127
  14. geolysis/soil_classifier.py +386 -285
  15. geolysis/spt.py +323 -257
  16. geolysis/{utils/__init__.py → utils.py} +48 -36
  17. geolysis-0.10.0.dist-info/METADATA +181 -0
  18. geolysis-0.10.0.dist-info/RECORD +22 -0
  19. {geolysis-0.8.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 -52
  28. geolysis/utils/validators.py +0 -129
  29. geolysis-0.8.0.dist-info/METADATA +0 -206
  30. geolysis-0.8.0.dist-info/RECORD +0 -24
  31. {geolysis-0.8.0.dist-info → geolysis-0.10.0.dist-info}/licenses/LICENSE.txt +0 -0
  32. {geolysis-0.8.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
- ground_water_level=ground_water_level,
139
- shape=shape)
140
-
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
+ }
141
127
  if ubc_type == UBCType.TERZAGHI:
142
- ubc_class = ubc_classes[ubc_type][fnd_size.footing_shape]
128
+ ubc_class = ubc_classes[ubc_type][foundation_shape]
143
129
  else:
144
130
  ubc_class = ubc_classes[ubc_type]
145
-
146
- ubc = ubc_class(friction_angle=friction_angle,
147
- cohesion=cohesion,
148
- moist_unit_wgt=moist_unit_wgt,
149
- foundation_size=fnd_size,
150
- load_angle=load_angle,
151
- apply_local_shear=apply_local_shear)
152
- return ubc
131
+ return ubc_class
@@ -1,43 +1,54 @@
1
1
  from abc import ABC, abstractmethod
2
+ from typing import Annotated
2
3
 
3
- from geolysis.foundation import FoundationSize
4
- from geolysis.utils import arctan, round_, tan, validators
4
+ from func_validator import (
5
+ validate_func_args,
6
+ MustBeNonNegative,
7
+ MustBePositive,
8
+ )
9
+
10
+ from geolysis.foundation import Foundation
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: FoundationSize,
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: FoundationSize
27
-
28
- :param load_angle: Inclination of the applied load with the vertical
29
- (:math:`\alpha^{\circ}`), defaults to 0.0.
30
- :type load_angle: float, optional
31
-
32
- :param apply_local_shear: Indicate whether bearing capacity failure is
33
- general shear or local shear failure,
34
- defaults to False.
35
- :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.
36
48
  """
37
49
  self.friction_angle = friction_angle
38
50
  self.cohesion = cohesion
39
51
  self.moist_unit_wgt = moist_unit_wgt
40
- self.load_angle = load_angle
41
52
  self.foundation_size = foundation_size
42
53
  self.apply_local_shear = apply_local_shear
43
54
 
@@ -46,13 +57,11 @@ class UltimateBearingCapacity(ABC):
46
57
  r"""Return friction angle for local shear in the case of local shear
47
58
  failure or general shear in the case of general shear failure.
48
59
 
49
- :Equation:
50
-
51
60
  In the case of local shear failure:
52
61
 
53
- .. math::
54
-
55
- \phi' = \tan^{-1} \left(\frac{2}{3} \tan \phi\right)
62
+ $$
63
+ \phi' = \tan^{-1} \left(\frac{2}{3} \tan \phi\right)
64
+ $$
56
65
 
57
66
  """
58
67
  if self.apply_local_shear:
@@ -60,8 +69,8 @@ class UltimateBearingCapacity(ABC):
60
69
  return self._friction_angle
61
70
 
62
71
  @friction_angle.setter
63
- @validators.ge(0.0)
64
- def friction_angle(self, val: float):
72
+ @validate_func_args
73
+ def friction_angle(self, val: Annotated[float, MustBeNonNegative]):
65
74
  self._friction_angle = val
66
75
 
67
76
  @property
@@ -69,87 +78,70 @@ class UltimateBearingCapacity(ABC):
69
78
  r"""Return cohesion for local shear in the case of local shear failure
70
79
  or general shear in the case of general shear failure.
71
80
 
72
- :Equation:
73
-
74
81
  In the case of local shear failure:
75
82
 
76
- .. math::
77
-
78
- C^{'} = \dfrac{2}{3} \cdot C
83
+ $$
84
+ C^{'} = \dfrac{2}{3} \cdot C
85
+ $$
79
86
  """
80
87
  if self.apply_local_shear:
81
88
  return (2.0 / 3.0) * self._cohesion
82
89
  return self._cohesion
83
90
 
84
91
  @cohesion.setter
85
- @validators.ge(0.0)
86
- def cohesion(self, val: float):
92
+ @validate_func_args
93
+ def cohesion(self, val: Annotated[float, MustBeNonNegative]):
87
94
  self._cohesion = val
88
95
 
89
96
  @property
90
97
  def moist_unit_wgt(self) -> float:
91
- """Moist unit weight of soil (:math:`kN/m^3`)."""
98
+ """Moist unit weight of soil ($kN/m^3$)."""
92
99
  return self._moist_unit_wgt
93
100
 
94
101
  @moist_unit_wgt.setter
95
- @validators.gt(0.0)
96
- def moist_unit_wgt(self, val: float):
102
+ @validate_func_args
103
+ def moist_unit_wgt(self, val: Annotated[float, MustBePositive]):
97
104
  self._moist_unit_wgt = val
98
105
 
99
106
  @property
100
- def load_angle(self) -> float:
107
+ def load_angle(self):
101
108
  """Inclination of the applied load with the vertical."""
102
- return self._load_angle
103
-
104
- @load_angle.setter
105
- @validators.le(90.0)
106
- @validators.ge(0.0)
107
- def load_angle(self, val: float):
108
- self._load_angle = val
109
+ return self.foundation_size.load_angle
109
110
 
110
111
  @property
111
112
  def s_c(self) -> float:
112
- """Shape factor :math:`S_c`"""
113
113
  return 1.0
114
114
 
115
115
  @property
116
116
  def s_q(self) -> float:
117
- """Shape factor :math:`S_q`"""
118
117
  return 1.0
119
118
 
120
119
  @property
121
120
  def s_gamma(self) -> float:
122
- r"""Shape factor :math:`S_{\gamma}`"""
123
121
  return 1.0
124
122
 
125
123
  @property
126
124
  def d_c(self) -> float:
127
- """Depth factor :math:`d_c`"""
128
125
  return 1.0
129
126
 
130
127
  @property
131
128
  def d_q(self) -> float:
132
- """Depth factor :math:`d_q`"""
133
129
  return 1.0
134
130
 
135
131
  @property
136
132
  def d_gamma(self) -> float:
137
- r"""Depth factor :math:`d_{\gamma}`"""
138
133
  return 1.0
139
134
 
140
135
  @property
141
136
  def i_c(self) -> float:
142
- """Inclination factor :math:`i_c`"""
143
137
  return 1.0
144
138
 
145
139
  @property
146
140
  def i_q(self) -> float:
147
- """Inclination factor :math:`i_q`"""
148
141
  return 1.0
149
142
 
150
143
  @property
151
144
  def i_gamma(self) -> float:
152
- r"""Inclination factor :math:`i_{\gamma}`"""
153
145
  return 1.0
154
146
 
155
147
  def _cohesion_term(self, coef: float = 1.0) -> float:
@@ -183,15 +175,25 @@ class UltimateBearingCapacity(ABC):
183
175
  b = max(water_level - depth, 0)
184
176
  water_corr = min(0.5 + 0.5 * b / width, 1)
185
177
 
186
- return (coef * self.moist_unit_wgt * width * self.n_gamma
187
- * 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
+ )
188
188
 
189
189
  @round_(ndigits=2)
190
190
  def bearing_capacity(self) -> float:
191
191
  """Calculates the ultimate bearing capacity."""
192
- return (self._cohesion_term(1.0)
192
+ return (
193
+ self._cohesion_term(1.0)
193
194
  + self._surcharge_term()
194
- + self._embedment_term(0.5))
195
+ + self._embedment_term(0.5)
196
+ )
195
197
 
196
198
  @property
197
199
  @abstractmethod