geolysis 0.3.0__py3-none-any.whl → 0.4.3__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,543 +0,0 @@
1
- import enum
2
- from abc import abstractmethod
3
- from dataclasses import dataclass
4
- from typing import Optional, Protocol
5
-
6
- from .utils import PI, round_
7
-
8
- __all__ = [
9
- "create_footing",
10
- "create_foundation",
11
- "CircularFooting",
12
- "SquareFooting",
13
- "RectangularFooting",
14
- "FootingSize",
15
- "FoundationSize",
16
- ]
17
-
18
-
19
- class FootingCreationError(TypeError):
20
- pass
21
-
22
-
23
- class Shape(enum.IntEnum):
24
- CIRCLE = enum.auto()
25
- SQUARE = enum.auto()
26
- RECTANGLE = enum.auto()
27
-
28
-
29
- class _FootingShape(Protocol):
30
- @property
31
- @abstractmethod
32
- def width(self) -> float: ...
33
-
34
- @width.setter
35
- def width(self, __val: float): ...
36
-
37
- @property
38
- @abstractmethod
39
- def length(self) -> float: ...
40
-
41
- @length.setter
42
- def length(self, __val: float): ...
43
-
44
- @property
45
- @abstractmethod
46
- def area(self) -> float: ...
47
-
48
- @property
49
- @abstractmethod
50
- def perimeter(self) -> float: ...
51
-
52
-
53
- @dataclass
54
- class CircularFooting:
55
- """A class representation of circular footing.
56
-
57
- Parameters
58
- ----------
59
- diameter : float, m
60
- Diameter of foundation footing.
61
-
62
- Attributes
63
- ----------
64
- width : float, m
65
- length : float, m
66
- area : float, :math:`m^2`
67
- perimeter : float, m
68
-
69
- See Also
70
- --------
71
- SquareFooting, RectangularFooting
72
-
73
- Notes
74
- -----
75
- The ``width`` and ``length`` properties refer to the diameter
76
- of the circular footing. This is to make it compatible with the
77
- protocol square and rectangular footing follow.
78
-
79
- Examples
80
- --------
81
- >>> from geolysis.core.foundation import CircularFooting
82
- >>> circ_footing = CircularFooting(diameter=1.2)
83
- >>> circ_footing.diameter
84
- 1.2
85
- >>> circ_footing.width
86
- 1.2
87
- >>> circ_footing.length
88
- 1.2
89
- >>> circ_footing.area
90
- 1.131
91
- >>> circ_footing.perimeter
92
- 3.7699
93
- """
94
-
95
- diameter: float
96
-
97
- @property
98
- def width(self) -> float:
99
- """Diameter of foundation footing."""
100
- return self.diameter
101
-
102
- @width.setter
103
- def width(self, __val: float):
104
- self.diameter = __val
105
-
106
- @property
107
- def length(self) -> float:
108
- """Diameter of foundation footing."""
109
- return self.diameter
110
-
111
- @length.setter
112
- def length(self, __val: float):
113
- self.diameter = __val
114
-
115
- @property
116
- @round_
117
- def area(self) -> float:
118
- """Area of circular footing. |rarr| :math:`m^2`"""
119
- return PI * (self.diameter**2) / 4
120
-
121
- @property
122
- @round_
123
- def perimeter(self) -> float:
124
- """Perimeter of circular footing. |rarr| m"""
125
- return PI * self.diameter
126
-
127
-
128
- @dataclass
129
- class SquareFooting:
130
- """A class representation of square footing.
131
-
132
- Parameters
133
- ----------
134
- width : float, m
135
- Width of foundation footing.
136
-
137
- Attributes
138
- ----------
139
- length : float, m
140
- area : float, :math:`m^2`
141
- perimeter : float, m
142
-
143
- See Also
144
- --------
145
- CircularFooting, RectangularFooting
146
-
147
- Examples
148
- --------
149
- >>> from geolysis.core.foundation import SquareFooting
150
- >>> sq_footing = SquareFooting(width=1.2)
151
- >>> sq_footing.width
152
- 1.2
153
- >>> sq_footing.length
154
- 1.2
155
- >>> sq_footing.area
156
- 1.44
157
- >>> sq_footing.perimeter
158
- 4.8
159
- """
160
-
161
- width: float
162
-
163
- @property
164
- def length(self) -> float:
165
- """Length of foundation footing."""
166
- return self.width
167
-
168
- @length.setter
169
- def length(self, __val: float):
170
- self.width = __val
171
-
172
- @property
173
- @round_
174
- def area(self) -> float:
175
- """Area of square footing. |rarr| :math:`m^2`"""
176
- return self.width**2
177
-
178
- @property
179
- @round_
180
- def perimeter(self) -> float:
181
- """Perimeter of square footing. |rarr| m"""
182
- return 4 * self.width
183
-
184
-
185
- @dataclass
186
- class RectangularFooting:
187
- """A class representation of rectangular footing.
188
-
189
- Parameters
190
- ----------
191
- width : float, m
192
- Width of foundation footing.
193
- length : float, m
194
- Length of foundation footing.
195
-
196
- Attributes
197
- ----------
198
- area : float, :math:`m^2`
199
- perimeter : float, m
200
-
201
- See Also
202
- --------
203
- CircularFooting, SquareFooting
204
-
205
- Examples
206
- --------
207
- >>> from geolysis.core.foundation import RectangularFooting
208
- >>> rect_footing = RectangularFooting(width=1.2, length=1.4)
209
- >>> rect_footing.width
210
- 1.2
211
- >>> rect_footing.length
212
- 1.4
213
- >>> rect_footing.area
214
- 1.68
215
- >>> rect_footing.perimeter
216
- 5.2
217
- """
218
-
219
- width: float
220
- length: float
221
-
222
- @property
223
- @round_
224
- def area(self) -> float:
225
- """Area of rectangular footing. |rarr| :math:`m^2`"""
226
- return self.length * self.width
227
-
228
- @property
229
- @round_
230
- def perimeter(self) -> float:
231
- """Perimeter of rectangular footing. |rarr| m"""
232
- return 2 * (self.length + self.width)
233
-
234
-
235
- @dataclass
236
- class FootingSize:
237
- """Size of foundation footing.
238
-
239
- Parameters
240
- ----------
241
- thickness : float, m
242
- Thickness of foundation footing.
243
- footing_shape : _FootingShape
244
- Shape of foundation footing.
245
-
246
- Attributes
247
- ----------
248
- width : float, m
249
- length : float, m
250
- area : float, :math:`m^2`
251
- perimeter : float, m
252
- volume : float, :math:`m^3`
253
-
254
- See Also
255
- --------
256
- FoundationSize
257
-
258
- Examples
259
- --------
260
- >>> from geolysis.core.foundation import FootingSize, SquareFooting
261
- >>> footing_shape = SquareFooting(width=1.2)
262
- >>> footing_size = FootingSize(thickness=0.45, footing_shape=footing_shape)
263
- >>> footing_size.thickness
264
- 0.45
265
- >>> footing_size.width
266
- 1.2
267
- >>> footing_size.length
268
- 1.2
269
- >>> footing_size.area
270
- 1.44
271
- >>> footing_size.perimeter
272
- 4.8
273
- >>> footing_size.volume
274
- 0.648
275
- """
276
-
277
- thickness: float
278
- footing_shape: _FootingShape
279
-
280
- @property
281
- def width(self) -> float:
282
- """Width of foundation footing."""
283
- return self.footing_shape.width
284
-
285
- @width.setter
286
- def width(self, __val: float):
287
- self.footing_shape.width = __val
288
-
289
- @property
290
- def length(self) -> float:
291
- """Length of foundation footing."""
292
- return self.footing_shape.length
293
-
294
- @length.setter
295
- def length(self, __val: float):
296
- self.footing_shape.length = __val
297
-
298
- @property
299
- def area(self) -> float:
300
- """Area of foundation footing. |rarr| :math:`m^2`"""
301
- return self.footing_shape.area
302
-
303
- @property
304
- def perimeter(self) -> float:
305
- """Perimeter of foundation footing. |rarr| m"""
306
- return self.footing_shape.perimeter
307
-
308
- @property
309
- @round_
310
- def volume(self) -> float:
311
- """Volume of foundation footing. |rarr| :math:`m^3`"""
312
- return self.area * self.thickness
313
-
314
-
315
- @dataclass
316
- class FoundationSize:
317
- """A simple class representing a foundation structure.
318
-
319
- Parameters
320
- ----------
321
- depth : float, m
322
- Depth of foundation.
323
- footing_size : FootingSize
324
- Represents the size of the foundation footing.
325
-
326
- Attributes
327
- ----------
328
- thickness : float, m
329
- width : float, m
330
- length : float, m
331
- footing_shape : _FootingShape
332
- area : float, :math:`m^2`
333
- perimeter : float, metre
334
- volume : float, :math:`m^3`
335
-
336
- See Also
337
- --------
338
- FootingSize
339
-
340
- Examples
341
- --------
342
- >>> from geolysis.core.foundation import (FoundationSize, CircularFooting,
343
- ... Shape, create_footing)
344
- >>> footing_size = create_footing(thickness=0.45, width=1.2,
345
- ... footing_shape=Shape.SQUARE)
346
- >>> foundation_size = FoundationSize(depth=1.5, footing_size=footing_size)
347
- >>> foundation_size.depth
348
- 1.5
349
- >>> foundation_size.thickness
350
- 0.45
351
- >>> foundation_size.length
352
- 1.2
353
- >>> foundation_size.width
354
- 1.2
355
- >>> foundation_size.area
356
- 1.44
357
- >>> foundation_size.perimeter
358
- 4.8
359
- >>> foundation_size.volume
360
- 2.16
361
- """
362
-
363
- depth: float
364
- footing_size: FootingSize
365
-
366
- @property
367
- def thickness(self) -> float:
368
- """Thickness of foundation footing."""
369
- return self.footing_size.thickness
370
-
371
- @thickness.setter
372
- def thickness(self, __val: float):
373
- self.footing_size.thickness = __val
374
-
375
- @property
376
- def width(self) -> float:
377
- """Width of foundation footing."""
378
- return self.footing_size.width
379
-
380
- @width.setter
381
- def width(self, __val: float):
382
- self.footing_size.width = __val
383
-
384
- @property
385
- def length(self) -> float:
386
- """Length of foundation footing."""
387
- return self.footing_size.length
388
-
389
- @length.setter
390
- def length(self, __val: float):
391
- self.footing_size.length = __val
392
-
393
- @property
394
- def footing_shape(self) -> _FootingShape:
395
- """Represents the shape of the foundation footing."""
396
- return self.footing_size.footing_shape
397
-
398
- @footing_shape.setter
399
- def footing_shape(self, __val: _FootingShape):
400
- self.footing_size.footing_shape = __val
401
-
402
- @property
403
- def area(self) -> float:
404
- """Area of foundation. |rarr| :math:`m^2`"""
405
- return self.footing_size.area
406
-
407
- @property
408
- def perimeter(self) -> float:
409
- """Perimeter of foundation. |rarr| m"""
410
- return self.footing_size.perimeter
411
-
412
- @property
413
- @round_
414
- def volume(self) -> float:
415
- """Volume of foundation. |rarr| :math:`m^3`"""
416
- return self.area * self.depth
417
-
418
-
419
- def create_footing(
420
- thickness: float,
421
- width: float,
422
- length: Optional[float] = None,
423
- footing_shape: Shape = Shape.SQUARE,
424
- ) -> FootingSize:
425
- """A factory function that encapsulate the creation of a foundation
426
- footing.
427
-
428
- Parameters
429
- ----------
430
- thickness : float, m
431
- Thickness of foundation footing.
432
- width : float, m
433
- Width of foundation footing.
434
- length : float, optional, m
435
- Length of foundation footing.
436
- footing_shape : Shape, default=Shape.SQUARE
437
- Shape of foundation footing.
438
-
439
- Returns
440
- -------
441
- FootingSize
442
- Size of foundation footing.
443
-
444
- Raises
445
- ------
446
- FootingCreationError
447
- Exception raised when footing is not created successfully.
448
-
449
- Examples
450
- --------
451
- >>> from geolysis.core.foundation import create_footing, Shape
452
- >>> square_footing = create_footing(thickness=0.3, width=1.2,
453
- ... footing_shape=Shape.SQUARE)
454
- >>> square_footing
455
- FootingSize(thickness=0.3, footing_shape=SquareFooting(width=1.2))
456
- >>> square_footing.footing_shape
457
- SquareFooting(width=1.2)
458
-
459
- >>> circ_footing = create_footing(thickness=0.4, width=1.4,
460
- ... footing_shape=Shape.CIRCLE)
461
- >>> circ_footing
462
- FootingSize(thickness=0.4, footing_shape=CircularFooting(diameter=1.4))
463
- >>> circ_footing.footing_shape
464
- CircularFooting(diameter=1.4)
465
-
466
- >>> rect_footing = create_footing(thickness=0.5, width=1.3, length=1.4,
467
- ... footing_shape=Shape.RECTANGLE)
468
- >>> rect_footing
469
- FootingSize(thickness=0.5, footing_shape=RectangularFooting(width=1.3, length=1.4))
470
- >>> rect_footing.footing_shape
471
- RectangularFooting(width=1.3, length=1.4)
472
- """
473
- _footing_shape: _FootingShape
474
-
475
- match footing_shape:
476
- case Shape.SQUARE:
477
- _footing_shape = SquareFooting(width=width)
478
- case Shape.CIRCLE:
479
- _footing_shape = CircularFooting(diameter=width)
480
- case Shape.RECTANGLE:
481
- if length:
482
- _footing_shape = RectangularFooting(width=width, length=length)
483
- else:
484
- err_msg = "The length of the footing must be provided"
485
- raise FootingCreationError(err_msg)
486
- case _:
487
- err_msg = (
488
- "Supported footing shapes are SQUARE, RECTANGLE, and CIRCLE"
489
- )
490
- raise FootingCreationError(err_msg)
491
-
492
- return FootingSize(thickness=thickness, footing_shape=_footing_shape)
493
-
494
-
495
- def create_foundation(
496
- depth: float,
497
- thickness: float,
498
- width: float,
499
- length: Optional[float] = None,
500
- footing_shape: Shape = Shape.SQUARE,
501
- ) -> FoundationSize:
502
- """A factory function that encapsulate the creation of a foundation.
503
-
504
- Parameters
505
- ----------
506
- depth : float, m
507
- Depth of foundation.
508
- thickness : float, m
509
- Thickness of foundation footing.
510
- width : float, m
511
- Width of foundation footing.
512
- length : float, optional, m
513
- Length of foundation footing.
514
- footing_shape : Shape, default=Shape.SQUARE
515
- Shape of foundation footing.
516
-
517
- Returns
518
- -------
519
- FootingSize
520
- Size of foundation footing.
521
-
522
- Raises
523
- ------
524
- FootingCreationError
525
- Exception raised when footing is not created successfully.
526
-
527
- Examples
528
- --------
529
- >>> from geolysis.core.foundation import Shape, create_foundation
530
- >>> foundation_size = create_foundation(depth=1.5, thickness=0.3,
531
- ... width=1.2, footing_shape=Shape.SQUARE)
532
- >>> foundation_size.depth
533
- 1.5
534
- >>> foundation_size.thickness
535
- 0.3
536
- >>> foundation_size.width
537
- 1.2
538
- >>> foundation_size.length
539
- 1.2
540
- """
541
-
542
- footing_size = create_footing(thickness, width, length, footing_shape)
543
- return FoundationSize(depth, footing_size)