Skip to content

Commit

Permalink
Update comments and remove unused code in scallib
Browse files Browse the repository at this point in the history
  • Loading branch information
harmdijk committed Jul 27, 2023
1 parent 1e79247 commit d547c94
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 116 deletions.
24 changes: 9 additions & 15 deletions python/example_Fig09_USS_dpw+dpo+noSwz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,7 @@
" 155 197 1.5090e+01 2.30e-04 1.08e-04 9.72e-01 \n",
" 156 198 1.5090e+01 4.60e-04 2.16e-04 9.74e-01 \n",
" 157 199 1.5089e+01 9.17e-04 4.32e-04 9.72e-01 \n",
" 158 200 1.5087e+01 1.84e-03 8.62e-04 1.54e+00 \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 158 200 1.5087e+01 1.84e-03 8.62e-04 1.54e+00 \n",
" 159 203 1.5087e+01 1.70e-05 5.25e-05 1.01e+00 \n",
" 160 204 1.5087e+01 7.97e-05 2.36e-05 9.79e-01 \n",
" 161 205 1.5087e+01 1.29e-04 5.12e-05 9.69e-01 \n",
Expand Down Expand Up @@ -843,7 +837,13 @@
" 198 252 1.5069e+01 1.52e-04 4.64e-05 9.19e-01 \n",
" 199 253 1.5069e+01 2.29e-04 1.05e-04 9.49e-01 \n",
" 200 254 1.5069e+01 1.39e-04 1.56e-04 1.43e+00 \n",
" 201 255 1.5069e+01 1.79e-04 4.41e-05 9.23e-01 \n",
" 201 255 1.5069e+01 1.79e-04 4.41e-05 9.23e-01 \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 202 256 1.5069e+01 2.35e-04 1.00e-04 1.54e+00 \n",
" 203 258 1.5068e+01 2.85e-05 2.53e-05 9.16e-01 \n",
" 204 259 1.5068e+01 3.05e-05 1.30e-05 9.21e-01 \n",
Expand Down Expand Up @@ -894,13 +894,7 @@
" 249 318 1.5052e+01 2.93e-05 1.32e-05 9.17e-01 \n",
" 250 319 1.5052e+01 5.56e-05 2.68e-05 9.14e-01 \n",
" 251 320 1.5052e+01 1.07e-04 5.36e-05 9.16e-01 \n",
" 252 321 1.5052e+01 2.14e-04 1.07e-04 9.17e-01 \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 252 321 1.5052e+01 2.14e-04 1.07e-04 9.17e-01 \n",
" 253 322 1.5052e+01 4.29e-04 2.15e-04 9.18e-01 \n",
" 254 323 1.5051e+01 8.56e-04 4.30e-04 9.20e-01 \n",
" 255 324 1.5049e+01 1.71e-03 8.61e-04 9.17e-01 \n",
Expand Down
16 changes: 8 additions & 8 deletions python/example_Fig17_USS_dpw+dpo+Swz_bumpfloods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -812,13 +812,7 @@
" 175 222 1.5081e+01 2.43e-04 9.95e-05 2.29e+00 \n",
" 176 224 1.5081e+01 2.17e-05 2.26e-05 9.53e-01 \n",
" 177 225 1.5081e+01 3.09e-05 1.32e-05 9.47e-01 \n",
" 178 226 1.5081e+01 5.90e-05 2.68e-05 9.48e-01 \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 178 226 1.5081e+01 5.90e-05 2.68e-05 9.48e-01 \n",
" 179 227 1.5081e+01 1.13e-04 5.38e-05 9.49e-01 \n",
" 180 228 1.5080e+01 2.26e-04 1.08e-04 9.50e-01 \n",
" 181 229 1.5080e+01 4.52e-04 2.15e-04 9.49e-01 \n",
Expand All @@ -836,7 +830,13 @@
" 193 244 1.5073e+01 4.45e-04 2.16e-04 9.52e-01 \n",
" 194 245 1.5072e+01 8.95e-04 4.31e-04 9.35e-01 \n",
" 195 246 1.5070e+01 1.64e-03 8.60e-04 1.20e+00 \n",
" 196 249 1.5070e+01 2.72e-04 9.44e-05 9.50e-01 \n",
" 196 249 1.5070e+01 2.72e-04 9.44e-05 9.50e-01 \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 197 250 1.5069e+01 2.86e-04 1.87e-04 1.10e+00 \n",
" 198 252 1.5069e+01 1.52e-04 4.64e-05 9.19e-01 \n",
" 199 253 1.5069e+01 2.29e-04 1.05e-04 9.49e-01 \n",
Expand Down
12 changes: 3 additions & 9 deletions python/scallib001/displacementmodel1D2P001.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# 03.04.2020 HD
# - completed set of columns in tss_table
# - included calculation of total pressure drop, as per MoReS model
# - included calculation of total pressure drop
# i.e., assume linear relperms in block before inlet
# - include PVinj as column in tss_table
# - information about columns in tss_table
Expand Down Expand Up @@ -246,9 +246,6 @@ def solve_1D2P_version1(
flxwdu [-1] = 0
flxwdd [-1] = 0

#TODO if np.any( flxw[:-1]<0 ):
#TODO raise ValueError('Counter current flow occurred - solver not appropriate STOP')

rhs = (sw_new - sw_prv)*delxi[1:]/dtD + flxw[1:] - flxw[:-1]

nr_residual = np.linalg.norm(rhs*dtD/delxi[1:])
Expand Down Expand Up @@ -293,13 +290,10 @@ def solve_1D2P_version1(

delp = -(1 + dpcwdx * mobn + gvhnD * mobn + gvhwD * mobw) / dtr / mobt / pres_conv

##delp[0] = -Fw/mobw[1] / dtr[0] / pres_conv

pcw /= pres_conv

# do not use pressure drop over begin/end faces in order to compare to PressureData_SIM WRONG
pw = np.zeros( sw.size )
pw[2:] = np.cumsum( delp[1:-1] ) #TODO
pw[2:] = np.cumsum( delp[1:-1] )
pw -= pw[-1] - 1.0 + delp[-1] # outer edge at 1 bar

pn = pw + pcw
Expand Down Expand Up @@ -386,7 +380,7 @@ def update_step( t, delt, t_end, i_t_stops, t_stops, s_stops, f_stops, follow_st

@numba.njit
def calc_inlet_Sw( FW, dPcdxD, vscw, vscn, gvhwD, gvhnD ):
'''Calculate Sw at inlet set assuming linear relperms at inlet (MoReS procedure)'''
'''Calculate Sw at inlet set assuming linear relperms at inlet'''
qw = vscw * FW
qn = vscn * (1-FW)
g = dPcdxD + gvhnD -gvhwD
Expand Down
93 changes: 9 additions & 84 deletions python/scallib001/relpermlib001.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@numba.njit
def pchip_estimate_derivatives(x, y, lex=1, rex=1 ):
'''Estimate derivatives for piecE1ise cubic hermite spline function.'''
'''Estimate derivatives for piecewise cubic hermite spline function.'''
hk = x[1:] - x[:-1]
mk = (y[1:] - y[:-1]) / hk

Expand Down Expand Up @@ -60,9 +60,9 @@ def pchip_estimate_derivatives(x, y, lex=1, rex=1 ):

@numba.njit
def pchip_fit( xi, yi, lex=1, rex=1 ):
'''Fit coefficients for piecE1ise cubic hermite spline function.'''
'''Fit coefficients for piecewise cubic hermite spline function.'''

# Extend interval T2 enforce truncation or linear extrapolation
# Extend interval to enforce truncation or linear extrapolation

n = len(xi)

Expand Down Expand Up @@ -94,7 +94,7 @@ def pchip_fit( xi, yi, lex=1, rex=1 ):

@numba.njit
def pchip_coefs( xi, yi, di ):
'''Calculate coefficients for piecE1ise cubic hermite spline function.'''
'''Calculate coefficients for piecewise cubic hermite spline function.'''
x1 = xi[:-1]
x2 = xi[+1:]

Expand All @@ -114,66 +114,9 @@ def pchip_coefs( xi, yi, di ):

return c0,c1,c2,c3

import numba

# T2DO: speed up

@numba.njit
def pchip_bisect_OLD( x, xi ):

n = len(x)

left = np.zeros( n )

n1 = len(xi)-1

for i in range( n ):

L2w = 0; high = n1

xv = x[i]

if xv < xi[L2w]:
left[i] = L2w
elif xv>xi[high]:
left[i] = high-1
else:
while True:
if L2w==high-1:
left[i] = L2w
break

mid = int( (high+L2w)/2 )

if xi[mid]<=xv:
L2w = mid
else:
high = mid

return left.astype(np.int32)


@numba.njit
def pchip_eval_OLD( x, xi, c0, c1, c2, c3 ):

left = pchip_bisect( x, xi )

dx = x - xi[left]

c0 = c0[left]
c1 = c1[left]
c2 = c2[left]
c3 = c3[left]

f = c0 + dx* ( c1 + dx * (c2 + dx*c3 ) )

d = c1 + dx * ( 2.0 * c2 + dx * 3.0 * c3 )

return f, d

@numba.njit
def pchip_eval( x, xi, c0, c1, c2, c3 ):
'''Evalulate piecE1ise cubic hermite spline function and its derivative at x.'''
'''Evalulate piecewise cubic hermite spline function and its derivative at x.'''
left = np.digitize( x, xi )-1
left = np.maximum( left, 0 )
left = np.minimum( left, len(xi)-2 )
Expand All @@ -191,24 +134,8 @@ def pchip_eval( x, xi, c0, c1, c2, c3 ):

return f, d

def make_pchip_OLD( xi, yi, lex=1, rex=1 ):

lex = lex
rex = rex

x0,(c0,c1,c2,c3) = pchip_fit( xi, yi, lex, rex )

@numba.njit
def itp(x):
return pchip_eval_OLD( x, x0, c0, c1, c2, c3 )

# compile
itp(np.ones(2))

return itp

def make_pchip( xi, yi, lex=1, rex=1 ):
'''Create piecE1ise cubic hermite spline evaluation function.'''
'''Create piecewise cubic hermite spline evaluation function.'''
lex = lex
rex = rex

Expand Down Expand Up @@ -237,7 +164,7 @@ def itp(x):

@numba.experimental.jitclass(spec)
class PchipInterpolator(object):
'''PiecE1ise cubic hermite spline interpolator.'''
'''Piecewise cubic hermite spline interpolator.'''
def __init__(self,xi,yi,lex=1,rex=1):
self.xi = xi
self.yi = yi
Expand All @@ -264,7 +191,7 @@ def calc(self,x):
# Corey and LET functions
#-------------------------------------------------------------------------------------

@numba.jit(nopython=True)
@numba.njit
def rlp_2p_linear(sat1v,sat1_data,kr1_data,kr2_data,lex=0,rex=0):

i = np.digitize( sat1v, sat1_data )-1
Expand Down Expand Up @@ -411,8 +338,6 @@ def rlp_2p_let(sat1v,Sr1,Sr2,L1,E1,T1,L2,E2,T2,Ke1,Ke2):
('rex', numba.int64 ),
]

# T2DO lex rex

@numba.experimental.jitclass(spec)
class Rlp2PLinear(object):

Expand All @@ -423,7 +348,7 @@ def __init__(self,sat1,kr1,kr2,lex=0,rex=0):
assert len(kr2)>1

# It is computationally more efficient to implement
# truncation by extending iput data set with edge values
# truncation by extending input dataset with edge values

if lex==0:
satn = sat1[0] - (sat1[1]-sat1[0])
Expand Down

0 comments on commit d547c94

Please sign in to comment.