Skip to content

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
merged 17 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

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

Expand Down
10 changes: 10 additions & 0 deletions docs/geos-geomechanics.rst
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
4 changes: 4 additions & 0 deletions docs/geos_geomechanics_docs/home.rst
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.
19 changes: 19 additions & 0 deletions docs/geos_geomechanics_docs/model.rst
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:
10 changes: 10 additions & 0 deletions docs/geos_geomechanics_docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
GEOS geomechanics tools
=========================

.. toctree::
:maxdepth: 5

model

processing

11 changes: 11 additions & 0 deletions docs/geos_geomechanics_docs/processing.rst
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:
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Packages

geos-posp

geos-geomechanics

geos-timehistory

geos-utils
Expand Down
56 changes: 56 additions & 0 deletions geos-geomechanics/pyproject.toml
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 = [
Copy link
Contributor

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

"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"]
13 changes: 13 additions & 0 deletions geos-geomechanics/setup.py
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.
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 ) )
Loading