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.
geolysis/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from . import bearing_capacity, foundation, soil_classifier, spt
2
2
 
3
- __version__ = "0.11.0"
3
+ __version__ = "0.13.0"
4
4
 
5
5
  __all__ = ["foundation", "soil_classifier", "spt", "bearing_capacity"]
@@ -1,10 +1,11 @@
1
1
  import enum
2
2
  from typing import Optional, Annotated
3
3
 
4
- from func_validator import MustBeMemberOf, validate_func_args
4
+ from func_validator import MustBeMemberOf, validate_params
5
5
 
6
6
  from geolysis.foundation import FoundationType, Shape, create_foundation
7
7
  from geolysis.utils import AbstractStrEnum, inf
8
+
8
9
  from ._core import AllowableBearingCapacity
9
10
  from .bowles_abc import BowlesABC4MatFoundation, BowlesABC4PadFoundation
10
11
  from .meyerhof_abc import MeyerhofABC4MatFoundation, MeyerhofABC4PadFoundation
@@ -16,7 +17,7 @@ class ABCType(AbstractStrEnum):
16
17
 
17
18
  Each member represents a different method for determining
18
19
  the allowable bearing capacity of soil.
19
- """
20
+ """
20
21
 
21
22
  BOWLES = enum.auto()
22
23
  """Bowles's method for calculating allowable bearing capacity"""
@@ -28,20 +29,34 @@ class ABCType(AbstractStrEnum):
28
29
  """Terzaghi's method for calculating allowable bearing capacity"""
29
30
 
30
31
 
31
- @validate_func_args
32
+ abc_classes = {
33
+ ABCType.BOWLES: {
34
+ FoundationType.PAD: BowlesABC4PadFoundation,
35
+ FoundationType.MAT: BowlesABC4MatFoundation,
36
+ },
37
+ ABCType.MEYERHOF: {
38
+ FoundationType.PAD: MeyerhofABC4PadFoundation,
39
+ FoundationType.MAT: MeyerhofABC4MatFoundation,
40
+ },
41
+ ABCType.TERZAGHI: {
42
+ FoundationType.PAD: TerzaghiABC4PadFoundation,
43
+ FoundationType.MAT: TerzaghiABC4MatFoundation,
44
+ },
45
+ }
46
+
47
+
48
+ @validate_params
32
49
  def create_abc_4_cohesionless_soils(
33
- corrected_spt_n_value: float,
34
- tol_settlement: float,
35
- depth: float,
36
- width: float,
37
- length: Optional[float] = None,
38
- eccentricity: float = 0.0,
39
- ground_water_level: float = inf,
40
- shape: Shape | str = "square",
41
- foundation_type: Annotated[
42
- FoundationType | str, MustBeMemberOf(FoundationType)
43
- ] = "pad",
44
- abc_type: Annotated[ABCType | str, MustBeMemberOf(ABCType)] = "bowles",
50
+ corrected_spt_n_value: float,
51
+ tol_settlement: float,
52
+ depth: float,
53
+ width: float,
54
+ length: Optional[float] = None,
55
+ eccentricity: float = 0.0,
56
+ ground_water_level: float = inf,
57
+ shape: Shape | str = "square",
58
+ foundation_type: FoundationType | str = "pad",
59
+ abc_type: Annotated[ABCType | str, MustBeMemberOf(ABCType)] = "bowles",
45
60
  ) -> AllowableBearingCapacity:
46
61
  r"""A factory function that encapsulate the creation of allowable
47
62
  bearing capacities.
@@ -58,13 +73,6 @@ def create_abc_4_cohesionless_soils(
58
73
  :param foundation_type: Type of foundation.
59
74
  :param abc_type: Type of allowable bearing capacity calculation to
60
75
  apply.
61
-
62
- :raises ValidationError: Raised if `abc_type` or `foundation_type`
63
- is not supported.
64
- :raises ValidationError: Raised if an invalid footing `shape` is
65
- provided.
66
- :raises ValueError: Raised when `length` is not provided for a
67
- rectangular footing.
68
76
  """
69
77
  abc_type = ABCType(abc_type)
70
78
  foundation_type = FoundationType(foundation_type)
@@ -80,30 +88,10 @@ def create_abc_4_cohesionless_soils(
80
88
  foundation_type=foundation_type,
81
89
  shape=shape,
82
90
  )
91
+ abc_class = abc_classes[abc_type][foundation_type]
83
92
 
