예제 #1
0
def _lorentzian_pink_beam(alpha, beta, fwhm_l, tth, tth_list):
    """
    @author Saransh Singh, Lawrence Livermore National Lab
    @date 03/22/2021 SS 1.0 original
    @details the lorentzian component of the pink beam peak profile
    obtained by convolution of gaussian with normalized back to back
    exponentials. more details can be found in
    Von Dreele et. al., J. Appl. Cryst. (2021). 54, 3–6
    """
    del_tth = tth_list - tth
    p = -alpha * del_tth + 1j * 0.5 * alpha * fwhm_l
    q = -beta * del_tth + 1j * 0.5 * beta * fwhm_l

    y = np.zeros(tth_list.shape)

    mask = np.logical_or(np.abs(np.real(p)) > 1e2, np.abs(np.imag(p)) > 1e2)
    f1 = np.zeros(tth_list.shape)
    f1[mask] = np.imag(np.exp(p[mask]) * exp1(p[mask]))

    mask = np.logical_or(np.abs(np.real(q)) > 1e2, np.abs(np.imag(q)) > 1e2)
    f2 = np.zeros(tth_list.shape)
    f2[mask] = np.imag(np.exp(q[mask]) * exp1(q[mask]))

    y = -(alpha*beta)/(np.pi*(alpha + beta)) *\
    (f1 + f2)

    y = np.nan_to_num(y)

    return y
def ILS_solver_global_coeff():
    coeff_all = np.zeros([BHE_wall_points_num_all, BHE_num, timestep_tot])

    for currstep in range(0, timestep_tot):
        #data container
        dist_bhe_to_ref_po = np.zeros([BHE_wall_points_num_all, BHE_num])
        localcoeff = np.zeros([BHE_wall_points_num_all, BHE_num])

        for i in range(0, BHE_num):
            #coefficient of current timestep
            for j in range(0, BHE_wall_points_num_all):
                dist_bhe_to_ref_po[j,i] = (bhe_pos_x[i] - bhe_wall_pos_x[j] )**2     \
                                        + (bhe_pos_y[i] - bhe_wall_pos_y[j] )**2
                exp1 = dist_bhe_to_ref_po[j, i] / (4 * alpha * delta_t *
                                                   (currstep + 1))
                n1 = sp.exp1(exp1)
                localcoeff[j, i] = 1 / (4 * math.pi * k_s) * n1
            #coefficient of current timestep after
            if currstep > 0:
                for j in range(0, BHE_wall_points_num_all):
                    dist_bhe_to_ref_po[j,i] = (bhe_pos_x[i] - bhe_wall_pos_x[j] )**2     \
                                            + (bhe_pos_y[i] - bhe_wall_pos_y[j] )**2
                    exp1 = dist_bhe_to_ref_po[j, i] / (4 * alpha * delta_t *
                                                       currstep)
                    n1 = sp.exp1(exp1)
                    localcoeff[
                        j, i] = localcoeff[j, i] - 1 / (4 * math.pi * k_s) * n1

        #reverse the coefficient order
        coeff_all[:, :, 1:] = coeff_all[:, :, :timestep_tot - 1]
        #store each timestep's localcoefficient into global time coefficient dataframe
        coeff_all[:, :, 0] = localcoeff

    return coeff_all
예제 #3
0
def _screening(e, ma):
    if ma == 0:
        return 0
    r0 = 1 / 0.001973  # 0.001973 MeV A -> 1 A (Ge) = 1/0.001973
    x = (r0 * ma**2 / (4 * e))**2
    numerator = 2 * log(2 * e / ma) - 1 - exp(-x) * (1 - exp(-x) / 2) + (
        x + 0.5) * exp1(2 * x) - (1 + x) * exp1(x)
    denomenator = 2 * log(2 * e / ma) - 1
    return numerator / denomenator
 def func(t, T, S):
     ftheis = Q / 4 / np.pi / T * exp1(
         R**2 * S / 4 / T /
         (t + 1e-9)) - Q / 4 / np.pi / T * exp1(R**2 * S / 4 / T /
                                                (trecov + 1e-9))
     if include_image_well:
         ftheis += Q / 4 / np.pi / T * exp1(
             Rimage**2 * S / 4 / T /
             (t + 1e-9)) - Q / 4 / np.pi / T * exp1(
                 Rimage**2 * S / 4 / T / (trecov + 1e-9))
     return ftheis
