geolysis 0.4.3__py3-none-any.whl → 0.4.5__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/foundation.py CHANGED
@@ -35,7 +35,7 @@ import enum
35
35
  from abc import ABC, abstractmethod
36
36
  from typing import Optional, TypeVar
37
37
 
38
- from geolysis.utils import inf, enum_repr, isclose, validators
38
+ from .utils import enum_repr, inf, isclose, validators
39
39
 
40
40
  __all__ = ["create_foundation",
41
41
  "FoundationSize",
@@ -66,7 +66,7 @@ class FoundationType(enum.StrEnum):
66
66
 
67
67
 
68
68
  class FootingSize(ABC):
69
- SHAPE: Shape
69
+ _SHAPE: Shape
70
70
 
71
71
  @property
72
72
  @abstractmethod
@@ -88,13 +88,14 @@ class FootingSize(ABC):
88
88
 
89
89
  @property
90
90
  def shape(self) -> Shape:
91
- return self.SHAPE
91
+ """Return the shape of the foundation footing."""
92
+ return self._SHAPE
92
93
 
93
94
 
94
95
  class StripFooting(FootingSize):
95
96
  """A class representation of strip footing."""
96
97
 
97
- SHAPE = Shape.STRIP
98
+ _SHAPE = Shape.STRIP
98
99
 
99
100
  def __init__(self, width: float, length: float = inf) -> None:
100
101
  """
@@ -109,6 +110,7 @@ class StripFooting(FootingSize):
109
110
 
110
111
  @property
111
112
  def width(self) -> float:
113
+ """Width of foundation footing (m)."""
112
114
  return self._width
113
115
 
114
116
  @width.setter
@@ -118,6 +120,7 @@ class StripFooting(FootingSize):
118
120
 
119
121
  @property
120
122
  def length(self) -> float:
123
+ """Length of foundation footing (m)."""
121
124
  return self._length
122
125
 
123
126
  @length.setter
@@ -136,7 +139,7 @@ class CircularFooting(FootingSize):
136
139
  square and rectangular footing follow.
137
140
  """
138
141
 
139
- SHAPE = Shape.CIRCLE
142
+ _SHAPE = Shape.CIRCLE
140
143
 
141
144
  def __init__(self, diameter: float):
142
145
  """
@@ -146,6 +149,7 @@ class CircularFooting(FootingSize):
146
149
 
147
150
  @property
148
151
  def diameter(self) -> float:
152
+ """Diameter of foundation footing (m)."""
149
153
  return self._diameter
150
154
 
151
155
  @diameter.setter
@@ -155,6 +159,7 @@ class CircularFooting(FootingSize):
155
159
 
156
160
  @property
157
161
  def width(self):
162
+ """Diameter of foundation footing (m)."""
158
163
  return self.diameter
159
164
 
160
165
  @width.setter
@@ -163,6 +168,7 @@ class CircularFooting(FootingSize):
163
168
 
164
169
  @property
165
170
  def length(self):
171
+ """Diameter of foundation footing (m)."""
166
172
  return self.diameter
167
173
 
168
174
  @length.setter
@@ -173,7 +179,7 @@ class CircularFooting(FootingSize):
173
179
  class SquareFooting(FootingSize):
174
180
  """A class representation of square footing."""
175
181
 
176
- SHAPE = Shape.SQUARE
182
+ _SHAPE = Shape.SQUARE
177
183
 
178
184
  def __init__(self, width: float):
179
185
  """
@@ -183,6 +189,7 @@ class SquareFooting(FootingSize):
183
189
 
184
190
  @property
185
191
  def width(self):
192
+ """Width of foundation footing (m)."""
186
193
  return self._width
187
194
 
188
195
  @width.setter
@@ -192,6 +199,7 @@ class SquareFooting(FootingSize):
192
199
 
193
200
  @property
194
201
  def length(self):
202
+ """Width of foundation footing (m)."""
195
203
  return self.width
196
204
 
197
205
  @length.setter
@@ -202,7 +210,7 @@ class SquareFooting(FootingSize):
202
210
  class RectangularFooting(FootingSize):
203
211
  """A class representation of rectangular footing."""
204
212
 
205
- SHAPE = Shape.RECTANGLE
213
+ _SHAPE = Shape.RECTANGLE
206
214
 
207
215
  def __init__(self, width: float, length: float):
208
216
  """
@@ -217,6 +225,7 @@ class RectangularFooting(FootingSize):
217
225
 
218
226
  @property
219
227
  def width(self) -> float:
228
+ """Width of foundation footing (m)."""
220
229
  return self._width
221
230
 
222
231
  @width.setter
@@ -226,6 +235,7 @@ class RectangularFooting(FootingSize):
226
235
 
227
236
  @property
228
237
  def length(self) -> float:
238
+ """Length of foundation footing (m)."""
229
239
  return self._length
230
240
 
231
241
  @length.setter
@@ -240,7 +250,8 @@ class FoundationSize:
240
250
  def __init__(self, depth: float,
241
251
  footing_size: FootingSize,
242
252
  eccentricity: float = 0.0,
243
- ground_water_level: Optional[float] = None) -> None:
253
+ ground_water_level: Optional[float] = None,
254
+ foundation_type: FoundationType = FoundationType.PAD) -> None:
244
255
  """
245
256
  :param depth: Depth of foundation (m).
246
257
  :type depth: float
@@ -258,14 +269,21 @@ class FoundationSize:
258
269
  :param ground_water_level: Depth of the water below ground level (m),
259
270
  defaults to inf.
260
271
  :type ground_water_level: float, optional
272
+
273
+ :param foundation_type: Type of foundation, defaults to
274
+ :attr:`FoundationType.PAD`
275
+ :type foundation_type: FoundationType, optional
261
276
  """
262
277
  self.depth = depth
263
278
  self.footing_size = footing_size
264
279
  self.eccentricity = eccentricity
280
+
265
281
  self._ground_water_level = ground_water_level
282
+ self._foundation_type = foundation_type
266
283
 
267
284
  @property
268
285
  def depth(self) -> float:
286
+ """Depth of foundation (m)."""
269
287
  return self._depth
270
288
 
271
289
  @depth.setter
@@ -274,7 +292,8 @@ class FoundationSize:
274
292
  self._depth = val
275
293
 
276
294
  @property
277
- def width(self):
295
+ def width(self) -> float:
296
+ """Width of foundation footing (m)."""
278
297
  return self.footing_size.width
279
298
 
280
299
  @width.setter
@@ -282,7 +301,8 @@ class FoundationSize:
282
301
  self.footing_size.width = val
283
302
 
284
303
  @property
285
- def length(self):
304
+ def length(self) -> float:
305
+ """Length of foundation footing (m)."""
286
306
  return self.footing_size.length
287
307
 
288
308
  @length.setter
@@ -290,11 +310,15 @@ class FoundationSize:
290
310
  self.footing_size.length = val
291
311
 
292
312
  @property
293
- def footing_shape(self):
313
+ def footing_shape(self) -> Shape:
314
+ """Shape of foundation footing."""
294
315
  return self.footing_size.shape
295
316
 
296
317
  @property
297
318
  def eccentricity(self) -> float:
319
+ """The deviation of the foundation load from the center of gravity of
320
+ the foundation footing.
321
+ """
298
322
  return self._eccentricity
299
323
 
300
324
  @eccentricity.setter
@@ -304,6 +328,7 @@ class FoundationSize:
304
328
 
305
329
  @property
306
330
  def ground_water_level(self) -> Optional[float]:
331
+ """Depth of the water below ground level (m)."""
307
332
  return self._ground_water_level
308
333
 
309
334
  @ground_water_level.setter
@@ -311,16 +336,19 @@ class FoundationSize:
311
336
  def ground_water_level(self, val: float) -> None:
312
337
  self._ground_water_level = val
313
338
 
339
+ @property
340
+ def foundation_type(self) -> FoundationType:
341
+ """Type of foundation."""
342
+ return self._foundation_type
343
+
314
344
  @property
315
345
  def effective_width(self) -> float:
316
346
  """Returns the effective width of the foundation footing."""
317
347
  return self.width - 2.0 * self.eccentricity
318
348
 
319
349
  def footing_params(self) -> tuple[float, float, Shape]:
320
- """Returns the ``width``, ``length``, and ``shape`` of the
321
- foundation footing.
322
-
323
- .. note:: "width" is the effective width of the foundation footing.
350
+ """Returns the :attr:`effective_width`, :attr:`length`, and
351
+ :attr:`footing_shape` of the foundation footing.
324
352
  """
325
353
  width, length, shape = self.effective_width, self.length, self.footing_shape
326
354
 
@@ -335,6 +363,7 @@ def create_foundation(depth: float,
335
363
  length: Optional[float] = None,
336
364
  eccentricity: float = 0.0,
337
365
  ground_water_level: Optional[float] = None,
366
+ foundation_type: FoundationType = FoundationType.PAD,
338
367
  shape: Shape | str = Shape.SQUARE) -> FoundationSize:
339
368
  """A factory function that encapsulate the creation of a foundation.
340
369
 
@@ -359,8 +388,12 @@ def create_foundation(depth: float,
359
388
  defaults to None.
360
389
  :type ground_water_level: float, optional
361
390
 
391
+ :param foundation_type: Type of foundation footing, defaults to
392
+ FoundationType.PAD.
393
+ :type foundation_type: FoundationType, optional
394
+
362
395
  :param shape: Shape of foundation footing, defaults to :class:`Shape.SQUARE`
363
- :type shape: Shape | str
396
+ :type shape: Shape | str, optional
364
397
 
365
398
  :raises ValueError: Raised when length is not provided for a rectangular
366
399
  footing.
@@ -371,7 +404,7 @@ def create_foundation(depth: float,
371
404
  try:
372
405
  shape = Shape(shape)
373
406
  except ValueError as e:
374
- msg = (f"{shape = } is not supported, Supported "
407
+ msg = (f"{shape=} is not supported, Supported "
375
408
  f"types are: {list(Shape)}")
376
409
 
377
410
  raise ValueError(msg) from e
@@ -390,4 +423,5 @@ def create_foundation(depth: float,
390
423
  return FoundationSize(depth=depth,
391
424
  eccentricity=eccentricity,
392
425
  ground_water_level=ground_water_level,
426
+ foundation_type=foundation_type,
393
427
  footing_size=footing_size)
@@ -15,7 +15,7 @@ Enums
15
15
  :toctree: _autosummary
16
16
  :nosignatures:
17
17
 
18
- CLF_TYPE
18
+ ClfType
19
19
  USCSSymbol
20
20
  AASHTOSymbol
21
21
 
@@ -40,12 +40,11 @@ Functions
40
40
  """
41
41
  import enum
42
42
  from abc import abstractmethod
43
- from typing import Protocol
44
- from typing import NamedTuple, Optional, Sequence
43
+ from typing import NamedTuple, Optional, Protocol, Sequence
45
44
 
46
- from geolysis.utils import enum_repr, isclose, round_, validators
45
+ from .utils import enum_repr, isclose, round_, validators
47
46
 
48
- __all__ = ["CLF_TYPE",
47
+ __all__ = ["ClfType",
49
48
  "AtterbergLimits",
50
49
  "PSD",
51
50
  "AASHTO",
@@ -163,6 +162,7 @@ class AtterbergLimits:
163
162
 
164
163
  @property
165
164
  def liquid_limit(self) -> float:
165
+ """Water content beyond which soils flows under their own weight (%)."""
166
166
  return self._liquid_limit
167
167
 
168
168
  @liquid_limit.setter
@@ -172,6 +172,7 @@ class AtterbergLimits:
172
172
 
173
173
  @property
174
174
  def plastic_limit(self) -> float:
175
+ """Water content at which plastic deformation can be initiated (%)."""
175
176
  return self._plastic_limit
176
177
 
177
178
  @plastic_limit.setter
@@ -196,9 +197,7 @@ class AtterbergLimits:
196
197
 
197
198
  @property
198
199
  def fine_material_type(self) -> USCSSymbol:
199
- """
200
- Checks whether the soil is either clay or silt.
201
- """
200
+ """Checks whether the soil is either clay or silt."""
202
201
  return USCSSymbol.CLAY if self.above_A_LINE() else USCSSymbol.SILT
203
202
 
204
203
  def above_A_LINE(self) -> bool:
@@ -440,6 +439,7 @@ class AASHTO:
440
439
 
441
440
  @property
442
441
  def fines(self) -> float:
442
+ """Percentage of fines in soil sample (%)."""
443
443
  return self._fines
444
444
 
445
445
  @fines.setter
@@ -683,18 +683,18 @@ class USCS:
683
683
  f"{coarse_material_type}{fine_material_type}")
684
684
 
685
685
 
686
+ class SoilClassifier(Protocol):
687
+ @abstractmethod
688
+ def classify(self) -> SoilClf: ...
689
+
690
+
686
691
  @enum_repr
687
- class CLF_TYPE(enum.StrEnum):
692
+ class ClfType(enum.StrEnum):
688
693
  """Enumeration of soil classification types."""
689
694
  AASHTO = enum.auto()
690
695
  USCS = enum.auto()
691
696
 
692
697
 
693
- class SoilClassifier(Protocol):
694
- @abstractmethod
695
- def classify(self) -> SoilClf: ...
696
-
697
-
698
698
  def create_soil_classifier(liquid_limit: float,
699
699
  plastic_limit: float,
700
700
  fines: float,
@@ -702,7 +702,7 @@ def create_soil_classifier(liquid_limit: float,
702
702
  d_10: float = 0, d_30: float = 0, d_60: float = 0,
703
703
  add_group_idx: bool = True,
704
704
  organic: bool = False,
705
- clf_type: Optional[CLF_TYPE | str] = None
705
+ clf_type: Optional[ClfType | str] = None
706
706
  ) -> SoilClassifier:
707
707
  """ A factory function that encapsulates the creation of a soil classifier.
708
708
 
@@ -722,17 +722,18 @@ def create_soil_classifier(liquid_limit: float,
722
722
  soil sample passing through No. 200 sieve (0.075mm).
723
723
  :type fines: float
724
724
 
725
- :param sand: Percentage of sand in soil sample (%).
726
- :type sand: float
725
+ :param sand: Percentage of sand in soil sample (%). This is optional for
726
+ :class:`AASHTO` classification.
727
+ :type sand: float, optional
727
728
 
728
729
  :param d_10: Diameter at which 10% of the soil by weight is finer.
729
- :type d_10: float
730
+ :type d_10: float, optional
730
731
 
731
732
  :param d_30: Diameter at which 30% of the soil by weight is finer.
732
- :type d_30: float
733
+ :type d_30: float, optional
733
734
 
734
735
  :param d_60: Diameter at which 60% of the soil by weight is finer.
735
- :type d_60: float
736
+ :type d_60: float, optional
736
737
 
737
738
  :param add_group_idx: Used to indicate whether the group index should
738
739
  be added to the classification or not, defaults to
@@ -744,28 +745,28 @@ def create_soil_classifier(liquid_limit: float,
744
745
 
745
746
  :param clf_type: Used to indicate which type of soil classifier should be
746
747
  used, defaults to None.
747
- :type clf_type: CLF_TYPE | str
748
+ :type clf_type: ClfType | str
748
749
 
749
750
  :raises ValueError: Raises ValueError if ``clf_type`` is not supported or
750
751
  None
751
752
  :raises ValueError: Raises ValueError if ``sand`` is not provided for
752
753
  :class:`USCS` classification.
753
754
  """
754
- msg = (f"{clf_type = } is not supported, Supported "
755
- f"types are: {list(CLF_TYPE)}")
755
+ msg = (f"{clf_type=} is not supported, Supported "
756
+ f"types are: {list(ClfType)}")
756
757
 
757
758
  if clf_type is None:
758
759
  raise ValueError(msg)
759
760
 
760
761
  try:
761
- clf_type = CLF_TYPE(str(clf_type).casefold())
762
+ clf_type = ClfType(str(clf_type).casefold())
762
763
  except ValueError as e:
763
764
  raise ValueError(msg) from e
764
765
 
765
766
  atterberg_lmts = AtterbergLimits(liquid_limit=liquid_limit,
766
767
  plastic_limit=plastic_limit)
767
768
 
768
- if clf_type == CLF_TYPE.AASHTO:
769
+ if clf_type == ClfType.AASHTO:
769
770
  clf = AASHTO(atterberg_limits=atterberg_lmts,
770
771
  fines=fines,
771
772
  add_group_idx=add_group_idx)