-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Adding a fault stability analysis workflow #232
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
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
763c6c6
Adding the code as is
paloma-martinez 6a95227
Split and change to camel case
paloma-martinez 2fc08a8
Merge branch 'main' into pmartinez/feature/faultStabilityVisu
paloma-martinez 237d21a
First pass of typing
paloma-martinez 7520eba
Removing Config due to problematic circular imports
paloma-martinez 94e2c65
Migration pyvista to vtk
paloma-martinez 79da00e
Clean and add logger and doc
paloma-martinez f6cb474
Merge branch 'main' into pmartinez/feature/faultStabilityVisu
paloma-martinez 6a89e8c
Missing docstring
paloma-martinez 525681a
Typing & linting
paloma-martinez 9e06935
Fix import
paloma-martinez 712aa0e
Add filter and tools to doc and fix doc build
paloma-martinez 373749e
First pass following review
paloma-martinez 2db9b6b
Second pass of review
paloma-martinez 54f58ef
Removing emoticons
paloma-martinez b57e398
Clean logger
paloma-martinez 0823b64
fix doc build
paloma-martinez e9f227c
Merge branch 'main' into pmartinez/feature/faultStabilityVisu
paloma-martinez 4ab0795
Changes folloing review
paloma-martinez d5ab0fa
Changes folloing review
paloma-martinez 1720150
Merge remote-tracking branch 'refs/remotes/origin/pmartinez/feature/f…
paloma-martinez 0abc275
Merge branch 'main' into pmartinez/feature/faultStabilityVisu
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
geos-geomechanics/src/geos/geomechanics/model/StressTensor.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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright 2023-2026 TotalEnergies. | ||
| # SPDX-FileContributor: Nicolas Pillardou, Paloma Martinez | ||
|
|
||
| import numpy as np | ||
| import numpy.typing as npt | ||
| from typing_extensions import Any | ||
|
|
||
|
|
||
| # ============================================================================ | ||
| # STRESS TENSOR OPERATIONS | ||
| # ============================================================================ | ||
| class StressTensor: | ||
| """Utility class for stress tensor operations.""" | ||
|
|
||
| @staticmethod | ||
| def buildFromArray( arr: npt.NDArray[ np.float64 ] ) -> npt.NDArray[ np.float64 ]: | ||
| """Convert stress array to 3x3 tensor format. | ||
|
|
||
| Args: | ||
| arr ( npt.NDArray[np.float64]): Array to convert. | ||
|
|
||
| Returns: | ||
| npt.NDArray[np.float64]: 3x3 converted stress tensor. | ||
| """ | ||
| n = arr.shape[ 0 ] | ||
| tensors: npt.NDArray[ np.float64 ] = np.zeros( ( n, 3, 3 ), dtype=np.float64 ) | ||
|
|
||
| if arr.shape[ 1 ] == 6: # Voigt notation | ||
| tensors[ :, 0, 0 ] = arr[ :, 0 ] # Sxx | ||
| tensors[ :, 1, 1 ] = arr[ :, 1 ] # Syy | ||
| tensors[ :, 2, 2 ] = arr[ :, 2 ] # Szz | ||
| tensors[ :, 1, 2 ] = tensors[ :, 2, 1 ] = arr[ :, 3 ] # Syz | ||
| tensors[ :, 0, 2 ] = tensors[ :, 2, 0 ] = arr[ :, 4 ] # Sxz | ||
| tensors[ :, 0, 1 ] = tensors[ :, 1, 0 ] = arr[ :, 5 ] # Sxy | ||
| elif arr.shape[ 1 ] == 9: | ||
| tensors = arr.reshape( ( -1, 3, 3 ) ) | ||
| else: | ||
| raise ValueError( f"Unsupported stress shape: {arr.shape}" ) | ||
|
|
||
| return tensors | ||
|
|
||
| @staticmethod | ||
| def rotateToFaultFrame( stressTensorArr: npt.NDArray[ np.float64 ], normal: npt.NDArray[ np.float64 ], | ||
| tangent1: npt.NDArray[ np.float64 ], | ||
| tangent2: npt.NDArray[ np.float64 ] ) -> dict[ str, Any ]: | ||
| """Rotate stress tensor to fault local coordinate system. | ||
|
|
||
| Args: | ||
| stressTensorArr (npt.NDArray[np.float64]): Stress tensor to rotate. | ||
| normal (npt.NDArray[np.float64]): Surface normal vectors. | ||
| tangent1 (npt.NDArray[np.float64]): Surface tangents vectors 1. | ||
| tangent2 (npt.NDArray[np.float64])): Surface tangents vectors 2. | ||
|
|
||
| Returns: | ||
| dict[str, Any]: Dictionary containing local stress, normal stress, shear stress and strike and shear dip. | ||
| """ | ||
| # Verify orthonormality | ||
| assert np.abs( np.linalg.norm( tangent1 ) - 1.0 ) < 1e-10, f"T1 - {np.abs( np.linalg.norm( tangent1 ) - 1.0 )}" | ||
| assert np.abs( np.linalg.norm( tangent2 ) - 1.0 ) < 1e-10, f"T2 - {np.abs( np.linalg.norm( tangent2 ) - 1.0 )}" | ||
| assert np.abs( np.dot( normal, tangent1 ) ) < 1e-10 | ||
| assert np.abs( np.dot( normal, tangent2 ) ) < 1e-10 | ||
|
|
||
| # Rotation matrix: columns = local directions (n, t1, t2) | ||
| R = np.column_stack( ( normal, tangent1, tangent2 ) ) | ||
|
|
||
| # Rotate tensor | ||
| stressLocal = R.T @ stressTensorArr @ R | ||
|
|
||
| # Traction on fault plane (normal = [1,0,0] in local frame) | ||
| tractionLocal = stressLocal @ np.array( [ 1.0, 0.0, 0.0 ] ) | ||
|
|
||
| return { | ||
| 'stressLocal': stressLocal, | ||
| 'normalStress': tractionLocal[ 0 ], | ||
| 'shearStress': np.sqrt( tractionLocal[ 1 ]**2 + tractionLocal[ 2 ]**2 ), | ||
| 'shearStrike': tractionLocal[ 1 ], | ||
| 'shearDip': tractionLocal[ 2 ] | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ dependencies = [ | |
| "vtk >= 9.3, < 9.6", | ||
| "numpy >= 2.2", | ||
| "typing_extensions >= 4.12", | ||
| "scipy", | ||
| ] | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.