예제 #5
0
def analytic_soln(z):
    EPS = 1e-9
    src_mag = 8
    sigma_t = 8
    zstop = 1
    if src_mag != sigma_t:
        print('Bad src_mag != sigma_t')
        sys.exit(-1)
    return 1 - 0.5 * (np.exp(-z * sigma_t) + np.exp(sigma_t * (z - zstop)) -
                      src_mag * z * sp.exp1(sigma_t * z + EPS) - src_mag *
                      (zstop - z) * sp.exp1(sigma_t * (zstop - z) + EPS))
예제 #6
0
파일: sc.py 프로젝트: ocelot-collab/ocelot
    def imp_lsc(self, gamma, sigma, w, dz):
        """
        gamma - energy
        sigma - transverse RMS size of the beam
        w - omega = 2*pi*f
        """
        eps = 1e-16
        ass = 40.0

        alpha = w * sigma / (gamma * speed_of_light)
        alpha2 = alpha * alpha

        inda = np.where(alpha2 > ass)[0]
        ind = np.where((alpha2 <= ass) & (alpha2 >= eps))[0]

        T = np.zeros(w.shape)
        T[ind] = np.exp(alpha2[ind]) *exp1(alpha2[ind])

        x= alpha2[inda]
        k = 0
        for i in range(10):
            k += (-1) ** i * factorial(i) / (x ** (i + 1))
        T[inda] = k
        Z = 1j * Z0 / (4 * pi * speed_of_light*gamma**2) * w * T * dz
        return Z # --> Omm/m
예제 #7
0
def exp_int(s, x):
    r"""Calculate the exponential integral :math:`E_s(x)`.

    Given by: :math:`E_s(x) = \int_1^\infty \frac{e^{-xt}}{t^s}\,\mathrm dt`

    Parameters
    ----------
    s : :class:`float`
        exponent in the integral (should be > -100)
    x : :class:`numpy.ndarray`
        input values
    """
    if np.isclose(s, 1):
        return sps.exp1(x)
    if np.isclose(s, np.around(s)) and s > -0.5:
        return sps.expn(int(np.around(s)), x)
    x = np.array(x, dtype=np.double)
    x_neg = x < 0
    x = np.abs(x)
    x_compare = x**min((10, max(((1 - s), 1))))
    res = np.empty_like(x)
    # use asymptotic behavior for zeros
    x_zero = np.isclose(x_compare, 0, atol=1e-20)
    x_inf = x > max(30, -s / 2)  # function is like exp(-x)*(1/x + s/x^2)
    x_fin = np.logical_not(np.logical_or(x_zero, x_inf))
    x_fin_pos = np.logical_and(x_fin, np.logical_not(x_neg))
    if s > 1.0:  # limit at x=+0
        res[x_zero] = 1.0 / (s - 1.0)
    else:
        res[x_zero] = np.inf
    res[x_inf] = np.exp(-x[x_inf]) * (x[x_inf]**-1 - s * x[x_inf]**-2)
    res[x_fin_pos] = inc_gamma(1 - s, x[x_fin_pos]) * x[x_fin_pos]**(s - 1)
    res[x_neg] = np.nan  # nan for x < 0
    return res
예제 #8
0
파일: inversion.py 프로젝트: wsavran/etas
def upper_gamma_ext(a, x):
    if a > 0:
        return gammaincc(a, x) * gamma_func(a)
    elif a == 0:
        return exp1(x)
    else:
        return (upper_gamma_ext(a + 1, x) - np.power(x, a) * np.exp(-x)) / a
예제 #9
0
def trans_rate(k, h, phi, mu, ct, B, rw, pwf, pi, t):
    """trans_rate(k, h, phi, mu, ct, B, rw, pwf, pi, t) 
    Calculates the transient flow rate"""
    td = (2.637 * 10**(-4)) * k * (t * 24) / (phi * mu * ct * (rw**2))
    return (7.08 * 10**(-3)) * (k * h / (mu * B)) * ((pi - pwf) /
                                                     (0.5 * sp.exp1(1 /
                                                                    (4 * td))))
