-
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 1 commit
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
213 changes: 213 additions & 0 deletions
213
pygeos-tools/examples/obl/2ph_comp/input_file_adaptative.xml
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,213 @@ | ||
| <?xml version="1.0"?> | ||
| <Problem> | ||
| <Solvers> | ||
| <ReactiveCompositionalMultiphaseOBL | ||
| name="compflow" | ||
| logLevel="1" | ||
| discretization="fluidTPFA" | ||
| targetRegions="{Region1}" | ||
| enableEnergyBalance="0" | ||
| maxCompFractionChange="1" | ||
| numComponents="3" | ||
| numPhases="2" | ||
| transMultExp="1"> | ||
| <NonlinearSolverParameters | ||
| timeStepDecreaseFactor="0.5" | ||
| newtonTol="0.0001" | ||
| newtonMaxIter="25"/> | ||
| <LinearSolverParameters | ||
| directParallel="0"/> | ||
| </ReactiveCompositionalMultiphaseOBL> | ||
| </Solvers> | ||
|
|
||
| <Mesh> | ||
| <InternalMesh | ||
| name="mesh1" | ||
| elementTypes="{C3D8}" | ||
| xCoords="{0.0, 500.0}" | ||
| yCoords="{0.0, 500.0}" | ||
| zCoords="{0.0, 20.0}" | ||
| nx="{25}" | ||
| ny="{25}" | ||
| nz="{1}" | ||
| cellBlockNames="{block1}"/> | ||
| </Mesh> | ||
|
|
||
| <Geometry> | ||
| <Box | ||
| name="inj1" | ||
| xMin="{-0.2, -0.2, -0.2}" | ||
| xMax="{20.2, 20.2, 20.2}"/> | ||
| <Box | ||
| name="prd1" | ||
| xMin="{479.8, 479.8, -0.1999999999999993}" | ||
| xMax="{500.2, 500.2, 20.2}"/> | ||
| </Geometry> | ||
|
|
||
| <Constitutive> | ||
| <CompressibleSolidConstantPermeability | ||
| name="rock" | ||
| solidModelName="nullSolid" | ||
| porosityModelName="rockPorosity" | ||
| permeabilityModelName="rockPerm"/> | ||
| <NullModel | ||
| name="nullSolid"/> | ||
| <PressurePorosity | ||
| name="rockPorosity" | ||
| defaultReferencePorosity="0.3" | ||
| referencePressure="5000000.0" | ||
| compressibility="1e-09"/> | ||
| <ConstantPermeability | ||
| name="rockPerm" | ||
| permeabilityComponents="{9.869e-14, 9.869e-14, 9.869e-14}"/> | ||
| <OBLFluid | ||
| name="fluid" | ||
| interpolatorMode="adaptive" | ||
| interpolatorType="multilinear"/> | ||
| </Constitutive> | ||
|
|
||
| <Events | ||
| maxTime="31536000.0"> | ||
| <!--PeriodicEvent | ||
| name="outputs" | ||
| timeFrequency="2592000.0" | ||
| target="/Outputs/vtkOutput"/--> | ||
| <PeriodicEvent | ||
| name="solver_1" | ||
| forceDt="86400.0" | ||
| endTime="604800.0" | ||
| target="/Solvers/compflow"/> | ||
| <PeriodicEvent | ||
| name="solver_2" | ||
| forceDt="1209600.0" | ||
| beginTime="604800.0" | ||
| target="/Solvers/compflow"/> | ||
| </Events> | ||
|
|
||
| <Outputs> | ||
| <VTK name="vtkOutput"/> | ||
| </Outputs> | ||
|
|
||
| <NumericalMethods> | ||
| <FiniteVolume> | ||
| <TwoPointFluxApproximation name="fluidTPFA"/> | ||
| </FiniteVolume> | ||
| </NumericalMethods> | ||
|
|
||
| <ElementRegions> | ||
| <CellElementRegion | ||
| name="Region1" | ||
| cellBlocks="{block1}" | ||
| materialList="{rock, fluid}"/> | ||
| </ElementRegions> | ||
|
|
||
| <FieldSpecifications> | ||
| <FieldSpecification | ||
| name="Region1InitialPressure" | ||
| initialCondition="1" | ||
| setNames="{ all }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="pressure" | ||
| scale="5000000.0"/> | ||
| <FieldSpecification | ||
| name="Region1InitialTemp" | ||
| initialCondition="1" | ||
| setNames="{ all }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="temperature" | ||
| scale="348.15"/> | ||
| <FieldSpecification | ||
| name="Region1InitCO2" | ||
| initialCondition="1" | ||
| setNames="{ all }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="0" | ||
| scale="0.1"/> | ||
| <FieldSpecification | ||
| name="Region1InitC1" | ||
| initialCondition="1" | ||
| setNames="{ all }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="1" | ||
| scale="0.2"/> | ||
| <FieldSpecification | ||
| name="Region1InitH2O" | ||
| initialCondition="1" | ||
| setNames="{ all }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="2" | ||
| scale="0.7"/> | ||
|
|
||
| <FieldSpecification | ||
| name="inj1Pressure" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="pressure" | ||
| scale="14000000.0" | ||
| setNames="{ inj1 }"/> | ||
| <FieldSpecification | ||
| name="inj1TermTemp" | ||
| setNames="{ inj1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="temperature" | ||
| scale="348.15"/> | ||
| <FieldSpecification | ||
| name="inj1CO2" | ||
| setNames="{ inj1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="0" | ||
| scale="0.99999998"/> | ||
| <FieldSpecification | ||
| name="inj1C1" | ||
| setNames="{ inj1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="1" | ||
| scale="1e-08"/> | ||
| <FieldSpecification | ||
| name="inj1H2O" | ||
| setNames="{ inj1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="2" | ||
| scale="1e-08"/> | ||
|
|
||
| <FieldSpecification | ||
| name="prd1Pressure" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="pressure" | ||
| scale="5000000.0" | ||
| setNames="{ prd1 }"/> | ||
| <FieldSpecification | ||
| name="prd1TermTemp" | ||
| setNames="{ prd1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="temperature" | ||
| scale="348.15"/> | ||
| <FieldSpecification | ||
| name="prd1CO2" | ||
| setNames="{ prd1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="0" | ||
| scale="0.99999998"/> | ||
| <FieldSpecification | ||
| name="prd1C1" | ||
| setNames="{ prd1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="1" | ||
| scale="1e-08"/> | ||
| <FieldSpecification | ||
| name="prd1H2O" | ||
| setNames="{ prd1 }" | ||
| objectPath="ElementRegions/Region1" | ||
| fieldName="globalCompFraction" | ||
| component="2" | ||
| scale="1e-08"/> | ||
| </FieldSpecifications> | ||
|
|
||
| </Problem> |
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,117 @@ | ||
| # ------------------------------------------------------------------------------------------------------------ | ||
| # SPDX-License-Identifier: LGPL-2.1-only | ||
| # | ||
| # Copyright (c) 2016-2024 Lawrence Livermore National Security LLC | ||
| # Copyright (c) 2018-2024 TotalEnergies | ||
| # Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University | ||
| # Copyright (c) 2023-2024 Chevron | ||
| # Copyright (c) 2019- GEOS/GEOSX Contributors | ||
| # Copyright (c) 2019- INRIA project-team Makutu | ||
| # All rights reserved | ||
| # | ||
| # See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. | ||
| # ------------------------------------------------------------------------------------------------------------ | ||
|
|
||
| # ---------------------------------------- README ---------------------------------------- | ||
| # Requires 'python -m pip install open-darts' and GEOS branch feature/anovikov/adaptive_obl | ||
| # to run this example. | ||
| # This is two-phase three-component model with fluid defined by constant K values. | ||
|
|
||
| import numpy as np | ||
| from mpi4py import MPI | ||
|
|
||
| from geos.pygeos_tools.input import XML | ||
| from geos.pygeos_tools.solvers import ReservoirSolver | ||
|
|
||
| from darts.models.darts_model import DartsModel | ||
| from darts.physics.super.physics import Compositional | ||
| from darts.physics.super.property_container import PropertyContainer | ||
| from darts.physics.properties.flash import ConstantK | ||
| from darts.physics.properties.basic import ConstFunc, PhaseRelPerm | ||
| from darts.physics.properties.density import DensityBasic | ||
|
|
||
|
|
||
| class Model( DartsModel ): | ||
|
|
||
| def __init__( self, n_points=50 ): | ||
| # Call base class constructor | ||
| super().__init__() | ||
| self.n_obl_points = n_points | ||
| self.set_physics() | ||
|
|
||
| def set_physics( self ): | ||
| """Physical properties""" | ||
| self.zero = 1e-8 | ||
| # Create property containers: | ||
| components = [ 'CO2', 'C1', 'H2O' ] | ||
| phases = [ 'gas', 'oil' ] | ||
| thermal = 0 | ||
| Mw = [ 44.01, 16.04, 18.015 ] | ||
|
|
||
| property_container = PropertyContainer( phases_name=phases, | ||
| components_name=components, | ||
| Mw=Mw, | ||
| min_z=self.zero / 10, | ||
| temperature=1. ) | ||
| """ properties correlations """ | ||
| property_container.flash_ev = ConstantK( len( components ), [ 4, 2, 1e-1 ], self.zero ) | ||
| property_container.density_ev = dict( [ ( 'gas', DensityBasic( compr=1e-3, dens0=200 ) ), | ||
| ( 'oil', DensityBasic( compr=1e-5, dens0=600 ) ) ] ) | ||
| property_container.viscosity_ev = dict( [ ( 'gas', ConstFunc( 0.05 ) ), ( 'oil', ConstFunc( 0.5 ) ) ] ) | ||
| property_container.rel_perm_ev = dict( [ ( 'gas', PhaseRelPerm( "gas" ) ), ( 'oil', PhaseRelPerm( "oil" ) ) ] ) | ||
| """ Activate physics """ | ||
| self.physics = Compositional( components, | ||
| phases, | ||
| self.timer, | ||
| n_points=self.n_obl_points, | ||
| min_p=1, | ||
| max_p=300, | ||
| min_z=self.zero / 10, | ||
| max_z=1 - self.zero / 10 ) | ||
| self.physics.add_property_region( property_container ) | ||
| self.engine = self.physics.init_physics( platform='cpu' ) | ||
| return | ||
|
|
||
|
|
||
| def run_darts_model( xml_name: str, darts_model=None ): | ||
| comm = MPI.COMM_WORLD | ||
| rank = comm.Get_rank() | ||
|
|
||
| xml = XML( xml_name ) | ||
|
|
||
| solver = ReservoirSolver( solverType="ReactiveCompositionalMultiphaseOBL" ) | ||
| solver.initialize( rank=rank, xml=xml ) | ||
|
|
||
| # connect solver to Python-based operators | ||
| functions = solver.geosx.get_group( "/Functions" ).groups() | ||
| for func in functions: | ||
| if hasattr( func, 'setAxes' ) and darts_model is not None: | ||
| func.setAxes( darts_model.physics.n_vars, darts_model.physics.n_ops, list( darts_model.physics.axes_min ), | ||
| list( darts_model.physics.axes_max ), list( darts_model.physics.n_axes_points ) ) | ||
| func.setEvaluateFunction( darts_model.physics.reservoir_operators[ 0 ].evaluate ) | ||
| print( "Adaptive OBL interpolator is configured." ) | ||
|
|
||
| solver.applyInitialConditions() | ||
| solver.setDtFromTimeVariable( "forceDt" ) | ||
| solver.setMaxTime( solver.getTimeVariables()[ "maxTime" ] ) | ||
|
|
||
| time: float = 0 | ||
| cycle: int = 0 | ||
|
|
||
| solver.outputVtk( time ) | ||
| while time < solver.maxTime: | ||
| if rank == 0: | ||
| if solver.dt is not None: | ||
| print( f"time = {time:.3f}s, dt = {solver.getDt():.4f}, iter = {cycle + 1}" ) | ||
| solver.execute( time ) | ||
| solver.outputVtk( time ) | ||
| time += solver.dt | ||
| cycle += 1 | ||
| solver.cleanup( time ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # run adaptive OBL | ||
| print( "\n" + "=" * 30 + " RUNNING ADAPTIVE OBL " + "=" * 30 + "\n" ) | ||
| darts_model = Model() | ||
| run_darts_model( xml_name="input_file_adaptive.xml", darts_model=darts_model ) |
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.