Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
cd58455
X-MGN for reservoir simulation
tonishi-nv Oct 26, 2025
784342c
installation bug fix
tonishi-nv Oct 26, 2025
b6c172f
well object docstring fix
tonishi-nv Oct 27, 2025
388ce1c
more well object docstring fix
tonishi-nv Oct 27, 2025
bbe573e
improve path_utils
tonishi-nv Oct 27, 2025
65d335a
fix while space in config
tonishi-nv Oct 27, 2025
e4cf2ce
fix version inconsistency in requirement.txt
tonishi-nv Oct 27, 2025
95b1aac
add versions for some libs in requirement.txt
tonishi-nv Oct 27, 2025
91b56f4
improve exception handling in mldlow_utils
tonishi-nv Oct 27, 2025
7508549
improve mldlow_utils
tonishi-nv Oct 27, 2025
a2cdfaf
improve datetiem in mlflow_utils
tonishi-nv Oct 27, 2025
be88a7d
improve exception handling in inference
tonishi-nv Oct 27, 2025
97613c2
improve inference
tonishi-nv Oct 27, 2025
bb0bd8a
improve ecl_reader
tonishi-nv Oct 27, 2025
69d82dd
formatting
tonishi-nv Oct 27, 2025
f635750
improve preprocessor
tonishi-nv Oct 27, 2025
b8b6003
improve preprocessor loop
tonishi-nv Oct 27, 2025
8ce3778
fmt
tonishi-nv Oct 27, 2025
d705514
fmt
tonishi-nv Oct 27, 2025
803c377
fmt
tonishi-nv Oct 27, 2025
0c910f9
fmt
tonishi-nv Oct 27, 2025
0635fd1
grad accum bug fix
tonishi-nv Oct 27, 2025
8a73d0b
total loss bug fix
tonishi-nv Oct 27, 2025
db2e534
added some safe guard for connection indexing
tonishi-nv Oct 27, 2025
37aa62e
fmt
tonishi-nv Oct 27, 2025
616c78d
bug fix
tonishi-nv Oct 27, 2025
8c5a8dc
bug fix
tonishi-nv Oct 27, 2025
048d693
cleanup
tonishi-nv Oct 27, 2025
bb2fc5d
fmt
tonishi-nv Oct 27, 2025
444d92f
update ecl_reader
tonishi-nv Oct 27, 2025
6c524e1
cleanup utils
tonishi-nv Oct 27, 2025
295cf6b
cleanup
tonishi-nv Oct 27, 2025
76cf0a0
cleanup
tonishi-nv Oct 27, 2025
17e44e8
update configs
tonishi-nv Oct 27, 2025
d81302c
Update README.md
megnvidia Oct 27, 2025
f2c87d3
Update README.md
megnvidia Oct 27, 2025
0656882
Merge branch 'main' into tonishi/xmgn_ressim
tonishi-nv Oct 28, 2025
a3109b4
fmt
tonishi-nv Oct 28, 2025
ba5e928
improve docstring fmt
tonishi-nv Oct 28, 2025
2a0e61b
update license yr
tonishi-nv Oct 28, 2025
1d8cf62
cleanup well
tonishi-nv Oct 28, 2025
c1c9edf
cleanup preproc fmt
tonishi-nv Oct 28, 2025
c95f833
cleanup preproc fmt
tonishi-nv Oct 28, 2025
cec0923
cimprove infrence fmt
tonishi-nv Oct 28, 2025
859a651
improve datetime
tonishi-nv Oct 28, 2025
fcc5420
improve readme fmt
tonishi-nv Oct 28, 2025
d492de4
improve readme
tonishi-nv Oct 28, 2025
84b3e6f
improve train.py fmt
tonishi-nv Oct 28, 2025
744cabd
improve readme fmt
tonishi-nv Oct 28, 2025
271fabb
improve requirement
tonishi-nv Oct 28, 2025
b29cf29
ilcense header
tonishi-nv Oct 29, 2025
7279bd0
improve ecl reader logging
tonishi-nv Oct 29, 2025
5bdeac1
cleanup
tonishi-nv Oct 29, 2025
149c6c0
license header
tonishi-nv Oct 29, 2025
965f0ca
improve graph builder (parallel) + added results to readme
tonishi-nv Oct 30, 2025
3978c9f
delete some unsed files
tonishi-nv Oct 30, 2025
bdfc71c
address PR comments
tonishi-nv Oct 31, 2025
21bcf76
improve inference grdecl header
tonishi-nv Oct 31, 2025
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
and three transient schemes.
- Added a check to `stochastic_sampler` that helps handle the `EDMPrecond` model,
which has a specific `.forward()` signature
- Examples: added a new example for reservoir simulation using X-MeshGraphNet.
Accessible in `examples/reservoir_simulation`

### Changed