84
- abc_class = _get_allowable_bearing_capacity(abc_type,
85
- fnd_size.foundation_type)
86
93
  return abc_class(
87
94
  corrected_spt_n_value=corrected_spt_n_value,
88
95
  tol_settlement=tol_settlement,
89
96
  foundation_size=fnd_size,
90
97
  )
91
-
92
-
93
- def _get_allowable_bearing_capacity(abc_type: ABCType,
94
- foundation_type: FoundationType):
95
- abc_classes = {
96
- ABCType.BOWLES: {
97
- FoundationType.PAD: BowlesABC4PadFoundation,
98
- FoundationType.MAT: BowlesABC4MatFoundation,
99
- },
100
- ABCType.MEYERHOF: {
101
- FoundationType.PAD: MeyerhofABC4PadFoundation,
102
- FoundationType.MAT: MeyerhofABC4MatFoundation,
103
- },
104
- ABCType.TERZAGHI: {
105
- FoundationType.PAD: TerzaghiABC4PadFoundation,
106
- FoundationType.MAT: TerzaghiABC4MatFoundation,
107
- },
108
- }
109
- return abc_classes[abc_type][foundation_type]
@@ -1,24 +1,34 @@
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
  MustBeLessThanOrEqual,
8
9
  )
9
10
 
10
11
  from geolysis.foundation import Foundation
12
+ from geolysis.utils import round_, add_repr
11
13
 
12
14
 
15
+ @dataclass
16
+ class AllowableBearingCapacityResult:
17
+ allowable_bearing_capacity: float
18
+ depth_factor: float
19
+ water_correction_factor: float = 1.0
20
+
21
+
22
+ @add_repr
13
23
  class AllowableBearingCapacity(ABC):
14
24
  #: Maximum tolerable foundation settlement (mm).
15
25
  MAX_TOL_SETTLEMENT = 25.4
16
26
 
17
27
  def __init__(
18
- self,
19
- corrected_spt_n_value: float,
20
- tol_settlement: float,
21
- foundation_size: Foundation,
28
+ self,
29
+ corrected_spt_n_value: float,
30
+ tol_settlement: float,
31
+ foundation_size: Foundation,
22
32
  ) -> None:
23
33
  self.corrected_spt_n_value = corrected_spt_n_value
24
34
  self.tol_settlement = tol_settlement
@@ -30,9 +40,12 @@ class AllowableBearingCapacity(ABC):
30
40
  return self._corrected_spt_n_value
31
41
 
32
42
  @corrected_spt_n_value.setter
33
- @validate_func_args
34
- def corrected_spt_n_value(self, val: Annotated[float, MustBeNonNegative]):
35
- self._corrected_spt_n_value = val
43
+ @validate_params
44
+ def corrected_spt_n_value(
45
+ self,
46
+ corrected_spt_n_value: Annotated[float, MustBeNonNegative],
47
+ ):
48
+ self._corrected_spt_n_value = corrected_spt_n_value
36
49
 
37
50
  @property
38
51
  def tol_settlement(self) -> float:
@@ -40,10 +53,10 @@ class AllowableBearingCapacity(ABC):
40
53
  return self._tol_settlement
41
54
 
42
55
  @tol_settlement.setter
43
- @validate_func_args
56
+ @validate_params
44
57
  def tol_settlement(
45
- self,
46
- tol_settlement: Annotated[float, MustBeLessThanOrEqual(25.4)],
58
+ self,
59
+ tol_settlement: Annotated[float, MustBeLessThanOrEqual(25.4)],
47
60
  ):
48
61
  self._tol_settlement = tol_settlement
49
62
 
@@ -57,17 +70,27 @@ class AllowableBearingCapacity(ABC):
57
70
  width = self.foundation_size.width
58
71
  return min(1.0 + 0.33 * depth / width, 1.33)
59
72
 
60
- def bearing_capacity_results(self) -> dict:
61
- """Return a dictionary of bearing capacity results with
62
- intermediate calculations.
73
+ def bearing_capacity_results(self) -> AllowableBearingCapacityResult:
74
+ """Return bearing capacity results with intermediate calculations.
63
75
 
64
76
  !!! info "Added in v0.11.0"
77
+ """
78
+ return AllowableBearingCapacityResult(
79
+ allowable_bearing_capacity=self.allowable_bearing_capacity(),
80
+ depth_factor=self._fd(),
81
+ )
82
+
83
+ @round_(ndigits=1)
84
+ def allowable_bearing_capacity(self) -> float:
85
+ """Calculates the allowable bearing capacity.
65
86
 
