Changes in / [0495db8:0b499f0] in sasmodels


Ignore:
Files:
1 added
26 edited

Legend:

Unmodified
Added
Removed
  • doc/conf.py

    r22975f0 r4a21670c  
    233233 
    234234numfig = True 
    235 #numfig_format = {"figure": "Fig. %s", "table": "Table %s", "code-block": "Program %s"} 
  • example/sesans_parameters_css-hs.py

    r3415f4f r84db7a5  
    2222# Initial parameter values (if other than defaults) 
    2323initial_vals = { 
    24     "sld_core" : 1.0592, 
    25     "sld_solvent" : 2.88, 
     24    "core_sld" : 1.0592, 
     25    "solvent_sld" : 2.88, 
    2626    "radius" : 890, 
    2727    "thickness" : 130 
  • sasmodels/compare.py

    r98d6cfc r72a081d  
    6969    -accuracy=Low accuracy of the resolution calculation Low, Mid, High, Xhigh 
    7070    -edit starts the parameter explorer 
    71     -default/-demo* use demo vs default parameters 
    7271 
    7372Any two calculation engines can be selected for comparison: 
     
    632631    'hist', 'nohist', 
    633632    'edit', 
    634     'demo', 'default', 
    635633    ]) 
    636634VALUE_OPTIONS = [ 
     
    656654 
    657655 
    658 def get_pars(model_info, use_demo=False): 
     656def get_demo_pars(model_info): 
    659657    """ 
    660658    Extract demo parameters from the model definition. 
     
    672670 
    673671    # Plug in values given in demo 
    674     if use_demo: 
    675         pars.update(model_info['demo']) 
     672    pars.update(model_info['demo']) 
    676673    return pars 
    677674 
     
    730727        'rel_err'   : True, 
    731728        'explore'   : False, 
    732         'use_demo'  : True, 
    733729    } 
    734730    engines = [] 
     
    769765        elif arg == '-sasview': engines.append(arg[1:]) 
    770766        elif arg == '-edit':    opts['explore'] = True 
    771         elif arg == '-demo':    opts['use_demo'] = True 
    772         elif arg == '-default':    opts['use_demo'] = False 
    773767    # pylint: enable=bad-whitespace 
    774768 
     
    788782    # Get demo parameters from model definition, or use default parameters 
    789783    # if model does not define demo parameters 
    790     pars = get_pars(model_info, opts['use_demo']) 
    791  
     784    pars = get_demo_pars(model_info) 
    792785 
    793786    # Fill in parameters given on the command line 
  • sasmodels/compare_many.py

    rce346b6 red048b2  
    2222from . import generate 
    2323from .compare import (MODELS, randomize_pars, suppress_pd, make_data, 
    24                       make_engine, get_pars, columnize, 
     24                      make_engine, get_demo_pars, columnize, 
    2525                      constrain_pars, constrain_new_to_old) 
    2626 
     
    102102    is_2d = hasattr(data, 'qx_data') 
    103103    model_info = core.load_model_info(name) 
    104     pars = get_pars(model_info, use_demo=True) 
     104    pars = get_demo_pars(model_info) 
    105105    header = ('\n"Model","%s","Count","%d","Dimension","%s"' 
    106106              % (name, N, "2D" if is_2d else "1D")) 
  • sasmodels/convert.py

    r062db5a rbad8b12  
    154154        elif name == 'fractal': 
    155155            del oldpars['volfraction'] 
    156         elif name == 'vesicle': 
    157             del oldpars['volfraction'] 
    158156 
    159157    return oldpars 
     
    193191        elif name == 'fractal': 
    194192            pars['volfraction'] = 1 
    195         elif name == 'vesicle': 
    196             pars['volfraction'] = 1 
    197193             
  • sasmodels/models/binary_hard_sphere.c

    re481a39 r115d0f0  
    1313    ); 
    1414 
    15 void calculate_psfs(double qval, 
     15int calculate_psfs(double qval, 
    1616    double r2, double nf2, 
    1717    double aa, double phi, 
     
    3434    double phi1,phi2,phr,a3; 
    3535    double v1,v2,n1,n2,qr1,qr2,b1,b2,sc1,sc2; 
     36    int err; 
    3637     
    3738    r2 = lg_radius; 
     
    5152    nf2 = phr*a3/(1.0-phr+phr*a3); 
    5253    // calculate the PSF's here 
    53     calculate_psfs(q,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 
     54    err = calculate_psfs(q,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 
    5455     
    5556    // /* do form factor calculations  */ 
     
    102103} 
    103104 
    104 void calculate_psfs(double qval, 
     105int calculate_psfs(double qval, 
    105106    double r2, double nf2, 
    106107    double aa, double phi, 
     
    111112     
    112113    //   calculate constant terms 
    113     double s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4; 
     114    double s1,s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4; 
    114115    double a1,a2i,a2,b1,b2,b12,gm1,gm12; 
    115     double yy,ay,ay2,ay3,t1,t2,t3,f11,y2,y3,tt1,tt2,tt3; 
     116    double err=0.0,yy,ay,ay2,ay3,t1,t2,t3,f11,y2,y3,tt1,tt2,tt3; 
    116117    double c11,c22,c12,f12,f22,ttt1,ttt2,ttt3,ttt4,yl,y13; 
    117118    double t21,t22,t23,t31,t32,t33,t41,t42,yl3,wma3,y1; 
    118119     
    119120    s2 = 2.0*r2; 
    120 //    s1 = aa*s2;  why is this never used?  check original paper? 
     121    s1 = aa*s2; 
    121122    v = phi; 
    122123    a3 = aa*aa*aa; 
     
    188189    *s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12));    
    189190     
    190     return; 
     191    return(err); 
    191192} 
    192193 
  • sasmodels/models/binary_hard_sphere.py

    rd189429 r115d0f0  
    11r""" 
    22 
    3 Definition 
    4 ---------- 
    53The binary hard sphere model provides the scattering intensity, for binary 
    64mixture of hard spheres including hard sphere interaction between those 
    75particles, using rhw Percus-Yevick closure. The calculation is an exact 
    86multi-component solution that properly accounts for the 3 partial structure 
    9 factors as follows: 
     7factors. 
     8 
     9Definition 
     10---------- 
    1011 
    1112.. math:: 
    1213 
    1314    \begin{eqnarray} 
    14     I(q) = (1-x)f_1^2(q) S_{11}(q) + 2[x(1-x)]^{1/2} f_1(q)f_2(q)S_{12}(q) + 
    15     x\,f_2^2(q)S_{22}(q) 
     15    I(q) = (1-x)f_1^2(q) S_{11}(q) + 2[x(1-x)]^{1/2} f_1(q)f_2(q)S_{12}(q) + \\ 
     16    x\,f_2^2(q)S_{22}(q) \\ 
    1617    \end{eqnarray} 
    1718 
     
    2526 
    2627    \begin{eqnarray} 
    27     x &=& \frac{(\phi_2 / \phi)\alpha^3}{(1-(\phi_2/\phi) + (\phi_2/\phi) 
    28     \alpha^3)} \\ 
    29     \phi &=& \phi_1 + \phi_2 = \text{total volume fraction} \\ 
     28    x &=& \frac{(\phi_2 / \phi)\alpha^3}{(1-(\phi_2/\phi) + (\phi_2/\phi) \\ 
     29    \alpha^3)} \phi &=& \phi_1 + \phi_2 = \text{total volume fraction} \\ 
    3030    \alpha &=& R_1/R_2 = \text{size ratio} 
    3131    \end{eqnarray} 
     
    6767S R Kline, *J Appl. Cryst.*, 39 (2006) 895 
    6868 
    69 **Author:** NIST IGOR/DANSE **on:** pre 2010 
     69**Author:** N/A **on:** 
    7070 
    71 **Last Modified by:** Paul Butler **on:** March 20, 2016 
     71**Modified by:** Paul Butler **on:** March 18, 2016 
    7272 
    73 **Last Reviewed by:** Paul Butler **on:** March 20, 2016 
     73**Reviewed by:** Paul Butler **on:** March 18, 2016 
    7474""" 
    7575 
    76 from numpy import inf 
    77  
    78 category = "shape:sphere" 
    79 single = False  # double precision only! 
     76import numpy as np 
     77from numpy import pi, inf 
    8078 
    8179name = "binary_hard_sphere" 
     
    9290        sld_solvent: solvent scattering length density. 
    9391""" 
     92category = "shape:sphere" 
     93 
    9494#             ["name", "units", default, [lower, upper], "type", "description"], 
    9595parameters = [["radius_lg", "Ang", 100, [0, inf], "", 
     
    112112 
    113113# parameters for demo and documentation 
    114 demo = dict(sld_lg=3.5, sld_sm=0.5, sld_solvent=6.36, 
     114demo = dict(scale=1, background=0, 
     115            sld_lg=3.5, sld_sm=0.5, sld_solvent=6.36, 
    115116            radius_lg=100, radius_sm=20, 
    116117            volfraction_lg=0.1, volfraction_sm=0.2) 
     
    124125 
    125126# NOTE: test results taken from values returned by SasView 3.1.2 
    126 tests = [[{}, 0.001, 25.8927262013]] 
     127tests = [[{'scale':1.0}, 0.001, 25.8927262013]] 
    127128 
  • sasmodels/models/correlation_length.py

    r0cc31e1 raa2edb2  
    1515and therefore the thermodynamics. The two multiplicative factors A and C, the 
    1616incoherent 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. 
     17parameters. The final parameter ξ is a correlation length for the polymer 
     18chains. Note that when m=2 this functional form becomes the familiar Lorentzian 
     19function. 
    2220 
    2321For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
     
    4745              ["lorentz_scale", "", 10.0, [0, inf], "", "Lorentzian Scaling Factor"], 
    4846              ["porod_scale", "", 1e-06, [0, inf], "", "Porod Scaling Factor"], 
    49               ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length, xi, in Lorentzian"], 
    50               ["exponent_p", "", 3.0, [0, inf], "", "Porod Exponent, n, in q^-n"], 
    51               ["exponent_l", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent, m, in 1/( 1 + (q.xi)^m)"], 
     47              ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length"], 
     48              ["exponent_p", "", 3.0, [0, inf], "", "Porod Exponent"], 
     49              ["exponent_l", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent"], 
    5250             ] 
    5351# pylint: enable=bad-continuation, line-too-long 
  • sasmodels/models/cylinder.py

    r6ef4293 r5933c7f  
    3131To provide easy access to the orientation of the cylinder, we define the 
    3232axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 
    33 are defined in :numref:`cylinder-angle-definition`. 
     33are defined in :numref:`figure #<cylinder-angle-definition>`. 
    3434 
    3535.. _cylinder-angle-definition: 
  • sasmodels/models/elliptical_cylinder.py

    r0cc31e1 r74fd96f  
    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_{minor}$ and \nu = $axis\_ratio$ = $r_{major} / r_{minor}$ 
    1515 
    1616The function calculated is 
  • sasmodels/models/fractal.py

    r5e29b9d rdff1088  
    4646J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785 
    4747 
    48 **Author:** NIST IGOR/DANSE **on:** pre 2010 
     48**Author:** N/A **on:** 
    4949 
    5050**Last Modified by:** Paul Butler **on:** March 20, 2016 
  • sasmodels/models/fractal_core_shell.c

    r6794301 r7d4b2ae  
    4747    double qr = q*radius; 
    4848 
    49     double t1 = frac_dim*sas_gamma(frac_1)*sin(frac_1*atan(q*cor_length)); 
     49    double t1 = frac_dim*exp(lanczos_gamma(frac_1))*sin(frac_1*atan(q*cor_length)); 
    5050    double t2 = (1.0 + 1.0/(q*cor_length)/(q*cor_length)); 
    5151    double t3 = pow(qr, frac_dim) * pow(t2, (frac_1/2.0)); 
  • sasmodels/models/fractal_core_shell.py

    r6794301 raa2edb2  
    7373# pylint: enable=bad-whitespace, line-too-long 
    7474 
    75 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/core_shell.c", "fractal_core_shell.c"] 
     75source = ["lib/sph_j1c.c", "lib/lanczos_gamma.c", "lib/core_shell.c", "fractal_core_shell.c"] 
    7676 
    7777demo = dict(scale=0.05, 
  • sasmodels/models/fuzzy_sphere.py

    r0cc31e1 raa2edb2  
    1919 
    2020    A(q) = \frac{3\left[\sin(qR) - qR \cos(qR)\right]}{(qR)^3} 
    21            \exp\left(\frac{-(\sigma_{fuzzy}q)^2}{2}\right) 
     21           \exp\left(\frac{-(o_{fuzzy}q)^2}{2}\right) 
    2222 
    2323Here *|A(q)|*:sup:`2`\  is the form factor, *P(q)*. The scale is equivalent to the 
     
    2626solvent. 
    2727 
    28 Poly-dispersion in radius and in fuzziness is provided for, though the fuzziness 
    29 must be kept much smaller than the sphere radius for meaningful results. 
     28Poly-dispersion in radius and in fuzziness is provided for. 
    3029 
    3130 
     
    6665or just volume fraction for absolute scale data 
    6766radius: radius of the solid sphere 
    68 fuzziness = the standard deviation of the fuzzy interfacial 
     67fuzziness = the STD of the height of fuzzy interfacial 
    6968thickness (ie., so-called interfacial roughness) 
    7069sld: the SLD of the sphere 
     
    7776# pylint: disable=bad-whitespace,line-too-long 
    7877# ["name", "units", default, [lower, upper], "type","description"], 
    79 parameters = [["sld",         "1e-6/Ang^2",  1, [-inf, inf], "",       "Particle scattering length density"], 
    80               ["sld_solvent", "1e-6/Ang^2",  3, [-inf, inf], "",       "Solvent scattering length density"], 
     78parameters = [["sld",         "1e-6/Ang^2",  1, [-inf, inf], "",       "Layer scattering length density"], 
     79              ["solvent_sld", "1e-6/Ang^2",  3, [-inf, inf], "",       "Solvent scattering length density"], 
    8180              ["radius",      "Ang",        60, [0, inf],    "volume", "Sphere radius"], 
    82               ["fuzziness",   "Ang",        10, [0, inf],    "",       "std deviation of Gaussian convolution for interface (must be << radius)"], 
     81              ["fuzziness",   "Ang",        10, [0, inf],    "",       "The STD of the height of fuzzy interfacial"], 
    8382             ] 
    8483# pylint: enable=bad-whitespace,line-too-long 
     
    9695    const double bes = sph_j1c(qr); 
    9796    const double qf = q*fuzziness; 
    98     const double fq = bes * (sld - sld_solvent) * form_volume(radius) * exp(-0.5*qf*qf); 
     97    const double fq = bes * (sld - solvent_sld) * form_volume(radius) * exp(-0.5*qf*qf); 
    9998    return 1.0e-4*fq*fq; 
    10099    """ 
     
    103102    // never called since no orientation or magnetic parameters. 
    104103    //return -1.0; 
    105     return Iq(sqrt(qx*qx + qy*qy), sld, sld_solvent, radius, fuzziness); 
     104    return Iq(sqrt(qx*qx + qy*qy), sld, solvent_sld, radius, fuzziness); 
    106105    """ 
    107106 
     
    115114 
    116115demo = dict(scale=1, background=0.001, 
    117             sld=1, sld_solvent=3, 
     116            sld=1, solvent_sld=3, 
    118117            radius=60, 
    119118            fuzziness=10, 
     
    122121 
    123122oldname = "FuzzySphereModel" 
    124 oldpars = dict(sld='sldSph', sld_solvent='sldSolv', radius='radius', fuzziness='fuzziness') 
     123oldpars = dict(sld='sldSph', solvent_sld='sldSolv', radius='radius', fuzziness='fuzziness') 
    125124 
    126125 
  • sasmodels/models/mass_fractal.c

    r6794301 r61fd21d  
    2828    //calculate S(q) 
    2929    double mmo = mass_dim-1.0; 
    30     double sq = sas_gamma(mmo)*sin((mmo)*atan(q*cutoff_length)); 
     30    double sq = exp(lanczos_gamma(mmo))*sin((mmo)*atan(q*cutoff_length)); 
    3131    sq *= pow(cutoff_length, mmo); 
    3232    sq /= pow((1.0 + (q*cutoff_length)*(q*cutoff_length)),(mmo/2.0)); 
  • sasmodels/models/mass_fractal.py

    r6794301 r684eff9  
    8585# pylint: enable=bad-whitespace, line-too-long 
    8686 
    87 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "mass_fractal.c"] 
     87source = ["lib/sph_j1c.c", "lib/lanczos_gamma.c", "mass_fractal.c"] 
    8888 
    8989demo = dict(scale=1, background=0, 
  • sasmodels/models/parallelepiped.py

    r6ef4293 r5933c7f  
    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 (:numref:`Figure #<parallelepiped-image>`). 
    1010| If you need to apply polydispersity, see also :ref:`rectangular-prism`. 
    1111 
  • sasmodels/models/raspberry.c

    ra2d8a67 rbad8b12  
    2121double Iq(double q, 
    2222          double sld_lg, double sld_sm, double sld_solvent, 
    23           double volfraction_lg, double volfraction_sm, double surface_fraction, 
     23          double volfraction_lg, double volfraction_sm, double surf_fraction, 
    2424          double radius_lg, double radius_sm, double penetration) 
    2525{ 
     
    3737    sldL = sld_lg; 
    3838    vfS = volfraction_sm; 
    39     fSs = surface_fraction; 
    4039    rS = radius_sm; 
     40    aSs = surf_fraction; 
    4141    sldS = sld_sm; 
    4242    deltaS = penetration; 
     
    4848    VL = M_4PI_3*rL*rL*rL; 
    4949    VS = M_4PI_3*rS*rS*rS; 
    50  
    51     //Number of small particles per large particle 
    52     Np = vfS*fSs*VL/vfL/VS; 
    53  
    54     //Total scattering length difference 
     50    Np = aSs*4.0*pow(((rL+deltaS)/rS), 2.0); 
     51    fSs = Np*vfL*VS/vfS/VL; 
     52     
     53    Np2 = aSs*4.0*(rS/(rL+deltaS))*VL/VS;  
     54    fSs2 = Np2*vfL*VS/vfS/VL; 
    5555    slT = delrhoL*VL + Np*delrhoS*VS; 
    5656 
    57     //Form factors for each particle 
    58     psiL = sph_j1c(q*rL); 
    59     psiS = sph_j1c(q*rS); 
    60  
    61     //Cross term between large and small particles 
    62     sfLS = psiL*psiS*sinc(q*(rL+deltaS*rS)); 
    63     //Cross term between small particles at the surface 
    64     sfSS = psiS*psiS*sinc(q*(rL+deltaS*rS))*sinc(q*(rL+deltaS*rS)); 
    65  
    66     //Large sphere form factor term 
    67     f2 = delrhoL*delrhoL*VL*VL*psiL*psiL; 
    68     //Small sphere form factor term 
    69     f2 += Np*delrhoS*delrhoS*VS*VS*psiS*psiS; 
    70     //Small particle - small particle cross term 
    71     f2 += Np*(Np-1)*delrhoS*delrhoS*VS*VS*sfSS; 
    72     //Large-small particle cross term 
    73     f2 += 2*Np*delrhoL*delrhoS*VL*VS*sfLS; 
    74     //Normalise by total scattering length difference 
     57    sfLS = sph_j1c(q*rL)*sph_j1c(q*rS)*sinc(q*(rL+deltaS*rS)); 
     58    sfSS = sph_j1c(q*rS)*sph_j1c(q*rS)*sinc(q*(rL+deltaS*rS))*sinc(q*(rL+deltaS*rS)); 
     59         
     60    f2 = delrhoL*delrhoL*VL*VL*sph_j1c(q*rL)*sph_j1c(q*rL);  
     61    f2 += Np2*delrhoS*delrhoS*VS*VS*sph_j1c(q*rS)*sph_j1c(q*rS);  
     62    f2 += Np2*(Np2-1)*delrhoS*delrhoS*VS*VS*sfSS;  
     63    f2 += 2*Np2*delrhoL*delrhoS*VL*VS*sfLS; 
    7564    if (f2 != 0.0){ 
    7665        f2 = f2/slT/slT; 
    7766        } 
    7867 
    79     //I(q) for large-small composite particles 
    80     f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs*Np*delrhoS*delrhoS*VS); 
    81     //I(q) for free small particles 
    82     f2+= vfS*(1.0-fSs)*delrhoS*delrhoS*VS*psiS*psiS; 
     68    f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs2*Np2*delrhoS*delrhoS*VS); 
     69 
     70    f2+= vfS*(1.0-fSs)*pow(delrhoS, 2)*VS*sph_j1c(q*rS)*sph_j1c(q*rS); 
    8371     
    8472    // normalize to single particle volume and convert to 1/cm 
  • sasmodels/models/raspberry.py

    r5745f0b rbad8b12  
    33---------- 
    44 
    5 The figure below shows a schematic of a large droplet surrounded by several smaller particles 
    6 forming a structure similar to that of Pickering emulsions. 
     5The large and small spheres have their own SLD, as well as the solvent. The 
     6surface coverage term is a fractional coverage (maximum of approximately 0.9 
     7for hexagonally-packed spheres on a surface). Since not all of the small 
     8spheres are necessarily attached to the surface, the excess free (small) 
     9spheres scattering is also included in the calculation. The function calculate 
     10follows equations (8)-(12) of the reference below, and the equations are not 
     11reproduced here. 
     12 
     13No inter-particle scattering is included in this model. 
     14 
    715 
    816.. figure:: img/raspberry_geometry.jpg 
    917 
    1018    Schematic of the raspberry model 
     19     
     20where *Ro* is the radius of the large sphere, *Rp* the radius of the smaller  
     21spheres on the surface and |delta| = the fractional penetration depth. 
    1122 
    12 In order to calculate the form factor of the entire complex, the self-correlation of the large droplet, 
    13 the self-correlation of the particles, the correlation terms between different particles 
    14 and the cross terms between large droplet and small particles all need to be calculated. 
    15  
    16 Consider two infinitely thin shells of radii R2 and R2 separated by distance r. The general 
    17 structure of the equation is then the form factor of the two shells multiplied by the phase 
    18 factor that accounts for the separation of their centers. 
     23For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 
     24where the *q* vector is defined as 
    1925 
    2026.. math:: 
    2127 
    22     S(q) = \frac{sin(qR_1)}{qR_1}\frac{sin(qR_2)}{qR_2}\frac{sin(qr)}{qr} 
    23  
    24 In this case, the large droplet and small particles are solid spheres rather than thin shells. Thus 
    25 the two terms must be integrated over $R_L$ and $R_S$ respectively using the weighting function of 
    26 a sphere. We then obtain the functions for the form of the two spheres: 
    27  
    28 .. math:: 
    29  
    30     \Psi_L = \int_0^{R_L}(4\pi R^2_L)\frac{sin(qR_L)}{qR_L}dR_L = \frac{3[sin(qR_L)-qR_Lcos(qR_L)]}{(qR_L)^2} 
    31  
    32 .. math:: 
    33  
    34     \Psi_S = \int_0^{R_S}(4\pi R^2_S)\frac{sin(qR_S)}{qR_S}dR_S = \frac{3[sin(qR_S)-qR_Lcos(qR_S)]}{(qR_S)^2} 
    35  
    36 The cross term between the large droplet and small particles is given by: 
    37  
    38 .. math:: 
    39     S_{LS} = \Psi_L\Psi_S\frac{sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)} 
    40  
    41 and the self term between small particles is given by: 
    42  
    43 .. math:: 
    44     S_{SS} = \Psi_S^2\bigl[\frac{sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)}\bigr]^2 
    45  
    46 The number of small particles per large droplet, $N_p$, is given by: 
    47  
    48 .. math:: 
    49  
    50     N_p = \frac{\phi_S\phi_{surface}V_L}{\phi_L V_S} 
    51  
    52 where $\phi_S$ is the volume fraction of small particles in the sample, $\phi_{surface}$ is the 
    53 fraction of the small particles that are adsorbed to the large droplets, $\phi_L$ is the volume fraction 
    54 of large droplets in the sample, and $V_S$ and $V_L$ are the volumes of individual small particles and 
    55 large droplets respectively. 
    56  
    57 The form factor of the entire complex can now be calculated including the excess scattering length 
    58 densities of the components $\Delta\rho_L$ and $\Delta\rho_S$, where $\Delta\rho_x = |\rho_x-\rho_{solvent}|$ : 
    59  
    60 .. math:: 
    61  
    62     P_{LS} = \frac{1}{M^2}\bigl[(\Delta\rho_L)^2V_L^2\Psi_L^2+N_p(\Delta\rho_S)^2V_S^2\Psi_S^2 
    63                 + N_p(1-N_p)(\Delta\rho_S)^2V_S^2S_{SS} + 2N_p\Delta\rho_L\Delta\rho_SV_LV_SS_{LS} 
    64  
    65 where M is the total scattering length of the whole complex : 
    66  
    67 .. math:: 
    68     M = \Delta\rho_LV_L + N_p\Delta\rho_SV_S 
    69  
    70 In a real system, there will ususally be an excess of small particles such that some fraction remain unbound. 
    71 Therefore the overall scattering intensity is given by: 
    72  
    73 .. math:: 
    74     I(Q) = I_{LS}(Q) + I_S(Q) = (\phi_L(\Delta\rho_L)^2V_L + \phi_S\phi_{surface}N_p(\Delta\rho_S)^2V_S)P_{LS} 
    75             + \phi_S(1-\phi_{surface})(\Delta\rho_S)^2V_S\Psi_S^2 
    76  
    77 A useful parameter to extract is the fraction of the surface area of the large droplets that is covered by small 
    78 particles. This can be calculated from the model parameters as: 
    79  
    80 .. math:: 
    81     \chi = \frac{4\phi_L\phi_{surface}(R_L+\delta R_S)}{\phi_LR_S} 
     28    q = \sqrt{q_x^2 + q_y^2} 
    8229 
    8330 
     
    8835*particles*, *Journal of Colloid and Interface Science*, 343(1) (2010) 36-41 
    8936 
    90 **Author:** Andrew Jackson **on:** 2008 
     37**Author:** Andrew jackson **on:** 2008 
    9138 
    92 **Modified by:** Andrew Jackson **on:** March 20, 2016 
     39**Modified by:** Paul Butler **on:** March 18, 2016 
    9340 
    94 **Reviewed by:** Andrew Jackson **on:** March 20, 2016 
     41**Reviewed by:** Paul Butler **on:** March 18, 2016 
    9542""" 
    9643 
     
    10350description = """ 
    10451                RaspBerryModel: 
    105                 volfraction_lg = volume fraction large spheres 
    106                 radius_lg = radius large sphere (A) 
    107                 sld_lg = sld large sphere (A-2) 
    108                 volfraction_sm = volume fraction small spheres 
    109                 radius_sm = radius small sphere (A) 
    110                 surface_fraction = fraction of small spheres at surface 
    111                 sld_sm = sld small sphere 
    112                 penetration = small sphere penetration (A) 
    113                 sld_solvent   = sld solvent 
     52                volf_Lsph = volume fraction large spheres 
     53                radius_Lsph = radius large sphere (A) 
     54                sld_Lsph = sld large sphere (A-2) 
     55                volf_Ssph = volume fraction small spheres 
     56                radius_Ssph = radius small sphere (A) 
     57                surfrac_Ssph = fraction of small spheres at surface 
     58                sld_Ssph = sld small sphere 
     59                delta_Ssph = small sphere penetration (A)  
     60                sld_solv   = sld solvent 
    11461                background = background (cm-1) 
    11562            Ref: J. coll. inter. sci. (2010) vol. 343 (1) pp. 36-41.""" 
     
    12774              ["volfraction_sm", "", 0.005, [-inf, inf], "", 
    12875               "volume fraction of small spheres"], 
    129               ["surface_fraction", "", 0.4, [-inf, inf], "", 
     76              ["surf_fraction", "", 0.4, [-inf, inf], "", 
    13077               "fraction of small spheres at surface"], 
    13178              ["radius_lg", "Ang", 5000, [0, inf], "volume", 
     
    13380              ["radius_sm", "Ang", 100, [0, inf], "", 
    13481               "radius of small spheres"], 
    135               ["penetration", "Ang", 0, [-1, 1], "", 
    136                "fractional penetration depth of small spheres into large sphere"], 
     82              ["penetration", "Ang", 0.0, [0, inf], "", 
     83               "penetration depth of small spheres into large sphere"], 
    13784             ] 
    13885 
     
    14289demo = dict(scale=1, background=0.001, 
    14390            sld_lg=-0.4, sld_sm=3.5, sld_solvent=6.36, 
    144             volfraction_lg=0.05, volfraction_sm=0.005, surface_fraction=0.4, 
     91            volfraction_lg=0.05, volfraction_sm=0.005, surf_fraction=0.4, 
    14592            radius_lg=5000, radius_sm=100, penetration=0.0, 
    14693            radius_lg_pd=.2, radius_lg_pd_n=10) 
     
    14895# For testing against the old sasview models, include the converted parameter 
    14996# names and the target sasview model name. 
     97oldname = 'RaspBerryModel' 
     98oldpars = dict(sld_lg='sld_Lsph', sld_sm='sld_Ssph', sld_solvent='sld_solv', 
     99               volfraction_lg='volf_Lsph', volfraction_sm='volf_Ssph', 
     100               surf_fraction='surfrac_Ssph', 
     101               radius_lg='radius_Lsph', radius_sm='radius_Ssph', 
     102               penetration='delta_Ssph') 
     103 
    150104 
    151105# NOTE: test results taken from values returned by SasView 3.1.2, with 
  • sasmodels/models/surface_fractal.c

    r6794301 r9c461c7  
    2626    //calculate S(q) 
    2727    mmo = 5.0 - surface_dim; 
    28     sq  = sas_gamma(mmo)*sin(-(mmo)*atan(q*cutoff_length)); 
     28    sq  = exp(lanczos_gamma(mmo))*sin(-(mmo)*atan(q*cutoff_length)); 
    2929    sq *= pow(cutoff_length, mmo); 
    3030    sq /= pow((1.0 + (q*cutoff_length)*(q*cutoff_length)),(mmo/2.0)); 
  • sasmodels/models/surface_fractal.py

    r6794301 raa2edb2  
    8787# pylint: enable=bad-whitespace, line-too-long 
    8888 
    89 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "surface_fractal.c"] 
     89source = ["lib/sph_j1c.c", "lib/lanczos_gamma.c", "surface_fractal.c"] 
    9090 
    9191demo = dict(scale=1, background=0, 
  • sasmodels/models/triaxial_ellipsoid.py

    r6ef4293 r5933c7f  
    3636we define the axis of the cylinder using the angles $\theta$, $\phi$ 
    3737and $\psi$. These angles are defined on 
    38 :numref:`triaxial-ellipsoid-angles`. 
     38:numref:`figure #<triaxial-ellipsoid-angles>`. 
    3939The angle $\psi$ is the rotational angle around its own $c$ axis 
    4040against the $q$ plane. For example, $\psi = 0$ when the 
  • sasmodels/models/vesicle.c

    r062db5a r321736f  
    22 
    33double Iq(double q,  
    4           double sld, double sld_solvent, double volfraction, 
     4          double sld, double solvent_sld, 
    55          double radius, double thickness); 
    66 
    77double Iqxy(double qx, double qy, 
    8           double sld, double sld_solvent, double volfraction, 
     8          double sld, double solvent_sld, 
    99          double radius, double thickness); 
    1010 
     
    2020double Iq(double q, 
    2121    double sld, 
    22     double sld_solvent, 
    23     double volfraction, 
     22    double solvent_sld, 
    2423    double radius, 
    2524    double thickness) 
     
    3130*/ 
    3231 
     32/* 
     33   note that the sph_j1c we are using has been optimized for precision over 
     34   SasView's original implementation. HOWEVER at q==0 that implementation 
     35   set bes=1.0 rather than 0.0 (correct value) on the grounds I believe that  
     36   bes=0.00 causes Iq to have a divide by 0 error (mostly encountered when 
     37   doing a theory curve in 2D?  We should verify this and if necessary fix 
     38     -PDB Feb 7, 2016  
     39*/ 
    3340{ 
    34     double vol,contrast,f,f2; 
     41    double bes,vol,contrast,f,f2; 
    3542 
    3643    // core first, then add in shell 
    37     contrast = sld_solvent-sld; 
     44    contrast = solvent_sld-sld; 
     45    bes = sph_j1c(q*radius); 
    3846    vol = 4.0*M_PI/3.0*radius*radius*radius; 
    39     f = vol*sph_j1c(q*radius)*contrast; 
     47    f = vol*bes*contrast; 
    4048  
    41     //now the shell. No volume normalization as this is done by the caller 
    42     contrast = sld-sld_solvent; 
     49    //now the shell 
     50    contrast = sld-solvent_sld; 
     51    bes = sph_j1c(q*(radius+thickness)); 
    4352    vol = 4.0*M_PI/3.0*(radius+thickness)*(radius+thickness)*(radius+thickness); 
    44     f += vol*sph_j1c(q*(radius+thickness))*contrast; 
     53    f += vol*bes*contrast; 
    4554 
    46     //rescale to [cm-1].  
    47     f2 = volfraction*f*f*1.0e-4; 
     55    //rescale to [cm-1]. No volume normalization as this is done by the caller 
     56    f2 = f*f*1.0e-4; 
    4857     
    4958    return(f2); 
     
    5261 
    5362double Iqxy(double qx, double qy, 
    54           double sld, double sld_solvent, double volfraction, 
     63          double sld, double solvent_sld, 
    5564          double radius, double thickness) 
    5665           
     
    5867    double q = sqrt(qx*qx + qy*qy); 
    5968    return Iq(q, 
    60         sld, sld_solvent, volfraction, 
     69        sld, solvent_sld, 
    6170        radius,thickness); 
    6271 
  • sasmodels/models/vesicle.py

    r062db5a raa2edb2  
    77.. math:: 
    88 
    9     P(q) = \frac{\phi}{V_\text{shell}} \left[ 
     9    P(q) = \frac{\text{scale}}{V_\text{shell}} \left[ 
    1010           \frac{3V_{\text{core}}({\rho_{\text{solvent}} 
    1111           - \rho_{\text{shell}})j_1(qR_{\text{core}})}}{qR_{\text{core}}} 
     
    1515 
    1616 
    17 where $\phi$ is the volume fraction of shell material, $V_{shell}$ is the volume 
    18 of the shell, $V_{\text{cor}}$ is the volume of the core, $V_{\text{tot}}$ is 
    19 the total volume, $R_{\text{core}}$ is the radius of the core, $R_{\text{tot}}$ 
    20 is the outer radius of the shell, $\rho_{\text{solvent}}$ is the scattering 
    21 length density of the solvent (which is the same as for the core in this case), 
     17where scale is a scale factor equivalent to the volume fraction of shell 
     18material if the data is on an absolute scale, $V_{shell}$ is the volume of the 
     19shell, $V_{\text{cor}}$ is the volume of the core, $V_{\text{tot}}$ is the 
     20total volume, $R_{\text{core}}$ is the radius of the core, $R_{\text{tot}}$ is 
     21the outer radius of the shell, $\rho_{\text{solvent}}$ is the scattering length 
     22density of the solvent (which is the same as for the core in this case), 
    2223$\rho_{\text{scale}}$ is the scattering length density of the shell, background 
    2324is a flat background level (due for example to incoherent scattering in the 
     
    5556A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and 
    5657Sons, New York, (1955) 
    57  
    58 **Author:** NIST IGOR/DANSE **on:** pre 2010 
    59  
    60 **Last Modified by:** Paul Butler **on:** March 20, 2016 
    61  
    62 **Last Reviewed by:** Paul Butler **on:** March 20, 2016 
    6358""" 
    6459 
     
    7570        thickness: the shell thickness 
    7671        sld: the shell SLD 
    77         sld_slovent: the solvent (and core) SLD 
     72        solvent_sld: the solvent (and core) SLD 
    7873        background: incoherent background 
    79         volfraction: shell volume fraction 
    80         scale : scale factor = 1 if on absolute scale""" 
     74        scale : scale factor = shell volume fraction if on absolute scale""" 
    8175category = "shape:sphere" 
    8276 
     
    8478parameters = [["sld", "1e-6/Ang^2", 0.5, [-inf, inf], "", 
    8579               "vesicle shell scattering length density"], 
    86               ["sld_solvent", "1e-6/Ang^2", 6.36, [-inf, inf], "", 
     80              ["solvent_sld", "1e-6/Ang^2", 6.36, [-inf, inf], "", 
    8781               "solvent scattering length density"], 
    88               ["volfraction", "", 0.05, [0, 1.0], "", 
    89                "volume fraction of shell"], 
    9082              ["radius", "Ang", 100, [0, inf], "volume", 
    9183               "vesicle core radius"], 
     
    122114 
    123115# parameters for demo 
    124 demo = dict(sld=0.5, sld_solvent=6.36, 
    125             volfraction=0.05, 
     116demo = dict(scale=1, background=0, 
     117            sld=0.5, solvent_sld=6.36, 
    126118            radius=100, thickness=30, 
    127119            radius_pd=.2, radius_pd_n=10, 
     
    131123# names and the target sasview model name. 
    132124oldname = 'VesicleModel' 
    133 oldpars = dict(sld='shell_sld', sld_solvent='solv_sld') 
     125oldpars = dict(sld='shell_sld', solvent_sld='solv_sld') 
    134126 
    135127 
    136128# NOTE: test results taken from values returned by SasView 3.1.2, with 
    137129# 0.001 added for a non-zero default background. 
    138 tests = [[{}, 0.0005, 859.916526646], 
    139          [{}, 0.100600200401, 1.77063682331], 
    140          [{}, 0.5, 0.00355351388906], 
     130tests = [[{}, 0.0010005303255, 17139.8278799], 
     131         [{}, 0.200027832249, 0.131387268704], 
    141132         [{}, 'ER', 130.], 
    142133         [{}, 'VR', 0.54483386436], 
  • sasmodels/resolution.py

    r8b935d1 r2f63032  
    689689        self.pars = TEST_PARS_PINHOLE_SPHERE 
    690690        from sasmodels import core 
    691         self.model = core.load_model("sphere", dtype='double') 
     691        from sasmodels.models import sphere 
     692        self.model = core.load_model(sphere, dtype='double') 
    692693 
    693694    def _eval_sphere(self, pars, resolution): 
  • sasmodels/sesans.py

    ra154ad16 rd554bd7  
    2626    q_max is determined by the acceptance angle of the SESANS instrument. 
    2727    """ 
    28     from sas.sascalc.data_util.nxsunit import Converter 
    29  
    3028    q_min = dq = 0.1 * 2*pi / Rmax 
    31     return np.arange(q_min, Converter("1/A")(q_max[0], units=q_max[1]), dq) 
     29    return np.arange(q_min, q_max[0], dq) 
    3230     
    3331def make_all_q(data): 
Note: See TracChangeset for help on using the changeset viewer.