|
1 |
| -# SPDX-License-Identifier: Apache-2.0 |
2 |
| -# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies. |
3 |
| -# SPDX-FileContributor: Alexandre Benedicto, Martin Lemay |
4 |
| -import numpy as np |
5 |
| -import numpy.typing as npt |
6 |
| -from typing_extensions import Self |
7 |
| - |
8 |
| -from geos_posp.processing.geomechanicsCalculatorFunctions import ( |
9 |
| - computeStressPrincipalComponentsFromStressVector, |
10 |
| -) |
11 |
| - |
12 |
| -__doc__ = """ |
13 |
| -MohrCircle module define the Mohr's circle parameters. |
14 |
| -
|
15 |
| -Inputs are a 6 component stress vector, a circle id, and the mechanical |
16 |
| -convention used for compression. |
17 |
| -The class computes principal components from stress vector during initialization. |
18 |
| -Accessors get access to these 3 principal components as well as circle center |
19 |
| -and radius. |
20 |
| -
|
21 |
| -To use the object: |
22 |
| -
|
23 |
| -.. code-block:: python |
24 |
| -
|
25 |
| - from processing.MohrCircle import MohrCircle |
26 |
| -
|
27 |
| - # create the object |
28 |
| - stressVector :npt.NDArray[np.float64] |
29 |
| - circleId :str |
30 |
| - mohrCircle :MohrCircle = MohrCircle(circleId) |
31 |
| -
|
32 |
| - # either directly set principal components (p3 <= p2 <= p1) |
33 |
| - mohrCircle.SetPrincipalComponents(p3, p2, p1) |
34 |
| - # or compute them from stress vector |
35 |
| - mohrCircle.computePrincipalComponents(stressVector) |
36 |
| -
|
37 |
| - # access to members |
38 |
| - id :str = mohrCircle.getCircleId() |
39 |
| - p1, p2, p3 :float = mohrCircle.getPrincipalComponents() |
40 |
| - radius :float = mohrCircle.getCircleRadius() |
41 |
| - center :float = mohrCircle.getCircleCenter() |
42 |
| -""" |
43 |
| - |
44 |
| - |
45 |
| -class MohrCircle: |
46 |
| - def __init__(self: Self, circleId: str) -> None: |
47 |
| - """Compute Mohr's Circle from input stress. |
48 |
| -
|
49 |
| - Args: |
50 |
| - circleId (str): Mohr's circle id. |
51 |
| - """ |
52 |
| - self.m_circleId: str = circleId |
53 |
| - |
54 |
| - self.m_p1: float = 0.0 |
55 |
| - self.m_p2: float = 0.0 |
56 |
| - self.m_p3: float = 0.0 |
57 |
| - |
58 |
| - def __str__(self: Self) -> str: |
59 |
| - """Overload of __str__ method.""" |
60 |
| - return self.m_circleId |
61 |
| - |
62 |
| - def __repr__(self: Self) -> str: |
63 |
| - """Overload of __repr__ method.""" |
64 |
| - return self.m_circleId |
65 |
| - |
66 |
| - def setCircleId(self: Self, circleId: str) -> None: |
67 |
| - """Set circle Id variable. |
68 |
| -
|
69 |
| - Args: |
70 |
| - circleId (str): circle Id. |
71 |
| - """ |
72 |
| - self.m_circleId = circleId |
73 |
| - |
74 |
| - def getCircleId(self: Self) -> str: |
75 |
| - """Access the Id of the Mohr circle. |
76 |
| -
|
77 |
| - Returns: |
78 |
| - str: Id of the Mohr circle |
79 |
| - """ |
80 |
| - return self.m_circleId |
81 |
| - |
82 |
| - def getCircleRadius(self: Self) -> float: |
83 |
| - """Compute and return Mohr's circle radius from principal components.""" |
84 |
| - return (self.m_p1 - self.m_p3) / 2.0 |
85 |
| - |
86 |
| - def getCircleCenter(self: Self) -> float: |
87 |
| - """Compute and return Mohr's circle center from principal components.""" |
88 |
| - return (self.m_p1 + self.m_p3) / 2.0 |
89 |
| - |
90 |
| - def getPrincipalComponents(self: Self) -> tuple[float, float, float]: |
91 |
| - """Get Moh's circle principal components.""" |
92 |
| - return (self.m_p3, self.m_p2, self.m_p1) |
93 |
| - |
94 |
| - def setPrincipalComponents(self: Self, p3: float, p2: float, p1: float) -> None: |
95 |
| - """Set principal components. |
96 |
| -
|
97 |
| - Args: |
98 |
| - p3 (float): first component. Must be the lowest. |
99 |
| - p2 (float): second component. |
100 |
| - p1 (float): third component. Must be the greatest. |
101 |
| - """ |
102 |
| - assert (p3 <= p2) and (p2 <= p1), "Component order is wrong." |
103 |
| - self.m_p3 = p3 |
104 |
| - self.m_p2 = p2 |
105 |
| - self.m_p1 = p1 |
106 |
| - |
107 |
| - def computePrincipalComponents( |
108 |
| - self: Self, stressVector: npt.NDArray[np.float64] |
109 |
| - ) -> None: |
110 |
| - """Calculate principal components. |
111 |
| -
|
112 |
| - Args: |
113 |
| - stressVector (npt.NDArray[np.float64]): 6 components stress vector |
114 |
| - Stress vector must follow GEOS convention (XX, YY, ZZ, YZ, XZ, XY) |
115 |
| - """ |
116 |
| - # get stress principal components |
117 |
| - self.m_p3, self.m_p2, self.m_p1 = ( |
118 |
| - computeStressPrincipalComponentsFromStressVector(stressVector) |
119 |
| - ) |
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies. |
| 3 | +# SPDX-FileContributor: Alexandre Benedicto, Martin Lemay |
| 4 | +import numpy as np |
| 5 | +import numpy.typing as npt |
| 6 | +from typing_extensions import Self |
| 7 | + |
| 8 | +from geos.geomechanics.processing.geomechanicsCalculatorFunctions import ( |
| 9 | + computeStressPrincipalComponentsFromStressVector, ) |
| 10 | + |
| 11 | +__doc__ = """ |
| 12 | +MohrCircle module define the Mohr's circle parameters. |
| 13 | +
|
| 14 | +Inputs are a 6 component stress vector, a circle id, and the mechanical |
| 15 | +convention used for compression. |
| 16 | +The class computes principal components from stress vector during initialization. |
| 17 | +Accessors get access to these 3 principal components as well as circle center |
| 18 | +and radius. |
| 19 | +
|
| 20 | +To use the object: |
| 21 | +
|
| 22 | +.. code-block:: python |
| 23 | +
|
| 24 | + from processing.MohrCircle import MohrCircle |
| 25 | +
|
| 26 | + # create the object |
| 27 | + stressVector :npt.NDArray[np.float64] |
| 28 | + circleId :str |
| 29 | + mohrCircle :MohrCircle = MohrCircle(circleId) |
| 30 | +
|
| 31 | + # either directly set principal components (p3 <= p2 <= p1) |
| 32 | + mohrCircle.SetPrincipalComponents(p3, p2, p1) |
| 33 | + # or compute them from stress vector |
| 34 | + mohrCircle.computePrincipalComponents(stressVector) |
| 35 | +
|
| 36 | + # access to members |
| 37 | + id :str = mohrCircle.getCircleId() |
| 38 | + p1, p2, p3 :float = mohrCircle.getPrincipalComponents() |
| 39 | + radius :float = mohrCircle.getCircleRadius() |
| 40 | + center :float = mohrCircle.getCircleCenter() |
| 41 | +""" |
| 42 | + |
| 43 | + |
| 44 | +class MohrCircle: |
| 45 | + |
| 46 | + def __init__( self: Self, circleId: str ) -> None: |
| 47 | + """Compute Mohr's Circle from input stress. |
| 48 | +
|
| 49 | + Args: |
| 50 | + circleId (str): Mohr's circle id. |
| 51 | + """ |
| 52 | + self.m_circleId: str = circleId |
| 53 | + |
| 54 | + self.m_p1: float = 0.0 |
| 55 | + self.m_p2: float = 0.0 |
| 56 | + self.m_p3: float = 0.0 |
| 57 | + |
| 58 | + def __str__( self: Self ) -> str: |
| 59 | + """Overload of __str__ method.""" |
| 60 | + return self.m_circleId |
| 61 | + |
| 62 | + def __repr__( self: Self ) -> str: |
| 63 | + """Overload of __repr__ method.""" |
| 64 | + return self.m_circleId |
| 65 | + |
| 66 | + def setCircleId( self: Self, circleId: str ) -> None: |
| 67 | + """Set circle Id variable. |
| 68 | +
|
| 69 | + Args: |
| 70 | + circleId (str): circle Id. |
| 71 | + """ |
| 72 | + self.m_circleId = circleId |
| 73 | + |
| 74 | + def getCircleId( self: Self ) -> str: |
| 75 | + """Access the Id of the Mohr circle. |
| 76 | +
|
| 77 | + Returns: |
| 78 | + str: Id of the Mohr circle |
| 79 | + """ |
| 80 | + return self.m_circleId |
| 81 | + |
| 82 | + def getCircleRadius( self: Self ) -> float: |
| 83 | + """Compute and return Mohr's circle radius from principal components.""" |
| 84 | + return ( self.m_p1 - self.m_p3 ) / 2.0 |
| 85 | + |
| 86 | + def getCircleCenter( self: Self ) -> float: |
| 87 | + """Compute and return Mohr's circle center from principal components.""" |
| 88 | + return ( self.m_p1 + self.m_p3 ) / 2.0 |
| 89 | + |
| 90 | + def getPrincipalComponents( self: Self ) -> tuple[ float, float, float ]: |
| 91 | + """Get Moh's circle principal components.""" |
| 92 | + return ( self.m_p3, self.m_p2, self.m_p1 ) |
| 93 | + |
| 94 | + def setPrincipalComponents( self: Self, p3: float, p2: float, p1: float ) -> None: |
| 95 | + """Set principal components. |
| 96 | +
|
| 97 | + Args: |
| 98 | + p3 (float): first component. Must be the lowest. |
| 99 | + p2 (float): second component. |
| 100 | + p1 (float): third component. Must be the greatest. |
| 101 | + """ |
| 102 | + assert ( p3 <= p2 ) and ( p2 <= p1 ), "Component order is wrong." |
| 103 | + self.m_p3 = p3 |
| 104 | + self.m_p2 = p2 |
| 105 | + self.m_p1 = p1 |
| 106 | + |
| 107 | + def computePrincipalComponents( self: Self, stressVector: npt.NDArray[ np.float64 ] ) -> None: |
| 108 | + """Calculate principal components. |
| 109 | +
|
| 110 | + Args: |
| 111 | + stressVector (npt.NDArray[np.float64]): 6 components stress vector |
| 112 | + Stress vector must follow GEOS convention (XX, YY, ZZ, YZ, XZ, XY) |
| 113 | + """ |
| 114 | + # get stress principal components |
| 115 | + self.m_p3, self.m_p2, self.m_p1 = ( computeStressPrincipalComponentsFromStressVector( stressVector ) ) |
0 commit comments