Skip to content

Commit 21893cb

Browse files
committed
Add CASEGEN_UPCARS forward model
1 parent ff349b9 commit 21893cb

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

src/subscript/casegen_upcars/casegen_upcars.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#!/usr/bin/env python
2-
"""
3-
casegen_upcars is script to create conceptual model
2+
import argparse
3+
import shutil
4+
5+
from jinja2 import DebugUndefined, Environment, FileSystemLoader, meta
6+
from yaml import Loader, load
7+
8+
from subscript import getLogger
9+
from subscript.casegen_upcars.model import Model
10+
from subscript.casegen_upcars.udf import TERMINALCOLORS, conversion, flatten, listify
11+
from subscript.casegen_upcars.udf_arg_parser import fill_parser
12+
13+
DESCRIPTION = """casegen_upcars is script to create conceptual model
414
based on sugar-cube representation of fracture.
515
616
It has capability to:
@@ -10,17 +20,20 @@
1020
- multple throws (vertical shifting in any part of the model)
1121
- vugs distribution: random, near fracture and near streak
1222
- etc. Check wiki for more details:
13-
https://wiki.equinor.com/wiki/index.php/UpCaRs_Upscaling_casegen
14-
"""
15-
import argparse
16-
import shutil
23+
https://wiki.equinor.com/wiki/index.php/UpCaRs_Upscaling_casegen"""
1724

18-
from jinja2 import DebugUndefined, Environment, FileSystemLoader, meta
19-
from yaml import Loader, load
25+
CATEGORY = "modelling.reservoir"
2026

21-
from subscript.casegen_upcars.model import Model
22-
from subscript.casegen_upcars.udf import TERMINALCOLORS, conversion, flatten, listify
23-
from subscript.casegen_upcars.udf_arg_parser import fill_parser
27+
EXAMPLES = """
28+
.. code-block:: console
29+
30+
DEFINE <CASEGEN_CONFIG_FILE> <RUNPATH>/model.yaml
31+
DEFINE <CASEGEN_ECLIPSE_TEMPLATE> <CONFIG_PATH>/../input/config/eclipse.tmpl
32+
FORWARD_MODEL CASEGEN_UPCARS(<CONFIG>=<CASEGEN_CONFIG_FILE>, <ECLTMP>=<CASEGEN_ECLIPSE_TEMPLATE>, <ECL>=<ECLIPSE_NAME>-<IENS>)
33+
34+
""" # noqa
35+
36+
logger = getLogger(__name__)
2437

2538

2639
def mask_token(stream_buffer, unique_token="#|{}^", unmask=False):
@@ -397,7 +410,7 @@ def main():
397410
for var in parser.variables:
398411
dictionary[var[0]] = var[1]
399412

400-
print("Creating model")
413+
logger.info("Creating model")
401414
grid = Model(
402415
cell_matrix_x,
403416
cell_matrix_y,
@@ -438,7 +451,7 @@ def main():
438451
grid.set_throws(throws)
439452

440453
if vug1_fraction_max + vug2_fraction_max + vug3_fraction_max > 0:
441-
print("Set vugs")
454+
logger.info("Set vugs")
442455
grid.set_vug(
443456
[vug1_fraction_min, vug1_fraction_max],
444457
[vug1_perm_min, vug1_perm_max],
@@ -464,7 +477,7 @@ def main():
464477
vug3_spread,
465478
)
466479

467-
print("Set property")
480+
logger.info("Set property")
468481
grid.set_fracture_anisotropy_property("PERM", fracture_perm_x, fracture_perm_y)
469482
grid.set_layers_property("PERM", matrix_perm, streak_perm)
470483
for keyword, var_matrix, var_layer, var_fracture in zip(
@@ -491,7 +504,7 @@ def main():
491504

492505
dictionary["GRDECL_file"] = f"gridinc_{base_name}.GRDECL"
493506

494-
print("Exporting GRDECL file")
507+
logger.info("Exporting GRDECL file")
495508
grid.export_grdecl(dictionary["GRDECL_file"])
496509

497510
for keyword, var_matrix, var_layer, var_fracture, var_vug in zip(
@@ -505,7 +518,7 @@ def main():
505518
[vug1_swatinit, vug2_swatinit, vug3_swatinit],
506519
],
507520
):
508-
print("Exporting " + keyword + " include file")
521+
logger.info("Exporting " + keyword + " include file")
509522
include_file = f"{keyword.lower()}_file"
510523
dictionary[include_file] = f"{keyword.lower()}_{base_name}.INC"
511524
grid.export_props(
@@ -541,9 +554,9 @@ def main():
541554
undefined_var.append(var)
542555

543556
if undefined_var:
544-
print(
545-
f"\033[91mWarning: Found {len(undefined_var)} undefined variables."
546-
f"Please verify your output files.\033[0m\n{undefined_var}"
557+
logger.warning(
558+
f"Found {len(undefined_var)} undefined variables."
559+
f"Please verify your output files.\n{undefined_var}"
547560
)
548561

549562
with open(base_name + ".DATA", "w", encoding="utf8") as file_handle:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
EXECUTABLE casegen_upcars
2+
3+
ARG_TYPE 0 STRING
4+
ARG_TYPE 1 STRING
5+
ARG_TYPE 2 STRING
6+
7+
ARGLIST <CONFIG> "--et" <ECLTMP> "--base" <ECL>
8+
9+
MIN_ARG 3
10+
MAX_ARG 3

0 commit comments

Comments
 (0)