예제 #10
0
def test_GG(x, y):
    # Test some properties of the function according to [Del, p.367].
    z = x + 1j*y
    assert np.isclose(E1(z), exp1(z), rtol=1e-3)

    # (A3.5)
    assert np.isclose(E1(x - 1j*y), np.conjugate(E1(x + 1j*y)), rtol=1e-3)
예제 #11
0
 def forward(ctx, input):
     ctx.save_for_backward(input)
     dev = input.device
     with torch.no_grad():
         x = special.exp1(input.detach().cpu()).to(dev)
         input.to(dev)
     return x
예제 #12
0
파일: app.py 프로젝트: shubhamsoulpage/deep
def gfunc(xi, gamma=None):
    """
    MMSE-LSA Gain function
    """
    nu = np.multiply(np.divide(xi, np.add(1, xi)), gamma)
    G = np.multiply(np.divide(xi, np.add(1, xi)), np.exp(np.multiply(0.5, exp1(nu))))
    return G
예제 #13
0
 def distFunc(r_i):
     """
     Eq (20) of Bailer-Jones (2015) with everything that can be calculated
     outside, moved outside.
     """
     sc_int = .5 * exp1(.5 * ((r_i - mu) / lim_u)**2)
     sc_int.T[np.isinf(sc_int.T)] = 0.
     return B2 * sc_int
예제 #14
0
def test_exponential_integral(x, y):
    z = x + 1j*y

    # Compare with Scipy implementation
    assert np.isclose(E1(z), exp1(z), rtol=1e-3)

    # Test property (A3.5) of the function according to [Del, p.367]. 
    if y != 0.0:
        assert np.isclose(E1(np.conjugate(z)), np.conjugate(E1(z)), rtol=1e-3)
예제 #15
0
def CSTR_2_macro (x, p, grad=False):
	R  = p * x[0] * x[1]
	if R < 1.5e-3:
		# Risk of overflow
		C  = np.array([1.])
		dC = np.array([0.])
	else:
		C  = (1. / R) * np.exp(1. / R) * exp1(1. / R)
		dC = (1. - C*R - C)/(R*p)
	return C if not grad else [C, dC[None,:]]
 def _compute_van_regemorter(self, T, f_lu, nu_lu):
     g = 0.2  # This value is set to 2. We should select the value based on the main quantum number
     u = constants.h.cgs.value * nu_lu / constants.k_B.cgs.value / T
     I = 13.6  # eV
     c0 = 5.46510e-11
     gamma = lambda a,u: max(a,(0.276 * np.exp(u) * scisp.exp1(u)))
     #c = c0 * T ** (0.5) * 14.5 * (I / constants.h.cgs.value / nu_lu ) * f_lu * constants.h.cgs.value * nu_lu \
     #    / constants.k_B.cgs.value / T * np.exp(- u) * gamma
     c = c0 * T ** (0.5) * 14.5 * (I / constants.h.cgs.value / nu_lu ) * f_lu * u * np.exp(- u) * gamma(g, u)
     return c
예제 #17
0
파일: rfunc.py 프로젝트: adivicco47/pastas
 def step(self, p, dt=1, cutoff=0.99):
     if isinstance(dt, np.ndarray):
         t = dt
     else:
         self.tmax = max(self.get_tmax(p, cutoff), 3 * dt)
         t = np.arange(dt, self.tmax, dt)
     r = p[2]
     u = r**2.0 * p[0] / (4.0 * p[1] * t)
     s = self.up * exp1(u)
     return s
