[Python] invertlaplace() function makes abnomal calculations

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    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, method='stehfest'))

    print(i,y)
    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.

    Continue reading...

Compartilhe esta Página