87
+ !!! info "Added in v0.12.0"
66
88
  """
67
- return {
68
- "bearing_capacity": self.bearing_capacity(),
69
- "depth_factor": self._fd(),
70
- }
89
+ return self._bearing_capacity()
90
+
91
+ def allowable_applied_load(self) -> float:
92
+ """Calculate the allowable applied load on the foundation."""
93
+ return self._bearing_capacity() * self.foundation_size.foundation_area()
71
94
 
72
95
  @abstractmethod
73
- def bearing_capacity(self): ...
96
+ def _bearing_capacity(self) -> float: ...
@@ -14,10 +14,10 @@ class BowlesABC4PadFoundation(AllowableBearingCapacity):
14
14
  """
15
15
 
16
16
  def __init__(
17
- self,
18
- corrected_spt_n_value: float,
19
- tol_settlement: float,
20
- foundation_size: Foundation,
17
+ self,
18
+ corrected_spt_n_value: float,
19
+ tol_settlement: float,
20
+ foundation_size: Foundation,
21
21
  ) -> None:
22
22
  """
23
23
  :param corrected_spt_n_value: Statistical average of corrected
@@ -35,7 +35,7 @@ class BowlesABC4PadFoundation(AllowableBearingCapacity):
35
35
  )
36
36
 
37
37
  @round_(ndigits=2)
38
- def bearing_capacity(self) -> float:
38
+ def _bearing_capacity(self) -> float:
39
39
  """
40
40
  Calculate the allowable bearing capacity of the pad foundation.
41
41
  """
@@ -46,11 +46,11 @@ class BowlesABC4PadFoundation(AllowableBearingCapacity):
46
46
  return 19.16 * n_corr * self._fd() * self._sr()
47
47
 
48
48
  return (
49
- 11.98
50
- * n_corr
51
- * ((3.28 * width + 1) / (3.28 * width)) ** 2
52
- * self._fd()
53
- * self._sr()
49
+ 11.98
50
+ * n_corr
51
+ * ((3.28 * width + 1) / (3.28 * width)) ** 2
52
+ * self._fd()
53
+ * self._sr()
54
54
  )
55
55
 
56
56
 
@@ -64,7 +64,7 @@ class BowlesABC4MatFoundation(BowlesABC4PadFoundation):
64
64
  """
65
65
 
66
66
  @round_(ndigits=2)
67
- def bearing_capacity(self) -> float:
67
+ def _bearing_capacity(self) -> float:
68
68
  """
69
69
  Calculate the allowable bearing capacity of the mat foundation.
70
70
  """
@@ -14,10 +14,10 @@ class MeyerhofABC4PadFoundation(AllowableBearingCapacity):
14
14
  """
15
15
 
16
16
  def __init__(
17
- self,
18
- corrected_spt_n_value: float,
19
- tol_settlement: float,
20
- foundation_size: Foundation,
17
+ self,
18
+ corrected_spt_n_value: float,
19
+ tol_settlement: float,
20
+ foundation_size: Foundation,
21
21
  ):
22
22
  """
23
23
  :param corrected_spt_n_value: Average uncorrected SPT N-value
@@ -35,7 +35,7 @@ class MeyerhofABC4PadFoundation(AllowableBearingCapacity):
35
35
  )
36
36
 
37
37
  @round_(ndigits=2)
38
- def bearing_capacity(self):
38
+ def _bearing_capacity(self):
39
39
  """
40
40
  Calculates the allowable bearing capacity of the pad foundation.
41
41
  """
@@ -46,11 +46,11 @@ class MeyerhofABC4PadFoundation(AllowableBearingCapacity):
46
46
  return 12 * n_corr * self._fd() * self._sr()
47
47
 
48
48
  return (
49
- 8
50
- * n_corr
51
- * ((3.28 * width + 1) / (3.28 * width)) ** 2
52
- * self._fd()
53
- * self._sr()
49
+ 8
50
+ * n_corr
51
+ * ((3.28 * width + 1) / (3.28 * width)) ** 2
52
+ * self._fd()
53
+ * self._sr()
54
54
  )
55
55
 
56
56
 
