Changeset 40a87fa in sasmodels for sasmodels/models


Ignore:
Timestamp:
Aug 8, 2016 11:24:11 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2472141
Parents:
2d65d51
Message:

lint and latex cleanup

Location:
sasmodels/models
Files:
1 deleted
45 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/adsorbed_layer.py

    r2c74c11 r40a87fa  
    9393    inten = 6.0e-02 * pi * volfraction * aa**2 * exp(-bb**2) / radius 
    9494    return inten 
    95 Iq.vectorized =  True  # Iq accepts an array of q values 
     95Iq.vectorized = True  # Iq accepts an array of q values 
    9696 
    9797# unit test values taken from SasView 3.1.2 
    98 tests =  [ 
     98tests = [ 
    9999    [{'scale': 1.0, 'second_moment': 23.0, 'adsorbed_amount': 1.9, 
    100100      'density_shell': 0.7, 'radius': 500.0, 'volfraction': 0.14, 
  • sasmodels/models/broad_peak.py

    r2c74c11 r40a87fa  
    1515The scattering intensity $I(q)$ is calculated as 
    1616 
    17 .. math:: 
    18  
    19     I(q) = \frac{A}{q^n} + \frac{C}{1 + (|q - q_0|\xi)^m} + B 
     17.. math:: I(q) = \frac{A}{q^n} + \frac{C}{1 + (|q - q_0|\xi)^m} + B 
    2018 
    2119Here the peak position is related to the d-spacing as $q_o = 2\pi / d_o$. 
    2220 
    23 $A$ is the Porod law scale factor, $n$ the Porod exponent, $C$ is the Lorentzian  
    24 scale factor, $m$ the exponent of q, \ |xi|\  the screening length, and $B$ the flat background. 
     21$A$ is the Porod law scale factor, $n$ the Porod exponent, $C$ is the 
     22Lorentzian scale factor, $m$ the exponent of $q$, $\xi$ the screening length, 
     23and $B$ the flat background. 
    2524 
    2625For 2D data the scattering intensity is calculated in the same way as 1D, 
    2726where the $q$ vector is defined as 
    2827 
    29 .. math:: 
    30  
    31     q = \sqrt{q_x^2 + q_y^2} 
    32  
     28.. math:: q = \sqrt{q_x^2 + q_y^2} 
    3329 
    3430References 
     
    3834 
    3935*2013/09/09 - Description reviewed by King, S and Parker, P.* 
    40  
    4136""" 
    4237 
  • sasmodels/models/core_multi_shell.py

    re187b25 r40a87fa  
    44 
    55This model is a trivial extension of the CoreShell function to a larger number 
    6 of shells. The scattering length density profile for the default sld values  
     6of shells. The scattering length density profile for the default sld values 
    77(w/ 4 shells). 
    88 
     
    2525          effective radius for $S(Q)$ when $P(Q)*S(Q)$ is applied. 
    2626 
    27 For information about polarised and magnetic scattering, see  
     27For information about polarised and magnetic scattering, see 
    2828the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` documentation. 
    2929 
     
    3333References 
    3434---------- 
    35 See the :ref:`core_shell_sphere <core_shell_sphere>` model documentation. 
     35See the :ref:`core-shell-sphere` model documentation. 
    3636 
    3737L A Feigin and D I Svergun, 
     
    5151 
    5252import numpy as np 
    53 from numpy import inf, nan 
    54 from math import fabs, exp, expm1 
     53from numpy import inf 
    5554 
    5655name = "core_multi_shell" 
     
    9998              ["thickness[n]", "Ang", 40., [0, inf], "volume", 
    10099               "Thickness of shell k"], 
    101               ] 
     100             ] 
    102101 
    103102source = ["lib/sph_j1c.c", "core_multi_shell.c"] 
     
    107106    Returns the SLD profile *r* (Ang), and *rho* (1e-6/Ang^2). 
    108107    """ 
    109     r = [] 
     108    z = [] 
    110109    rho = [] 
    111110 
    112111    # add in the core 
    113     r.append(0) 
     112    z.append(0) 
    114113    rho.append(sld_core) 
    115     r.append(radius) 
     114    z.append(radius) 
    116115    rho.append(sld_core) 
    117116 
     
    119118    for k in range(n): 
    120119        # Left side of each shells 
    121         r.append(r[-1]) 
     120        z.append(z[-1]) 
    122121        rho.append(sld[k]) 
    123         r.append(r[-1] + thickness[k]) 
     122        z.append(z[-1] + thickness[k]) 
    124123        rho.append(sld[k]) 
    125124    # add in the solvent 
    126     r.append(r[-1]) 
     125    z.append(z[-1]) 
    127126    rho.append(sld_solvent) 
    128     r.append(r[-1]*1.25) 
     127    z.append(z[-1]*1.25) 
    129128    rho.append(sld_solvent) 
    130129 
    131     return np.asarray(r), np.asarray(rho) 
     130    return np.asarray(z), np.asarray(rho) 
    132131 
    133132def ER(radius, n, thickness): 
     133    """Effective radius""" 
    134134    n = n[0]  # n cannot be polydisperse 
    135135    return np.sum(thickness[:n], axis=0) + radius 
    136136 
    137 def VR(radius, n, thickness): 
    138     return 1.0, 1.0 
    139  
    140 demo = dict(sld_core = 6.4, 
    141             radius = 60, 
    142             sld_solvent = 6.4, 
    143             n = 2, 
    144             sld = [2.0, 3.0], 
    145             thickness = 20, 
    146             thickness1_pd = 0.3, 
    147             thickness2_pd = 0.3, 
    148             thickness1_pd_n = 10, 
    149             thickness2_pd_n = 10, 
     137demo = dict(sld_core=6.4, 
     138            radius=60, 
     139            sld_solvent=6.4, 
     140            n=2, 
     141            sld=[2.0, 3.0], 
     142            thickness=20, 
     143            thickness1_pd=0.3, 
     144            thickness2_pd=0.3, 
     145            thickness1_pd_n=10, 
     146            thickness2_pd_n=10, 
    150147            ) 
  • sasmodels/models/core_shell_bicelle.py

    r42356c8 r40a87fa  
    33Definition 
    44---------- 
    5 This model provides the form factor for a circular cylinder with a core-shell 
    6 scattering length density profile. Thus this is a variation of a core-shell cylinder  
    7 or disc where the shell on the walls and ends may be of different thicknesses and scattering 
    8 length densities. The form factor is normalized by the particle volume. 
     5This model provides the form factor for a circular cylinder with a 
     6core-shell scattering length density profile. Thus this is a variation 
     7of a core-shell cylinder or disc where the shell on the walls and ends 
     8may be of different thicknesses and scattering length densities. The form 
     9factor is normalized by the particle volume. 
    910 
    1011.. _core-shell-bicelle-geometry: 
     
    1213.. figure:: img/core_shell_bicelle_geometry.png 
    1314 
    14     (Graphic from DOI: 10.1039/C0NP00002G, note however that the model here calculates for rectangular, not curved, rims.) 
    15  
     15    (Graphic from DOI: 10.1039/C0NP00002G, note however that the model here 
     16    calculates for rectangular, not curved, rims.) 
    1617 
    1718The output of the 1D scattering intensity function for randomly oriented 
     
    8889# pylint: enable=bad-whitespace, line-too-long 
    8990 
    90 source = ["lib/Si.c","lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_bicelle.c"] 
     91source = ["lib/Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", 
     92          "core_shell_bicelle.c"] 
    9193 
    9294demo = dict(scale=1, background=0, 
  • sasmodels/models/core_shell_cylinder.py

    r42356c8 r40a87fa  
    5252 
    5353To provide easy access to the orientation of the core-shell cylinder, we 
    54 define the axis of the cylinder using two angles $\theta$ and $\phi$.  
     54define the axis of the cylinder using two angles $\theta$ and $\phi$. 
    5555(see :ref:`cylinder model <cylinder-angle-definition>`) 
    5656 
     
    130130             ] 
    131131 
    132 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] 
     132source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] 
    133133 
    134134def ER(radius, thickness, length): 
    135135    """ 
    136         Returns the effective radius used in the S*P calculation 
     136    Returns the effective radius used in the S*P calculation 
    137137    """ 
    138138    radius = radius + thickness 
     
    143143def VR(radius, thickness, length): 
    144144    """ 
    145         Returns volume ratio 
     145    Returns volume ratio 
    146146    """ 
    147147    whole = pi * (radius + thickness) ** 2 * (length + 2 * thickness) 
  • sasmodels/models/core_shell_ellipsoid.py

    r7f1ee79 r40a87fa  
    55.. math:: 
    66 
    7     P(q) = scale * \left<f^2\right>/V + background 
     7    P(q) = \text{scale} * \left<f^2\right>/V + \text{background} 
    88 
    9 where the volume $V = (4/3)\pi(R_{major\_outer}R_{minor\_outer}^2)$ and the averaging $< >$ is 
    10 applied over all orientations for 1D. 
     9where the volume $V = (4/3)\pi(r_\text{major outer} r_\text{minor outer}^2)$ 
     10and the averaging $< >$ is applied over all orientations for 1D. 
    1111 
    1212.. figure:: img/core_shell_ellipsoid_geometry.png 
    1313 
    14     The returned value is in units of $cm^{-1}$, on absolute scale. 
     14    The returned value is in units of |cm^-1|, on absolute scale. 
    1515 
    1616Definition 
     
    2121.. math:: 
    2222 
    23     P(q) = \frac{scale}{V}\int_0^1 
    24         \left|F(q,r_{minor\_core},r_{major\_core},\alpha) + F(q,r_{major\_outer},r_{major\_outer},\alpha)\right|^2d\alpha + background 
     23    P(q) &= \frac{\text{scale}}{V}\int_0^1 
     24        \left|F(q,r_\text{minor core},r_\text{major core},\alpha) 
     25        + F(q,r_\text{minor outer},r_\text{major outer},\alpha)\right|^2 
     26        d\alpha 
     27        + \text{background} 
    2528 
    26     \left|F(q,r_{minor},r_{major},\alpha)\right|=(4\pi/3)r_{major}r_{minor}^2 \Delta \rho \cdot (3j_1(u)/u) 
     29    \left|F(q,r_\text{minor},r_\text{major},\alpha)\right| 
     30        &=(4\pi/3)r_\text{major}r_\text{minor}^2 \Delta \rho \cdot (3j_1(u)/u) 
    2731 
    28     u = q\left[ r_{major}^2\alpha ^2 + r_{minor}^2(1-\alpha ^2)\right]^{1/2} 
     32    u &= q\left[ r_\text{major}^2\alpha ^2 
     33                  + r_\text{minor}^2(1-\alpha ^2)\right]^{1/2} 
    2934 
    3035where 
     
    4045The contrast is defined as SLD(core) - SLD(shell) and SLD(shell) - SLD(solvent). 
    4146 
    42 In the parameters, *equat_core* = equatorial core radius, *polar_core* = 
    43 polar core radius, *equat_shell* = $r_{min}$ (or equatorial outer radius), 
    44 and *polar_shell* = $r_{maj}$ (or polar outer radius). 
    45  
    46 Note:It is the users' responsibility to ensure that shell radii are larger than  
     47Note: It is the users' responsibility to ensure that shell radii are larger than 
    4748the core radii, especially if both are polydisperse, in which case the 
    4849core_shell_ellipsoid_xt model may be much better. 
     
    6768 
    6869S J Berr, *Phys. Chem.*, 91 (1987) 4760 
    69  
    7070""" 
    7171 
     
    100100 
    101101# pylint: disable=bad-whitespace, line-too-long 
    102 #             ["name", "units", default, [lower, upper], "type", "description"], 
     102#   ["name", "units", default, [lower, upper], "type", "description"], 
    103103parameters = [ 
    104     ["equat_core",  "Ang",      200,   [0, inf],    "volume",      "Equatorial radius of core, Rminor_core "], 
    105     ["polar_core",  "Ang",       10,   [0, inf],    "volume",      "Polar radius of core, Rmajor_core"], 
    106     ["equat_shell", "Ang",      250,   [0, inf],    "volume",      "Equatorial radius of shell, Rminor_outer "], 
    107     ["polar_shell", "Ang",       30,   [0, inf],    "volume",      "Polar radius of shell, Rmajor_outer"], 
    108     ["sld_core",    "1e-6/Ang^2", 2,   [-inf, inf], "sld",            "Core scattering length density"], 
    109     ["sld_shell",   "1e-6/Ang^2", 1,   [-inf, inf], "sld",            "Shell scattering length density"], 
    110     ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld",            "Solvent scattering length density"], 
     104    ["equat_core",  "Ang",      200,   [0, inf],    "volume",      "Equatorial radius of core, r minor core"], 
     105    ["polar_core",  "Ang",       10,   [0, inf],    "volume",      "Polar radius of core, r major core"], 
     106    ["equat_shell", "Ang",      250,   [0, inf],    "volume",      "Equatorial radius of shell, r minor outer"], 
     107    ["polar_shell", "Ang",       30,   [0, inf],    "volume",      "Polar radius of shell, r major outer"], 
     108    ["sld_core",    "1e-6/Ang^2", 2,   [-inf, inf], "sld",         "Core scattering length density"], 
     109    ["sld_shell",   "1e-6/Ang^2", 1,   [-inf, inf], "sld",         "Shell scattering length density"], 
     110    ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld",         "Solvent scattering length density"], 
    111111    ["theta",       "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"], 
    112112    ["phi",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"], 
     
    120120        Returns the effective radius used in the S*P calculation 
    121121    """ 
    122     import numpy as np 
    123122    from .ellipsoid import ER as ellipsoid_ER 
    124123    return ellipsoid_ER(polar_shell, equat_shell) 
  • sasmodels/models/core_shell_ellipsoid_xt.py

    r42356c8 r40a87fa  
    11r""" 
    22An alternative version of $P(q)$ for the core_shell_ellipsoid 
    3 having as parameters the core axial ratio X and a shell thickness,  
     3having as parameters the core axial ratio X and a shell thickness, 
    44which are more often what we would like to determine. 
    55 
  • sasmodels/models/core_shell_sphere.py

    r42356c8 r40a87fa  
    22.. _core_shell_sphere: 
    33 
    4 This model provides the form factor, $P(q)$, for a spherical particle with a core-shell structure. 
    5 The form factor is normalized by the particle volume. 
     4This model provides the form factor, $P(q)$, for a spherical particle with 
     5a core-shell structure. The form factor is normalized by the particle volume. 
    66 
    77Definition 
     
    1818.. math:: 
    1919 
    20     F^2(q)=\frac{3}{V_s}\left[V_c(\rho_c-\rho_s)\frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+ 
    21     V_s(\rho_s-\rho_{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right] 
     20    F^2(q) = \frac{3}{V_s}\left[ 
     21       V_c(\rho_c-\rho_s)\frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3} + 
     22       V_s(\rho_s-\rho_\text{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3} 
     23       \right] 
    2224 
    23 where $V_s$ is the volume of the whole particle, $V_c$ is 
    24 the volume of the core, $r_s$ = $radius$ + $thickness$ is the radius of the particle, $r_c$ is the radius of the 
    25 core, $\rho_c$ is the scattering length density of the core, $\rho_s$ is the scattering length 
    26 density of the shell, $\rho_{solv}$ is the scattering length density of the solvent. 
     25where $V_s$ is the volume of the whole particle, $V_c$ is the volume of the 
     26core, $r_s$ = $radius$ + $thickness$ is the radius of the particle, $r_c$ 
     27is the radius of the core, $\rho_c$ is the scattering length density of the 
     28core, $\rho_s$ is the scattering length density of the shell, 
     29$\rho_\text{solv}$, is the scattering length density of the solvent. 
    2730 
    2831The 2D scattering intensity is the same as $P(q)$ above, regardless of the 
     
    3538---------- 
    3639 
    37 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, (1955) 
     40A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, 
     41John Wiley and Sons, New York, (1955) 
    3842 
    3943Validation 
    4044---------- 
    4145 
    42 Validation of our code was done by comparing the output of the 1D model to the output of 
    43 the software provided by NIST (Kline, 2006). Figure 1 shows a comparison of the output of 
    44 our model and the output of the NIST software. 
    45  
     46Validation of our code was done by comparing the output of the 1D model to 
     47the output of the software provided by NIST (Kline, 2006). Figure 1 shows a 
     48comparison of the output of our model and the output of the NIST software. 
    4649""" 
    4750 
     
    8891        @param thickness: shell thickness 
    8992    """ 
    90     return (1,1) 
     93    return (1, 1) 
    9194    whole = 4.0 * pi / 3.0 * pow((radius + thickness), 3) 
    9295    core = 4.0 * pi / 3.0 * radius * radius * radius 
    9396    return whole, whole - core 
    9497 
    95 tests = [[{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0], 
    96          # TODO: VR test suppressed until we sort out new product model 
    97          # and determine what to do with volume ratio. 
    98          #[{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704], 
     98tests = [ 
     99    [{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0], 
     100     # TODO: VR test suppressed until we sort out new product model 
     101     # and determine what to do with volume ratio. 
     102     #[{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704], 
    99103 
    100          # The SasView test result was 0.00169, with a background of 0.001 
    101          [{'radius': 60.0, 
    102            'thickness': 10.0, 
    103            'sld_core': 1.0, 
    104            'sld_shell':2.0, 
    105            'sld_solvent':3.0, 
    106            'background':0.0 
    107           }, 0.4, 0.000698838]] 
     104     # The SasView test result was 0.00169, with a background of 0.001 
     105     [{'radius': 60.0, 'thickness': 10.0, 'sld_core': 1.0, 'sld_shell':2.0, 
     106       'sld_solvent':3.0, 'background':0.0}, 
     107      0.4, 0.000698838], 
     108] 
  • sasmodels/models/correlation_length.py

    r2c74c11 r40a87fa  
    88 
    99.. math:: 
    10     I(Q) = \frac{A}{Q^n} + \frac{C}{1 + (Q\xi)^m} + B 
     10    I(Q) = \frac{A}{Q^n} + \frac{C}{1 + (Q\xi)^m} + \text{background} 
    1111 
    12 The first term describes Porod scattering from clusters (exponent = n) and the 
    13 second term is a Lorentzian function describing scattering from polymer chains 
    14 (exponent = m). This second term characterizes the polymer/solvent interactions 
    15 and therefore the thermodynamics. The two multiplicative factors A and C, the 
    16 incoherent background B and the two exponents n and m are used as fitting 
    17 parameters. (Respectively $porod\_scale$, $lorentz\_scale$, $background$, $exponent\_p$ and  
    18 $exponent\_l$ in the parameter list.) The remaining parameter \ |xi|\  is a correlation  
    19 length for the polymer chains. Note that when m=2 this functional form becomes the  
    20 familiar Lorentzian function. Some interpretation of the values of A and C may be  
    21 possible depending on the values of m and n. 
     12The first term describes Porod scattering from clusters (exponent = $n$) and 
     13the second term is a Lorentzian function describing scattering from 
     14polymer chains (exponent = $m$). This second term characterizes the 
     15polymer/solvent interactions and therefore the thermodynamics. The two 
     16multiplicative factors $A$ and $C$, and the two exponents $n$ and $m$ are 
     17used as fitting parameters. (Respectively *porod_scale*, *lorentz_scale*, 
     18*exponent_p* and *exponent_l* in the parameter list.) The remaining 
     19parameter $\xi$ (*cor_length* in the parameter list) is a correlation 
     20length for the polymer chains. Note that when $m=2$ this functional form 
     21becomes the familiar Lorentzian function. Some interpretation of the 
     22values of $A$ and $C$ may be possible depending on the values of $m$ and $n$. 
    2223 
    2324For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
    2425where the q vector is defined as 
    2526 
    26 .. math:: 
    27     q = \sqrt{q_x^2 + q_y^2} 
     27.. math::  q = \sqrt{q_x^2 + q_y^2} 
    2828 
    2929References 
  • sasmodels/models/cylinder.py

    r42356c8 r40a87fa  
    119119             ] 
    120120 
    121 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 
     121source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 
    122122 
    123123def ER(radius, length): 
  • sasmodels/models/elliptical_cylinder.c

    rabdd01c r40a87fa  
    1919 
    2020    arg = q*r_minor*sqrt((1.0+r_ratio*r_ratio)/2+(1.0-r_ratio*r_ratio)*cos(theta)/2); 
    21     if (arg == 0.0){ 
    22         retval = 1.0; 
    23     }else{ 
    24         //retval = 2.0*NR_BessJ1(arg)/arg; 
    25         retval = sas_J1c(arg); 
    26     } 
     21    //retval = 2.0*J1(arg)/arg; 
     22    retval = sas_J1c(arg); 
    2723    return retval*retval ; 
    2824} 
     
    6864        //now calculate the value of the inner integral 
    6965        answer = (vbj-vaj)/2.0*summj; 
    70         //divide integral by Pi 
    71         answer /= M_PI; 
    7266 
    7367        //now calculate outer integral 
    7468        arg = q*length*zi/2.0; 
    75         if (arg == 0.0){ 
    76             si = 1.0; 
    77         }else{ 
    78             si = sin(arg) * sin(arg) / arg / arg; 
    79         } 
     69        si = square(sinc(arg)); 
    8070        yyy = Gauss76Wt[i] * answer * si; 
    8171        summ += yyy; 
    8272    } 
    8373 
    84     answer = (vb-va)/2.0*summ; 
     74    //divide integral by Pi 
     75    answer = (vb-va)/2.0*summ/M_PI; 
    8576    // Multiply by contrast^2 
    8677    answer *= delrho*delrho; 
  • sasmodels/models/elliptical_cylinder.py

    r42356c8 r40a87fa  
    11# pylint: disable=line-too-long 
    22r""" 
    3 This function calculates the scattering from an elliptical cylinder. 
    4  
    53Definition for 2D (orientated system) 
    64------------------------------------- 
    75 
    8 The angles |theta| and |phi| define the orientation of the axis of the cylinder. The angle |bigpsi| is defined as the 
    9 orientation of the major axis of the ellipse with respect to the vector *Q*\ . A gaussian polydispersity can be added 
    10 to any of the orientation angles, and also for the minor radius and the ratio of the ellipse radii. 
     6The angles $\theta$ and $\phi$ define the orientation of the axis of the 
     7cylinder. The angle $\Psi$ is defined as the orientation of the major 
     8axis of the ellipse with respect to the vector $Q$. A gaussian polydispersity 
     9can be added to any of the orientation angles, and also for the minor 
     10radius and the ratio of the ellipse radii. 
    1111 
    1212.. figure:: img/elliptical_cylinder_geometry.png 
    1313 
    14    Elliptical cylinder geometry $a$ = $r_{minor}$ and \ |nu|\  = $axis\_ratio$ = $r_{major} / r_{minor}$ 
     14   Elliptical cylinder geometry $a = r_\text{minor}$ 
     15   and $\nu = r_\text{major} / r_\text{minor}$ is the *axis_ratio*. 
    1516 
    1617The function calculated is 
     
    1819.. math:: 
    1920 
    20     I(\mathbf{q})=\frac{1}{V_{cyl}}\int{d\psi}\int{d\phi}\int{p(\theta,\phi,\psi)F^2(\mathbf{q},\alpha,\psi)\sin(\theta)d\theta} 
     21    I(\vec q)=\frac{1}{V_\text{cyl}}\int{d\psi}\int{d\phi}\int{ 
     22        p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\theta)d\theta} 
    2123 
    2224with the functions 
     
    2426.. math:: 
    2527 
    26     F(\mathbf{q},\alpha,\psi)=2\frac{J_1(a)\sin(b)}{ab} 
    27     \\ 
    28     where  a = \mathbf{q}\sin(\alpha)\left[ r^2_{major}\sin^2(\psi)+r^2_{minor}\cos(\psi) \right]^{1/2} 
    29     \\ 
    30     b=\mathbf{q}\frac{L}{2}\cos(\alpha) 
     28    F(\vec q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 
    3129 
    32 and the angle |bigpsi| is defined as the orientation of the major axis of the ellipse with respect to the vector $\vec q$ . 
    33 The angle $\alpha$ is the angle between the axis of the cylinder and $\vec q$. 
     30where 
     31 
     32.. math:: 
     33 
     34    a &= \vec q\sin(\alpha)\left[ 
     35        r^2_\text{major}\sin^2(\psi)+r^2_\text{minor}\cos(\psi) \right]^{1/2} 
     36 
     37    b &= \vec q\frac{L}{2}\cos(\alpha) 
     38 
     39and the angle $\Psi$ is defined as the orientation of the major axis of the 
     40ellipse with respect to the vector $\vec q$. The angle $\alpha$ is the angle 
     41between the axis of the cylinder and $\vec q$. 
    3442 
    3543 
     
    3745-------------------------------------------- 
    3846 
    39 The form factor is averaged over all possible orientation before normalized by the particle volume 
     47The form factor is averaged over all possible orientation before normalized 
     48by the particle volume 
    4049 
    4150.. math:: 
    42     P(q) = scale  <F^2> / V 
    4351 
    44 To provide easy access to the orientation of the elliptical cylinder, we define the axis of the cylinder using two 
    45 angles |theta|, |phi| and |bigpsi| (see :ref:`cylinder orientation <cylinder-angle-definition>`). 
    46 The angle |bigpsi| is the rotational angle around its own long_c axis against the *q* plane. 
    47 For example, |bigpsi| = 0 when the *r_minor* axis is parallel to the *x*\ -axis of the detector. 
     52    P(q) = \text{scale}  <F^2> / V 
    4853 
    49 All angle parameters are valid and given only for 2D calculation; ie, an oriented system. 
     54To provide easy access to the orientation of the elliptical cylinder, we 
     55define the axis of the cylinder using two angles $\theta$, $\phi$ and $\Psi$ 
     56(see :ref:`cylinder orientation <cylinder-angle-definition>`). The angle 
     57$\Psi$ is the rotational angle around its own long_c axis against the $q$ plane. 
     58For example, $\Psi = 0$ when the $r_\text{minor}$ axis is parallel to the 
     59$x$ axis of the detector. 
     60 
     61All angle parameters are valid and given only for 2D calculation; ie, an 
     62oriented system. 
    5063 
    5164.. figure:: img/elliptical_cylinder_angle_definition.jpg 
     
    5568.. figure:: img/cylinder_angle_projection.jpg 
    5669 
    57     Examples of the angles for oriented elliptical cylinders against the detector plane. 
     70    Examples of the angles for oriented elliptical cylinders against the 
     71    detector plane. 
    5872 
    59 NB: The 2nd virial coefficient of the cylinder is calculated based on the averaged radius (= sqrt(*r_minor*\ :sup:`2` \* *axis_ratio*)) 
    60 and length values, and used as the effective radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied. 
     73NB: The 2nd virial coefficient of the cylinder is calculated based on the 
     74averaged radius $(=\sqrt{r_\text{minor}^2 * \text{axis ratio}})$ and length 
     75values, and used as the effective radius for $S(Q)$ when $P(Q)*S(Q)$ is applied. 
    6176 
    6277 
     
    6479---------- 
    6580 
    66 Validation of our code was done by comparing the output of the 1D calculation to the  
    67 angular average of the output of the 2D calculation over all possible angles.  
     81Validation of our code was done by comparing the output of the 1D calculation 
     82to the angular average of the output of the 2D calculation over all possible 
     83angles. 
    6884 
    69 In the 2D average, more binning in the angle |phi| is necessary to get the proper result.  
    70 The following figure shows the results of the averaging by varying the number of angular bins. 
     85In the 2D average, more binning in the angle $\phi$ is necessary to get the 
     86proper result. The following figure shows the results of the averaging by 
     87varying the number of angular bins. 
    7188 
    7289.. figure:: img/elliptical_cylinder_averaging.png 
     
    7794---------- 
    7895 
    79 L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum, 
    80 New York, (1987) 
     96L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
     97Neutron Scattering*, Plenum, New York, (1987) 
    8198""" 
    8299 
     
    104121# pylint: enable=bad-whitespace, line-too-long 
    105122 
    106 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c", "elliptical_cylinder.c"] 
     123source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c", 
     124          "elliptical_cylinder.c"] 
    107125 
    108126demo = dict(scale=1, background=0, r_minor=100, axis_ratio=1.5, length=400.0, 
    109             sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, theta_pd=10, phi_pd=2, psi_pd=3) 
     127            sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, 
     128            theta_pd=10, phi_pd=2, psi_pd=3) 
    110129 
    111130def ER(r_minor, axis_ratio, length): 
     
    117136    """ 
    118137    radius = sqrt(r_minor * r_minor * axis_ratio) 
    119     ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) 
     138    ddd = 0.75 * radius * (2 * radius * length 
     139                           + (length + radius) * (length + pi * radius)) 
    120140    return 0.5 * (ddd) ** (1. / 3.) 
    121141 
    122 tests = [[{'r_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 
    123          [{'r_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 
     142tests = [ 
     143    [{'r_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 
     144    [{'r_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 
    124145 
    125          # The SasView test result was 0.00169, with a background of 0.001 
    126          [{'r_minor': 20.0, 
    127            'axis_ratio': 1.5, 
    128            'sld': 4.0, 
    129            'length':400.0, 
    130            'sld_solvent':1.0, 
    131            'background':0.0 
    132           }, 0.001, 675.504402]] 
     146    # The SasView test result was 0.00169, with a background of 0.001 
     147    [{'r_minor': 20.0, 'axis_ratio': 1.5, 'sld': 4.0, 'length':400.0, 
     148      'sld_solvent':1.0, 'background':0.0}, 
     149     0.001, 675.504402], 
     150] 
  • sasmodels/models/flexible_cylinder_elliptical.py

    r42356c8 r40a87fa  
    109109# pylint: enable=bad-whitespace, line-too-long 
    110110 
    111 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/wrc_cyl.c", "flexible_cylinder_elliptical.c"] 
     111source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "lib/wrc_cyl.c", 
     112          "flexible_cylinder_elliptical.c"] 
    112113 
    113114demo = dict(scale=1.0, background=0.0001, 
  • sasmodels/models/fuzzy_sphere.py

    r2c74c11 r40a87fa  
    11r""" 
    2 For information about polarised and magnetic scattering, see  
    3 the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` documentation. 
     2For information about polarised and magnetic scattering, see 
     3the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` 
     4documentation. 
    45 
    56Definition 
    67---------- 
    78 
    8 The scattering intensity *I(q)* is calculated as: 
     9The scattering intensity $I(q)$ is calculated as: 
    910 
    1011.. math:: 
    11     I(q) = \frac{scale}{V}(\Delta \rho)^2 A^2(q) S(q) +\text{background} 
     12 
     13    I(q) = \frac{\text{scale}}{V}(\Delta \rho)^2 A^2(q) S(q) 
     14           + \text{background} 
    1215 
    1316 
    14 where the amplitude *A(q)* is given as the typical sphere scattering convoluted 
     17where the amplitude $A(q)$ is given as the typical sphere scattering convoluted 
    1518with a Gaussian to get a gradual drop-off in the scattering length density: 
    1619 
     
    1821 
    1922    A(q) = \frac{3\left[\sin(qR) - qR \cos(qR)\right]}{(qR)^3} 
    20            \exp\left(\frac{-(\sigma_{fuzzy}q)^2}{2}\right) 
     23           \exp\left(\frac{-(\sigma_\text{fuzzy}q)^2}{2}\right) 
    2124 
    22 Here *|A(q)|*:sup:`2`\  is the form factor, *P(q)*. The scale is equivalent to the 
    23 volume fraction of spheres, each of volume, *V*\. Contrast (|drho|) is the 
    24 difference of scattering length densities of the sphere and the surrounding 
    25 solvent. 
     25Here $A(q)^2$ is the form factor, $P(q)$. The scale is equivalent to the 
     26volume fraction of spheres, each of volume, $V$. Contrast $(\Delta \rho)$ 
     27is the difference of scattering length densities of the sphere and the 
     28surrounding solvent. 
    2629 
    27 Poly-dispersion in radius and in fuzziness is provided for, though the fuzziness 
    28 must be kept much smaller than the sphere radius for meaningful results. 
    29  
    30  
     30Poly-dispersion in radius and in fuzziness is provided for, though the 
     31fuzziness must be kept much smaller than the sphere radius for meaningful 
     32results. 
    3133 
    3234From the reference: 
    3335 
    3436  The "fuzziness" of the interface is defined by the parameter 
    35   |sigma| :sub:`fuzzy`\ . The particle radius *R* represents the radius of the 
     37  $\sigma_\text{fuzzy}$. The particle radius $R$ represents the radius of the 
    3638  particle where the scattering length density profile decreased to 1/2 of the 
    37   core density. The |sigma| :sub:`fuzzy`\ is the width of the smeared particle 
     39  core density. $\sigma_\text{fuzzy}$ is the width of the smeared particle 
    3840  surface; i.e., the standard deviation from the average height of the fuzzy 
    3941  interface. The inner regions of the microgel that display a higher density 
    4042  are described by the radial box profile extending to a radius of 
    41   approximately *Rbox* ~ *R* - 2\ |sigma|\ . The profile approaches zero as 
    42   *Rsans* ~ *R* + 2\ |sigma|\ . 
     43  approximately $R_\text{box} \sim R - 2 \sigma$. The profile approaches 
     44  zero as $R_\text{sans} \sim R + 2\sigma$. 
    4345 
    4446For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
    45 where the *q* vector is defined as 
     47where the $q$ vector is defined as 
    4648 
    47 .. math:: 
    48  
    49     q = \sqrt{{q_x}^2 + {q_y}^2} 
    50  
     49.. math:: q = \sqrt{{q_x}^2 + {q_y}^2} 
    5150 
    5251References 
  • sasmodels/models/gauss_lorentz_gel.py

    r2c74c11 r40a87fa  
    99---------- 
    1010 
    11 The scattering intensity I(q) is calculated as (Eqn. 5 from the reference) 
     11The scattering intensity $I(q)$ is calculated as (Eqn. 5 from the reference) 
    1212 
    13 .. math:: 
     13.. math:: I(q) = I_G(0) \exp(-q^2\Xi ^2/2) + I_L(0)/(1+q^2\xi^2) 
    1414 
    15     I(q) = I_G(0)exp(-q^2\Xi ^2/2) + I_L(0)/(1+q^2\xi^2) 
    16  
    17 $\Xi$ is the length scale of the static correlations in the gel, 
    18 which can be attributed to the "frozen-in" crosslinks. 
    19 \ |xi|\  is the dynamic correlation length, which can be attributed to the 
    20 fluctuating polymer chains between crosslinks. 
    21 $I_G(0)$ and $I_L(0)$ are the scaling factors for each of these structures. 
    22 Think carefully about how these map to your particular system! 
     15$\Xi$ is the length scale of the static correlations in the gel, which can 
     16be attributed to the "frozen-in" crosslinks. $\xi$ is the dynamic correlation 
     17length, which can be attributed to the fluctuating polymer chains between 
     18crosslinks. $I_G(0)$ and $I_L(0)$ are the scaling factors for each of these 
     19structures. Think carefully about how these map to your particular system! 
    2320 
    2421.. note:: 
    2522    The peaked structure at higher $q$ values (Figure 2 from the reference) 
    2623    is not reproduced by the model. Peaks can be introduced into the model 
    27     by summing this model with the PeakGaussModel function. 
     24    by summing this model with the :ref:`gaussian-peak` model. 
    2825 
    2926For 2D data the scattering intensity is calculated in the same way as 1D, 
    3027where the $q$ vector is defined as 
    3128 
    32 .. math:: 
    33  
    34     q = \sqrt{q_x^2 + q_y^2} 
    35  
     29.. math:: q = \sqrt{q_x^2 + q_y^2} 
    3630 
    3731References 
  • sasmodels/models/gel_fit.py

    rec45c4f r40a87fa  
    88and a longer distance (denoted here as $a2$ ) needed to account for the static 
    99accumulations of polymer pinned down by junction points or clusters of such 
    10 points. The latter is derived from a simple Guinier function. Compare also the  
     10points. The latter is derived from a simple Guinier function. Compare also the 
    1111gauss_lorentz_gel model. 
    1212 
  • sasmodels/models/guinier.py

    r2c74c11 r40a87fa  
    55This model fits the Guinier function 
    66 
    7 .. math:: I(q) = scale \exp{\left[ \frac{-Q^2R_g^2}{3} \right]} 
     7.. math:: 
    88 
    9 to the data directly without any need for linearisation 
    10 (*cf*. the usual plot of $\ln I(q)$ vs $q^2$\ ). Note that you may have to  
    11 restrict the data range to include small q only, where the Guinier approximation 
    12 actually applies. See also the guinier_porod model. 
     9    I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2R_g^2}{3} \right]} 
     10            + \text{background} 
     11 
     12to the data directly without any need for linearisation (*cf*. the usual 
     13plot of $\ln I(q)$ vs $q^2$\ ). Note that you may have to restrict the data 
     14range to include small q only, where the Guinier approximation actually 
     15applies. See also the guinier_porod model. 
    1316 
    1417For 2D data the scattering intensity is calculated in the same way as 1D, 
    1518where the $q$ vector is defined as 
    1619 
    17 .. math:: q=\sqrt{q_x^2 + q_y^2} 
     20.. math:: q = \sqrt{q_x^2 + q_y^2} 
    1821 
    1922References 
  • sasmodels/models/guinier_porod.py

    r2c74c11 r40a87fa  
    1 # pylint: disable=line-too-long 
    21r""" 
    32Calculates the scattering for a generalized Guinier/power law object. 
     
    1312 
    1413.. math:: 
    15     I(q) = \frac{G}{Q^s} \ \exp{\left[ \frac{-Q^2R_g^2}{3-s} \right]} \textrm{ for } Q \leq Q_1 
    16     \\ 
    17     I(q) = D / Q^m \textrm{ for } Q \geq Q_1 
     14 
     15    I(q) = \begin{cases} 
     16    \frac{G}{Q^s}\ \exp{\left[\frac{-Q^2R_g^2}{3-s} \right]} & Q \leq Q_1 \\ 
     17    D / Q^m  & Q \geq Q_1 
     18    \end{cases} 
    1819 
    1920This is based on the generalized Guinier law for such elongated objects 
    20 (see the Glatter reference below). For 3D globular objects (such as spheres), $s = 0$ 
    21 and one recovers the standard Guinier formula. 
    22 For 2D symmetry (such as for rods) $s = 1$, 
    23 and for 1D symmetry (such as for lamellae or platelets) $s = 2$. 
    24 A dimensionality parameter ($3-s$) is thus defined, and is 3 for spherical objects, 
    25 2 for rods, and 1 for plates. 
     21(see the Glatter reference below). For 3D globular objects (such as spheres), 
     22$s = 0$ and one recovers the standard Guinier formula. For 2D symmetry 
     23(such as for rods) $s = 1$, and for 1D symmetry (such as for lamellae or 
     24platelets) $s = 2$. A dimensionality parameter ($3-s$) is thus defined, 
     25and is 3 for spherical objects, 2 for rods, and 1 for plates. 
    2626 
    27 Enforcing the continuity of the Guinier and Porod functions and their derivatives yields 
     27Enforcing the continuity of the Guinier and Porod functions and their 
     28derivatives yields 
    2829 
    2930.. math:: 
     31 
    3032    Q_1 = \frac{1}{R_g} \sqrt{(m-s)(3-s)/2} 
    3133 
     
    3335 
    3436.. math:: 
    35     D = G \ \exp{ \left[ \frac{-Q_1^2 R_g^2}{3-s} \right]} \ Q_1^{m-s} 
    36       = \frac{G}{R_g^{m-s}} \ \exp{\left[  -\frac{m-s}{2} \right]} \left( \frac{(m-s)(3-s)}{2} \right)^{\frac{m-s}{2}} 
     37 
     38    D &= G \ \exp{ \left[ \frac{-Q_1^2 R_g^2}{3-s} \right]} \ Q_1^{m-s} 
     39 
     40      &= \frac{G}{R_g^{m-s}} \ \exp \left[ -\frac{m-s}{2} \right] 
     41          \left( \frac{(m-s)(3-s)}{2} \right)^{\frac{m-s}{2}} 
    3742 
    3843 
    39 Note that the radius-of-gyration for a sphere of radius R is given by $R_g = R \sqrt(3/5)$. 
    40  
    41 For a cylinder of radius $R$ and length $L$,    $R_g^2 = \frac{L^2}{12} + \frac{R^2}{2}$ 
    42  
    43 from which the cross-sectional radius-of-gyration for a randomly oriented thin  
    44 cylinder is $R_g = R / \sqrt(2)$. 
    45  
    46 and the cross-sectional radius-of-gyration of a randomly oriented lamella 
    47 of thickness $T$ is given by $R_g = T / \sqrt(12)$. 
     44Note that the radius of gyration for a sphere of radius $R$ is given 
     45by $R_g = R \sqrt{3/5}$. For a cylinder of radius $R$ and length $L$, 
     46$R_g^2 = \frac{L^2}{12} + \frac{R^2}{2}$ from which the cross-sectional 
     47radius of gyration for a randomly oriented thin cylinder is $R_g = R/\sqrt{2}$ 
     48and the cross-sectional radius of gyration of a randomly oriented lamella 
     49of thickness $T$ is given by $R_g = T / \sqrt{12}$. 
    4850 
    4951For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
     
    5759--------- 
    5860 
    59 A Guinier, G Fournet, Small-Angle Scattering of X-Rays, John Wiley and Sons, New York, (1955) 
     61A Guinier, G Fournet, *Small-Angle Scattering of X-Rays*, 
     62John Wiley and Sons, New York, (1955) 
    6063 
    61 O Glatter, O Kratky, Small-Angle X-Ray Scattering, Academic Press (1982) 
     64O Glatter, O Kratky, *Small-Angle X-Ray Scattering*, Academic Press (1982) 
    6265Check out Chapter 4 on Data Treatment, pages 155-156. 
    6366""" 
  • sasmodels/models/hardsphere.py

    r7f1ee79 r40a87fa  
    33spherical particles interacting through hard sphere (excluded volume) 
    44interactions. 
    5 May be a reasonable approximation for other shapes of particles that  
    6 freely rotate, and for moderately polydisperse systems. Though strictly  
     5May be a reasonable approximation for other shapes of particles that 
     6freely rotate, and for moderately polydisperse systems. Though strictly 
    77the maths needs to be modified (no \Beta(Q) correction yet in sasview). 
    88 
     
    1313used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    1414 
    15 For numerical stability the computation uses a Taylor series expansion  
     15For numerical stability the computation uses a Taylor series expansion 
    1616at very small $qR$, there may be a very minor glitch at the transition point 
    1717in some circumstances. 
     
    156156# VR defaults to 1.0 
    157157 
    158 demo = dict(radius_effective=200, volfraction=0.2, radius_effective_pd=0.1, radius_effective_pd_n=40) 
     158demo = dict(radius_effective=200, volfraction=0.2, 
     159            radius_effective_pd=0.1, radius_effective_pd_n=40) 
    159160# Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 
    160161tests = [ 
    161         [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.2, 
    162            'radius_effective_pd' : 0}, [0.001,0.1], [0.209128,0.930587]] 
     162        [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 
     163           'volfraction' : 0.2, 'radius_effective_pd' : 0}, 
     164          [0.001,0.1], [0.209128,0.930587]], 
    163165        ] 
    164 # ADDED by: RKH  ON: 16Mar2016  using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q,  
     166# ADDED by: RKH  ON: 16Mar2016  using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q, 
  • sasmodels/models/hayter_msa.py

    rd2bb604 r40a87fa  
    1616there is no provision for entering the ionic strength directly nor for use 
    1717of any multivalent salts, though it should be possible to simulate the effect 
    18 of this by increasing the salt concentration. The counterions are also assumed to  
    19 be monovalent. 
     18of this by increasing the salt concentration. The counterions are also 
     19assumed to be monovalent. 
    2020 
    2121In sasview the effective radius may be calculated from the parameters 
    2222used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    2323 
    24 The computation uses a Taylor series expansion at very small rescaled $qR$, to  
    25 avoid some serious rounding error issues, this may result in a minor artefact  
     24The computation uses a Taylor series expansion at very small rescaled $qR$, to 
     25avoid some serious rounding error issues, this may result in a minor artefact 
    2626in the transition region under some circumstances. 
    2727 
     
    103103            radius_effective_pd_n=40) 
    104104# 
    105 # attempt to use same values as old sasview unit test at Q=.001 was 0.0712928,  
    106 # then add lots new ones assuming values from new model are OK, need some low Q values to test the small Q Taylor expansion 
     105# attempt to use same values as old sasview unit test at Q=.001 was 0.0712928, 
     106# then add lots new ones assuming values from new model are OK, need some 
     107# low Q values to test the small Q Taylor expansion 
    107108tests = [ 
    108109    [{'scale': 1.0, 
     
    115116      'dielectconst': 78.0, 
    116117      'radius_effective_pd': 0}, 
    117      [0.00001,0.0010,0.01,0.075], [0.0711646,0.0712928,0.0847006,1.07150]], 
     118     [0.00001, 0.0010, 0.01, 0.075], [0.0711646, 0.0712928, 0.0847006, 1.07150]], 
    118119    [{'scale': 1.0, 
    119120      'background': 0.0, 
     
    126127      'radius_effective_pd': 0.1, 
    127128      'radius_effective_pd_n': 40}, 
    128      [0.00001,0.0010,0.01,0.075], [0.450272,0.450420,0.465116,1.039625]] 
     129     [0.00001, 0.0010, 0.01, 0.075], [0.450272, 0.450420, 0.465116, 1.039625]] 
    129130    ] 
    130131# ADDED by:  RKH  ON: 16Mar2016 converted from sasview, new Taylor expansion at smallest rescaled Q 
  • sasmodels/models/hollow_rectangular_prism.py

    r42356c8 r40a87fa  
    115115             ] 
    116116 
    117 source = [ "lib/gauss76.c", "hollow_rectangular_prism.c"] 
     117source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 
    118118 
    119119def ER(a_side, b2a_ratio, c2a_ratio, thickness): 
    120120    """ 
    121         Return equivalent radius (ER) 
    122         thickness parameter not used 
     121    Return equivalent radius (ER) 
     122    thickness parameter not used 
    123123    """ 
    124124    b_side = a_side * b2a_ratio 
     
    133133def VR(a_side, b2a_ratio, c2a_ratio, thickness): 
    134134    """ 
    135         Return shell volume and total volume 
     135    Return shell volume and total volume 
    136136    """ 
    137137    b_side = a_side * b2a_ratio 
  • sasmodels/models/lamellar.py

    r42356c8 r40a87fa  
    55---------- 
    66 
    7 The scattering intensity $I(q)$ for dilute, randomly oriented, "infinitely large" sheets or lamellae is 
     7The scattering intensity $I(q)$ for dilute, randomly oriented, 
     8"infinitely large" sheets or lamellae is 
    89 
    910.. math:: 
     
    1920        = \frac{4\Delta\rho^2}{q^2}\sin^2\left(\frac{q\delta}{2}\right) 
    2021 
    21 where $\delta$ is the total layer thickness and $\Delta\rho$ is the scattering length density difference. 
     22where $\delta$ is the total layer thickness and $\Delta\rho$ is the 
     23scattering length density difference. 
    2224 
    23 This is the limiting form for a spherical shell of infinitely large radius. Note that the division by $\delta$ 
    24 means that $scale$ in sasview is the volume fraction of sheet, $\phi = S\delta$ where $S$ is the area of  
    25 sheet per unit volume. $S$ is half the Porod surface area per unit volume of a thicker layer (as that would  
    26 include both faces of the sheet). 
     25This is the limiting form for a spherical shell of infinitely large radius. 
     26Note that the division by $\delta$ means that $scale$ in sasview is the 
     27volume fraction of sheet, $\phi = S\delta$ where $S$ is the area of sheet 
     28per unit volume. $S$ is half the Porod surface area per unit volume of a 
     29thicker layer (as that would include both faces of the sheet). 
    2730 
    2831The 2D scattering intensity is calculated in the same way as 1D, where 
     
    6063category = "shape:lamellae" 
    6164 
    62 #             ["name", "units", default, [lower, upper], "type","description"], 
    63 parameters = [ ["thickness", "Ang", 50, [0, inf], "volume","total layer thickness" ], 
    64                ["sld", "1e-6/Ang^2", 1, [-inf, inf], "sld","Layer scattering length density" ], 
    65                ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld","Solvent scattering length density" ], 
    66              ] 
     65# pylint: disable=bad-whitespace, line-too-long 
     66#   ["name", "units", default, [lower, upper], "type","description"], 
     67parameters = [ 
     68    ["thickness",          "Ang", 50, [0, inf],    "volume", "total layer thickness" ], 
     69    ["sld",         "1e-6/Ang^2",  1, [-inf, inf], "sld",    "Layer scattering length density" ], 
     70    ["sld_solvent", "1e-6/Ang^2",  6, [-inf, inf], "sld",    "Solvent scattering length density" ], 
     71    ] 
     72# pylint: enable=bad-whitespace, line-too-long 
    6773 
    6874# No volume normalization despite having a volume parameter 
     
    9197            thickness_pd=0.2, thickness_pd_n=40) 
    9298tests = [ 
    93         [ {'scale': 1.0, 'background' : 0.0, 'thickness' : 50.0, 'sld' : 1.0,'sld_solvent' : 6.3, 'thickness_pd' : 0.0,  
    94            }, [0.001], [882289.54309]] 
     99        [ {'scale': 1.0, 'background': 0.0, 'thickness': 50.0, 
     100           'sld': 1.0, 'sld_solvent': 6.3, 'thickness_pd': 0.0}, 
     101          [0.001], [882289.54309]] 
    95102        ] 
    96103# ADDED by: converted by PAK? (or RKH?)     ON: 16Mar2016 - RKH adding unit tests from sasview to early 2015 conversion 
  • sasmodels/models/lamellar_hg.py

    r42356c8 r40a87fa  
    2929and $\Delta\rho_T$ is tail contrast (*sld* $-$ *sld_solvent*). 
    3030 
    31 The total thickness of the lamellar sheet is $\delta_H$ + $\delta_T$ + $\delta_T$ + $\delta_H$. 
    32 Note that in a non aqueous solvent the chemical "head" group may be the  
     31The total thickness of the lamellar sheet is $\delta_H + \delta_T + \delta_T + \delta_H$. 
     32Note that in a non aqueous solvent the chemical "head" group may be the 
    3333"Tail region" and vice-versa. 
    3434 
     
    3636the $q$ vector is defined as 
    3737 
    38 .. math:: 
    39  
    40     q = \sqrt{q_x^2 + q_y^2} 
    41  
     38.. math:: q = \sqrt{q_x^2 + q_y^2} 
    4239 
    4340References 
     
    111108 
    112109# 
    113 tests = [[{'scale': 1.0, 'background': 0.0, 'tail_length': 15.0, 'head_length': 10.0, 
    114            'sld': 0.4, 'sld_head': 3.0, 'sld_solvent': 6.0}, [0.001], [653143.9209]]] 
     110tests = [ 
     111    [{'scale': 1.0, 'background': 0.0, 'tail_length': 15.0, 'head_length': 10.0, 
     112      'sld': 0.4, 'sld_head': 3.0, 'sld_solvent': 6.0}, 
     113     [0.001], [653143.9209]], 
     114] 
    115115# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs 
  • sasmodels/models/lamellar_stack_paracrystal.py

    r42356c8 r40a87fa  
    142142# 
    143143tests = [ 
    144         [ {'scale': 1.0, 'background' : 0.0, 'thickness' : 33.,'Nlayers' : 20.0, 'spacing' : 250., 'spacing_polydisp' : 0.2, 
    145             'sld' : 1.0, 'sld_solvent' : 6.34, 
    146             'thickness_pd' : 0.0, 'thickness_pd_n' : 40 }, [0.001, 0.215268], [21829.3, 0.00487686]] 
    147         ] 
     144    [{'scale': 1.0, 'background': 0.0, 'thickness': 33.,'Nlayers': 20.0, 
     145      'spacing': 250., 'spacing_polydisp': 0.2, 'sld': 1.0, 
     146      'sld_solvent': 6.34, 'thickness_pd': 0.0, 'thickness_pd_n': 40 }, 
     147     [0.001, 0.215268], [21829.3, 0.00487686]], 
     148] 
    148149# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs 
  • sasmodels/models/linear_pearls.py

    rd2d6100 r40a87fa  
    6161    ] 
    6262# pylint: enable=bad-whitespace, line-too-long 
    63 single=False 
     63single = False 
    6464 
    6565source = ["linear_pearls.c"] 
  • sasmodels/models/mono_gauss_coil.py

    r2c74c11 r40a87fa  
    22#conversion of DebyeModel.py 
    33#converted by Steve King, Mar 2016 
     4r""" 
     5This Debye Gaussian coil model strictly describes the scattering from 
     6*monodisperse* polymer chains in theta solvents or polymer melts, conditions 
     7under which the distances between segments follow a Gaussian distribution. 
     8Provided the number of segments is large (ie, high molecular weight polymers) 
     9the single-chain form factor P(Q) is that described by Debye (1947). 
    410 
    5  
    6  
    7 r""" 
    8 This Debye Gaussian coil model strictly describes the scattering from *monodisperse* polymer chains in theta solvents or polymer melts, conditions under which the distances between segments follow a Gaussian distribution. Provided the number of segments is large (ie, high molecular weight polymers) the single-chain form factor P(Q) is that described by Debye (1947). 
    9  
    10 To describe the scattering from *polydisperse* polymer chains see the :ref:`poly_gauss_coil <poly-gauss-coil>` model. 
     11To describe the scattering from *polydisperse* polymer chains see the 
     12:ref:`poly-gauss-coil` model. 
    1113 
    1214Definition 
    1315---------- 
    1416 
    15      *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 
     17.. math:: 
     18 
     19     I(q) = \text{scale} \cdot I_0 \cdot P(q) + \text{background} 
    1620 
    1721where 
    1822 
    19      *I*\ :sub:`0` = |phi|\ :sub:`poly` |cdot| *V* |cdot| (|rho|\ :sub:`poly` - |rho|\ :sub:`solv`)\  :sup:`2` 
     23.. math:: 
    2024 
    21      *P(q)* = 2 [exp(-Z) + Z - 1] / Z \ :sup:`2` 
     25     I_0 &= \phi_\text{poly} \cdot V 
     26            \cdot (\rho_\text{poly} - \rho_\text{solv})^2 
    2227 
    23      *Z* = (*q R* \ :sub:`g`)\ :sup:`2` 
     28     P(q) &= 2 [\exp(-Z) + Z - 1] / Z^2 
    2429 
    25 and 
     30     Z &= (q R_g)^2 
    2631 
    27      *V* = *M* / (*N*\ :sub:`A` |delta|) 
     32     V &= M / (N_A \delta) 
    2833 
    29 Here, |phi|\ :sub:`poly` is the volume fraction of polymer, *V* is the volume of a polymer coil, *M* is the molecular weight of the polymer, *N*\ :sub:`A` is Avogadro's Number, |delta| is the bulk density of the polymer, |rho|\ :sub:`poly` is the sld of the polymer, |rho|\ :sub:`solv` is the sld of the solvent, and *R*\ :sub:`g` is the radius of gyration of the polymer coil. 
     34Here, $\phi_\text{poly}$ is the volume fraction of polymer, $V$ is the 
     35volume of a polymer coil, *M* is the molecular weight of the polymer, 
     36$N_A$ is Avogadro's Number, $\delta$ is the bulk density of the polymer, 
     37$\rho_\text{poly}$ is the sld of the polymer, $\rho\text{solv}$ is the 
     38sld of the solvent, and $R_g$ is the radius of gyration of the polymer coil. 
    3039 
    31 The 2D scattering intensity is calculated in the same way as the 1D, but where the *q* vector is redefined as 
     40The 2D scattering intensity is calculated in the same way as the 1D, 
     41but where the *q* vector is redefined as 
    3242 
    3343.. math:: 
     
    4050P Debye, *J. Phys. Colloid. Chem.*, 51 (1947) 18. 
    4151 
    42 R J Roe, *Methods of X-Ray and Neutron Scattering in Polymer Science*, Oxford University Press, New York (2000). 
     52R J Roe, *Methods of X-Ray and Neutron Scattering in Polymer Science*, 
     53Oxford University Press, New York (2000). 
    4354 
    4455http://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_28.pdf 
     
    4758from numpy import inf, exp, errstate 
    4859 
    49 name =  "mono_gauss_coil" 
    50 title =  "Scattering from monodisperse polymer coils" 
     60name = "mono_gauss_coil" 
     61title = "Scattering from monodisperse polymer coils" 
    5162 
    52 description =  """ 
     63description = """ 
    5364    Evaluates the scattering from  
    5465    monodisperse polymer chains. 
    5566    """ 
    56 category =  "shape-independent" 
     67category = "shape-independent" 
    5768 
    58 #             ["name", "units", default, [lower, upper], "type", "description"], 
    59 parameters =  [["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
    60                ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"]] 
     69# pylint: disable=bad-whitespace, line-too-long 
     70#   ["name", "units", default, [lower, upper], "type", "description"], 
     71parameters = [ 
     72    ["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
     73    ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
     74    ] 
     75# pylint: enable=bad-whitespace, line-too-long 
    6176 
    6277# NB: Scale and Background are implicit parameters on every model 
     
    7186Iq.vectorized = True # Iq accepts an array of q values 
    7287 
    73 demo =  dict(scale = 1.0, 
    74             i_zero = 70.0, 
    75             radius_gyration = 75.0, 
    76             background = 0.0) 
     88demo = dict(scale=1.0, i_zero=70.0, radius_gyration=75.0, background=0.0) 
    7789 
    7890# these unit test values taken from SasView 3.1.2 
    79 tests =  [ 
     91tests = [ 
    8092    [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 'background': 0.0}, 
    8193     [0.0106939, 0.469418], [57.1241, 0.112859]], 
  • sasmodels/models/multilayer_vesicle.py

    rf67f26c r40a87fa  
    1313    Geometry of the multilayer_vesicle model. 
    1414 
    15 See the core_shell_ function for more documentation. 
    16  
    17 .. _core_shell: core_shell_sphere.html 
     15See the :ref:`core-shell` model for more documentation. 
    1816 
    1917The 2D scattering intensity is the same as 1D, regardless of the orientation 
     
    2927    is used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied. 
    3028 
    31 For information about polarised and magnetic scattering, see  
     29For information about polarised and magnetic scattering, see 
    3230the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` documentation. 
    3331 
  • sasmodels/models/onion.py

    r785cbec r40a87fa  
    300300# TODO: n is a volume parameter that is not polydisperse 
    301301 
    302 #             ["name", "units", default, [lower, upper], "type","description"], 
    303 parameters = [["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", 
    304                "Core scattering length density"], 
    305               ["radius_core", "Ang", 200., [0, inf], "volume", 
    306                "Radius of the core"], 
    307               ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", 
    308                "Solvent scattering length density"], 
    309               ["n_shells", "", 1, [0, 10], "volume", 
    310                "number of shells"], 
    311               ["sld_in[n_shells]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", 
    312                "scattering length density at the inner radius of shell k"], 
    313               ["sld_out[n_shells]", "1e-6/Ang^2", 2.0, [-inf, inf], "sld", 
    314                "scattering length density at the outer radius of shell k"], 
    315               ["thickness[n_shells]", "Ang", 40., [0, inf], "volume", 
    316                "Thickness of shell k"], 
    317               ["A[n_shells]", "", 1.0, [-inf, inf], "", 
    318                "Decay rate of shell k"], 
    319               ] 
     302# pylint: disable=bad-whitespace, line-too-long 
     303#   ["name", "units", default, [lower, upper], "type","description"], 
     304parameters = [ 
     305    ["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "Core scattering length density"], 
     306    ["radius_core", "Ang", 200., [0, inf], "volume", "Radius of the core"], 
     307    ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", "Solvent scattering length density"], 
     308    ["n_shells", "", 1, [0, 10], "volume", "number of shells"], 
     309    ["sld_in[n_shells]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", "scattering length density at the inner radius of shell k"], 
     310    ["sld_out[n_shells]", "1e-6/Ang^2", 2.0, [-inf, inf], "sld", "scattering length density at the outer radius of shell k"], 
     311    ["thickness[n_shells]", "Ang", 40., [0, inf], "volume", "Thickness of shell k"], 
     312    ["A[n_shells]", "", 1.0, [-inf, inf], "", "Decay rate of shell k"], 
     313    ] 
     314# pylint: enable=bad-whitespace, line-too-long 
    320315 
    321316source = ["lib/sph_j1c.c", "onion.c"] 
     
    330325 
    331326    total_radius = 1.25*(sum(thickness[:n_shells]) + radius_core + 1) 
    332     dr = total_radius/400  # 400 points for a smooth plot 
    333  
    334     r = [] 
     327    dz = total_radius/400  # 400 points for a smooth plot 
     328 
     329    z = [] 
    335330    rho = [] 
    336331 
    337332    # add in the core 
    338     r.append(0) 
     333    z.append(0) 
    339334    rho.append(sld_core) 
    340     r.append(radius_core) 
     335    z.append(radius_core) 
    341336    rho.append(sld_core) 
    342337 
     
    344339    for k in range(n_shells): 
    345340        # Left side of each shells 
    346         r0 = r[-1] 
    347         r.append(r0) 
     341        z_current = z[-1] 
     342        z.append(z_current) 
    348343        rho.append(sld_in[k]) 
    349344 
    350345        if fabs(A[k]) < 1.0e-16: 
    351346            # flat shell 
    352             r.append(r0 + thickness[k]) 
     347            z.append(z_current + thickness[k]) 
    353348            rho.append(sld_out[k]) 
    354349        else: 
     
    356351            # num_steps must be at least 1, so use floor()+1 rather than ceil 
    357352            # to protect against a thickness0. 
    358             num_steps = np.floor(thickness[k]/dr) + 1 
     353            num_steps = np.floor(thickness[k]/dz) + 1 
    359354            slope = (sld_out[k] - sld_in[k]) / expm1(A[k]) 
    360355            const = (sld_in[k] - slope) 
    361             for rk in np.linspace(0, thickness[k], num_steps+1): 
    362                 r.append(r0+rk) 
    363                 rho.append(slope*exp(A[k]*rk/thickness[k]) + const) 
     356            for z_shell in np.linspace(0, thickness[k], num_steps+1): 
     357                z.append(z_current+z_shell) 
     358                rho.append(slope*exp(A[k]*z_shell/thickness[k]) + const) 
    364359 
    365360    # add in the solvent 
    366     r.append(r[-1]) 
     361    z.append(z[-1]) 
    367362    rho.append(sld_solvent) 
    368     r.append(total_radius) 
     363    z.append(total_radius) 
    369364    rho.append(sld_solvent) 
    370365 
    371     return np.asarray(r), np.asarray(rho) 
     366    return np.asarray(z), np.asarray(rho) 
    372367 
    373368def ER(core_radius, n, thickness): 
     369    """Effective radius""" 
    374370    return np.sum(thickness[:n[0]], axis=0) + core_radius 
    375  
    376 def VR(core_radius, n, thickness): 
    377     return 1.0, 1.0 
    378371 
    379372demo = { 
  • sasmodels/models/parallelepiped.py

    r42356c8 r40a87fa  
    77---------- 
    88 
    9 | This model calculates the scattering from a rectangular parallelepiped (:numref:`parallelepiped-image`). 
     9| This model calculates the scattering from a rectangular parallelepiped 
     10| (:numref:`parallelepiped-image`). 
    1011| If you need to apply polydispersity, see also :ref:`rectangular-prism`. 
    1112 
     
    3435.. math:: 
    3536 
    36     I(q) = \frac{\text{scale}}{V} (\Delta\rho \cdot V)^2 \left< P(q, \alpha) \right> 
    37     + \text{background} 
     37    I(q) = \frac{\text{scale}}{V} (\Delta\rho \cdot V)^2 
     38           \left< P(q, \alpha) \right> + \text{background} 
    3839 
    3940where the volume $V = A B C$, the contrast is defined as 
    40 :math:`\Delta\rho = \rho_{\textstyle p} - \rho_{\textstyle solvent}`, 
     41$\Delta\rho = \rho_\text{p} - \rho_\text{solvent}$, 
    4142$P(q, \alpha)$ is the form factor corresponding to a parallelepiped oriented 
    42 at an angle $\alpha$ (angle between the long axis C and :math:`\vec q`), 
     43at an angle $\alpha$ (angle between the long axis C and $\vec q$), 
    4344and the averaging $\left<\ldots\right>$ is applied over all orientations. 
    4445 
     
    5556.. math:: 
    5657 
    57     \phi_Q(\mu,a) = \int_0^1 
     58    \phi_Q(\mu,a) &= \int_0^1 
    5859        \left\{S\left[\frac{\mu}{2}\cos\left(\frac{\pi}{2}u\right)\right] 
    5960               S\left[\frac{\mu a}{2}\sin\left(\frac{\pi}{2}u\right)\right] 
    6061               \right\}^2 du 
    6162 
    62     S(x) = \frac{\sin x}{x} 
    63  
    64     \mu = qB 
     63    S(x) &= \frac{\sin x}{x} 
     64 
     65    \mu &= qB 
    6566 
    6667 
     
    105106.. figure:: img/parallelepiped_angle_projection.jpg 
    106107 
    107     Examples of the angles for oriented parallelepipeds against the detector plane. 
    108  
    109 For a given orientation of the parallelepiped, the 2D form factor is calculated as 
    110  
    111 .. math:: 
    112  
    113     P(q_x, q_y) = \left[\frac{sin(qA\cos\alpha/2)}{(qA\cos\alpha/2)}\right]^2 
    114                   \left[\frac{sin(qB\cos\beta/2)}{(qB\cos\beta/2)}\right]^2 
    115                   \left[\frac{sin(qC\cos\gamma/2)}{(qC\cos\gamma/2)}\right]^2 
     108    Examples of the angles for oriented parallelepipeds against the 
     109    detector plane. 
     110 
     111For a given orientation of the parallelepiped, the 2D form factor is 
     112calculated as 
     113 
     114.. math:: 
     115 
     116    P(q_x, q_y) = \left[\frac{\sin(qA\cos\alpha/2)}{(qA\cos\alpha/2)}\right]^2 
     117                  \left[\frac{\sin(qB\cos\beta/2)}{(qB\cos\beta/2)}\right]^2 
     118                  \left[\frac{\sin(qC\cos\gamma/2)}{(qC\cos\gamma/2)}\right]^2 
    116119 
    117120with 
     
    119122.. math:: 
    120123 
    121     \cos\alpha = \hat A \cdot \hat q, \; 
    122     \cos\beta  = \hat B \cdot \hat q, \; 
    123     \cos\gamma = \hat C \cdot \hat q 
     124    \cos\alpha &= \hat A \cdot \hat q, 
     125 
     126    \cos\beta  &= \hat B \cdot \hat q, 
     127 
     128    \cos\gamma &= \hat C \cdot \hat q 
    124129 
    125130and the scattering intensity as: 
     
    127132.. math:: 
    128133 
    129     I(q_x, q_y) = \frac{\text{scale}}{V} V^2 \Delta\rho^2 P(q_x, q_y) + \text{background} 
     134    I(q_x, q_y) = \frac{\text{scale}}{V} V^2 \Delta\rho^2 P(q_x, q_y) 
     135            + \text{background} 
    130136 
    131137.. Comment by Miguel Gonzalez: 
    132138   This reflects the logic of the code, as in parallelepiped.c the call 
    133    to _pkernel returns P(q_x, q_y) and then this is multiplied by V^2 * (delta rho)^2. 
    134    And finally outside parallelepiped.c it will be multiplied by scale, normalized by 
    135    V and the background added. But mathematically it makes more sense to write 
    136    I(q_x, q_y) = \text{scale} V \Delta\rho^2 P(q_x, q_y) + \text{background}, 
     139   to _pkernel returns $P(q_x, q_y)$ and then this is multiplied by 
     140   $V^2 * (\Delta \rho)^2$. And finally outside parallelepiped.c it will be 
     141   multiplied by scale, normalized by $V$ and the background added. But 
     142   mathematically it makes more sense to write 
     143   $I(q_x, q_y) = \text{scale} V \Delta\rho^2 P(q_x, q_y) + \text{background}$, 
    137144   with scale being the volume fraction. 
    138145 
     
    143150Validation of the code was done by comparing the output of the 1D calculation 
    144151to the angular average of the output of a 2D calculation over all possible 
    145 angles.  
     152angles. 
    146153 
    147154This model is based on form factor calculations implemented in a c-library 
  • sasmodels/models/poly_gauss_coil.py

    r2c74c11 r40a87fa  
    22#conversion of Poly_GaussCoil.py 
    33#converted by Steve King, Mar 2016 
     4r""" 
     5This empirical model describes the scattering from *polydisperse* polymer 
     6chains in theta solvents or polymer melts, assuming a Schulz-Zimm type 
     7molecular weight distribution. 
    48 
    5  
    6   
    7 r""" 
    8 This empirical model describes the scattering from *polydisperse* polymer chains in theta solvents or polymer melts, assuming a Schulz-Zimm type molecular weight distribution. 
    9  
    10 To describe the scattering from *monodisperse* polymer chains, see the :ref:`mono_gauss_coil <mono-gauss-coil>` model. 
     9To describe the scattering from *monodisperse* polymer chains, see the 
     10:ref:`mono-gauss-coil` model. 
    1111 
    1212Definition 
    1313---------- 
    1414 
    15      *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 
     15.. math:: 
     16 
     17     I(q) = \text{scale} \cdot I_0 \cdot P(q) + \text{background} 
    1618 
    1719where 
    1820 
    19      *I*\ :sub:`0` = |phi|\ :sub:`poly` |cdot| *V* |cdot| (|rho|\ :sub:`poly` - |rho|\ :sub:`solv`)\ :sup:`2` 
     21.. math:: 
    2022 
    21      *P(q)* = 2 [(1 + UZ)\ :sup:`-1/U` + Z - 1] / [(1 + U) Z\ :sup:`2`] 
     23     I_0 &= \phi_\text{poly} \cdot V \cdot (\rho_\text{poly}-\rho_\text{solv})^2 
    2224 
    23      *Z* = [(*q R*\ :sub:`g`)\ :sup:`2`] / (1 + 2U) 
     25     P(q) &= 2 [(1 + UZ)^{-1/U} + Z - 1] / [(1 + U) Z^2] 
    2426 
    25      *U* = (Mw / Mn) - 1 = (*polydispersity ratio*) - 1 
     27     Z &= [(q R_g)^2] / (1 + 2U) 
    2628 
    27 and 
     29     U &= (Mw / Mn) - 1 = \text{polydispersity ratio} - 1 
    2830 
    29      *V* = *M* / (*N*\ :sub:`A` |delta|) 
     31     V &= M / (N_A \delta) 
    3032 
    31 Here, |phi|\ :sub:`poly`, is the volume fraction of polymer, *V* is the volume of a polymer coil, *M* is the molecular weight of the polymer, *N*\ :sub:`A` is Avogadro's Number, |delta| is the bulk density of the polymer, |rho|\ :sub:`poly` is the sld of the polymer, |rho|\ :sub:`solv` is the sld of the solvent, and *R*\ :sub:`g` is the radius of gyration of the polymer coil. 
     33Here, $\phi_\text{poly}$, is the volume fraction of polymer, $V$ is the 
     34volume of a polymer coil, $M$ is the molecular weight of the polymer, 
     35$N_A$ is Avogadro's Number, $\delta$ is the bulk density of the polymer, 
     36$\rho_\text{poly}$ is the sld of the polymer, $\rho_\text{solv}$ is the 
     37sld of the solvent, and $R_g$ is the radius of gyration of the polymer coil. 
    3238 
    33 The 2D scattering intensity is calculated in the same way as the 1D, but where the *q* vector is redefined as 
     39The 2D scattering intensity is calculated in the same way as the 1D, 
     40but where the $q$ vector is redefined as 
    3441 
    3542.. math:: 
     
    4047---------- 
    4148 
    42 O Glatter and O Kratky (editors), *Small Angle X-ray Scattering*, Academic Press, (1982) 
    43 Page 404. 
     49O Glatter and O Kratky (editors), *Small Angle X-ray Scattering*, 
     50Academic Press, (1982) Page 404. 
    4451 
    45 J S Higgins, H C Benoit, *Polymers and Neutron Scattering*, Oxford Science Publications, (1996). 
     52J S Higgins, H C Benoit, *Polymers and Neutron Scattering*, 
     53Oxford Science Publications, (1996). 
    4654 
    47 S M King, *Small Angle Neutron Scattering* in *Modern Techniques for Polymer Characterisation*, Wiley, (1999). 
     55S M King, *Small Angle Neutron Scattering* in *Modern Techniques for 
     56Polymer Characterisation*, Wiley, (1999). 
    4857 
    4958http://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_28.pdf 
     
    5261from numpy import inf, exp, power 
    5362 
    54 name =  "poly_gauss_coil" 
    55 title =  "Scattering from polydisperse polymer coils" 
     63name = "poly_gauss_coil" 
     64title = "Scattering from polydisperse polymer coils" 
    5665 
    57 description =  """ 
     66description = """ 
    5867    Evaluates the scattering from  
    5968    polydisperse polymer chains. 
    6069    """ 
    61 category =  "shape-independent" 
     70category = "shape-independent" 
    6271 
    63 #             ["name", "units", default, [lower, upper], "type", "description"], 
    64 parameters =  [["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
    65                ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
    66                ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"]] 
     72# pylint: disable=bad-whitespace, line-too-long 
     73#   ["name", "units", default, [lower, upper], "type", "description"], 
     74parameters = [ 
     75    ["i_zero",          "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
     76    ["radius_gyration",  "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
     77    ["polydispersity",  "None",  2.0, [1.0, inf], "", "Polymer Mw/Mn"], 
     78    ] 
     79# pylint: enable=bad-whitespace, line-too-long 
    6780 
    6881# NB: Scale and Background are implicit parameters on every model 
     
    7184    u = polydispersity - 1.0 
    7285    z = (q*radius_gyration)**2 / (1.0 + 2.0*u) 
    73     # need to trap the case of the polydispersity being 1 (ie, monodispersity!) 
     86    # need to trap the case of the polydispersity being 1 (ie, monodisperse!) 
    7487    if polydispersity == 1.0: 
    7588        inten = i_zero * 2.0 * (exp(-z) + z - 1.0) 
     
    8093    inten[index] /= z[index]**2 
    8194    return inten 
    82 Iq.vectorized =  True  # Iq accepts an array of q values 
     95Iq.vectorized = True  # Iq accepts an array of q values 
    8396 
    84 demo =  dict(scale = 1.0, 
    85             i_zero = 70.0, 
    86             radius_gyration = 75.0, 
    87             polydispersity = 2.0, 
    88             background = 0.0) 
     97demo = dict(scale=1.0, 
     98            i_zero=70.0, 
     99            radius_gyration=75.0, 
     100            polydispersity=2.0, 
     101            background=0.0) 
    89102 
    90103# these unit test values taken from SasView 3.1.2 
    91 tests =  [ 
    92     [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 'polydispersity': 2.0, 'background': 0.0}, 
     104tests = [ 
     105    [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 
     106      'polydispersity': 2.0, 'background': 0.0}, 
    93107     [0.0106939, 0.469418], [57.6405, 0.169016]], 
    94108    ] 
  • sasmodels/models/polymer_excl_volume.py

    r2c74c11 r40a87fa  
    106106 
    107107# pylint: disable=bad-whitespace, line-too-long 
    108 #             ["name", "units", default, [lower, upper], "type", "description"], 
    109 parameters = [["rg",        "Ang", 60.0, [0, inf],    "", "Radius of Gyration"], 
    110               ["porod_exp", "",     3.0, [-inf, inf], "", "Porod exponent"], 
    111              ] 
     108#   ["name", "units", default, [lower, upper], "type", "description"], 
     109parameters = [ 
     110    ["rg",        "Ang", 60.0, [0, inf],    "", "Radius of Gyration"], 
     111    ["porod_exp", "",     3.0, [-inf, inf], "", "Porod exponent"], 
     112] 
    112113# pylint: enable=bad-whitespace, line-too-long 
    113114 
     
    120121    :return:          Calculated intensity 
    121122    """ 
    122     u = (q*rg)**2 * (2.0/porod_exp + 1.0) * (2.0/porod_exp + 2.0)/6.0 
     123    usub = (q*rg)**2 * (2.0/porod_exp + 1.0) * (2.0/porod_exp + 2.0)/6.0 
    123124    with errstate(divide='ignore', invalid='ignore'): 
    124         upow = power(u, -0.5*porod_exp) 
    125         iq = (porod_exp*upow * 
    126               (gamma(0.5*porod_exp)*gammainc(0.5*porod_exp, u) - 
    127                upow*gamma(porod_exp)*gammainc(porod_exp, u))) 
    128     iq[q <= 0] = 1.0 
     125        upow = power(usub, -0.5*porod_exp) 
     126        result= (porod_exp*upow * 
     127                 (gamma(0.5*porod_exp)*gammainc(0.5*porod_exp, usub) - 
     128                  upow*gamma(porod_exp)*gammainc(porod_exp, usub))) 
     129    result[q <= 0] = 1.0 
    129130 
    130     return iq 
     131    return result 
    131132 
    132133Iq.vectorized = True  # Iq accepts an array of q values 
    133  
    134134 
    135135tests = [ 
  • sasmodels/models/polymer_micelle.py

    rd2d6100 r40a87fa  
    33This model provides the form factor, $P(q)$, for a micelle with a spherical 
    44core and Gaussian polymer chains attached to the surface, thus may be applied 
    5 to block copolymer micelles. To work well the Gaussian chains must be much smaller 
    6 than the core, which is often not the case.  Please study the reference carefully. 
     5to block copolymer micelles. To work well the Gaussian chains must be much 
     6smaller than the core, which is often not the case.  Please study the 
     7reference carefully. 
    78 
    89Definition 
     
    7172    [{}, 0.01, 15.3532], 
    7273    ] 
    73 # RKH 20Mar2016 - need to check whether the core & corona volumes are per monomer ??? and how aggregation number works! 
    74 # renamed from micelle_spherical_core to polymer_micelle, moved from shape-independent to spheres section. 
     74# RKH 20Mar2016 - need to check whether the core & corona volumes are per 
     75#                 monomer ??? and how aggregation number works! 
     76# renamed from micelle_spherical_core to polymer_micelle, 
     77# moved from shape-independent to spheres section. 
    7578# Ought to be able to add polydisp to core? And add ability to x by S(Q) ? 
  • sasmodels/models/porod.py

    r2c74c11 r40a87fa  
    22This model fits the Porod function 
    33 
    4 .. math:: 
    5  
    6     I(q) = C/q^4 
    7     \\ 
    8     C = 2\pi (\Delta\rho)^2 S_v 
     4.. math:: I(q) = C/q^4 
    95 
    106to the data directly without any need for linearisation (cf. Log I(q) vs Log q). 
    117 
    12 Here $C$ is the scale factor and $S_v$ is the specific surface area (ie, surface area / volume) 
    13 of the sample, and $\Delta\rho$ is the contrast factor. 
     8Here $C = 2\pi (\Delta\rho)^2 S_v$ is the scale factor where $S_v$ is 
     9the specific surface area (ie, surface area / volume) of the sample, and 
     10$\Delta\rho$ is the contrast factor. 
    1411 
    1512For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
    1613where the q vector is defined as 
    1714 
    18 .. math:: 
    19     q = \sqrt{q_x^2+q_y^2} 
     15.. math:: q = \sqrt{q_x^2+q_y^2} 
    2016 
    2117References 
     
    2319 
    2420G Porod. *Kolloid Zeit*. 124 (1951) 83. 
    25 L A Feigin, D I Svergun, G W Taylor. *Structure Analysis by Small-Angle X-ray and Neutron Scattering*. Springer. (1987) 
     21 
     22L A Feigin, D I Svergun, G W Taylor. *Structure Analysis by Small-Angle 
     23X-ray and Neutron Scattering*. Springer. (1987) 
    2624""" 
    2725 
  • sasmodels/models/power_law.py

    r2c74c11 r40a87fa  
    4646    # pylint: disable=missing-docstring 
    4747    with errstate(divide='ignore'): 
    48         iq = q**-power 
    49     return iq 
     48        result = q**-power 
     49    return result 
    5050Iq.vectorized = True  # Iq accepts an array of q values 
    5151 
    52 demo = dict(scale=1.0, 
    53             power=4.0, 
    54             background=0.0) 
     52demo = dict(scale=1.0, power=4.0, background=0.0) 
    5553 
    5654tests = [ 
  • sasmodels/models/pringle.py

    rc047acf r40a87fa  
    3131$d$ and $R$ are the "pringle" thickness and radius respectively, $\alpha$ and 
    3232$\beta$ are the two curvature parameters, and $J_n$ is the n\ :sup:`th` order 
    33 Bessel function of the first kind.  
     33Bessel function of the first kind. 
    3434 
    3535.. figure:: img/pringles_fig1.png 
     
    7979def ER(radius, thickness, alpha, beta): 
    8080    """ 
    81         Return equivalent radius (ER) 
     81    Return equivalent radius (ER) 
    8282    """ 
    8383    ddd = 0.75 * radius * (2 * radius * thickness + (thickness + radius) \ 
  • sasmodels/models/raspberry.py

    r42356c8 r40a87fa  
    2222.. math:: 
    2323 
    24     S(q) = \frac{sin(qR_1)}{qR_1}\frac{sin(qR_2)}{qR_2}\frac{sin(qr)}{qr} 
     24    S(q) = \frac{\sin(qR_1)}{qR_1}\frac{\sin(qR_2)}{qR_2}\frac{\sin(qr)}{qr} 
    2525 
    2626In this case, the large droplet and small particles are solid spheres rather 
     
    3131.. math:: 
    3232 
    33     \Psi_L = \int_0^{R_L}(4\pi R^2_L)\frac{sin(qR_L)}{qR_L}dR_L =  
    34     \frac{3[sin(qR_L)-qR_Lcos(qR_L)]}{(qR_L)^2} 
     33    \Psi_L = \int_0^{R_L}(4\pi R^2_L)\frac{\sin(qR_L)}{qR_L}dR_L = 
     34    \frac{3[\sin(qR_L)-qR_L\cos(qR_L)]}{(qR_L)^2} 
    3535 
    3636.. math:: 
    3737 
    38     \Psi_S = \int_0^{R_S}(4\pi R^2_S)\frac{sin(qR_S)}{qR_S}dR_S = 
    39     \frac{3[sin(qR_S)-qR_Lcos(qR_S)]}{(qR_S)^2} 
     38    \Psi_S = \int_0^{R_S}(4\pi R^2_S)\frac{\sin(qR_S)}{qR_S}dR_S = 
     39    \frac{3[\sin(qR_S)-qR_L\cos(qR_S)]}{(qR_S)^2} 
    4040 
    4141The cross term between the large droplet and small particles is given by: 
    4242 
    4343.. math:: 
    44     S_{LS} = \Psi_L\Psi_S\frac{sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)} 
     44    S_{LS} = \Psi_L\Psi_S\frac{\sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)} 
    4545 
    4646and the self term between small particles is given by: 
    4747 
    4848.. math:: 
    49     S_{SS} = \Psi_S^2\biggl[\frac{sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)} 
     49    S_{SS} = \Psi_S^2\biggl[\frac{\sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)} 
    5050    \biggr]^2 
    5151 
     
    5454.. math:: 
    5555 
    56     N_p = \frac{\phi_S\phi_{surface}V_L}{\phi_L V_S} 
     56    N_p = \frac{\phi_S\phi_\text{surface}V_L}{\phi_L V_S} 
    5757 
    5858where $\phi_S$ is the volume fraction of small particles in the sample, 
    59 $\phi_{surface}$ is the fraction of the small particles that are adsorbed to 
    60 the large droplets, $\phi_L$ is the volume fraction of large droplets in the 
     59$\phi_\text{surface}$ is the fraction of the small particles that are adsorbed 
     60to the large droplets, $\phi_L$ is the volume fraction of large droplets in the 
    6161sample, and $V_S$ and $V_L$ are the volumes of individual small particles and 
    6262large droplets respectively. 
     
    6464The form factor of the entire complex can now be calculated including the excess 
    6565scattering length densities of the components $\Delta\rho_L$ and $\Delta\rho_S$, 
    66 where $\Delta\rho_x = |\rho_x-\rho_{solvent}|$ : 
     66where $\Delta\rho_x = \left|\rho_x-\rho_\text{solvent}\right|$ : 
    6767 
    6868.. math:: 
     
    8383 
    8484.. math:: 
    85     I(Q) = I_{LS}(Q) + I_S(Q) = (\phi_L(\Delta\rho_L)^2V_L +  
    86             \phi_S\phi_{surface}N_p(\Delta\rho_S)^2V_S)P_{LS} 
    87             + \phi_S(1-\phi_{surface})(\Delta\rho_S)^2V_S\Psi_S^2 
     85    I(Q) = I_{LS}(Q) + I_S(Q) = (\phi_L(\Delta\rho_L)^2V_L + 
     86            \phi_S\phi_\text{surface}N_p(\Delta\rho_S)^2V_S)P_{LS} 
     87            + \phi_S(1-\phi_\text{surface})(\Delta\rho_S)^2V_S\Psi_S^2 
    8888 
    8989A useful parameter to extract is the fraction of the surface area of the large 
     
    9292 
    9393.. math:: 
    94     \chi = \frac{4\phi_L\phi_{surface}(R_L+\delta R_S)}{\phi_LR_S} 
     94    \chi = \frac{4\phi_L\phi_\text{surface}(R_L+\delta R_S)}{\phi_LR_S} 
    9595 
    9696 
     
    109109""" 
    110110 
    111 from numpy import pi, inf 
     111from numpy import inf 
    112112 
    113113name = "raspberry" 
  • sasmodels/models/rpa.py

    r51ec7e8 r40a87fa  
    111111HIDE_AB = set("N2 Phi2 v2 L2 b2 K23 K24".split()).union(HIDE_A) 
    112112def hidden(case_num): 
     113    """ 
     114    Return a list of parameters to hide depending on the multiplicity parameter. 
     115    """ 
    113116    if case_num < 2: 
    114117        return HIDE_AB 
  • sasmodels/models/sphere.py

    r2c74c11 r40a87fa  
    11r""" 
    2 For information about polarised and magnetic scattering, see  
    3 the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` documentation. 
     2For information about polarised and magnetic scattering, see 
     3the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` 
     4documentation. 
    45 
    56Definition 
  • sasmodels/models/squarewell.py

    r56b2687 r40a87fa  
    11# Note: model title and parameter table are inserted automatically 
    22r""" 
    3 This calculates the interparticle structure factor for a square well fluid spherical particles. The mean spherical 
    4 approximation (MSA) closure was used for this calculation, and is not the most appropriate closure for an attractive 
    5 interparticle potential. This solution has been compared to Monte Carlo simulations for a square well fluid, showing 
    6 this calculation to be limited in applicability to well depths |epsilon| < 1.5 kT and volume fractions |phi| < 0.08. 
     3This calculates the interparticle structure factor for a square well fluid 
     4spherical particles. The mean spherical approximation (MSA) closure was 
     5used for this calculation, and is not the most appropriate closure for 
     6an attractive interparticle potential. This solution has been compared 
     7to Monte Carlo simulations for a square well fluid, showing this calculation 
     8to be limited in applicability to well depths $\epsilon < 1.5$ kT and 
     9volume fractions $\phi < 0.08$. 
    710 
    8 Positive well depths correspond to an attractive potential well. Negative well depths correspond to a potential 
    9 "shoulder", which may or may not be physically reasonable. The stickyhardsphere model may be a better choice in 
     11Positive well depths correspond to an attractive potential well. Negative 
     12well depths correspond to a potential "shoulder", which may or may not be 
     13physically reasonable. The stickyhardsphere model may be a better choice in 
    1014some circumstances. Computed values may behave badly at extremely small $qR$. 
    1115 
    12 The well width (|lambda| ) is defined as multiples of the particle diameter (2\*\ *R*\ ) 
     16The well width $(\lambda)$ is defined as multiples of the particle diameter 
     17$(2 R)$. 
    1318 
    1419The interaction potential is: 
     
    2934used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    3035 
    31 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as 
     36For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
     37where the $q$ vector is defined as 
    3238 
    3339.. math:: 
     
    130136# 
    131137tests = [ 
    132         [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2,  
    133            'radius_effective_pd' : 0}, [0.001], [0.97665742]] 
    134         ] 
     138    [{'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 
     139      'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2, 
     140      'radius_effective_pd' : 0}, 
     141     [0.001], [0.97665742]], 
     142    ] 
    135143# ADDED by: converting from sasview RKH  ON: 16Mar2016 
    136144 
  • sasmodels/models/stacked_disks.py

    r42356c8 r40a87fa  
    1414of the q vector which is defined as 
    1515 
    16 .. math:: 
    17  
    18     q = \sqrt{q_x^2 + q_y^2} 
     16.. math:: q = \sqrt{q_x^2 + q_y^2} 
    1917 
    2018Definition 
     
    2826 
    2927    I(q) = N\int_{0}^{\pi /2}\left[ \Delta \rho_t 
    30     \left( V_tf_t(q) - V_cf_c(q)\right) + \Delta \rho_cV_cf_c(q) 
    31     \right]^2S(q)\sin{\alpha d\alpha} + background 
     28    \left( V_t f_t(q) - V_c f_c(q)\right) + \Delta \rho_c V_c f_c(q) 
     29    \right]^2 S(q)\sin{\alpha}\ d\alpha + \text{background} 
    3230 
    3331where the contrast 
     
    3533.. math:: 
    3634 
    37     \Delta \rho_i = \rho_i - \rho_{solvent} 
    38  
    39 and *N* is the number of discs per unit volume, 
    40 $\alpha$ is the angle between the axis of the disc and *q*, 
     35    \Delta \rho_i = \rho_i - \rho_\text{solvent} 
     36 
     37and $N$ is the number of discs per unit volume, 
     38$\alpha$ is the angle between the axis of the disc and $q$, 
    4139and $V_t$ and $V_c$ are the total volume and the core volume of 
    4240a single disc, respectively. 
     
    4644    \left\langle f_{t}^2(q)\right\rangle_{\alpha} = 
    4745    \int_{0}^{\pi/2}\left[ 
    48     \left(\frac{sin(q(d+h)\cos{\alpha})}{q(d+h)\cos{\alpha}}\right) 
     46    \left(\frac{\sin(q(d+h)\cos{\alpha})}{q(d+h)\cos{\alpha}}\right) 
    4947    \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right) 
    50     \right]^2 \sin{\alpha d\alpha} 
     48    \right]^2 \sin{\alpha}\ d\alpha 
    5149 
    5250    \left\langle f_{c}^2(q)\right\rangle_{\alpha} = 
    5351    \int_{0}^{\pi/2}\left[ 
    54     \left(\frac{sin(qh)\cos{\alpha})}{qh\cos{\alpha}}\right) 
    55     \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right) 
    56     \right]^2 \sin{\alpha d\alpha} 
    57  
    58 where *d* = thickness of the layer (layer_thick), 
    59 *2h* = core thickness (core_thick), and *R* = radius of the disc (radius). 
     52    \left(\frac{\sin(qh)\cos{\alpha})}{qh\cos{\alpha}}\right) 
     53    \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}}\right) 
     54    \right]^2 \sin{\alpha}\ d\alpha 
     55 
     56where $d$ = thickness of the layer (*layer_thick*), 
     57$2h$ = core thickness (*core_thick*), and $R$ = radius of the disc (*radius*). 
    6058 
    6159.. math:: 
    6260 
    6361    S(q) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})} 
    64     exp\left[ -k(q\cos{\alpha})^2\sigma_D/2\right] 
    65  
    66 where *n* = the total number of the disc stacked (n_stacking), 
    67 *D* = 2*(*d*+*h*)the next neighbor center-to-center distance (d-spacing), 
    68 and $\sigma_D$ = the Gaussian standard deviation of the d-spacing (sigma_d). 
     62    \exp\left[ -k(q\cos{\alpha})^2\sigma_D/2\right] 
     63 
     64where $n$ is the total number of the disc stacked (*n_stacking*), 
     65$D = 2(d+h)$ is the next neighbor center-to-center distance (d-spacing), 
     66and $\sigma_D$ = the Gaussian standard deviation of the d-spacing (*sigma_d*). 
    6967 
    7068.. note:: 
    71     Each assmebly in the stack is layer/core/layer, so the spacing of the cores 
    72     is core plus two layers. The 2nd virial coefficient of the cylinder is  
    73     calculated based on the  
    74     *radius* and *length* = *n_stacking* * (*core_thick* + 2 * *layer_thick*) 
     69    Each assmebly in the stack is layer/core/layer, so the spacing of the 
     70    cores is core plus two layers. The 2nd virial coefficient of the cylinder 
     71    is calculated based on the *radius* and *length* 
     72    = *n_stacking* * (*core_thick* + 2 * *layer_thick*) 
    7573    values, and used as the effective radius for $S(Q)$ when $P(Q) * S(Q)$ 
    7674    is applied. 
     
    9492---------- 
    9593 
    96 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, 1955 
     94A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, 
     95John Wiley and Sons, New York, 1955 
    9796 
    9897O Kratky and G Porod, *J. Colloid Science*, 4, (1949) 35 
    9998 
    100 J S Higgins and H C Benoit, *Polymers and Neutron Scattering*, Clarendon, Oxford, 1994 
     99J S Higgins and H C Benoit, *Polymers and Neutron Scattering*, 
     100Clarendon, Oxford, 1994 
    101101 
    102102**Author:** NIST IGOR/DANSE **on:** pre 2010 
  • sasmodels/models/star_polymer.py

    rec45c4f r40a87fa  
    11r""" 
    2 The Benoit model for a simple star polymer, with Gaussian coils arms from  
     2The Benoit model for a simple star polymer, with Gaussian coils arms from 
    33a common point. 
    44 
     
    1010.. math:: 
    1111 
    12     I(q) = \frac{2}{fv^2}\left[ v-1+exp(-v)+\frac{f-1}{2} 
    13            \left[ 1-exp(-v)\right]^2\right] 
     12    I(q) = \frac{2}{fv^2}\left[ v-1+\exp(-v)+\frac{f-1}{2} 
     13           \left[ 1-\exp(-v)\right]^2\right] 
    1414 
    1515where 
    1616 
    17 .. math:: 
    18  
    19     v=\frac{u^2f}{(3f-2)} 
     17.. math:: v=\frac{u^2f}{(3f-2)} 
    2018 
    2119and 
    2220 
    23 .. math:: 
     21.. math:: u = \left\langle R_{g}^2\right\rangle q^2 
    2422 
    25     u = \left\langle R_{g}^2\right\rangle q^2 
    26  
    27 contains the square of the ensemble average radius-of-gyration of an arm.  Note that  
    28 when there is only one arm, $f$ = 1, the Debye Gaussian coil equation is recovered. 
    29 Star polymers in solutions tend to have strong interparticle and osmotic effects, so  
    30 the Benoit equation may not work well. At small q the Guinier term and hence I(q=0) 
    31 is the same as for $f$ arms of radius of gyration $R_g$, as described for the :ref:`mono_gauss_coil <mono-gauss-coil>`. 
    32  
     23contains the square of the ensemble average radius-of-gyration of an arm. 
     24Note that when there is only one arm, $f = 1$, the Debye Gaussian coil 
     25equation is recovered. Star polymers in solutions tend to have strong 
     26interparticle and osmotic effects, so the Benoit equation may not work well. 
     27At small $q$ the Guinier term and hence $I(q=0)$ is the same as for $f$ arms 
     28of radius of gyration $R_g$, as described for the :ref:`mono-gauss-coil` model. 
    3329 
    3430References 
     
    3632 
    3733H Benoit *J. Polymer Science*, 11, 596-599 (1953) 
    38  
    39  
    4034""" 
    4135 
  • sasmodels/models/stickyhardsphere.py

    rd2bb604 r40a87fa  
    178178# 
    179179tests = [ 
    180         [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'perturb' : 0.05, 'stickiness' : 0.2, 'volfraction' : 0.1, 
    181            'radius_effective_pd' : 0}, [0.001, 0.003], [1.09718, 1.087830]] 
    182         ] 
    183  
    184  
     180    [{'scale': 1.0, 'background': 0.0, 'radius_effective': 50.0, 
     181      'perturb': 0.05, 'stickiness': 0.2, 'volfraction': 0.1, 
     182      'radius_effective_pd': 0}, 
     183     [0.001, 0.003], [1.09718, 1.087830]], 
     184    ] 
  • sasmodels/models/teubner_strey.py

    r2c74c11 r40a87fa  
    4747 
    4848import numpy as np 
    49 from numpy import inf, sqrt 
     49from numpy import inf 
    5050 
    5151name = "teubner_strey" 
     
    5858category = "shape-independent" 
    5959 
    60 #             ["name", "units", default, [lower, upper], "type","description"], 
    61 parameters = [["a2", "", 0.1, [0, inf], "", 
    62                "a2"], 
    63               ["c1", "1e-6/Ang^2", -30., [-inf, 0], "", 
    64                "c1"], 
    65               ["c2", "Ang", 5000., [0, inf], "volume", 
    66                "c2"], 
    67              ] 
    68  
     60#   ["name", "units", default, [lower, upper], "type","description"], 
     61parameters = [ 
     62    ["a2", "", 0.1, [0, inf], "", "a2"], 
     63    ["c1", "1e-6/Ang^2", -30., [-inf, 0], "", "c1"], 
     64    ["c2", "Ang", 5000., [0, inf], "volume", "c2"], 
     65    ] 
    6966 
    7067def Iq(q, a2, c1, c2): 
     68    """SAS form""" 
    7169    return 1. / np.polyval([c2, c1, a2], q**2) 
    7270Iq.vectorized = True  # Iq accepts an array of q values 
  • sasmodels/models/two_power_law.py

    r2c74c11 r40a87fa  
    1414where $q_c$ = the location of the crossover from one slope to the other, 
    1515$A$ = the scaling coefficent that sets the overall intensity of the lower Q 
    16 power law region, $m1$ = power law exponent at low Q, and $m2$ = power law  
     16power law region, $m1$ = power law exponent at low Q, and $m2$ = power law 
    1717exponent at high Q.  The scaling of the second power law region (coefficent C) 
    1818is then automatically scaled to match the first by following formula: 
     
    6262category = "shape-independent" 
    6363 
    64 #            ["name", "units", default, [lower, upper], "type", "description"], 
    65 parameters = [["coefficent_1",  "",         1.0, [-inf, inf], "", 
    66                "coefficent A in low Q region"], 
    67               ["crossover",     "1/Ang",    0.04,[0, inf],    "", 
    68                "crossover location"], 
    69               ["power_1",       "",         1.0, [0, inf],    "", 
    70                "power law exponent at low Q"], 
    71               ["power_2",       "",         4.0, [0, inf],    "", 
    72                "power law exponent at high Q"], 
    73              ] 
     64# pylint: disable=bad-whitespace, line-too-long 
     65#   ["name", "units", default, [lower, upper], "type", "description"], 
     66parameters = [ 
     67    ["coefficent_1", "",       1.0, [-inf, inf], "", "coefficent A in low Q region"], 
     68    ["crossover",    "1/Ang",  0.04,[0, inf],    "", "crossover location"], 
     69    ["power_1",      "",       1.0, [0, inf],    "", "power law exponent at low Q"], 
     70    ["power_2",      "",       4.0, [0, inf],    "", "power law exponent at high Q"], 
     71    ] 
     72# pylint: enable=bad-whitespace, line-too-long 
    7473 
    7574 
     
    8988    :return:                    Calculated intensity 
    9089    """ 
    91     iq = empty(q.shape, 'd') 
    92     idx = (q <= crossover) 
     90    result= empty(q.shape, 'd') 
     91    index = (q <= crossover) 
    9392    with errstate(divide='ignore'): 
    9493        coefficent_2 = coefficent_1 * power(crossover, power_2 - power_1) 
    95         iq[idx] = coefficent_1 * power(q[idx], -power_1) 
    96         iq[~idx] = coefficent_2 * power(q[~idx], -power_2) 
    97     return iq 
     94        result[index] = coefficent_1 * power(q[index], -power_1) 
     95        result[~index] = coefficent_2 * power(q[~index], -power_2) 
     96    return result 
    9897 
    9998Iq.vectorized = True  # Iq accepts an array of q values 
  • sasmodels/models/unified_power_Rg.py

    r785cbec r40a87fa  
    3737$q_i^*$ which is ignored here. 
    3838 
    39 For example, to approximate the scattering from random coils (Debye_ equation), 
     39For example, to approximate the scattering from random coils (Debye equation), 
    4040set $R_{gi}$ as the Guinier radius, $P_i = 2$, and $B_i = 2 G_i / R_{gi}$ 
    4141 
     
    6565from scipy.special import erf 
    6666 
     67category = "shape-independent" 
     68 
     69# pylint: disable=bad-whitespace, line-too-long 
    6770parameters = [ 
    6871    ["level",     "",     1,      [0, 6], "", "Level number"], 
     
    7275    ["G[level]",  "1/cm", 400,    [0, inf], "", ""], 
    7376    ] 
    74 category = "shape-independent" 
     77# pylint: enable=bad-whitespace, line-too-long 
    7578 
    7679def Iq(q, level, rg, power, B, G): 
     
    8790            exp_next = exp(-(q*rg[i+1])**2/3.) if i < ilevel-1 else 1. 
    8891            result += G[i]*exp_now + B[i]*exp_next*pow_now 
    89     result[q==0] = np.sum(G[:ilevel]) 
     92    result[q == 0] = np.sum(G[:ilevel]) 
    9093    return result 
    9194 
Note: See TracChangeset for help on using the changeset viewer.