예제 #18
0
def chi(z):
    """Hyperbolic cosine integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = -(exp1(-zc) + exp1(zc) + log(-zc) - log(zc)) / 2.0
    if not iscomplexobj(z):
        res = real(res)

    # Return -inf for 0, +inf for +inf, +inf for -inf:
    res[where(zc == -inf)[0]] = inf
    res[where(zc == inf)[0]] = inf
    res[where(zc == 0)[0]] = -inf

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #19
0
def _compute_mean(C, g, ctx):
    """
    Compute mean according to equation 8a, page 773.
    """
    mag = ctx.mag
    dis = ctx.rrup

    # computing r02 parameter and the average distance to the fault surface
    ro2 = 1.4447e-5 * np.exp(2.3026 * mag)
    avg = np.sqrt(dis**2 + ro2)

    # computing fourth term of Eq. 8a, page 773.
    trm4 = (exp1(C['c4'] * dis) - exp1(C['c4'] * avg)) / ro2

    # computing the mean
    mean = C['c1'] + C['c2'] * mag + C['c3'] * np.log(trm4)

    # convert from cm/s**2 to 'g'
    mean = np.log(np.exp(mean) * 1e-2 / g)
    return mean
예제 #20
0
def chi(z):
    """Hyperbolic cosine integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = -(exp1(-zc)+exp1(zc)+log(-zc)-log(zc))/2.0
    if not iscomplexobj(z):
        res = real(res)

    # Return -inf for 0, +inf for +inf, +inf for -inf:
    res[where(zc==-inf)[0]] = inf
    res[where(zc==inf)[0]] = inf
    res[where(zc==0)[0]] = -inf

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #21
0
def si(z):
    """Sine integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = (1j/2)*(exp1(-1j*zc)-exp1(1j*zc)+log(-1j*zc)-log(1j*zc))
    if not iscomplexobj(z):
        res = real(res)

    # Return 0 for 0, pi/2 for +inf, -pi/2 for -inf:
    res[where(zc==-inf)[0]] = -pi/2
    res[where(zc==inf)[0]] = pi/2
    res[where(zc==0)[0]] = 0

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #22
0
def si(z):
    """Sine integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = (1j / 2) * (exp1(-1j * zc) - exp1(1j * zc) + log(-1j * zc) -
                      log(1j * zc))
    if not iscomplexobj(z):
        res = real(res)

    # Return 0 for 0, pi/2 for +inf, -pi/2 for -inf:
    res[where(zc == -inf)[0]] = -pi / 2
    res[where(zc == inf)[0]] = pi / 2
    res[where(zc == 0)[0]] = 0

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #23
0
def ci(z):
    """Cosine integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = log(zc)-(exp1(-1j*zc)+exp1(1j*zc)+log(-1j*zc)+log(1j*zc))/2.0

    if not iscomplexobj(z):
        res = real(res)

    # Return -inf for 0, 0 for +inf, and pi*1j for -inf:
    res[where(zc==-inf)[0]] = pi*1j
    res[where(zc==inf)[0]] = 0
    res[where(zc==0)[0]] = -inf

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #24
0
def i_tir_integrand(lamb, z_s, bc03):
    prefactor = 1 / (8 * np.pi) / np.sin(np.abs(b))
    term1 = 1 - dust_albedo_f(lamb)
    term2 = surface_power_deriv(bc03, z_s, lamb)
    tau_zs = tau_f(lamb, z_s)
    tau_0 = tau_f(lamb, 0)
    term3 = 2 + tau_zs * special.exp1(tau_zs) - np.exp(-tau_zs) \
        + (tau_0 - tau_zs) * special.exp1(tau_0 - tau_zs) - np.exp(tau_zs - tau_0)
    term3_2 = (tau_0 - tau_zs)*special.exp1(tau_zs - tau_0) + np.exp(tau_0 - tau_zs) \
        + tau_zs * special.exp1(tau_zs) - np.exp(-tau_zs)

    if type(z_s) == np.ndarray or type(lamb) == np.ndarray:
        np.putmask(term3, tau_zs > tau_0, term3_2)
    elif tau_zs > tau_0:
        term3 = term3_2

    # apply neg. sign:
    term3 = -term3

    result = prefactor * term1 * term2 * term3
    return result
def gompertz_lifeyears(par, minage, maxage):
    a = par[0]
    b = par[1]
    if -0.00001 < b < 0.00001:  # b is approximately 0
        return exp(-a) - exp(-a - exp(a) * (maxage - minage))
    else:
        f_min = 1 / b * exp(a + b * minage)
        f_max = 1 / b * exp(a + b * maxage)
        cons_of_integ = exp(f_min)

        if b > 0:
            LY = -1 * cons_of_integ / b * (exp1(f_max) - exp1(f_min))
        else:
            LY = -1 * cons_of_integ / b * (exp1(complex(f_max)) -
                                           exp1(complex(f_min))).real

        if isnan(LY) and gompertz_survival(
                a, b, minage,
                minage + 0.01) < 0.00001:  # everyone dies instantly
            return 0.0
        else:
            return LY
예제 #26
0
def ci(z):
    """Cosine integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = log(zc) - (exp1(-1j * zc) + exp1(1j * zc) + log(-1j * zc) +
                     log(1j * zc)) / 2.0

    if not iscomplexobj(z):
        res = real(res)

    # Return -inf for 0, 0 for +inf, and pi*1j for -inf:
    res[where(zc == -inf)[0]] = pi * 1j
    res[where(zc == inf)[0]] = 0
    res[where(zc == 0)[0]] = -inf

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #27
0
def f_dust(tau): 
    '''(ndarray) -> ndarray
    Dust extinction functin'''
    out = nu.zeros_like(tau)
    if nu.all(out == tau): #if all zeros
        return nu.ones_like(tau)
    if nu.any(tau < 0): #if has negitive tau
        out.fill(nu.inf)
        return out
    temp = tau[tau <= 1]
    out[tau <= 1] = (1 / (2. * temp) * (1 + (temp - 1) * nu.exp(-temp)
                                        - temp ** 2 * exp1(temp)))
    out[tau > 1] = nu.exp(-tau[tau > 1])
    return out
