Esempio n. 1
0
def test_errstate_all_but_one():
    olderr = sc.geterr()
    with sc.errstate(all='raise', singular='ignore'):
        sc.gammaln(0)
        with assert_raises(sc.SpecialFunctionError):
            sc.spence(-1.0)
    assert_equal(olderr, sc.geterr())
Esempio n. 2
0
def test_errstate_all_but_one():
    olderr = sc.geterr()
    with sc.errstate(all='raise', singular='ignore'):
        sc.gammaln(0)
        with assert_raises(sc.SpecialFunctionError):
            sc.spence(-1.0)
    assert_equal(olderr, sc.geterr())
Esempio n. 3
0
 def Jplus2(self):
     return (spence(1 - self.u1 / self.z1) - spence(1 - self.u2 / self.z2) +
             spence(1 - self.z1 / (self.z1 + self.u2)) -
             spence(1 - self.z2 / (self.z2 + self.u1)) +
             np.log(self.u1 / self.z1) * np.log(1 - self.u1 / self.z1) -
             np.log(self.u2 / self.z2) * np.log(1 - self.u2 / self.z2) +
             np.log(self.z2 / self.z1) * np.log(self.u *
                                                (self.z1 + self.u2)))
Esempio n. 4
0
def DiLog(arg):
  """Return the dilogarithm (Spence's function) defined as
     \Phi(x) = -\int_{0}^{x} \frac{\ln|1 - u|}{u} du.
     See https://en.wikipedia.org/wiki/Spence's_function"""
  if (arg <= 1):
    return special.spence(1. - arg)
  else:
    return (pi**2)/3. - (np.log(arg)**2)/2. - special.spence(1. - 1./arg)
Esempio n. 5
0
 def Iplus(self):
     return (spence(1 - self.u1 / self.w1) - spence(1 - self.u2 / self.w2) -
             2 * spence(1 - self.w1 / self.w2) +
             spence(1 - self.w1 / (self.w1 + self.u2)) -
             spence(1 - self.w2 / (self.w2 + self.u1)) + np.pi**2 / 3 +
             np.log(self.w2 / self.w1) * np.log(
                 (self.w1 + self.u2) * self.u / (self.w2 * self.z)) +
             np.log(self.u1 / self.w1) * np.log(1 - self.u1 / self.w1) -
             np.log(self.u2 / self.w2) * np.log(1 - self.u2 / self.w2))
Esempio n. 6
0
def test_consistency():
    # Make sure the implementation of spence for real arguments
    # agrees with the implementation of spence for imaginary arguments.

    x = np.logspace(-30, 300, 200)
    dataset = np.vstack((x + 0j, spence(x))).T
    FuncData(spence, dataset, 0, 1, rtol=1e-14).check()
Esempio n. 7
0
def Sc(c):
    ans = (0.5 * np.pi**2 - old_div(np.log(c), 2.) - old_div(0.5, c) -
           old_div(0.5, (1 + c)**2) - old_div(3, (1 + c)) + np.log(1 + c) *
           (0.5 + old_div(0.5, c**2) - old_div(2, c) - old_div(1, (1 + c))) +
           1.5 * (np.log(1 + c))**2 + 3. * spence(c + 1))

    return ans
Esempio n. 8
0
def gen(x, name):
    """Generate fixture data and writes them to file.

    # Arguments

    * `x`: domain
    * `name::str`: output filename

    # Examples

    ``` python
    python> x = linspace(0.0, 1.0, 2001)
    python> gen(x, './data.json')
    ```
    """
    y = spence(x)

    # Store data to be written to file as a dictionary:
    data = {"x": x.tolist(), "expected": y.tolist()}

    # Based on the script directory, create an output filepath:
    filepath = os.path.join(DIR, name)

    # Write the data to the output filepath as JSON:
    with open(filepath, "w") as outfile:
        json.dump(data, outfile)
