Skip to content

Commit

Permalink
Allow SWFN and SGFN without any kro defined
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Feb 20, 2020
1 parent 59bd992 commit 0792d86
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 25 deletions.
24 changes: 14 additions & 10 deletions pyscal/gasoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def crosspoint(self):

return tmp[np.isclose(tmp.index, 0.0)].sg.values[0]

def selfcheck(self):
def selfcheck(self, mode="SGOF"):
"""Check validities of the data in the table.
This is to catch errors that are either physically wrong
Expand All @@ -614,14 +614,14 @@ def selfcheck(self):
is found.
If you call SGOF/SLGOF, this function must not return False.
Args:
mode (str): If mode is "SGFN", krog is not required.
"""
error = False
if "krg" not in self.table:
logger.error("krg data missing")
error = True
if "krog" not in self.table:
logger.error("krog data missing")
error = True
if not (self.table["sg"].diff().dropna() > -epsilon).all():
logger.error("sg data not strictly increasing")
error = True
Expand All @@ -632,12 +632,16 @@ def selfcheck(self):
logger.error("krg data not monotonically decreasing")
error = True

if (
"krog" in self.table
and not (self.table["krog"].diff().dropna() <= epsilon).all()
):
logger.error("krog data not monotonically increasing")
error = True
if mode != "SGFN":
if "krog" not in self.table:
logger.error("krog data missing")
error = True
if (
"krog" in self.table
and not (self.table["krog"].diff().dropna() <= epsilon).all()
):
logger.error("krog data not monotonically increasing")
error = True
if "krg" in self.table and not np.isclose(min(self.table["krg"]), 0.0):
logger.error("krg must start at zero")
error = True
Expand Down
33 changes: 19 additions & 14 deletions pyscal/wateroil.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def crosspoint(self):

return tmp[np.isclose(tmp.index, 0.0)].sw.values[0]

def selfcheck(self):
def selfcheck(self, mode="SWOF"):
"""Check validities of the data in the table.
An unfinished object will return False.
Expand All @@ -906,14 +906,14 @@ def selfcheck(self):
This function should not throw an exception, but capture
the error and give an error.
Args:
mode (str): "SWOF" or "SWFN". If SWFN, krow is not required.
"""
error = False
if "krw" not in self.table:
logger.error("krw data not found")
error = True
if "krow" not in self.table:
logger.error("krow data not found")
error = True
if not (self.table["sw"].diff().dropna().round(10) > -epsilon).all():
logger.error("sw data not strictly increasing")
error = True
Expand All @@ -923,15 +923,20 @@ def selfcheck(self):
):
logger.error("krw data not monotonically increasing")
error = True
if (
"krow" in self.table.columns
and not (self.table["krow"].diff().dropna().round(10) <= epsilon).all()
):
# In normal Eclipse runs, krow needs to be level or decreasing.
# In hysteresis runs, it needs to be strictly decreasing, that must
# be the users responsibility.
logger.error("krow data not level or monotonically decreasing")
error = True
if mode != "SWFN":
if "krow" not in self.table:
logger.error("krow data not found")
error = True

if (
"krow" in self.table.columns
and not (self.table["krow"].diff().dropna().round(10) <= epsilon).all()
):
# In normal Eclipse runs, krow needs to be level or decreasing.
# In hysteresis runs, it needs to be strictly decreasing, that must
# be the users responsibility.
logger.error("krow data not level or monotonically decreasing")
error = True
if "pc" in self.table.columns and self.table["pc"][0] > -epsilon:
if not (self.table["pc"].diff().dropna().round(10) < epsilon).all():
logger.error("pc data not strictly decreasing")
Expand Down Expand Up @@ -1004,7 +1009,7 @@ def SWOF(self, header=True, dataincommentrow=True):

def SWFN(self, header=True, dataincommentrow=True):
"""Return a SWFN keyword with data to Eclipse"""
if not self.selfcheck():
if not self.selfcheck(mode="SWFN"):
# selfcheck will print errors/warnings
return ""
string = ""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def test_corey_let_mix():
have Corey and others have LET"""
dframe = pd.DataFrame(
columns=["SATNUM", "Nw", "Now", "Lw", "Ew", "Tw", "Ng", "Nog"],
data=[[1, 2, 2, np.nan, np.nan, np.nan, 1, 1], [2, np.nan, 3, 1, 1, 1, 2, 2],],
data=[[1, 2, 2, np.nan, np.nan, np.nan, 1, 1], [2, np.nan, 3, 1, 1, 1, 2, 2]],
)
relperm_data = PyscalFactory.load_relperm_df(dframe)
p_list = PyscalFactory.create_pyscal_list(relperm_data, h=0.2)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_gasoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,13 @@ def test_gasoil_let1(l, e, t, krgend, krgmax):
sgofstr = gasoil.SGOF()
assert len(sgofstr) > 100
assert sat_table_str_ok(sgofstr)


def test_sgfn():
"""Test that we can call SGFN without oil relperm defined"""
gasoil = GasOil()
gasoil.add_corey_gas()
sgfn_str = gasoil.SGFN()
assert "SGFN" in sgfn_str
assert len(sgfn_str) > 15
print(sgfn_str)
9 changes: 9 additions & 0 deletions tests/test_wateroil.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def test_wateroil_krendmax(swl, swcr, sorw, kroend, kromax, krwend, krwmax, h, f
assert 0 < wateroil.crosspoint() < 1


def test_swfn():
"""Test that we can dump SWFN without giving oil relperm"""
wateroil = WaterOil(h=0.1)
wateroil.add_corey_water()
swfnstr = wateroil.SWFN()
assert "SWFN" in swfnstr
assert len(swfnstr) > 15


def test_wateroil_linear():
"""Test linear wateroil curves"""
wateroil = WaterOil(h=1)
Expand Down

0 comments on commit 0792d86

Please sign in to comment.