Expand Down
125 changes: 125 additions & 0 deletions examples/reservoir_simulation/sim_utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Simulation Utilities

## Overview

The `sim_utils` package provides utilities for processing ECL/IX style binary
output files to prepare datasets for training. These scripts can read industry
standard simulator output formats (ECLIPSE, IX, OPM) and convert them into
various data structures suitable for different ML architectures.

## Supported Formats

- `.INIT`
- `.EGRID`
- `.UNRST` or `.X00xx`
- `.UNSMRY` or `.S00xx`

## Modules

### `ecl_reader.py`

Main class for reading ECLIPSE-style binary output files.

**Usage**:

```python
from sim_utils import EclReader

# Initialize reader with case name
reader = EclReader("path/to/CASE.DATA")

# Read static properties
init_data = reader.read_init(["PORV", "PERMX", "PERMY", "PERMZ"])

# Read grid geometry
egrid_data = reader.read_egrid(["COORD", "ZCORN", "FILEHEAD", "NNC1", "NNC2"])

# Read dynamic properties (all timesteps)
restart_data = reader.read_restart(["PRESSURE", "SWAT", "SGAS"])
```

**Common Keywords**:

Static properties (INIT):

- `PORV`: Pore volume
- `PERMX`, `PERMY`, `PERMZ`: Permeability in X, Y, Z directions
- `PORO`: Porosity
- `TRANX`, `TRANY`, `TRANZ`: Transmissibility in X, Y, Z directions

Dynamic properties (UNRST):

- `PRESSURE`: Cell pressure
- `SWAT`: Water saturation
- `SGAS`: Gas saturation
- `SOIL`: Oil saturation

Grid geometry (EGRID):

- `COORD`: Grid pillar coordinates
- `ZCORN`: Grid corner depths
- `FILEHEAD`: File header information
- `NNC1`, `NNC2`: Non-neighboring connections

### `grid.py`

**Grid** - Handles reservoir grid structure and operations.

**Features**:

- Grid dimensions and active cells
- Cell center coordinates computation
- Connection/edge computation for graph construction
- Aggregating directional transmissibilities for edge features
- Non-Neighboring Connections (NNC)
- Well completion arrays

**Usage**:

```python
from sim_utils import Grid

# Initialize grid from simulation data
grid = Grid(init_data, egrid_data)

# Get connections and transmissibilities for graph construction
connections, transmissibilities = grid.get_conx_tran()

# Create completion arrays for wells
completion_inj, completion_prd = grid.create_completion_array(wells)

# Access grid properties
print(f"Grid dimensions: {grid.nx} x {grid.ny} x {grid.nz}")
print(f"Active cells: {grid.nact}")
print(f"Cell coordinates: X={grid.X}, Y={grid.Y}, Z={grid.Z}")
```

### `well.py`

**Well** and **Completion** - Well and completion data structures. Typically,
use results from `UNRST` (well name, type, status, I, J, K, etc.) to
instantiate the object.

**Usage**:

```python
from sim_utils import Well, Completion

# Create a well
well = Well(name="INJ1", type_id=3, stat=1) # Water injector

# Add completions
well.add_completion(
I=10, # Grid I-index
J=10, # Grid J-index
K=5, # Grid K-index
dir=3, # Direction (1=X, 2=Y, 3=Z)
stat=1, # Status (1=OPEN)
conx_factor=1.0 # Connection factor
)

# Check well properties
print(f"Well type: {well.type}") # 'INJ' or 'PRD'
print(f"Well status: {well.status}") # 'OPEN' or 'SHUT'
print(f"Number of completions: {len(well.completions)}")
```
35 changes: 35 additions & 0 deletions examples/reservoir_simulation/sim_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 - 2024 NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Reservoir Utilities

Shared utilities for processing reservoir simulation data across different
machine learning architectures (XMeshGraphNet, FNO, DeepONet, etc.).

This package contains:
- ecl_reader: Read ECLIPSE-style simulation output files (.INIT, .EGRID, .UNRST, etc.)
- grid: Grid data structures and operations for reservoir simulations
- well: Well and completion data structures
"""

from .ecl_reader import EclReader
from .grid import Grid
from .well import Well, Completion

__all__ = ["EclReader", "Grid", "Well", "Completion"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify the code for all these utilities is written by NVIDIA. If the code has been taken from somewhere else, even if partially, we need to modify the license header.

Copy link
Author

@tonishi-nv tonishi-nv Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reused part of an open source code (my repository with Apache license: https://github.com/GEG-ETHZ/pyflowdiagnostics/tree/v0.1.0) and modified a bit. Do we need to add something to the license header?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in that case, please include the original license header first, followed by the NVIDIA license header. Add #ignore_header_test at the beginning of the file to skip the ci header test.


__version__ = "1.0.0"
Loading