Esempio n. 9
0
def test_consistency():
    # Make sure the implementation of spence for real arguments
    # agrees with the implementation of spence for imaginary arguments.

    x = np.logspace(-30, 300, 200)
    dataset = np.vstack((x + 0j, spence(x))).T
    FuncData(spence, dataset, 0, 1, rtol=1e-14).check()
Esempio n. 10
0
def w7_xy(mass):  #NLO
    y = NLOyy(mass)
    chunk_1 = (8 * y**2 - 28 * y + 12) / (3 * (y - 1)**3)
    chunk_2 = sp.spence(1.0 / y)
    chunk_3 = (3 * y**2 + 14 * y - 8) * (np.log(y))**2 / (3 * (y - 1)**4)
    chunk_4 = (4 * y**3 - 24 * y**2 + 2 * y + 6) * np.log(y) / (3 * (y - 1)**4)
    chunk_5 = (-2 * y**2 + 13 * y - 7) / ((y - 1)**3)
    return 4 / 3 * y * (chunk_1 * chunk_2 + chunk_3 + chunk_4 + chunk_5)
Esempio n. 11
0
def sig_dm2(x, c):  ##EQ 14 Lokas & Mamon 2001
    ans = 0.5 * x * c * gc(c) * (1 + x)**2 * (
        np.pi**2 - np.log(x) - (old_div(1., x)) - (old_div(1., (1. + x)**2)) -
        (old_div(6., (1. + x))) + np.log(1. + x) *
        (1. + (old_div(1., x**2)) - old_div(4., x) - old_div(2,
                                                             (1 + x))) + 3. *
        (np.log(1. + x))**2 + 6. * spence(x + 1))
    return ans
Esempio n. 12
0
def w8_xy(mass):  #NLO
    y = NLOyy(mass)
    c1 = (17 * y**2 - 25 * y + 36) / (2 * (y - 1)**3)
    c2 = sp.spence(1.0 / y)
    c3 = -(17 * y + 19) * (np.log(y))**2 / ((y - 1)**4)
    c4 = (14 * y**3 - 12 * y**2 + 187 * y + 3) * np.log(y) / (4 * (y - 1)**4)
    c5 = -(3 * (29 * y**2 - 44 * y + 143)) / (8 * (y - 1)**3)
    return 1 / 3 * y * (c1 * c2 + c3 + c4 + c5)
Esempio n. 13
0
 def test_spence_larger(self, dtype):
   x = np.random.uniform(1., 100., size=int(1e4)).astype(dtype)
   try:
     from scipy import special  # pylint: disable=g-import-not-at-top
     self.assertAllClose(
         special.spence(x), self.evaluate(special_math_ops.spence(x)))
   except ImportError as e:
     tf_logging.warn('Cannot test special functions: %s' % str(e))
Esempio n. 14
0
def sig_dm2(x, c):
    '''EQ 14 Lokas & Mamon 2001
    '''
    ans = 0.5 * x * c * gc(c) * (
        1 + x)**2 * (np.pi**2 - np.log(x) - (1. / x) - (1. / (1. + x)**2) -
                     (6. / (1. + x)) + np.log(1. + x) *
                     (1. + (1. / x**2) - 4. / x - 2 /
                      (1 + x)) + 3. * (np.log(1. + x))**2 + 6. * spence(x + 1))
    return ans
