Beispiel #1
0
def Gaussian_1D_rat(t, ng):
    """
    Gaussian quadrature points and weights for rational function 1/|x-t|
    integration
    """
    x,w = Idat.Gaussian1D(ng)
    w1 = np.zeros(ng)
    for i in range(ng):
        for j in range(ng):
            w1[i] += (2.0*j+1.0)*poly_Legendre(x[i],j)*Legendre_Qn(t,j)
        w1[i] *= w[i]
        
    return x, w1
Beispiel #2
0
def Gaussian_1D_log(t, ng):
    """
    Gaussian quadrature points and weights for logarithmic function log|x-t|
    integration
    """
    x,w = Idat.Gaussian1D(ng)
    w1 = np.zeros(ng)
    for i in range(ng):
        for j in range(1,ng-1):
            w1[i] += (poly_Legendre(x[i],j-1)-poly_Legendre(x[i],j+1))*\
            R_function(t,j)
            
        w1[i] += (poly_Legendre(x[i],0)-poly_Legendre(x[i],1))*R_function(t,0)
        w1[i] += poly_Legendre(x[i],ng-2)*R_function(t,ng-1)
        w1[i] += poly_Legendre(x[i],ng-1)*R_function(t,ng)
        w1[i] *= w[i]
    return x, w1
Beispiel #3
0
def Gaussian_1D_Pn_Log_Rat(t, ng, m = -1):
    if m <= 0:
        m = math.ceil(ng/3)
    x,_ = Idat.Gaussian1D(ng)
    xi = np.empty((3*m,ng))
    mi = np.zeros(3*m)
    mi[0] = 2.0
    
    for i in range(m):
        for j in range(ng):
            pol = poly_Legendre(x[j],i)
            xi[i,j] = pol
            xi[i+m,j] = pol*math.log(math.fabs(x[j]-t))
            xi[i+2*m,j] = pol/(t-x[j])
        mi[i+m] = integration_PnLog(t,i)
        mi[i+2*m] = integration_PnRat(t,i)
        
    w1,_,_,_ = np.linalg.lstsq(xi, mi)
    return x, w1
Beispiel #4
0
def Gaussian_1D_Pn_Log(t, ng, m = -1):
    """
    Gaussian quadrature points and weights for function Pn(x)*log|x-t|
    """
    if m <= 0:
        m = math.ceil(ng/3)
    x,_ = Idat.Gaussian1D(ng)
    xi = np.empty((2*m,ng))
    mi = np.zeros(2*m)
    mi[0] = 2.0
    
    for i in range(m):
        for j in range(ng):
            pol = poly_Legendre(x[j],i)
            xi[i,j] = pol
            xi[i+m,j] = pol*math.log(math.fabs(x[j]-t))
        mi[i+m] = integration_PnLog(t,i)
        
    w1,_,_,_ = np.linalg.lstsq(xi, mi)
    
    return x, w1
Beispiel #5
0
def Gaussian_1D_rat2(t, ng):
    """
    Gaussian quadrature points and weights for rational function 1/|x-t|
    integration
    """
    x,w = Idat.Gaussian1D(ng)
    w1 = np.zeros(ng)
    for i in range(ng):
#        for j in range(ng-1):
#            for k in range(j,math.trunc((ng+j-3)/2)+1):
#                w1[i] -= (2*j+1)*(4*k+3-2*i)*Legendre_Qn(t,j)*\
#                poly_Legendre(x[i],2*k+1-(i+1))
        for j in range(1,ng):
            for k in range(math.trunc((j-1)/2)+1):
                w1[i] -= (2*j-4*k-1)*poly_Legendre(x[i],j)*(2*j+1)*\
                Legendre_Qn(t,j-2*k-1)
        for j in range(ng):
            w1[i] += (2.0*j+1.0)/2*poly_Legendre(x[i],j)*\
            (1.0/(t-1.0) - ((-1.0)**j)/(t+1))
        w1[i] *= w[i]
        
    return x, w1