admin管理员组

文章数量:1406924

I'm working currently on an analytical model for of a pressure transient well-test (build-up). Using formula from Lake's Petroleum Engineering Handbook Vol. 1, which describes pressure change in Laplace domain, i then use mpmath.invertlaplace() function with Stehfest algorithm to inverse it and get the results in time that i need.

import numpy as np
import matplotlib.pyplot as plt
from mpmath import *
q=46 #m3/day
rw=1.08 #m
h=8.61 #m
fi=0.164
Ct=1.67E-04 #1/(kgs/cm2)
mu=3.90
Bo=1.12 #m3/m3
Cs=0.15
k=0.199
Sm=-2
nu = k / (fi * mu * Ct)

def run_invertlaplace(tt, fp):
    y = []
    for i in np.arange(0, len(tt)):
        y.append(invertlaplace(fp, tt[i], method='stehfest'))

        print(i,y[i])
    return y

deltaTT=np.linspace(0.001,76,100)
fp = lambda s: q*Bo*mu/(2*np.pi*k*h*s)*((besselk(0,np.sqrt(s/nu)*(rw+0.001))+Sm*np.sqrt(s/nu)*rw*besselk(1,np.sqrt(s/nu)*rw))/(np.sqrt(s/nu)*rw*besselk(1,np.sqrt(s/nu)*rw)+24*Cs*mu/(2*np.pi*k*h)*s*(besselk(0,np.sqrt(s/nu)*(rw+0.001))+Sm*np.sqrt(s/nu)*rw*besselk(1,np.sqrt(s/nu)*rw))))
y=run_invertlaplace(deltaTT,fp)
print(y)
plt.plot(deltaTT,y,color="black")
plt.xscale('log')
plt.yscale('log')

plt.grid()
plt.show()

The problem occurs, when the Sm (skin-factor) value is negative. As you can see, black line contains some abnormal values that experimental data isn't. Is it the problem with modified bessel functions? What can i do to solve the problem? P.S I deeply apologise for my bad English.

I'm working currently on an analytical model for of a pressure transient well-test (build-up). Using formula from Lake's Petroleum Engineering Handbook Vol. 1, which describes pressure change in Laplace domain, i then use mpmath.invertlaplace() function with Stehfest algorithm to inverse it and get the results in time that i need.

import numpy as np
import matplotlib.pyplot as plt
from mpmath import *
q=46 #m3/day
rw=1.08 #m
h=8.61 #m
fi=0.164
Ct=1.67E-04 #1/(kgs/cm2)
mu=3.90
Bo=1.12 #m3/m3
Cs=0.15
k=0.199
Sm=-2
nu = k / (fi * mu * Ct)

def run_invertlaplace(tt, fp):
    y = []
    for i in np.arange(0, len(tt)):
        y.append(invertlaplace(fp, tt[i], method='stehfest'))

        print(i,y[i])
    return y

deltaTT=np.linspace(0.001,76,100)
fp = lambda s: q*Bo*mu/(2*np.pi*k*h*s)*((besselk(0,np.sqrt(s/nu)*(rw+0.001))+Sm*np.sqrt(s/nu)*rw*besselk(1,np.sqrt(s/nu)*rw))/(np.sqrt(s/nu)*rw*besselk(1,np.sqrt(s/nu)*rw)+24*Cs*mu/(2*np.pi*k*h)*s*(besselk(0,np.sqrt(s/nu)*(rw+0.001))+Sm*np.sqrt(s/nu)*rw*besselk(1,np.sqrt(s/nu)*rw))))
y=run_invertlaplace(deltaTT,fp)
print(y)
plt.plot(deltaTT,y,color="black")
plt.xscale('log')
plt.yscale('log')

plt.grid()
plt.show()

The problem occurs, when the Sm (skin-factor) value is negative. As you can see, black line contains some abnormal values that experimental data isn't. Is it the problem with modified bessel functions? What can i do to solve the problem? P.S I deeply apologise for my bad English.

Share Improve this question asked Mar 23 at 9:29 GeieGeie 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Looking at the documentation in mpmath, you can try the more robust 'cohen' method:

y.append(invertlaplace(fp, tt[i], method='cohen'))

To get this to work I had to switch the numpy.sqrt for cmath.sqrt, and obviously import cmath

Complete code:

import cmath
import numpy as np
import matplotlib.pyplot as plt
import scipy
from mpmath import *

q=46 #m3/day
rw=1.08 #m
h=8.61 #m
fi=0.164
Ct=1.67E-04 #1/(kgs/cm2)
mu=3.90
Bo=1.12 #m3/m3
Cs=0.15
k=0.199
Sm=-2
nu = k / (fi * mu * Ct)

def run_invertlaplace(tt, fp):
    y = []
    for i in np.arange(0, len(tt)):
        y.append(invertlaplace(fp, tt[i], method='cohen'))
    return y

deltaTT=np.linspace(0.001,76,100)
def fp( s ):
    c0 = q*Bo*mu/(2*cmath.pi*k*h*s)
    c1 = 24*Cs*mu/(2*cmath.pi*k*h)
    snur = cmath.sqrt(s/nu)*rw
#   k0 = besselk(0,snur)
#   k1 = besselk(1,snur)
    k0 = scipy.special.kve(0,snur)
    k1 = scipy.special.kve(1,snur)
    top = c0 * ( k0 + Sm * snur * k1 )
    bottom = snur * k1   +   c1 * s * ( k0 + Sm * snur * k1 )
    return top / bottom
y=run_invertlaplace(deltaTT,fp)
plt.plot(deltaTT,y,color="black")
plt.xscale('log')
plt.yscale('log')

plt.grid()
plt.show()

本文标签: pythoninvertlaplace() function makes abnomal calculationsStack Overflow