Esempio n. 15
0
 def phi2_theta_phi3(self):
     return (
         (7. / 36 + 2. * self.z / 45 + 7. * self.z * self.theta / 72) *
         (np.log(self.z2 / self.z1)**2 + np.pi**2 + 2 * np.log(self.z)**2) +
         (7. / 18 + 3. * self.z / 20 + 7. * self.z * self.theta / 36) *
         np.log(self.z) + 653. / 270 - 28. / (9 * self.z) +
         2. * self.theta / 3 + (-3 * self.z / 10 - 92. / 45 + 52. /
                                (45 * self.z) +
                                (2. / 9 - 7. * self.z / 18) * self.theta) *
         self.Bz * np.log(self.z2 / self.z1) + self.Bz *
         (-8. * self.z / 45 - 19. / 45 - 8. / (45 * self.z) -
          (2. / 9 + 7. * self.z / 18) * self.theta) *
         (spence(1 - self.y) + 2 * spence(1 - 1 / self.z2) +
          3 * np.log(self.z2 / self.z1)**2 / 2) +
         (8. / self.z + self.z * self.theta) * (self.Bz / (3 *
                                                           (self.z + 4))) *
         (6 * spence(1 - 1 / self.z2) - spence(1 - self.y) +
          np.log(self.z2 / self.z1)**2 / 2))
Esempio n. 16
0
def w8_sm():  #NLO
    x = NLOxx
    chunk_1 = (-4 * x**4 + 40 * x**3 + 41 * x**2 + x) / (6 * (x - 1)**4)
    chunk_2 = sp.spence(1.0 / x)
    chunk_3 = (-17 * x**3 - 31 * x**2) * (np.log(x))**2 / (2 * (x - 1)**5)
    chunk_4 = (- 210 * x**5 + 1086 * x**4 + 4893 * x**3 + 2857 * x**2 - 1994 * x + 280) * \
    np.log(x) / (216 * (x - 1)**5)
    chunk_5 = (737 * x**4 - 14102 * x**3 - 28209 * x**2 + 610 * x - 508) \
    / (1296 * (x - 1)**4)
    return chunk_1 * chunk_2 + chunk_3 + chunk_4 + chunk_5
Esempio n. 17
0
def w8_yy(mass):  #NLO
    y = NLOyy(mass)
    chunk_1 = (13 * y**3 - 17 * y**2 + 30 * y) / ((y - 1)**4)
    chunk_2 = sp.spence(1.0 / y)
    chunk_3 = -(17 * y**2 + 31 * y) / ((y - 1)**5) * (np.log(y))**2
    chunk_4 = (42 * y**4 + 318 * y**3 + 1353 * y**2 + 817 * y - 226) * \
np.log(y) / (36 * (y - 1)**5)
    chunk_5 = (-4451 * y**3 + 7650 * y**2 - 18153 * y + 1130) / (216 *
                                                                 (y - 1)**4)
    return 1 / 6 * y * (chunk_1 * chunk_2 + chunk_3 + chunk_4 + chunk_5) - \
1 / 6 * E_H(mass)
Esempio n. 18
0
def w7_sm():  #NLO
    x = NLOxx
    chunk_1 = (-16 * x**4 - 122 * x**3 + 80 * x**2 - 8 * x) / (9 * (x - 1)**4)
    chunk_2 = sp.spence(1.0 / x)
    chunk_3 = (6 * x**4 + 46 * x**3 -
               28 * x**2) * (np.log(x))**2 / (3 * (x - 1)**5)
    chunk_4 = (- 102 * x**5 - 588 * x**4 - 2262 * x**3 + 3244 * x**2 - 1364 * x + 208 ) * \
    np.log(x) / (81 * (x - 1)**5)
    chunk_5 = (1646 * x**4 + 12205 * x**3 - 10740 * x**2 + 2509 * x -
               436) / (486 * (x - 1)**4)
    return chunk_1 * chunk_2 + chunk_3 + chunk_4 + chunk_5