예제 #28
0
def f_dust(tau):
    '''(ndarray) -> ndarray
    Dust extinction functin'''
    out = nu.zeros_like(tau)
    if nu.all(out == tau):  #if all zeros
        return nu.ones_like(tau)
    if nu.any(tau < 0):  #if has negitive tau
        out.fill(nu.inf)
        return out
    temp = tau[tau <= 1]
    out[tau <= 1] = (1 / (2. * temp) *
                     (1 + (temp - 1) * nu.exp(-temp) - temp**2 * exp1(temp)))
    out[tau > 1] = nu.exp(-tau[tau > 1])
    return out
예제 #29
0
def rate_function_Dere2007(Te, arr):
    """
    temperature is in eV
    """
    tck = interpolate.splrep(arr[2], arr[3],
                             s=1)  # spline representation of ionisation rate
    # arr[2] is x values, arr[3] is scaled rates
    redt = Te / arr[0]  # ratio of temperature in eV to IP
    xval = 1.0 - np.log(2.0) / np.log(2.0 + redt)  # Eq. (4) of Dere+ 2007
    #print(xval)
    rho = interpolate.splev(xval, tck, der=0, ext=0)
    rateval = (redt**-0.5) * (arr[0]**-1.5) * (
        1.0E-6 * rho) * specialfunc.exp1(1.0 / redt)
    return rateval
예제 #30
0
    def test_branch_cut(self):
        assert np.isnan(sc.exp1(-1))
        assert sc.exp1(complex(-1,
                               0)).imag == (-sc.exp1(complex(-1, -0.0)).imag)

        assert_allclose(sc.exp1(complex(-1, 0)),
                        sc.exp1(-1 + 1e-20j),
                        atol=0,
                        rtol=1e-15)
        assert_allclose(sc.exp1(complex(-1, -0.0)),
                        sc.exp1(-1 - 1e-20j),
                        atol=0,
                        rtol=1e-15)
예제 #31
0
파일: sc.py 프로젝트: sserkez/ocelot-1
    def imp_lsc(self, gamma, sigma, w, dz):
        """
        gamma - energy
        sigma - transverse RMS size of the beam
        w - omega = 2*pi*f
        """
        indx = np.where(w < 1e-7)[0]
        w[indx] = 1e-7
        alpha = w * sigma / (gamma * speed_of_light)
        alpha2 = alpha * alpha
        ksi = np.exp(alpha2 + np.log(exp1(alpha2)) - 2 * np.log(gamma))
        Z = 1j * Z0 / (4 * pi * speed_of_light) * w * ksi * dz

        Z[indx] = 0
        return Z * 1e-12  # --> V/pC
예제 #32
0
파일: gain.py 프로젝트: zk1001/DeepXi
def mmse_lsa(xi, gamma):
    '''
	Computes the MMSE-LSA gain function.
		
	Input/s: 
		xi - a priori SNR.
		gamma - a posteriori SNR.
		
	Output/s: 
		MMSE-LSA gain function.
	'''
    nu = np.multiply(np.divide(xi, np.add(1, xi)), gamma)
    return np.multiply(np.divide(xi, np.add(1, xi)),
                       np.exp(np.multiply(
                           0.5, exp1(nu))))  # MMSE-LSA gain function.
