Skip to content

Commit db95441

Browse files
refactor: Create geos-geomechanics package (#66)
* Move geomechanics processes to dedicated package * Update dependencies * Move tests to geomechanics package * Update build process * Correction to build process * Update documentation * Build typo and missing files * Doc automodule typo * Add module path to sys path for PV plugins * Typo in module import * Fix import path and move line to top of file * linting * Fix doc * Consistency with other packages pyproject.toml
1 parent 610898b commit db95441

27 files changed

+1824
-1920
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
# Add python modules to be documented
1919
python_root = '..'
20-
python_modules = ( 'geos-ats', 'geos-mesh', 'geos-posp', 'geos-timehistory', 'geos-utils', 'geos-xml-tools',
21-
'hdf5-wrapper', 'pygeos-tools' )
20+
python_modules = ( 'geos-ats', 'geos-mesh', 'geos-posp', 'geos-timehistory', 'geos-utils', 'geos-xml-tools', 'hdf5-wrapper',
21+
'pygeos-tools', 'geos-geomechanics' )
2222
for m in python_modules:
2323
sys.path.insert( 0, os.path.abspath( os.path.join( python_root, m, 'src' ) ) )
2424

docs/geos-geomechanics.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
GEOS Post-Processing tools
2+
=============================
3+
4+
.. toctree::
5+
:maxdepth: 5
6+
:caption: Contents:
7+
8+
./geos_geomechanics_docs/home.rst
9+
10+
./geos_geomechanics_docs/modules.rst

docs/geos_geomechanics_docs/home.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GEOS Geomechanics Tools
2+
=========================
3+
4+
This package contains geomechanics functions and data models.

docs/geos_geomechanics_docs/model.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Geomechanics models
2+
======================
3+
This
4+
5+
geos.geomechanics.model.MohrCircle module
6+
------------------------------------------
7+
8+
.. automodule:: geos.geomechanics.model.MohrCircle
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:
12+
13+
geos.geomechanics.model.MohrCoulomb module
14+
-------------------------------------------
15+
16+
.. automodule:: geos.geomechanics.model.MohrCoulomb
17+
:members:
18+
:undoc-members:
19+
:show-inheritance:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
GEOS geomechanics tools
2+
=========================
3+
4+
.. toctree::
5+
:maxdepth: 5
6+
7+
model
8+
9+
processing
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Processing
2+
============
3+
The processing part of `geos-geomechanics` package contains functions tools to compute geomechanical properties.
4+
5+
geos.geomechanics.processing.geomechanicsCalculatorFunctions module
6+
---------------------------------------------------------------------
7+
8+
.. automodule:: geos.geomechanics.processing.geomechanicsCalculatorFunctions
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Packages
8484

8585
geos-posp
8686

87+
geos-geomechanics
88+
8789
geos-timehistory
8890

8991
geos-utils

geos-geomechanics/pyproject.toml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[build-system]
2+
requires = ["setuptools>=61.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools]
6+
include-package-data = true
7+
8+
[tool.setuptools.packages.find]
9+
where = ["src"]
10+
include = ["geos_geomechanics*"]
11+
exclude = ['tests*']
12+
13+
[project]
14+
name = "geos-geomechanics"
15+
version = "0.1.0"
16+
description = "Geomechanics models and processing tools"
17+
authors = [{name = "GEOS contributors" }]
18+
maintainers = [{name = "Martin Lemay", email = "[email protected]"}]
19+
license = {text = "Apache-2.0"}
20+
classifiers = [
21+
"Development Status :: 4 - Beta",
22+
"Programming Language :: Python"
23+
]
24+
dynamic = ["dependencies"]
25+
requires-python = ">= 3.10"
26+
27+
[project.optional-dependencies]
28+
build = [
29+
"build ~= 1.2"
30+
]
31+
dev = [
32+
"yapf",
33+
"mypy",
34+
]
35+
test = [
36+
"pytest",
37+
]
38+
39+
[project.scripts]
40+
41+
42+
[tool.pytest.ini_options]
43+
addopts = "--import-mode=importlib"
44+
console_output_style = "count"
45+
pythonpath = ["src"]
46+
python_classes = "Test"
47+
python_files = "test*.py"
48+
python_functions = "test*"
49+
testpaths = ["tests"]
50+
norecursedirs = "bin"
51+
filterwarnings = []
52+
53+
54+
[tool.coverage.run]
55+
branch = true
56+
source = ["src/geos"]

geos-geomechanics/setup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pathlib import Path
2+
from setuptools import setup
3+
4+
# This is where you add any fancy path resolution to the local lib:
5+
geos_utils_path: str = ( Path( __file__ ).parent.parent / "geos-utils" ).as_uri()
6+
7+
setup( install_requires=[
8+
"vtk >= 9.3",
9+
"numpy >= 1.26",
10+
"pandas >= 2.2",
11+
"typing_extensions >= 4.12",
12+
f"geos-utils @ {geos_utils_path}",
13+
] )

geos-geomechanics/src/geos/geomechanics/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,115 @@
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

Comments
 (0)