Esempio n. 19
0
def integrand_1D_PotOpt_DensWS(a_r_int, a_Args):
    """
    The function for Definition of the integrand.
    ~~~  For Woods-Saxon-type nucleus density   ~~~
    ~~~ Potential is optional (sphere function) ~~~
    
    => Defined as Int(|r|, |rP|) = 2Pi Int d_cosP rho_WS(r-rP) [|rP|^2 V(rP)]
    
    For arguments,
    - a_Args[4] (1-dim array)
    
    return (The value of integrand)
    
    Note1: a_r                   := a_Args[0]
    .      a_func_potential      := a_Args[1]
    .      a_Params_pot  (array) := a_Args[2]
    .      a_Params_dens (array) := a_Args[3]
    Note2: Suppose that a_Params_dens[0] = R_A
    .      Suppose that a_Params_dens[1] = a_A
    Note3: Suppose that rho  has no normalized factor (which is rho_0)
    """

    # For Debug
    #from numpy           import array
    #from scipy.integrate import quad
    #WS_2D = lambda c0, Ag: (exp ((Ag[2] - sqrt(Ag[0]**2 + Ag[1]**2 + 2.0*Ag[0]*Ag[1]*c0)) / Ag[3]) /
    #                        (exp((Ag[2] - sqrt(Ag[0]**2 + Ag[1]**2 + 2.0*Ag[0]*Ag[1]*c0)) / Ag[3]) + 1.0))
    #ret_integrand = quad(WS_2D, -1.0, 1.0, args = array((a_r_int, a_Args[0], a_Args[3][0], a_Args[3][1])))[0]
    #return ret_integrand * 2.0*pi * a_r_int**2 * a_Args[1](a_r_int, *a_Args[2])

    rprP = a_Args[0] + a_r_int
    rmrP = abs(a_Args[0] - a_r_int)

    exp_p = exp((a_Args[3][0] - rprP) / a_Args[3][1])
    exp_m = exp((a_Args[3][0] - rmrP) / a_Args[3][1])

    tmp_d = ((-rprP * log(1 + exp_p) + rmrP * log(1 + exp_m)) +
             (+spence(1 + exp_p) - spence(1 + exp_m)) * a_Args[3][1])

    return tmp_d * 2.0 * pi * a_Args[3][1] * a_r_int * a_Args[1](
        a_r_int, *a_Args[2]) / a_Args[0]
Esempio n. 20
0
def sigma(r,subject_flag):
    if (subject_flag==1): #Plummer
        sigmasq=1/(6*np.sqrt(1+r**2))
        return np.sqrt(2*sigmasq)
    elif (subject_flag==2): #Hernquist
        sigmasq=(r*(1+r)**3*np.log((1+r)/r)-(r/(12*(1+r)))*(25+52*r+42*r**2+12*r**3))*np.heaviside(1e2-r,1)+(1/(5*r))*np.heaviside(r-1e2,1)
        return np.sqrt(2*sigmasq)
    elif (subject_flag==3): #NFW
        #Li2=-r*( 1+(10**(-0.5))*(r**(0.62/0.7)) )**(-0.7)
        Li2=spence(1+r)
        sigmasq=0.5*r*(1+r)**2*( np.pi**2-np.log(r)-1/r-1/(1+r)**2-6/(1+r)+(1+1/r**2-4/r-2/(1+r))*np.log(1+r)+3*(np.log(1+r))**2+6*Li2 )
        return np.sqrt(2*sigmasq)
Esempio n. 21
0
def w7_yy(mass):  #NLO
    y = NLOyy(mass)

    chunk_1 = (8 * y**3 - 37 * y**2 + 18 * y) / ((y - 1)**4)
    chunk_2 = sp.spence(1.0 / y)
    chunk_3 = (3 * y**3 + 23 * y**2 - 14 * y) * (np.log(y))**2 / ((y - 1)**5)
    chunk_4 = (21 * y**4 - 192 * y**3 - 174 * y**2 + 251 * y - 50) \
    * np.log(y) / (9 * (y - 1)**5)
    chunk_5 = (-1202 * y**3 + 7569 * y**2 - 5436 * y + 797) / (108 *
                                                               (y - 1)**4)
    return 2 * y / 9 * (chunk_1 * chunk_2 + chunk_3 + chunk_4 + chunk_5) - \