예제 #33
0
 def function(self, x, y, kappa_0, theta_c, center_x=0, center_y=0):
     """
     :param x: angular position (normally in units of arc seconds)
     :param y: angular position (normally in units of arc seconds)
     :param kappa_0: central convergence of profile
     :param theta_c: core radius (in arcsec)
     :param center_x: center of halo (in angular units)
     :param center_y: center of halo (in angular units)
     :return: lensing potential (in arcsec^2)
     """
     x_ = x - center_x
     y_ = y - center_y
     r = np.sqrt(x_**2 + y_**2)
     r = np.maximum(r, self._s)
     Integral_factor = 0.5 * exp1((r / theta_c)**2) + np.log((r / theta_c))
     function = kappa_0 * theta_c**2 * Integral_factor
     return function
예제 #34
0
파일: special.py 프로젝트: muizzk/GSTools
def exp_int(s, x):
    r"""The exponential integral :math:`E_s(x)`

    Given by: :math:`E_s(x) = \int_1^\infty \frac{e^{-xt}}{t^s}\,\mathrm dt`

    Parameters
    ----------
    s : :class:`float`
        exponent in the integral
    x : :class:`numpy.ndarray`
        input values
    """
    if np.isclose(s, 1):
        return sps.exp1(x)
    if np.isclose(s, np.around(s)) and s > -1:
        return sps.expn(int(np.around(s)), x)
    return inc_gamma(1 - s, x) * x**(s - 1)