@@ -64,7 +64,7 @@ class MeyerhofABC4MatFoundation(MeyerhofABC4PadFoundation):
64
64
  """
65
65
 
66
66
  @round_(ndigits=2)
67
- def bearing_capacity(self):
67
+ def _bearing_capacity(self):
68
68
  """Calculate the allowable bearing capacity of the mat foundation."""
69
69
  n_corr = self.corrected_spt_n_value
70
70
  return 8 * n_corr * self._fd() * self._sr()
@@ -1,7 +1,7 @@
1
1
  from geolysis.foundation import Foundation
2
- from geolysis.utils import round_
2
+ from geolysis.utils import round_, isinf
3
3
 
4
- from ._core import AllowableBearingCapacity
4
+ from ._core import AllowableBearingCapacity, AllowableBearingCapacityResult
5
5
 
6
6
 
7
7
  class TerzaghiABC4PadFoundation(AllowableBearingCapacity):
@@ -14,10 +14,10 @@ class TerzaghiABC4PadFoundation(AllowableBearingCapacity):
14
14
  """
15
15
 
16
16
  def __init__(
17
- self,
18
- corrected_spt_n_value: float,
19
- tol_settlement: float,
20
- foundation_size: Foundation,
17
+ self,
18
+ corrected_spt_n_value: float,
19
+ tol_settlement: float,
20
+ foundation_size: Foundation,
21
21
  ) -> None:
22
22
  """
23
23
  :param corrected_spt_n_value: Lowest (or average) uncorrected
@@ -46,7 +46,7 @@ class TerzaghiABC4PadFoundation(AllowableBearingCapacity):
46
46
  width = self.foundation_size.width
47
47
  water_level = self.foundation_size.ground_water_level
48
48
 
49
- if water_level is None:
49
+ if isinf(water_level):
50
50
  return 2.0
51
51
 
52
52
  if water_level <= depth:
@@ -57,7 +57,7 @@ class TerzaghiABC4PadFoundation(AllowableBearingCapacity):
57
57
  return min(cw, 2.0)
58
58
 
59
59
  @round_(ndigits=2)
60
- def bearing_capacity(self):
60
+ def _bearing_capacity(self):
61
61
  """
62
62
  Calculates the allowable bearing capacity of the pad foundation.
63
63
  """
@@ -68,16 +68,16 @@ class TerzaghiABC4PadFoundation(AllowableBearingCapacity):
68
68
  return 12 * n_corr * (1 / (self._cw() * self._fd())) * self._sr()
69
69
 
70
70
  return (
71
- 8
72
- * n_corr
73
- * ((3.28 * width + 1) / (3.28 * width)) ** 2
74
- * (1 / (self._cw() * self._fd()))
75
- * self._sr()
71
+ 8
72
+ * n_corr
73
+ * ((3.28 * width + 1) / (3.28 * width)) ** 2
74
+ * (1 / (self._cw() * self._fd()))
75
+ * self._sr()
76
76
  )
77
77
 
78
- def bearing_capacity_results(self) -> dict:
78
+ def bearing_capacity_results(self) -> AllowableBearingCapacityResult:
79
79
  res = super().bearing_capacity_results()
80
- res["water_correction_factor"] = self._cw()
80
+ res.water_correction_factor = self._cw()
81
81
  return res
82
82
 
83
83
 
@@ -91,7 +91,7 @@ class TerzaghiABC4MatFoundation(TerzaghiABC4PadFoundation):
91
91
  """
92
92
 
93
93
  @round_(ndigits=2)
94
- def bearing_capacity(self):
94
+ def _bearing_capacity(self):
95
95
  """
96
96
  Calculates the allowable bearing capacity of the mat foundation.
97
97
  """
@@ -1,12 +1,12 @@
1
1
  import enum
2
2
  from typing import Optional, Annotated
3
3
 
4
- from func_validator import MustBeMemberOf, validate_func_args
4
+ from func_validator import MustBeMemberOf, validate_params
5
5
 
6
6
  from geolysis.foundation import Shape, create_foundation
7
- from geolysis.utils import AbstractStrEnum
7
+ from geolysis.utils import AbstractStrEnum, inf
8
+
8
9
  from ._core import UltimateBearingCapacity