4 / 9 * E_H(mass)
Esempio n. 22
0
def Pkernel(x):
    """Kernel function from Biteau & Williams (2015), Eq. (7)"""

    m = (x < 0.) & (x >= 1.)
    x[x < 0.] = np.zeros(np.sum(x < 0.))
    x[x >= 1.] = np.zeros(np.sum(x >= 1.))
    x = np.sqrt(x)

    result = np.log(2.) * np.log(2.)  - np.pi *np.pi / 6. \
            + 2. * spence(0.5 + 0.5 * x) - (x + x*x*x) / (1. - x*x) \
            + (np.log(1. + x) - 2. * np.log(2.)) * np.log(1. - x) \
            + 0.5 * (np.log(1. - x) * np.log(1. - x) - np.log(1. + x) * np.log(1. + x)) \
            + 0.5 * (1. + x*x*x*x) / (1. - x*x) * (np.log(1. + x) - np.log(1. - x))
    result[x <= 0.] = np.zeros(np.sum(x <= 0.))
    result[x >= 1.] = np.zeros(np.sum(x >= 1.))
    return result
Esempio n. 23
0
 def H(self):
     return (spence(1 - self.z / (self.u + 4)) - spence(1 - (self.z + 4) /
                                                        (self.u + 4)) +
             spence(1 - self.z / (self.z + 4)) - 2 * spence(1 - self.u /
                                                            (self.u + 4)) +
             spence(1 - 4 * self.w / (self.u * (self.z + 4))) +
             spence(1 - 4 * self.z / (self.u * (self.w + 4))) -
             spence(1 - 4 / (self.w + 4)) + np.pi**2 / 6 +
             2 * np.log(self.z1) * np.log(self.z2) -
             4 * np.log(self.u1) * np.log(self.u2) - np.log(self.z)**2 +
             np.log(self.z + 4)**2 -
             np.log(1 + 4. / self.w) * np.log(self.u + 4) -
             np.log(4 * self.w) * np.log(self.z + 4) +
             np.log(16) * np.log(self.u + 4) - np.log(self.u + 4)**2 +
             2 * np.log(self.u)**2 + np.log(self.u) * np.log(
                 (self.z + 4) * (self.w + 4) /
                 (4 * 4 * self.w)) - np.log(self.z) * np.log(
                     (self.z + 4) * self.u / (4 * self.w)))
Esempio n. 24
0
def f(eta, b0,b1,b2,\
          rb0,rb1,rb2,rrb0,rrb1,rrb2,rrrb0,rrrb1,rrrb2,\
          lb0,lb1,lb2,llb0,llb1,llb2,\
          rlb0,rlb1,rlb2,\
          sb0,sb1,sb2
     ):
  betas = [beta(eta)**j for j in [0,1,2,3]]
  x = chi(eta)
  return (rho(eta)**1)*(beta(eta)**9) * (\
            np.dot([b0,b1,b2],betas[:3]) +\
            np.dot([rb0,rb1,rb2],betas[:3])*rho(eta) +\
            np.dot([rrb0,rrb1,rrb2],betas[:3])*(rho(eta)**2) +\
            np.dot([rrrb0,rrrb1,rrrb2],betas[:3])*(rho(eta)**3) +\
            np.dot([lb0,lb1,lb2],betas[:3])*np.log(x)+\
            np.dot([llb0,llb1,llb2],betas[:3])*np.log(x)**2+\
            #np.dot([lllb0,lllb1,lllb2],betas[:3])*np.log(1+x)+\
            np.dot([sb0,sb1,sb2],betas[:3])*spence(1-x)+\
            #np.dot([sMb0,sMb1,sMb2],betas[:3])*spence(1-x**2)\
            np.dot([rlb0,rlb1,rlb2],betas[:3])*rho(eta)*np.log(x)\
         )
Esempio n. 25
0
def get_v(u, epsilon=1e-8):
    """get_v

    Parameters
    ----------
    u : ``int``

    epsilon : ``float``

    Returns
    -------

    """
    v = u
    delta = 1
    while delta > epsilon:
        n_v = u * np.sqrt(spence(np.exp(-v)))
        delta = abs(n_v - v)
        v = n_v
    return v
