-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b99016a
commit 1abdbf6
Showing
12 changed files
with
314 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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 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,44 @@ | ||
from resdata import ResDataType | ||
from resdata.resfile import ResdataKW, openFortIO, FortIO | ||
|
||
|
||
def create_restart(grid, case, p1, p2=None, rporv1=None, rporv2=None): | ||
with openFortIO("%s.UNRST" % case, mode=FortIO.WRITE_MODE) as f: | ||
seq_hdr = ResdataKW("SEQNUM", 1, ResDataType.RD_FLOAT) | ||
seq_hdr[0] = 10 | ||
p = ResdataKW("PRESSURE", grid.getNumActive(), ResDataType.RD_FLOAT) | ||
for i in range(len(p1)): | ||
p[i] = p1[i] | ||
|
||
header = ResdataKW("INTEHEAD", 67, ResDataType.RD_INT) | ||
header[64] = 1 | ||
header[65] = 1 | ||
header[66] = 2000 | ||
|
||
seq_hdr.fwrite(f) | ||
header.fwrite(f) | ||
p.fwrite(f) | ||
|
||
if rporv1: | ||
rp = ResdataKW("RPORV", grid.getNumActive(), ResDataType.RD_FLOAT) | ||
for idx, val in enumerate(rporv1): | ||
rp[idx] = val | ||
|
||
rp.fwrite(f) | ||
|
||
if p2: | ||
seq_hdr[0] = 20 | ||
header[66] = 2010 | ||
for i in range(len(p2)): | ||
p[i] = p2[i] | ||
|
||
seq_hdr.fwrite(f) | ||
header.fwrite(f) | ||
p.fwrite(f) | ||
|
||
if rporv2: | ||
rp = ResdataKW("RPORV", grid.getNumActive(), ResDataType.RD_FLOAT) | ||
for idx, val in enumerate(rporv2): | ||
rp[idx] = val | ||
|
||
rp.fwrite(f) |
This file contains 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 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 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,101 @@ | ||
import time | ||
import datetime | ||
from resdata import ResDataType | ||
from resdata.resfile import ResdataKW, ResdataFile, openFortIO, FortIO | ||
from resdata.grid import Grid | ||
from resdata.gravimetry import ResdataGrav | ||
from resdata.util.test import TestAreaContext | ||
from tests import ResdataTest | ||
from resdata.rd_util import Phase | ||
|
||
|
||
class ResdataGravTest(ResdataTest): | ||
def setUp(self): | ||
self.grid = Grid.createRectangular((10, 10, 10), (1, 1, 1)) | ||
|
||
def test_create(self): | ||
# The init file created here only contains a PORO field. More | ||
# properties must be added to this before it can be used for | ||
# any usefull gravity calculations. | ||
poro = ResdataKW("PORO", self.grid.getGlobalSize(), ResDataType.RD_FLOAT) | ||
|
||
kws = [ | ||
ResdataKW(kw, self.grid.getGlobalSize(), ResDataType.RD_FLOAT) | ||
for kw in [ | ||
"PORO", | ||
"PORV", | ||
"PRESSURE", | ||
"SWAT", | ||
"OIL_DEN", | ||
"RPORV", | ||
"PORV_MOD", | ||
"FIPOIL", | ||
"RFIPOIL", | ||
] | ||
] | ||
int_kws = [ | ||
ResdataKW(kw, self.grid.getGlobalSize(), ResDataType.RD_INT) | ||
for kw in ["FIP_NUM", "PVTNUM"] | ||
] | ||
|
||
for kw in kws: | ||
for i in range(self.grid.getGlobalSize()): | ||
kw[i] = 0.5 | ||
for kw in int_kws: | ||
for i in range(self.grid.getGlobalSize()): | ||
kw[i] = 0 | ||
|
||
kws += int_kws | ||
|
||
with TestAreaContext("grav_init"): | ||
with openFortIO("TEST.UNRST", mode=FortIO.WRITE_MODE) as f: | ||
seq_hdr = ResdataKW("SEQNUM", 1, ResDataType.RD_FLOAT) | ||
seq_hdr[0] = 10 | ||
|
||
header = ResdataKW("INTEHEAD", 67, ResDataType.RD_INT) | ||
header[64] = 1 | ||
header[65] = 1 | ||
header[66] = 2000 | ||
|
||
seq_hdr.fwrite(f) | ||
header.fwrite(f) | ||
for kw in kws: | ||
kw.fwrite(f) | ||
|
||
seq_hdr[0] = 20 | ||
header[66] = 2009 | ||
|
||
seq_hdr.fwrite(f) | ||
header.fwrite(f) | ||
for kw in kws: | ||
kw.fwrite(f) | ||
|
||
seq_hdr[0] = 20 | ||
header[66] = 2010 | ||
|
||
seq_hdr.fwrite(f) | ||
header.fwrite(f) | ||
for kw in kws: | ||
kw.fwrite(f) | ||
|
||
# The init file created here only contains a PORO field. More | ||
# properties must be added to this before it can be used for | ||
# any usefull gravity calculations. | ||
header = ResdataKW("INTEHEAD", 95, ResDataType.RD_INT) | ||
header[14] = 1 # sets phase to oil | ||
header[94] = 100 # E100 | ||
with openFortIO("TEST.INIT", mode=FortIO.WRITE_MODE) as f: | ||
poro.fwrite(f) | ||
header.fwrite(f) | ||
for kw in kws: | ||
kw.fwrite(f) | ||
self.init = ResdataFile("TEST.INIT") | ||
|
||
grav = ResdataGrav(self.grid, self.init) | ||
|
||
restart_file = ResdataFile("TEST.UNRST") | ||
restart_view = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) | ||
|
||
grav.new_std_density(1, 0.5) | ||
grav.add_std_density(1, 0, 0.5) | ||
|
||
grav.add_survey_RPORV("rporv", restart_view) | ||
grav.add_survey_PORMOD("pormod", restart_view) | ||
grav.add_survey_FIP("fip", restart_view) | ||
grav.add_survey_RFIP("fip", restart_view) | ||
|
||
grav.eval("rporv", "pormod", (0, 0, 0), phase_mask=1) |
This file contains 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 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
Oops, something went wrong.