-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Create geos-geomechanics package #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexbenedicto
merged 17 commits into
main
from
pmartinez/feature/geos_geomechanics_package
Apr 4, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6c152c2
Move geomechanics processes to dedicated package
paloma-martinez 5dbbf94
Update dependencies
paloma-martinez 708f5a7
Move tests to geomechanics package
paloma-martinez 9f306fd
Update build process
paloma-martinez eadd1d0
Merge branch 'main' into pmartinez/feature/geos_geomechanics_package
paloma-martinez d3710b6
Merge branch 'main' into pmartinez/feature/geos_geomechanics_package
paloma-martinez cd64f59
Correction to build process
paloma-martinez 9a7aad5
Update documentation
paloma-martinez 37364c1
Build typo and missing files
paloma-martinez 4c2cf4b
Doc automodule typo
paloma-martinez 1cbda7b
Add module path to sys path for PV plugins
paloma-martinez 101b7d7
Typo in module import
paloma-martinez 0750d96
Fix import path and move line to top of file
paloma-martinez 87a7764
Merge branch 'main' into pmartinez/feature/geos_geomechanics_package
paloma-martinez 4424031
linting
paloma-martinez 86c8920
Fix doc
paloma-martinez 7fdd8c3
Consistency with other packages pyproject.toml
paloma-martinez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
GEOS Post-Processing tools | ||
============================= | ||
|
||
.. toctree:: | ||
:maxdepth: 5 | ||
:caption: Contents: | ||
|
||
./geos_geomechanics_docs/home.rst | ||
|
||
./geos_geomechanics_docs/modules.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
GEOS Geomechanics Tools | ||
========================= | ||
|
||
This package contains geomechanics functions and data models. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Geomechanics models | ||
====================== | ||
This | ||
|
||
geos.geomechanics.model.MohrCircle module | ||
------------------------------------------ | ||
|
||
.. automodule:: geos.geomechanics.model.MohrCircle | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
geos.geomechanics.model.MohrCoulomb module | ||
------------------------------------------- | ||
|
||
.. automodule:: geos.geomechanics.model.MohrCoulomb | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
GEOS geomechanics tools | ||
========================= | ||
|
||
.. toctree:: | ||
:maxdepth: 5 | ||
|
||
model | ||
|
||
processing | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Processing | ||
============ | ||
The processing part of `geos-geomechanics` package contains functions tools to compute geomechanical properties. | ||
|
||
geos.geomechanics.processing.geomechanicsCalculatorFunctions module | ||
--------------------------------------------------------------------- | ||
|
||
.. automodule:: geos.geomechanics.processing.geomechanicsCalculatorFunctions | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,8 @@ Packages | |
|
||
geos-posp | ||
|
||
geos-geomechanics | ||
|
||
geos-timehistory | ||
|
||
geos-utils | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.2"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
include-package-data = true | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["src"] | ||
include = ["geos_geomechanics*"] | ||
exclude = ['tests*'] | ||
|
||
[project] | ||
name = "geos-geomechanics" | ||
version = "0.1.0" | ||
description = "Geomechanics models and processing tools" | ||
authors = [{name = "GEOS contributors" }] | ||
maintainers = [{name = "Martin Lemay", email = "[email protected]"}] | ||
license = {text = "Apache-2.0"} | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Programming Language :: Python" | ||
] | ||
dynamic = ["dependencies"] | ||
requires-python = ">= 3.10" | ||
|
||
[project.optional-dependencies] | ||
build = [ | ||
"build ~= 1.2" | ||
] | ||
dev = [ | ||
"yapf", | ||
"mypy", | ||
] | ||
test = [ | ||
"pytest", | ||
] | ||
|
||
[project.scripts] | ||
|
||
|
||
[tool.pytest.ini_options] | ||
addopts = "--import-mode=importlib" | ||
console_output_style = "count" | ||
pythonpath = ["src"] | ||
python_classes = "Test" | ||
python_files = "test*.py" | ||
python_functions = "test*" | ||
testpaths = ["tests"] | ||
norecursedirs = "bin" | ||
filterwarnings = [] | ||
|
||
|
||
[tool.coverage.run] | ||
branch = true | ||
source = ["src/geos"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from pathlib import Path | ||
from setuptools import setup | ||
|
||
# This is where you add any fancy path resolution to the local lib: | ||
geos_utils_path: str = ( Path( __file__ ).parent.parent / "geos-utils" ).as_uri() | ||
|
||
setup( install_requires=[ | ||
"vtk >= 9.3", | ||
"numpy >= 1.26", | ||
"pandas >= 2.2", | ||
"typing_extensions >= 4.12", | ||
f"geos-utils @ {geos_utils_path}", | ||
] ) |
Empty file.
234 changes: 115 additions & 119 deletions
234
...sp/src/geos_posp/processing/MohrCircle.py → ...src/geos/geomechanics/model/MohrCircle.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,115 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies. | ||
# SPDX-FileContributor: Alexandre Benedicto, Martin Lemay | ||
import numpy as np | ||
import numpy.typing as npt | ||
from typing_extensions import Self | ||
|
||
from geos_posp.processing.geomechanicsCalculatorFunctions import ( | ||
computeStressPrincipalComponentsFromStressVector, | ||
) | ||
|
||
__doc__ = """ | ||
MohrCircle module define the Mohr's circle parameters. | ||
|
||
Inputs are a 6 component stress vector, a circle id, and the mechanical | ||
convention used for compression. | ||
The class computes principal components from stress vector during initialization. | ||
Accessors get access to these 3 principal components as well as circle center | ||
and radius. | ||
|
||
To use the object: | ||
|
||
.. code-block:: python | ||
|
||
from processing.MohrCircle import MohrCircle | ||
|
||
# create the object | ||
stressVector :npt.NDArray[np.float64] | ||
circleId :str | ||
mohrCircle :MohrCircle = MohrCircle(circleId) | ||
|
||
# either directly set principal components (p3 <= p2 <= p1) | ||
mohrCircle.SetPrincipalComponents(p3, p2, p1) | ||
# or compute them from stress vector | ||
mohrCircle.computePrincipalComponents(stressVector) | ||
|
||
# access to members | ||
id :str = mohrCircle.getCircleId() | ||
p1, p2, p3 :float = mohrCircle.getPrincipalComponents() | ||
radius :float = mohrCircle.getCircleRadius() | ||
center :float = mohrCircle.getCircleCenter() | ||
""" | ||
|
||
|
||
class MohrCircle: | ||
def __init__(self: Self, circleId: str) -> None: | ||
"""Compute Mohr's Circle from input stress. | ||
|
||
Args: | ||
circleId (str): Mohr's circle id. | ||
""" | ||
self.m_circleId: str = circleId | ||
|
||
self.m_p1: float = 0.0 | ||
self.m_p2: float = 0.0 | ||
self.m_p3: float = 0.0 | ||
|
||
def __str__(self: Self) -> str: | ||
"""Overload of __str__ method.""" | ||
return self.m_circleId | ||
|
||
def __repr__(self: Self) -> str: | ||
"""Overload of __repr__ method.""" | ||
return self.m_circleId | ||
|
||
def setCircleId(self: Self, circleId: str) -> None: | ||
"""Set circle Id variable. | ||
|
||
Args: | ||
circleId (str): circle Id. | ||
""" | ||
self.m_circleId = circleId | ||
|
||
def getCircleId(self: Self) -> str: | ||
"""Access the Id of the Mohr circle. | ||
|
||
Returns: | ||
str: Id of the Mohr circle | ||
""" | ||
return self.m_circleId | ||
|
||
def getCircleRadius(self: Self) -> float: | ||
"""Compute and return Mohr's circle radius from principal components.""" | ||
return (self.m_p1 - self.m_p3) / 2.0 | ||
|
||
def getCircleCenter(self: Self) -> float: | ||
"""Compute and return Mohr's circle center from principal components.""" | ||
return (self.m_p1 + self.m_p3) / 2.0 | ||
|
||
def getPrincipalComponents(self: Self) -> tuple[float, float, float]: | ||
"""Get Moh's circle principal components.""" | ||
return (self.m_p3, self.m_p2, self.m_p1) | ||
|
||
def setPrincipalComponents(self: Self, p3: float, p2: float, p1: float) -> None: | ||
"""Set principal components. | ||
|
||
Args: | ||
p3 (float): first component. Must be the lowest. | ||
p2 (float): second component. | ||
p1 (float): third component. Must be the greatest. | ||
""" | ||
assert (p3 <= p2) and (p2 <= p1), "Component order is wrong." | ||
self.m_p3 = p3 | ||
self.m_p2 = p2 | ||
self.m_p1 = p1 | ||
|
||
def computePrincipalComponents( | ||
self: Self, stressVector: npt.NDArray[np.float64] | ||
) -> None: | ||
"""Calculate principal components. | ||
|
||
Args: | ||
stressVector (npt.NDArray[np.float64]): 6 components stress vector | ||
Stress vector must follow GEOS convention (XX, YY, ZZ, YZ, XZ, XY) | ||
""" | ||
# get stress principal components | ||
self.m_p3, self.m_p2, self.m_p1 = ( | ||
computeStressPrincipalComponentsFromStressVector(stressVector) | ||
) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies. | ||
# SPDX-FileContributor: Alexandre Benedicto, Martin Lemay | ||
import numpy as np | ||
import numpy.typing as npt | ||
from typing_extensions import Self | ||
|
||
from geos.geomechanics.processing.geomechanicsCalculatorFunctions import ( | ||
computeStressPrincipalComponentsFromStressVector, ) | ||
|
||
__doc__ = """ | ||
MohrCircle module define the Mohr's circle parameters. | ||
|
||
Inputs are a 6 component stress vector, a circle id, and the mechanical | ||
convention used for compression. | ||
The class computes principal components from stress vector during initialization. | ||
Accessors get access to these 3 principal components as well as circle center | ||
and radius. | ||
|
||
To use the object: | ||
|
||
.. code-block:: python | ||
|
||
from processing.MohrCircle import MohrCircle | ||
|
||
# create the object | ||
stressVector :npt.NDArray[np.float64] | ||
circleId :str | ||
mohrCircle :MohrCircle = MohrCircle(circleId) | ||
|
||
# either directly set principal components (p3 <= p2 <= p1) | ||
mohrCircle.SetPrincipalComponents(p3, p2, p1) | ||
# or compute them from stress vector | ||
mohrCircle.computePrincipalComponents(stressVector) | ||
|
||
# access to members | ||
id :str = mohrCircle.getCircleId() | ||
p1, p2, p3 :float = mohrCircle.getPrincipalComponents() | ||
radius :float = mohrCircle.getCircleRadius() | ||
center :float = mohrCircle.getCircleCenter() | ||
""" | ||
|
||
|
||
class MohrCircle: | ||
|
||
def __init__( self: Self, circleId: str ) -> None: | ||
"""Compute Mohr's Circle from input stress. | ||
|
||
Args: | ||
circleId (str): Mohr's circle id. | ||
""" | ||
self.m_circleId: str = circleId | ||
|
||
self.m_p1: float = 0.0 | ||
self.m_p2: float = 0.0 | ||
self.m_p3: float = 0.0 | ||
|
||
def __str__( self: Self ) -> str: | ||
"""Overload of __str__ method.""" | ||
return self.m_circleId | ||
|
||
def __repr__( self: Self ) -> str: | ||
"""Overload of __repr__ method.""" | ||
return self.m_circleId | ||
|
||
def setCircleId( self: Self, circleId: str ) -> None: | ||
"""Set circle Id variable. | ||
|
||
Args: | ||
circleId (str): circle Id. | ||
""" | ||
self.m_circleId = circleId | ||
|
||
def getCircleId( self: Self ) -> str: | ||
"""Access the Id of the Mohr circle. | ||
|
||
Returns: | ||
str: Id of the Mohr circle | ||
""" | ||
return self.m_circleId | ||
|
||
def getCircleRadius( self: Self ) -> float: | ||
"""Compute and return Mohr's circle radius from principal components.""" | ||
return ( self.m_p1 - self.m_p3 ) / 2.0 | ||
|
||
def getCircleCenter( self: Self ) -> float: | ||
"""Compute and return Mohr's circle center from principal components.""" | ||
return ( self.m_p1 + self.m_p3 ) / 2.0 | ||
|
||
def getPrincipalComponents( self: Self ) -> tuple[ float, float, float ]: | ||
"""Get Moh's circle principal components.""" | ||
return ( self.m_p3, self.m_p2, self.m_p1 ) | ||
|
||
def setPrincipalComponents( self: Self, p3: float, p2: float, p1: float ) -> None: | ||
"""Set principal components. | ||
|
||
Args: | ||
p3 (float): first component. Must be the lowest. | ||
p2 (float): second component. | ||
p1 (float): third component. Must be the greatest. | ||
""" | ||
assert ( p3 <= p2 ) and ( p2 <= p1 ), "Component order is wrong." | ||
self.m_p3 = p3 | ||
self.m_p2 = p2 | ||
self.m_p1 = p1 | ||
|
||
def computePrincipalComponents( self: Self, stressVector: npt.NDArray[ np.float64 ] ) -> None: | ||
"""Calculate principal components. | ||
|
||
Args: | ||
stressVector (npt.NDArray[np.float64]): 6 components stress vector | ||
Stress vector must follow GEOS convention (XX, YY, ZZ, YZ, XZ, XY) | ||
""" | ||
# get stress principal components | ||
self.m_p3, self.m_p2, self.m_p1 = ( computeStressPrincipalComponentsFromStressVector( stressVector ) ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need only mypy and yapf packages