Esempio n. 26
0
def test_errstate_c_basic():
    olderr = sc.geterr()
    with sc.errstate(domain='raise'):
        with assert_raises(sc.SpecialFunctionError):
            sc.spence(-1)
    assert_equal(olderr, sc.geterr())
Esempio n. 27
0
def polylog(x):
    return spence(1-x)
Esempio n. 28
0
def test_errstate_c_basic():
    olderr = sc.geterr()
    with sc.errstate(domain='raise'):
        with assert_raises(sc.SpecialFunctionError):
            sc.spence(-1)
    assert_equal(olderr, sc.geterr())
Esempio n. 29
0
def g2(x):
    """ polylog(2, x) implemented via scipy.special.spence.
        This translation is due to scipy's definition of the dilogarithm
    """
    return spence(1.0 - x)
Esempio n. 30
0
def radiate_inelastic_xs(func, z, a, e, ep, theta, tb, ta, *, args=()):
    """
    Return radiated inelastic cross section.

    Parameters
    ----------
    func : callable
        Non-radiated cross section function.
    z : int
        Atomic number.
    a : int
        Mass number.
    e : rank-1 array of float
        Energy of incident electron.
    ep : rank-1 array of float
        Energy of scattered electron.
    theta : rank-1 array of float
        Scattering angle.
    tb : float
        Radiation length before scattering.
    ta : float
        Radiation length after scattering.
    args : tuple, optional
        Extra arguments to pass to function, if any.

    References
    ----------
    S. Stein et al., Phys. Rev. D 12(1975)1884
    """

    es = e
    m_t = mass(z, a)

    # scalars
    de = 0.005  # (A83)
    logz13 = np.log(183 * np.power(z, -1 / 3))
    eta = np.log(1440 * np.power(z, -2 / 3)) / logz13  # (A46)
    b = 4 / 3 * (1 + 1 / 9 * ((z + 1) / (z + eta)) / logz13)  # (A45)
    t = tb + ta  # (A47)
    xi = _m_e / (2 * _alpha_pi) * t / ((z + eta) * logz13)  # (A52)

    # vectors
    sin2_theta_2 = np.sin(theta / 2)**2
    q2 = 4 * es * ep * sin2_theta_2
    r = (m_t + 2 * es * sin2_theta_2) / (m_t - 2 * ep * sin2_theta_2)
    tr = _alpha_pi * (np.log(q2 / _m_e**2) - 1) / b  # (A57)

    # in scipy, spence is defined as \int_0^z log(t)/(1-t) dt
    # spence in the reference is spence(1 - z) here
    # so use 1 - cos2_theta_2 = sin2_theta_2
    spence = special.spence(sin2_theta_2)  # (A48)

    # (A44)
    def _f(es, ep, q2, spence):
        logq2me = np.log(q2 / _m_e**2)
        ff = 1 + 0.5772 * b * t
        ff += 2 * _alpha_pi * (-14 / 9 + 13 / 12 * logq2me)
        ff -= _alpha_pi / 2 * (np.log(es / ep))**2
        ff += _alpha_pi * (np.pi**2 / 6 - spence)
        return ff

    # (A82), 1st term
    term1_1 = np.power(r * de / es, b * (tb + tr))
    term1_2 = np.power(de / ep, b * (ta + tr))
    term1_3 = 1 - xi / de / (1 - b * (t + 2 * tr))
    xs = func(z, a, es, ep, theta, *args)
    term1 = term1_1 * term1_2 * term1_3 * _f(es, ep, q2, spence) * xs

    # (A54)
    def _phi(v):
        return 1 - v + 0.75 * v**2

    # (A82), 2nd term, integrand
    def term2_integrand(esp, es, ep, theta, q2, r, tr, spence):
        term2_1 = np.power((es - esp) / (ep * r), b * (ta + tr))
        term2_2 = np.power((es - esp) / es, b * (tb + tr))
        term2_3 = b * (tb + tr) / (es - esp) * _phi((es - esp) / es)
        term2_3 += xi / (2 * (es - esp)**2)
        xs = func(z, a, esp, ep, theta, *args)
        return term2_1 * term2_2 * term2_3 * _f(es, ep, q2, spence) * xs

    # (A82), 3rd term, integrand
    def term3_integrand(epp, es, ep, theta, q2, r, tr, spence):
        term3_1 = np.power((epp - ep) / epp, b * (ta + tr))
        term3_2 = np.power((epp - ep) * r / es, b * (tb + tr))
        term3_3 = b * (ta + tr) / (epp - ep) * _phi((epp - ep) / epp)
        term3_3 += xi / (2 * (epp - ep)**2)
        xs = func(z, a, es, epp, theta, *args)
        return term3_1 * term3_2 * term3_3 * _f(es, ep, q2, spence) * xs

    if np.isscalar(term1):
        term2, _ = integrate.quad(
            term2_integrand,
            ep / (1 - q2 / (2 * es * m_t)),  # (A50)
            es - r * de,
            args=(es, ep, theta, q2, r, tr, spence),
            epsrel=1e-3,
        )
        term3, _ = integrate.quad(
            term3_integrand,
            ep + de,
            es / (1 + q2 / (2 * ep * m_t)),  # (A51)
            args=(es, ep, theta, q2, r, tr, spence),
            epsrel=1e-3,
        )
    else:
        term2 = np.zeros_like(term1)
        term3 = np.zeros_like(term1)
        it = np.nditer(
            [es, ep, theta, q2, r, tr, spence, term2, term3],
            op_flags=[['readonly'], ['readonly'], ['readonly'], ['readonly'],
                      ['readonly'], ['readonly'], ['readonly'], ['writeonly'],
                      ['writeonly']],
        )
        for ies, iep, itheta, iq2, ir, itr, ispence, iterm2, iterm3 in it:
            iterm2[...], _ = integrate.quad(
                term2_integrand,
                iep / (1 - iq2 / (2 * ies * m_t)),  # (A50)
                ies - ir * de,
                args=(ies, iep, itheta, iq2, ir, itr, ispence),
                epsrel=1e-3,
            )
            iterm3[...], _ = integrate.quad(
                term3_integrand,
                iep + de,
                ies / (1 + iq2 / (2 * iep * m_t)),  # (A51)
                args=(ies, iep, itheta, iq2, ir, itr, ispence),
                epsrel=1e-3,
            )

    return term1 + term2 + term3
