-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Python interfaces to geos from Makutu repo (refactoring) #74
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 62 commits into
main
from
origin/feature/benedicto/rework_makutu_pygeos_tools
Apr 17, 2025
Merged
Changes from 57 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
7f9fa60
Created utils repository and updated every import for mesh_doctor
alexbenedicto c7bc10a
Messages correction in io
alexbenedicto 1948f60
All the initial files from the Makutu PR are added for future refacto…
alexbenedicto 50c6f02
Refactoring mesh files
alexbenedicto 7fa1d04
Moved solverutils to utils
alexbenedicto 7cae0cd
Modified model directory structure + renamed vtkUtils into pyevtk_tools
alexbenedicto b3a8637
Adding acoustic / elastic modeling tools
alexbenedicto 6735025
Merge branch 'main' of https://github.com/GEOS-DEV/geosPythonPackages…
alexbenedicto 9bd7c4d
Correction exports and module names for pygeos-tools
alexbenedicto 3bbfbd7
Change imports for geos-mesh
alexbenedicto 5972c30
Support processing of included XML files
av-novikov cb666e4
Fix to wave prop modeling in p4 and p3. Also fix to allow use of pyth…
Victor-M-Gomes 6ab34ef
Bug fix for io with VtkOutput
alexbenedicto d4a08bb
Format update io and GeosxArgs
alexbenedicto 5990979
Error handling for class methods
alexbenedicto e1110db
Update XML class
alexbenedicto 0166a7f
Update Solver base class with also the use of wrapper file
alexbenedicto 9530ffc
Update WaveSolver
alexbenedicto 7ea90d2
Update AcousticSolver
alexbenedicto bba1762
bug fix
alexbenedicto 14ae4cb
Add minTime and maxTime handling
alexbenedicto 55f6804
Update ElasticSolver
alexbenedicto bf3a827
Update ReservoirSolver
alexbenedicto 512156e
Update GeomechanicsSolver
alexbenedicto bf3be8e
Update hinting of variables and methods
alexbenedicto ccb6b57
Add examples of scripts to pilot a GEOS simulation through pygeos usi…
alexbenedicto c8fa6dc
Add __doc__ at the beginning of scritps
alexbenedicto 0112ad4
Moved examples inside utilities
alexbenedicto 2ec5997
Change examples folder to solvers-examples
alexbenedicto 176b03f
Moved all files outside of "utilities" folder and remove utilities fo…
alexbenedicto e124dbf
Update format of acquisition_library files
alexbenedicto f3ab221
Update format of Trace outputs
alexbenedicto f0f4e04
Update pyproject.toml
alexbenedicto 762d100
Added .rst documentation
alexbenedicto 6924879
Merge remote-tracking branch 'refs/remotes/origin/origin/feature/bene…
alexbenedicto 2a3b83d
yapf formatting
alexbenedicto b0af0d6
Merge remote-tracking branch 'origin/main' into origin/feature/benedi…
alexbenedicto 1d83a2d
yapf formatting + change minimum python version to 3.8
alexbenedicto b91259e
For pygeos-tools: update documentation, removed geos-utils/pygeos-too…
alexbenedicto 85fc721
Move geos.utils.vtk to geos.mesh.vtk
alexbenedicto 2adecdd
Update geos-mesh tests
alexbenedicto 4c7e8bc
Update docs for pygeos-tools to remove warnings
alexbenedicto 4ef5c35
Merge remote-tracking branch 'origin/main' into origin/feature/benedi…
alexbenedicto 9555339
Exclude build directory when processing mypy checks + removed ruff ch…
alexbenedicto 8b4aa25
Bugfix for tests + yapf formatting
alexbenedicto 2d2bcb0
Merge remote-tracking branch 'origin/main' into origin/feature/benedi…
alexbenedicto a48b6cb
Remove conflict between ruff and mypy checking in classes.py
alexbenedicto fdce1fa
Fix build projects with invalid path
alexbenedicto 5d9faef
Update documentation
alexbenedicto 8ea6146
Merge remote-tracking branch 'origin/main' into origin/feature/benedi…
alexbenedicto 0c5959b
Move checking of xml file from __init__ to initialize method
alexbenedicto 95a4dff
Add examples for ReactiveCompositionalMultiphaseOBL solver
av-novikov c3edf00
Merge remote-tracking branch 'origin/main' into origin/feature/benedi…
alexbenedicto 940e27e
Upgrade python version to 3.10
alexbenedicto 3c26d90
Remove examples to check if CI cache build error still occurs
alexbenedicto a79a9b8
Merge remote-tracking branch 'origin/main' into origin/feature/benedi…
alexbenedicto 4306dce
Readded the examples for obl provided by Aleks Novikov + moved all ex…
alexbenedicto d05f90b
Fix name of the *.xml in 2ph_comp example
av-novikov 7950e43
Fix timestepping in OBL solver examples
av-novikov a62cf92
Rename folder with OBL examples
av-novikov d4db9e6
Updated example.rst and yapf formatting
alexbenedicto 5d5ce74
Fix write_mesh
alexbenedicto 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 |
|---|---|---|
| @@ -1,24 +1,47 @@ | ||
|
|
||
| PyGEOS Tools | ||
| -------------------------- | ||
| ============= | ||
|
|
||
| The `pygeos-tools` python package adds a variety of tools for working with pygeosx objects. | ||
| These include common operations such as setting the value of geosx wrappers with python functions, parallel communication, and file IO. | ||
| Examples using these tools can be found here: `PYGEOSX Examples <https://geosx-geosx.readthedocs-hosted.com/en/latest/docs/sphinx/advancedExamples/pygeosxExamples/Index.html>`_ . | ||
|
|
||
| To get the pygeosx objects, you need to build your GEOS with pygeosx, using this command in your cmake file. | ||
|
|
||
| API | ||
| ^^^^^ | ||
| .. code-block:: cmake | ||
|
|
||
| .. automodule:: geos.pygeos_tools.wrapper | ||
| :members: | ||
| set(ENABLE_PYGEOSX ON CACHE BOOL "") | ||
|
|
||
| .. automodule:: geos.pygeos_tools.file_io | ||
| :members: | ||
|
|
||
| .. automodule:: geos.pygeos_tools.mesh_interpolation | ||
| :members: | ||
| **The python used to build GEOS with pygeosx will be the python to build the pygeos-tools.** | ||
| Once the correct python is selected, you need to run in your virtual environment. | ||
|
|
||
| .. automodule:: geos.pygeos_tools.well_log | ||
| :members: | ||
| .. code-block:: console | ||
|
|
||
| python -m pip install ./pygeos-tools/ | ||
|
|
||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :caption: Contents | ||
|
|
||
| ./pygeos_tools_docs/api.rst | ||
|
|
||
| ./pygeos_tools_docs/acquisition_library.rst | ||
|
|
||
| ./pygeos_tools_docs/input.rst | ||
|
|
||
| ./pygeos_tools_docs/mesh.rst | ||
|
|
||
| ./pygeos_tools_docs/model.rst | ||
|
|
||
| ./pygeos_tools_docs/output.rst | ||
|
|
||
| ./pygeos_tools_docs/solvers.rst | ||
|
|
||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :caption: Example | ||
|
|
||
| ./pygeos_tools_docs/Example/reservoir.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,166 @@ | ||
| ################################################################################# | ||
| Driving a reservoir simulation with Pygeos | ||
| ################################################################################# | ||
|
|
||
|
|
||
| **Context** | ||
|
|
||
| In this example, we will use pygeos to control a CompositionalMultiphaseFVM solver throughout a GEOS simulation. | ||
| The goal is to reproduce the same results as if the simulation was launched directly through the XML file. | ||
|
|
||
| For the rest of this example, every part highlighting Python snippets will represent what is used to control pygeos and | ||
| how it is linked to the XML file. | ||
|
|
||
| The example python script for this documentation is the following: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| pygeos-tools/examples/solvers/reservoir_modeling.py | ||
|
|
||
|
|
||
| ------------------------------------------------------------------ | ||
| XML file and initialization of Solver object | ||
| ------------------------------------------------------------------ | ||
|
|
||
|
|
||
| The xml input file for the test case is located at: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| /path/to/your/GEOS/src/inputFiles/compositionalMultiphaseFlow/2ph_cap_1d_ihu.xml | ||
|
|
||
|
|
||
| After setting up the MPI communication and parsing all the args, we can set the XML object that has parsed our XML file. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| xmlfile = args.xml | ||
| xml = XML( xmlfile ) | ||
|
|
||
|
|
||
| **Solver** | ||
|
|
||
| The simulation is performed using the GEOS general-purpose multiphase flow solver. | ||
| The solver can be found in the ``Solvers`` block. | ||
|
|
||
| .. code-block:: xml | ||
|
|
||
| <Solvers gravityVector="{0.38268, 0., -0.92388}"> | ||
|
|
||
| <CompositionalMultiphaseFVM | ||
| name="compflow" | ||
| logLevel="1" | ||
| discretization="fluidTPFA" | ||
| targetRegions="{ Region1 }" | ||
| temperature="297.15"> | ||
|
|
||
| <NonlinearSolverParameters | ||
| newtonTol="5e-4" | ||
| lineSearchAction="None" | ||
| newtonMaxIter="15"/> | ||
|
|
||
| <LinearSolverParameters | ||
| directParallel="0"/> | ||
|
|
||
| </CompositionalMultiphaseFVM> | ||
|
|
||
| </Solvers> | ||
|
|
||
|
|
||
| The important thing to note here is the solver type ``CompositionalMultiphaseFVM``. | ||
| Because we are dealing with a flow solver, which is not coupled, we can use the ``ReservoirSolver`` class to pilot the simulation. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| solver = ReservoirSolver( "CompositionalMultiphaseFVM" ) | ||
| solver.initialize( rank=rank, xml=xml ) | ||
| solver.applyInitialConditions() | ||
|
|
||
|
|
||
| **Events** | ||
|
|
||
| To trigger the timestepping of the solver and the different outputs to perform, the "Events" block is the following: | ||
|
|
||
| .. code-block:: xml | ||
|
|
||
| <Events | ||
| maxTime="1.0368e8"> | ||
|
|
||
| <PeriodicEvent | ||
| name="outputs" | ||
| timeFrequency="1.728e6" | ||
| target="/Outputs/vtkOutput"/> | ||
|
|
||
| <PeriodicEvent | ||
| name="solverApplications1" | ||
| forceDt="1.728e6" | ||
| target="/Solvers/compflow"/> | ||
|
|
||
| <PeriodicEvent | ||
| name="restarts" | ||
| timeFrequency="3e7" | ||
| targetExactTimestep="0" | ||
| target="/Outputs/restartOutput"/> | ||
|
|
||
| </Events> | ||
|
|
||
|
|
||
| The first attribute to use is ``maxTime`` which will be the limit for the simulation. | ||
| The ``solverApplications1`` event targets the ``CompositionalMultiphaseFVM`` solver that we are using. | ||
| This block contains a ``forceDt`` attribute that will be used later to choose as the timestep of the simulation. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| solver.setDtFromTimeVariable( "forceDt" ) # solver.dt = 1.728e6 | ||
| solver.setMaxTime( solver.getTimeVariables()[ "maxTime" ] ) # solver.maxTime = 1.0368e8 | ||
|
|
||
|
|
||
| The "outputs" event triggers the output of the vtk files. The attribute "timeFrequency" has the same value as "forceDt" | ||
| so we can use the same timestep for the solver and the outputs. | ||
| To start, we will set the time to 0.0 and trigger one output of the vtk files. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| time = 0.0 | ||
| solver.outputVtk( time ) | ||
|
|
||
|
|
||
| ------------------------------------------------------------------ | ||
| Iterations process and simulation end | ||
| ------------------------------------------------------------------ | ||
|
|
||
| The iterative process organizes the execution of the solver at each timestep while not exceeding the maxTime of the simulation. | ||
| Once done, the simulation is ended by calling the ``cleanup`` method. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| while time < solver.maxTime: | ||
| solver.execute( time ) | ||
| solver.outputVtk( time ) | ||
| time += solver.dt | ||
| solver.cleanup( time ) | ||
|
|
||
|
|
||
| More complex timestepping strategies can be implemented by modifying the timestep duration and the outputs. | ||
|
|
||
|
|
||
| ------------------------------------------------------------------ | ||
| How to run that script | ||
| ------------------------------------------------------------------ | ||
|
|
||
| Using the same python used to build your GEOS installation with, run this command: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| python pygeos-tools/examples/solvers/reservoir_modeling.py | ||
| --xml /path/to/your/GEOS/src/inputFiles/compositionalMultiphaseFlow/2ph_cap_1d_ihu.xml | ||
|
|
||
|
|
||
| ------------------------------------------------------------------ | ||
| To go further | ||
| ------------------------------------------------------------------ | ||
|
|
||
|
|
||
| **Feedback on this example** | ||
|
|
||
| For any feedback on this example, please submit a `GitHub issue on the project's GitHub page <https://github.com/GEOS-DEV/geosPythonPackages/issues>`_. |
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,37 @@ | ||
| Acquisition library | ||
| =================== | ||
|
|
||
| This package contain utilities for seismic acquisition. | ||
|
|
||
|
|
||
| Acquisition | ||
| ----------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.acquisition_library.Acquisition | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| EquispacedAcquisition | ||
| --------------------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.acquisition_library.EquispacedAcquisition | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| SegyAcquisition | ||
| --------------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.acquisition_library.SegyAcquisition | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| Shot | ||
| ---- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.acquisition_library.Shot | ||
| :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,35 @@ | ||
| API | ||
| ==== | ||
|
|
||
|
|
||
| Wrapper | ||
| ------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.wrapper | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| File IO | ||
| ------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.file_io | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| Mesh Interpolation | ||
| ------------------ | ||
|
|
||
| .. automodule:: geos.pygeos_tools.mesh_interpolation | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| Well Log | ||
| -------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.well_log | ||
| :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,23 @@ | ||
| Input | ||
| ===== | ||
|
|
||
| This packages has utilities for handling the two principal arguments of GEOS: | ||
| - the XML file that will be used to setup GEOS simulation | ||
| - the Geos args which are -i input, partitions ... | ||
|
|
||
|
|
||
| GeosxArgs | ||
| --------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.input.GeosxArgs | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| Xml | ||
| --- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.input.Xml | ||
| :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,23 @@ | ||
| Mesh | ||
| ==== | ||
|
|
||
| This packages has utilities to handle the two different mesh formats to use in GEOS: | ||
| - InternalMesh that is provided by GEOS | ||
| - VtkMesh that is imported by GEOS | ||
|
|
||
|
|
||
| InternalMesh | ||
| ------------ | ||
|
|
||
| .. automodule:: geos.pygeos_tools.mesh.InternalMesh | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| VtkMesh | ||
| ------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.mesh.VtkMesh | ||
| :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,27 @@ | ||
| Model | ||
| ===== | ||
|
|
||
|
|
||
| pyevtk_tools | ||
| ------------ | ||
|
|
||
| .. automodule:: geos.pygeos_tools.model.pyevtk_tools | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| SepModel | ||
| -------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.model.SepModel | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
|
|
||
| VtkModel | ||
| -------- | ||
|
|
||
| .. automodule:: geos.pygeos_tools.model.VtkModel | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
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.
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.
Since the doc for pygeos-examples is generic and is not related to a specific python file, I am not sure having pygeos_tools_docs /Example/reservoir.rst is necessary. Maybe a example.rst file in pygeos_tools_docs is ok.