예제 #35
0
def ei(z):
    """Exponential integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = -exp1(-zc)+(log(zc)-log(1.0/zc))/2.0-log(-zc)
    if not iscomplexobj(z):
        res = real(res)

    # Return 0 for -inf, inf for +inf, and -inf for 0:
    res[where(zc==-inf)[0]] = 0
    res[where(zc==inf)[0]] = inf
    res[where(zc==0)[0]] = -inf

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #36
0
def li(z):
    """Logarithmic integral of a complex value."""

    if iterable(z):
        zc = asarray(z, complex)
    else:
        zc = array(z, complex, ndmin=1)
    res = -exp1(-log(zc))+(log(log(zc))-log(1/log(zc)))/2.0-log(-log(zc))
    if not iscomplexobj(z) and not any(z < 0):
        res = real(res)

    # Return 0 for 0, -inf for 1, and +inf for +inf:
    res[where(zc==inf)[0]] = inf
    res[where(zc==0)[0]] = 0
    res[where(zc==1)[0]] = -inf

    if iterable(z):
        return res
    else:
        return asscalar(res)
예제 #37
0
파일: rfunc.py 프로젝트: pastas/pasta
 def step(self, p, dt=1, cutoff=None):
     rho = p[1]
     cS = p[2]
     k0rho = k0(rho)
     if isinstance(dt, np.ndarray):
         t = dt
     else:
         self.tmax = max(self.get_tmax(p, cutoff), 10 * dt)
         t = np.arange(dt, self.tmax, dt)
     tau = t / cS
     tau1 = tau[tau < rho / 2]
     tau2 = tau[tau >= rho / 2]
     w = (exp1(rho) - k0rho) / (exp1(rho) - exp1(rho / 2))
     F = np.zeros_like(tau)
     F[tau < rho / 2] = w * exp1(rho ** 2 / (4 * tau1)) - (w - 1) * exp1(
         tau1 + rho ** 2 / (4 * tau1))
     F[tau >= rho / 2] = 2 * k0rho - w * exp1(tau2) + (w - 1) * exp1(
         tau2 + rho ** 2 / (4 * tau2))
     return p[0] * F / (2 * k0rho)
 def compute_by_noise_pow(self,signal,n_pow):
     s_spec = sp.fft(signal*self._window)
     s_amp = sp.absolute(s_spec)
     s_phase = sp.angle(s_spec)
     gamma = self._calc_aposteriori_snr(s_amp,n_pow)
     xi = self._calc_apriori_snr(gamma)
     #xi = self._calc_apriori_snr2(gamma,n_pow)
     self._prevGamma = gamma
     nu = gamma * xi / (1.0+xi)
     self._G = xi/(1.0+xi)*sp.exp(0.5*spc.exp1(nu))
     idx = sp.less(s_amp**2.0,n_pow)
     self._G[idx] = self._constant
     idx = sp.isnan(self._G) + sp.isinf(self._G)
     self._G[idx] = xi[idx] / ( xi[idx] + 1.0)
     idx = sp.isnan(self._G) + sp.isinf(self._G)
     self._G[idx] = self._constant
     self._G = sp.maximum(self._G,0.0)
     amp = self._G * s_amp
     amp = sp.maximum(amp,0.0)
     amp2 = self._ratio*amp + (1.0-self._ratio)*s_amp
     self._prevAmp = amp
     spec = amp2 * sp.exp(s_phase*1j)
     return sp.real(sp.ifft(spec))
예제 #39
0
 def test_exp1_complex128(self):
     z = np.asarray(np.random.rand(4, 4) + 1j*np.random.rand(4, 4), np.complex128)
     z_gpu = gpuarray.to_gpu(z)
     e_gpu = special.exp1(z_gpu)
     assert np.allclose(sp.special.exp1(z), e_gpu.get())   
예제 #40
0
 def W0(t):
     '''compute the dimensionless pressure increase in the bottom aquifer created by the injection, at the distance d'''
     return exp1(d**2/(4*t*GetTSratio(w_b, k_b, Cr_b, mu_b, Cb_b)))
예제 #41
0
 def W_lb(t):
     '''compute the dimensionless well pressure decrease in the bottom aquifer created by the leakage, at the leak location'''
     return exp1(r_l**2/(4*t*GetTSratio(w_b, k_b, Cr_b, mu_b, Cb_b)))
예제 #42
0
 def W_lt(t):
     '''compute the dimensionless well pressure increase in the top aquifer created by the leakage, at the leak location'''
     return rho_t*mu_t*h_b*k_b/(rho_b*mu_b*h_t*k_t) * exp1(r_l**2/(4*t*GetTSratio(w_t, k_t, Cr_t, mu_t, Cb_t)))
예제 #43
0
Deff=k/(theta*beta*mu)
Tunit=k*b
Sunit=b*theta*beta
Kg=k*rho*g/mu
vinj=Qv/(2*np.pi*rwell*b)
Re=2*rwell*rho*vinj/mu

Trans = Tunit*rho*g/mu
Stor = Sunit*rho*g

r=np.linspace(rwell, rout, 1000)
rMat=np.tile(r,(len(t), 1))
tMat=np.tile(t,(1,len(r)))

u=np.power(rMat,2.)*Stor/(4*Trans*tMat)
W=sp.exp1(u)
s=Qv/(4*np.pi*Trans)*W
pres=P-s*rho*g

falc=np.loadtxt('../Theis problem BM/theis_falcon.csv',delimiter=',',skiprows=1)

p1 = plt.plot(r,pres[0,:],'b-',r,pres[1,:],'g-',r,pres[2,:],'r-')
p2 = plt.plot(falc[:,0],falc[:,1],'bs',falc[:,0],falc[:,2],'gs',falc[:,0],falc[:,3],'rs')
plt.setp(p2, alpha=0.25)
plt.xlabel('Radius [m]')
plt.ylabel('Pressure [Pa]')
p1.extend(p2)
plt.legend(p1,['Ana. $t=2.00$ s','Ana. $t=20.0$ s','Ana. $t=200$ s','FALCON $t=2.00$ s','FALCON $t=20.0$ s','FALCON $t=200$ s'],loc=4)
plt.ylim([9.2e4, 1e5])
#tikz_save('Theis.tikz',figureheight=r'\figureheight', figurewidth=r'\figurewidth',show_info=False)
plt.show()
예제 #44
0
파일: 4-7.py 프로젝트: creasyw/Courses
def function(x):
    return 1 / x * exp(-x / average) - exp1(x / average) / average
예제 #45
0
 def theor_prod_uni_norm(a, sigma, x):
     return 0.5/sqrt(2*numpy.pi) * exp1(0.5 * (x/(a*sigma))**2)