Esempio n. 31
0
def NFW_sigma(R, Mhalo, z, CosPar, fcorr=1., alpha=1.):
    """
    NFW_sigma(R, Mhalo, z, CosPar, fcorr=1., alpha=1.)
    return rho(R), R in Mpc, rho in MSun pc^-2
    """
    R = np.array(R) # r could be r(r) or r(r, Mhalo)
    R = R.reshape(R.shape[0], R.size/R.shape[0])
    Mhalo = np.array(Mhalo)
    c = fcorr*concentration(Mhalo, z, M_star)
    R_vir = virial_radius(Mhalo, z, CosPar)
    rhos = rho_s(c,z,CosPar,alpha)

    x = c*R/R_vir # cr/rvir(R, Mhalo)
    
    gc = 1./(np.log(1.+c)-c/(1.+c))
    return circular_virial(Mhalo,z,CosPar)*(1.+x)*np.sqrt(0.5*x*c*gc*(np.pi**2-np.log(x)-1./x-1./(1.+x)**2-6./(1.+x)+(1.+1./x/x-4./x-2./(1.+x))*np.log(1.+x)+3.*pow(np.log(1.+x),2)+6.*spence(1.+x)))
Esempio n. 32
0
import numpy as np
from numpy import abs, sqrt, arccos as acos, arccosh as acosh, log as ln, pi, inf
from scipy.special import spence
from scipy.integrate import quad as integrate

