Ejemplo n.º 1
0
def hollow_cylinder_theta(q,
                          radius,
                          thickness,
                          length,
                          sld,
                          sld_solvent,
                          volfraction=0,
                          radius_effective=None):
    #creates values z and corresponding probabilities w from legendre-gauss quadrature
    z, w = leggauss(76)
    F1 = np.zeros_like(q)
    F2 = np.zeros_like(q)
    #use a u subsition(u=cos) and then u=(z+1)/2 to change integration from
    #0->2pi with respect to alpha to -1->1 with respect to z, allowing us to use
    #legendre-gauss quadrature
    lower = 0.0
    upper = 1.0
    gamma_sq = (radius / (radius + thickness))**2
    for k, qk in enumerate(q):
        for i, zt in enumerate(z):
            # quadrature loop
            cos_theta = 0.5 * (zt * (upper - lower) + lower + upper)
            sin_theta = sqrt(1.0 - cos_theta * cos_theta)
            aaa = (radius + thickness) * qk * sin_theta
            ## sas_J1 expects an array, so try direct use of J1
            lam1 = J1(aaa) / aaa
            aaa = radius * qk * sin_theta
            lam2 = J1(aaa) / aaa
            psi = (lam1 - gamma_sq * lam2) / (1.0 - gamma_sq)
            #Note: lim_{thickness -> 0} psi = sas_J0(radius*qab)
            #Note: lim_{radius -> 0} psi = sas_2J1x_x(thickness*qab)
            aaa = 0.5 * length * qk * cos_theta
            t2 = sin(aaa) / aaa
            #            t2 = sas_sinx_x(0.5*length*qk*cos_theta)
            form = psi * t2
            F1[i] += w[i] * form
            F2[i] += w[i] * form * form
    volume = pi * ((radius + thickness)**2 - radius**2) * length
    s = (sld - sld_solvent) * volume
    F2 = F2 * s * (upper - lower) / 2.0
    F1 = F1 * s * s * (upper - lower) / 2.0
    if radius_effective is None:
        radius_effective = ER_hollow_cylinder(radius, thickness, length)
    SQ = hardsphere_simple(q, radius_effective, volfraction)
    SQ_EFF = 1 + F1**2 / F2 * (SQ - 1)
    IQM = 1e-4 * F2 / volume
    IQSM = volfraction * IQM * SQ
    IQBM = volfraction * IQM * SQ_EFF
    return Theory(Q=q,
                  F1=F1,
                  F2=F2,
                  P=IQM,
                  S=SQ,
                  I=IQSM,
                  Seff=SQ_EFF,
                  Ibeta=IQBM)
Ejemplo n.º 2
0
def np_fn(x, dtype):
    """
    Direct calculation using scipy.
    """
    from scipy.special import j1 as J1
    x = np.asarray(x, dtype)
    return np.asarray(2, dtype)*J1(x)/x
Ejemplo n.º 3
0
 def f(beta):
     u = core_radius * np.sqrt(k_core**2 - beta**2)
     v = core_radius * np.sqrt(beta**2 - k_clad**2)
     return v * J0(u) / J1(u) - u * K0(v) / K1(v)
Ejemplo n.º 4
0
 def f(r):
     if r < a:
         return 1 / np.pi * (v / (a * V) * J0(u / a * r) / J1(u))**2
     else:
         return 1 / np.pi * (u / (a * V) * K0(v / a * r) / K1(v))**2
Ejemplo n.º 5
0
def sas_2J1x_x(x):
    with np.errstate(all='ignore'):
        retvalue = 2 * J1(x) / x
    retvalue[x == 0] = 1.
    return retvalue