9
- from ._hansen_ubc import HansenUltimateBearingCapacity
10
10
  from ._terzaghi_ubc import (
11
11
  TerzaghiUBC4CircularFooting,
12
12
  TerzaghiUBC4RectangularFooting,
@@ -20,7 +20,6 @@ __all__ = [
20
20
  "TerzaghiUBC4CircularFooting",
21
21
  "TerzaghiUBC4RectangularFooting",
22
22
  "TerzaghiUBC4SquareFooting",
23
- "HansenUltimateBearingCapacity",
24
23
  "VesicUltimateBearingCapacity",
25
24
  "UBCType",
26
25
  "create_ubc_4_all_soil_types",
@@ -44,7 +43,18 @@ class UBCType(AbstractStrEnum):
44
43
  """Vesic's method for calculating ultimate bearing capacity."""
45
44
 
46
45
 
47
- @validate_func_args
46
+ ubc_classes = {
47
+ UBCType.TERZAGHI: {
48
+ Shape.STRIP: TerzaghiUBC4StripFooting,
49
+ Shape.CIRCLE: TerzaghiUBC4CircularFooting,
50
+ Shape.SQUARE: TerzaghiUBC4SquareFooting,
51
+ Shape.RECTANGLE: TerzaghiUBC4RectangularFooting,
52
+ },
53
+ UBCType.VESIC: VesicUltimateBearingCapacity,
54
+ }
55
+
56
+
57
+ @validate_params
48
58
  def create_ubc_4_all_soil_types(
49
59
  friction_angle: float,
50
60
  cohesion: float,
@@ -52,12 +62,13 @@ def create_ubc_4_all_soil_types(
52
62
  depth: float,
53
63
  width: float,
54
64
  length: Optional[float] = None,
65
+ saturated_unit_wgt: float = 20.5,
55
66
  eccentricity: float = 0.0,
56
- ground_water_level: Optional[float] = None,
67
+ ground_water_level: Optional[float] = inf,
57
68
  load_angle: float = 0.0,
58
69
  apply_local_shear: bool = False,
59
70
  shape: Shape | str = "square",
60
- ubc_type: Annotated[UBCType | str, MustBeMemberOf(UBCType)] = "hansen",
71
+ ubc_type: Annotated[UBCType | str, MustBeMemberOf(UBCType)] = "vesic",
61
72
  ) -> UltimateBearingCapacity:
62
73
  r"""A factory function that encapsulate the creation of ultimate
63
74
  bearing capacity.
@@ -70,6 +81,7 @@ def create_ubc_4_all_soil_types(
70
81
  :param depth: Depth of foundation (m).
71
82
  :param width: Width of foundation footing (m).
72
83
  :param length: Length of foundation footing (m).
84
+ :param saturated_unit_wgt: Saturated unit weight of soil ($kN/m^3$).
73
85
  :param eccentricity: The deviation of the foundation load from the
74
86
  center of gravity of the foundation footing.
75
87
  :param ground_water_level: Depth of water below ground level (m).
@@ -84,8 +96,8 @@ def create_ubc_4_all_soil_types(
84
96
  :raises ValidationError: Raised if ubc_type is not supported.
85
97
  :raises ValidationError: Raised if an invalid footing shape is
86
98
  provided.
87
- :raises ValueError: Raised when length is not provided for a
88
- rectangular footing.
99
+ :raises ValidationError: Raised when length is not provided for a
100
+ rectangular footing.
89
101
  """
90
102
  ubc_type = UBCType(ubc_type)
91
103
 
@@ -100,31 +112,16 @@ def create_ubc_4_all_soil_types(
100
112
  ground_water_level=ground_water_level,
101
113
  shape=shape,
102
114
  )
115
+ ubc_class = ubc_classes[ubc_type]
103
116
 
104
- ubc_class = _get_ultimate_bearing_capacity(ubc_type, fnd_size.footing_shape)
117
+ if ubc_type == UBCType.TERZAGHI:
118
+ ubc_class = ubc_classes[ubc_type][fnd_size.footing_shape]
105
119
 
106
120
  return ubc_class(
107
121
  friction_angle=friction_angle,
108
122
  cohesion=cohesion,
109
123
  moist_unit_wgt=moist_unit_wgt,
124
+ saturated_unit_wgt=saturated_unit_wgt,
110
125
  foundation_size=fnd_size,
111
126
  apply_local_shear=apply_local_shear,
112
127
  )
113
-
114
-
115
- def _get_ultimate_bearing_capacity(ubc_type: UBCType, foundation_shape: Shape):
116
- ubc_classes = {
117
- UBCType.HANSEN: HansenUltimateBearingCapacity,
118
- UBCType.TERZAGHI: {
119
- Shape.STRIP: TerzaghiUBC4StripFooting,
120
- Shape.CIRCLE: TerzaghiUBC4CircularFooting,
121
- Shape.SQUARE: TerzaghiUBC4SquareFooting,
122
- Shape.RECTANGLE: TerzaghiUBC4RectangularFooting,
123
- },
124
- UBCType.VESIC: VesicUltimateBearingCapacity,
125
- }
126
- if ubc_type == UBCType.TERZAGHI:
127
- ubc_class = ubc_classes[ubc_type][foundation_shape]
128
- else:
129
- ubc_class = ubc_classes[ubc_type]
130
- return ubc_class