__all__ = ['lokas']

pi2 = pi**2
Li = lambda x: spence(1-x)

sa = 4/3
sa2 = sa**2


g = lambda c: 1 / (ln(1+c) - c/(1+c))

C1 = lambda Rt, c: acos if Rt>1/c else acosh

beta_om = lambda s: s**2 / (s**2 + sa2)
def sigmar2_overvvir2_om(s, c):
    c2 = c**2
    cs = c*s
    ln1cs = ln(1+cs)

    f1 = g(c) * s * (1+cs)**2 / (2 * (s**2 + sa2))
    f2  = -c * sa2 / s
    f2 += -c2 * sa2 * ln(cs)
    f2 +=  c2 * sa2 * ln1cs * (1 + 1/cs**2 - 4/cs)
    f2 += -(1 + c2*sa2) * (1/(1+cs)**2 + 2*ln1cs/(1+cs))
    f2 +=  (1 + 3*c2*sa2) * (pi2/3 - 2/(1+cs) + ln1cs**2 + 2*Li(-cs))
Esempio n. 33
0
def Li2(x):
    return special.spence(1-x)
Esempio n. 34
0
 def Jplus1(self):
     return 2 * spence(1 - 1 / self.z2) - spence(1 - self.y) + np.log(
         self.z1) * np.log(self.z2 / self.z1)
Esempio n. 35
0
    gamSModp = (GF*pow(alphaEM,2)*pow(125.0,3)/(128.*sqrt(2)*pow(pi,3)))*pow(abs(Aone + Atopsm),2)
    gamSMotot = 0.00407
    brsmdpnew = gamSMvlqdp/(gamSMotot - gamSModp + gamSMvlqdp)
    RgamgamSM = gamSMvlqdp/gamSModp
    
    mmtau = 1.777
    if 1.0 - 4.0*pow(mmtau/mHH,2) < 0:
        gamHtotata = 0
    else:
        gamHtotata = (GF*mHH*(mmtau**2)*((tan(beta))**2)/(4.*sqrt(2)*pi))*pow(sqrt(1.0 - 4.0*pow(mmtau/mHH,2)),3)
        
    #alphast = 0.096
    betat = sqrt(1. - 4.*(mt/mHH)**2)
    xbetat = ( 1. - betat)/(1. +  betat)
    #Spence function Li2(x) = spence(1-x)
    Li2 = spence(1.-betat)
    mLi2 = spence(1.+betat)
    Afunction = (1. + betat**2)*(4.*Li2 + 2.*mLi2 + 3.*log(xbetat)*log(2./(1.+betat)) + 2.*log(xbetat)*log(betat)) - 3.*betat*log((4.*betat**(4./3.))/(1. - betat**2))
    deltaHt = (1./betat)*Afunction + (1./(16.*betat**3))*(3. + 34.*betat**2 - 13.*betat**4)*log((1. + betat)/(1. - betat)) + (3./(8.*betat**2))*(7.*betat**2 - 1.)
    if mHH > 2.0*mtpole:
        gamHtott = ((3*GF)/(4*sqrt(2)*pi))*mHH*((mt/tan(beta))**2)*(betat**3)*(1. + (4./3.)*(alphas(mHH)/pi)*deltaHt)
    else:
        gamHtott = 0.


        
    gamHtot = gamHtot4 + gamHtogg + gamHtobb + gamHtohh + gamHtocc + gamHdiph + gamHtotata + gamHtott + gamHtot5 + gamHt4t4 + gamHt4t5 + gamHt5t5 + gamHtob4 + gamHtob5 + gamHb4b4 + gamHb4b5 + gamHb5b5
    brHtot4 = gamHtot4/gamHtot
    brHtobb = gamHtobb/gamHtot
    brHtohh = gamHtohh/gamHtot
    brHtogg = gamHtogg/gamHtot