Changeset b716cc6 in sasmodels


Ignore:
Timestamp:
Oct 14, 2016 5:20:17 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a48772
Parents:
6831fa0
Message:

surface_fractal: document usable q range; suppress negative values outside that range

Location:
sasmodels/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/surface_fractal.c

    ra807206 rb716cc6  
     1// Don't need invalid test since fractal_dim_surf is not polydisperse 
     2// #define INVALID(v) (v.fractal_dim_surf <= 1.0 || v.fractal_dim_surf >= 3.0) 
     3 
    14double form_volume(double radius); 
    25 
     
    1114    double cutoff_length) 
    1215{ 
    13     double pq, sq, mmo, result; 
     16    // calculate P(q) 
     17    const double pq = square(sph_j1c(q*radius)); 
    1418 
    15     //Replaced the original formula with Taylor expansion near zero. 
    16     //pq = pow((3.0*(sin(q*radius) - q*radius*cos(q*radius))/pow((q*radius),3)),2); 
     19    // calculate S(q) 
     20    // Note: lim q->0 S(q) = -gamma(mmo) cutoff_length^mmo (mmo cutoff_length) 
     21    // however, the surface fractal formula is invalid outside the range 
     22    const double mmo = 5.0 - fractal_dim_surf; 
     23    const double sq = sas_gamma(mmo) * pow(cutoff_length, mmo) 
     24           * pow(1.0 + square(q*cutoff_length), -0.5*mmo) 
     25           * sin(-mmo * atan(q*cutoff_length)) / q; 
    1726 
    18     pq = sph_j1c(q*radius); 
    19     pq = pq*pq; 
     27    // Empirically determined that the results are valid within this range. 
     28    // Above 1/r, the form starts to oscillate;  below 
     29    //const double result = (q > 5./(3-fractal_dim_surf)/cutoff_length) && q < 1./radius 
     30    //                      ? pq * sq : 0.); 
    2031 
    21     //calculate S(q) 
    22     mmo = 5.0 - fractal_dim_surf; 
    23     sq  = sas_gamma(mmo)*sin(-(mmo)*atan(q*cutoff_length)); 
    24     sq *= pow(cutoff_length, mmo); 
    25     sq /= pow((1.0 + (q*cutoff_length)*(q*cutoff_length)),(mmo/2.0)); 
    26     sq /= q; 
     32    double result = pq * sq; 
    2733 
    28     //combine and return 
    29     result = pq * sq; 
    30  
    31     return result; 
     34    // exclude negative results 
     35    return result > 0. ? result : 0.; 
    3236} 
    33 double form_volume(double radius){ 
    34  
    35     return 1.333333333333333*M_PI*radius*radius*radius; 
     37double form_volume(double radius) 
     38{ 
     39    return M_4PI_3*cube(radius); 
    3640} 
    3741 
  • sasmodels/models/surface_fractal.py

    ra807206 rb716cc6  
    1010.. math:: 
    1111 
    12     I(q) = scale \times P(q)S(q) + background 
    13  
    14 .. math:: 
    15  
    16     P(q) = F(qR)^2 
    17  
    18 .. math:: 
    19  
    20     F(x) = \frac{3\left[sin(x)-xcos(x)\right]}{x^3} 
    21  
    22 .. math:: 
    23  
    24     S(q) = \frac{\Gamma(5-D_S)\zeta^{5-D_S}}{\left[1+(q\zeta)^2 
    25     \right]^{(5-D_S)/2}} 
    26     \frac{sin\left[(D_S - 5) tan^{-1}(q\zeta) \right]}{q} 
    27  
    28 .. math:: 
    29  
    30     scale = scale\_factor \times NV^2(\rho_{particle} - \rho_{solvent})^2 
    31  
    32 .. math:: 
    33  
    34     V = \frac{4}{3}\pi R^3 
     12    I(q) &= \text{scale} \times P(q)S(q) + \text{background} \\ 
     13    P(q) &= F(qR)^2 \\ 
     14    F(x) &= \frac{3\left[\sin(x)-x\cos(x)\right]}{x^3} \\ 
     15    S(q) &= \Gamma(5-D_S)\xi^{\,5-D_S}\left[1+(q\xi)^2 \right]^{-(5-D_S)/2} 
     16            \sin\left[-(5-D_S) \tan^{-1}(q\xi) \right] q^{-1} \\ 
     17    \text{scale} &= \phi N V^2(\rho_\text{particle} - \rho_\text{solvent})^2 \\ 
     18    V &= \frac{4}{3}\pi R^3 
    3519 
    3620where $R$ is the radius of the building block, $D_S$ is the **surface** fractal 
    37 dimension,| \zeta\|  is the cut-off length, $\rho_{solvent}$ is the scattering 
    38 length density of the solvent, 
    39 and $\rho_{particle}$ is the scattering length density of particles. 
     21dimension, $\xi$ is the cut-off length, $\rho_\text{solvent}$ is the scattering 
     22length density of the solvent, $\rho_\text{particle}$ is the scattering 
     23length density of particles and $\phi$ is the volume fraction of the particles. 
    4024 
    4125.. note:: 
    42     The surface fractal dimension $D_s$ is only valid if $1<surface\_dim<3$. 
    43     It is also only valid over a limited $q$ range (see the reference for 
    44     details) 
     26 
     27    The surface fractal dimension is only valid if $1<D_S<3$. The result is 
     28    only valid over a limited $q$ range, $\tfrac{5}{3-D_S}\xi^{\,-1} < q < R^{-1}$. 
     29    See the reference for details. 
    4530 
    4631 
     
    8974source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "surface_fractal.c"] 
    9075 
    91 demo = dict(scale=1, background=0, 
     76demo = dict(scale=1, background=1e-5, 
    9277            radius=10, fractal_dim_surf=2.0, cutoff_length=500) 
    9378 
Note: See TracChangeset for help on using the changeset viewer.