Changeset 3f12f59 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 7:06:39 AM (9 years ago)
Author:
butler
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:
ce346b6
Parents:
e481a39 (diff), 98d6cfc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/SasView/sasmodels.git

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • doc/conf.py

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

    r72a081d r98d6cfc  
    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 
    7172 
    7273Any two calculation engines can be selected for comparison: 
     
    631632    'hist', 'nohist', 
    632633    'edit', 
     634    'demo', 'default', 
    633635    ]) 
    634636VALUE_OPTIONS = [ 
     
    654656 
    655657 
    656 def get_demo_pars(model_info): 
     658def get_pars(model_info, use_demo=False): 
    657659    """ 
    658660    Extract demo parameters from the model definition. 
     
    670672 
    671673    # Plug in values given in demo 
    672     pars.update(model_info['demo']) 
     674    if use_demo: 
     675        pars.update(model_info['demo']) 
    673676    return pars 
    674677 
     
    727730        'rel_err'   : True, 
    728731        'explore'   : False, 
     732        'use_demo'  : True, 
    729733    } 
    730734    engines = [] 
     
    765769        elif arg == '-sasview': engines.append(arg[1:]) 
    766770        elif arg == '-edit':    opts['explore'] = True 
     771        elif arg == '-demo':    opts['use_demo'] = True 
     772        elif arg == '-default':    opts['use_demo'] = False 
    767773    # pylint: enable=bad-whitespace 
    768774 
     
    782788    # Get demo parameters from model definition, or use default parameters 
    783789    # if model does not define demo parameters 
    784     pars = get_demo_pars(model_info) 
     790    pars = get_pars(model_info, opts['use_demo']) 
     791 
    785792 
    786793    # Fill in parameters given on the command line 
  • sasmodels/models/core_shell_ellipsoid_xt.py

    r29172aa r3556ad7  
    8989parameters = [ 
    9090    ["equat_core",    "Ang",       20,   [0, inf],    "volume",      "Equatorial radius of core"], 
    91     ["x_core",        "None",       3,   [0, inf],    "volume",      "Polar radius of core"], 
    92     ["t_shell",       "Ang",       30,   [0, inf],    "volume",      "Equatorial radius of shell"], 
    93     ["x_polar_shell", "",           1,   [0, inf],    "volume",      "Polar radius of shell"], 
     91    ["x_core",        "None",       3,   [0, inf],    "volume",      "axial ratio of core, X = r_polar/r_equatorial"], 
     92    ["t_shell",       "Ang",       30,   [0, inf],    "volume",      "thickness of shell at equator"], 
     93    ["x_polar_shell", "",           1,   [0, inf],    "volume",      "ratio of thickness of shell at pole to that at equator"], 
    9494    ["sld_core",      "1e-6/Ang^2", 2,   [-inf, inf], "",            "Core scattering length density"], 
    9595    ["sld_shell",     "1e-6/Ang^2", 1,   [-inf, inf], "",            "Shell scattering length density"], 
  • sasmodels/models/core_shell_sphere.py

    raa2edb2 r3556ad7  
    1919    V_s(\rho_s-\rho_{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right] 
    2020 
    21 where $V_s$ is the volume of the outer shell, $V_c$ is 
    22 the volume of the core, $r_s$ is the radius of the shell, $r_c$ is the radius of the 
     21where $V_s$ is the volume of the whole particle, $V_c$ is 
     22the volume of the core, $r_s$ = $radius$ + $thickness$ is the radius of the particle, $r_c$ is the radius of the 
    2323core, $\rho_c$ is the scattering length density of the core, $\rho_s$ is the scattering length 
    2424density of the shell, $\rho_{solv}$ is the scattering length density of the solvent. 
     
    3030effective radius for $S(Q)$ when $P(Q) \cdot S(Q)$ is applied. 
    3131 
    32 Reference 
    33 --------- 
     32References 
     33---------- 
    3434 
    3535A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, (1955) 
     
    4949title = "Form factor for a monodisperse spherical particle with particle with a core-shell structure." 
    5050description = """ 
    51     F^2(q) = 3/V_s [V_c (core_sld-shell_sld) (sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^3  
    52                    + V_s (shell_sld-solvent_sld) (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3] 
     51    F^2(q) = 3/V_s [V_c (sld_core-sld_shell) (sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^3  
     52                   + V_s (sld_shell-sld_solvent) (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3] 
    5353 
    5454            V_s: Volume of the sphere shell 
     
    6262parameters = [["radius",      "Ang",        60.0, [0, inf],    "volume", "Sphere core radius"], 
    6363              ["thickness",   "Ang",        10.0, [0, inf],    "volume", "Sphere shell thickness"], 
    64               ["core_sld",    "1e-6/Ang^2", 1.0,  [-inf, inf], "",       "Sphere core scattering length density"], 
    65               ["shell_sld",   "1e-6/Ang^2", 2.0,  [-inf, inf], "",       "Sphere shell scattering length density"], 
    66               ["solvent_sld", "1e-6/Ang^2", 3.0,  [-inf, inf],  "",      "Solvent scattering length density"]] 
     64              ["sld_core",    "1e-6/Ang^2", 1.0,  [-inf, inf], "",       "core scattering length density"], 
     65              ["sld_shell",   "1e-6/Ang^2", 2.0,  [-inf, inf], "",       "shell scattering length density"], 
     66              ["sld_solvent", "1e-6/Ang^2", 3.0,  [-inf, inf],  "",      "Solvent scattering length density"]] 
    6767# pylint: enable=bad-whitespace, line-too-long 
    6868 
     
    7070 
    7171demo = dict(scale=1, background=0, radius=60, thickness=10, 
    72             core_sld=1.0, shell_sld=2.0, solvent_sld=0.0) 
     72            sld_core=1.0, sld_shell=2.0, sld_solvent=0.0) 
    7373 
    7474oldname = 'CoreShellModel' 
    75 oldpars = {} 
     75oldpars = dict( sld_core='core_sld', 
     76               sld_shell='shell_sld', 
     77               sld_solvent='solvent_sld') 
    7678 
    7779def ER(radius, thickness): 
     
    99101         [{'radius': 60.0, 
    100102           'thickness': 10.0, 
    101            'core_sld': 1.0, 
    102            'shell_sld':2.0, 
    103            'solvent_sld':3.0, 
     103           'sld_core': 1.0, 
     104           'sld_shell':2.0, 
     105           'sld_solvent':3.0, 
    104106           'background':0.0 
    105107          }, 0.4, 0.000698838]] 
  • sasmodels/models/cylinder.py

    r5933c7f r6ef4293  
    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:`figure #<cylinder-angle-definition>`. 
     33are defined in :numref:`cylinder-angle-definition`. 
    3434 
    3535.. _cylinder-angle-definition: 
  • sasmodels/models/ellipsoid.py

    rcedad32 r3556ad7  
    22# Note: model title and parameter table are inserted automatically 
    33r""" 
    4 The form factor is normalized by the particle volume. 
     4The form factor is normalized by the particle volume  
    55 
    66Definition 
     
    3131 
    3232$\alpha$ is the angle between the axis of the ellipsoid and $\vec q$, 
    33 $V$ is the volume of the ellipsoid, $R_p$ is the polar radius along the 
     33$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the polar radius along the 
    3434rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular 
    3535to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the 
     
    4141:ref:`cylinder orientation figure <cylinder-angle-definition>`. 
    4242For the ellipsoid, $\theta$ is the angle between the rotational axis 
    43 and the $z$-axis. 
     43and the $z$ -axis. 
    4444 
    4545NB: The 2nd virial coefficient of the solid ellipsoid is calculated based 
     
    5454.. figure:: img/ellipsoid_angle_projection.jpg 
    5555 
    56     The angles for oriented ellipsoid. 
     56    The angles for oriented ellipsoid, shown here as oblate, $a$ = $R_p$ and $b$ = $R_e$ 
    5757 
    5858Validation 
     
    7474    calculated from our 2D model and the intensity from the NIST SANS 
    7575    analysis software. The parameters used were: *scale* = 1.0, 
    76     *rpolar* = 20 |Ang|, *requatorial* = 400 |Ang|, 
     76    *r_polar* = 20 |Ang|, *r_equatorial* = 400 |Ang|, 
    7777    *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. 
    7878 
     
    102102description = """\ 
    103103P(q.alpha)= scale*f(q)^2 + background, where f(q)= 3*(sld 
    104         - solvent_sld)*V*[sin(q*r(Rp,Re,alpha)) 
     104        - sld_solvent)*V*[sin(q*r(Rp,Re,alpha)) 
    105105        -q*r*cos(qr(Rp,Re,alpha))] 
    106106        /[qr(Rp,Re,alpha)]^3" 
     
    110110 
    111111        sld: SLD of the ellipsoid 
    112         solvent_sld: SLD of the solvent 
     112        sld_solvent: SLD of the solvent 
    113113        V: volume of the ellipsoid 
    114114        Rp: polar radius of the ellipsoid 
     
    120120parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "", 
    121121               "Ellipsoid scattering length density"], 
    122               ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", 
     122              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "", 
    123123               "Solvent scattering length density"], 
    124               ["rpolar", "Ang", 20, [0, inf], "volume", 
     124              ["r_polar", "Ang", 20, [0, inf], "volume", 
    125125               "Polar radius"], 
    126               ["requatorial", "Ang", 400, [0, inf], "volume", 
     126              ["r_equatorial", "Ang", 400, [0, inf], "volume", 
    127127               "Equatorial radius"], 
    128128              ["theta", "degrees", 60, [-inf, inf], "orientation", 
     
    134134source = ["lib/sph_j1c.c", "lib/gauss76.c", "ellipsoid.c"] 
    135135 
    136 def ER(rpolar, requatorial): 
     136def ER(r_polar, r_equatorial): 
    137137    import numpy as np 
    138138 
    139     ee = np.empty_like(rpolar) 
    140     idx = rpolar > requatorial 
    141     ee[idx] = (rpolar[idx] ** 2 - requatorial[idx] ** 2) / rpolar[idx] ** 2 
    142     idx = rpolar < requatorial 
    143     ee[idx] = (requatorial[idx] ** 2 - rpolar[idx] ** 2) / requatorial[idx] ** 2 
    144     idx = rpolar == requatorial 
    145     ee[idx] = 2 * rpolar[idx] 
    146     valid = (rpolar * requatorial != 0) 
     139    ee = np.empty_like(r_polar) 
     140    idx = r_polar > r_equatorial 
     141    ee[idx] = (r_polar[idx] ** 2 - r_equatorial[idx] ** 2) / r_polar[idx] ** 2 
     142    idx = r_polar < r_equatorial 
     143    ee[idx] = (r_equatorial[idx] ** 2 - r_polar[idx] ** 2) / r_equatorial[idx] ** 2 
     144    idx = r_polar == r_equatorial 
     145    ee[idx] = 2 * r_polar[idx] 
     146    valid = (r_polar * r_equatorial != 0) 
    147147    bd = 1.0 - ee[valid] 
    148148    e1 = np.sqrt(ee[valid]) 
     
    152152    delta = 0.75 * b1 * b2 
    153153 
    154     ddd = np.zeros_like(rpolar) 
    155     ddd[valid] = 2.0 * (delta + 1.0) * rpolar * requatorial ** 2 
     154    ddd = np.zeros_like(r_polar) 
     155    ddd[valid] = 2.0 * (delta + 1.0) * r_polar * r_equatorial ** 2 
    156156    return 0.5 * ddd ** (1.0 / 3.0) 
    157157 
    158158 
    159159demo = dict(scale=1, background=0, 
    160             sld=6, solvent_sld=1, 
    161             rpolar=50, requatorial=30, 
     160            sld=6, sld_solvent=1, 
     161            r_polar=50, r_equatorial=30, 
    162162            theta=30, phi=15, 
    163             rpolar_pd=.2, rpolar_pd_n=15, 
    164             requatorial_pd=.2, requatorial_pd_n=15, 
     163            r_polar_pd=.2, r_polar_pd_n=15, 
     164            r_equatorial_pd=.2, r_equatorial_pd_n=15, 
    165165            theta_pd=15, theta_pd_n=45, 
    166166            phi_pd=15, phi_pd_n=1) 
    167167oldname = 'EllipsoidModel' 
    168168oldpars = dict(theta='axis_theta', phi='axis_phi', 
    169                sld='sldEll', solvent_sld='sldSolv', 
    170                rpolar='radius_a', requatorial='radius_b') 
     169               sld='sldEll', sld_solvent='sldSolv', 
     170               r_polar='radius_a', r_equatorial='radius_b') 
  • sasmodels/models/parallelepiped.py

    r5933c7f r6ef4293  
    77---------- 
    88 
    9 | This model calculates the scattering from a rectangular parallelepiped (:numref:`Figure #<parallelepiped-image>`). 
     9| This model calculates the scattering from a rectangular parallelepiped (:numref:`parallelepiped-image`). 
    1010| If you need to apply polydispersity, see also :ref:`rectangular-prism`. 
    1111 
  • sasmodels/models/triaxial_ellipsoid.py

    r5933c7f r6ef4293  
    3636we define the axis of the cylinder using the angles $\theta$, $\phi$ 
    3737and $\psi$. These angles are defined on 
    38 :numref:`figure #<triaxial-ellipsoid-angles>`. 
     38:numref:`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/binary_hard_sphere.c

    r115d0f0 re481a39  
    1313    ); 
    1414 
    15 int calculate_psfs(double qval, 
     15void 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; 
    3736     
    3837    r2 = lg_radius; 
     
    5251    nf2 = phr*a3/(1.0-phr+phr*a3); 
    5352    // calculate the PSF's here 
    54     err = calculate_psfs(q,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 
     53    calculate_psfs(q,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 
    5554     
    5655    // /* do form factor calculations  */ 
     
    103102} 
    104103 
    105 int calculate_psfs(double qval, 
     104void calculate_psfs(double qval, 
    106105    double r2, double nf2, 
    107106    double aa, double phi, 
     
    112111     
    113112    //   calculate constant terms 
    114     double s1,s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4; 
     113    double s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4; 
    115114    double a1,a2i,a2,b1,b2,b12,gm1,gm12; 
    116     double err=0.0,yy,ay,ay2,ay3,t1,t2,t3,f11,y2,y3,tt1,tt2,tt3; 
     115    double yy,ay,ay2,ay3,t1,t2,t3,f11,y2,y3,tt1,tt2,tt3; 
    117116    double c11,c22,c12,f12,f22,ttt1,ttt2,ttt3,ttt4,yl,y13; 
    118117    double t21,t22,t23,t31,t32,t33,t41,t42,yl3,wma3,y1; 
    119118     
    120119    s2 = 2.0*r2; 
    121     s1 = aa*s2; 
     120//    s1 = aa*s2;  why is this never used?  check original paper? 
    122121    v = phi; 
    123122    a3 = aa*aa*aa; 
     
    189188    *s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12));    
    190189     
    191     return(err); 
     190    return; 
    192191} 
    193192 
  • sasmodels/models/binary_hard_sphere.py

    r115d0f0 re481a39  
    11r""" 
    22 
     3Definition 
     4---------- 
    35The binary hard sphere model provides the scattering intensity, for binary 
    46mixture of hard spheres including hard sphere interaction between those 
    57particles, using rhw Percus-Yevick closure. The calculation is an exact 
    68multi-component solution that properly accounts for the 3 partial structure 
    7 factors. 
    8  
    9 Definition 
    10 ---------- 
     9factors as follows: 
    1110 
    1211.. math:: 
    1312 
    1413    \begin{eqnarray} 
    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) \\ 
     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) 
    1716    \end{eqnarray} 
    1817 
     
    2625 
    2726    \begin{eqnarray} 
    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} \\ 
     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} \\ 
    3030    \alpha &=& R_1/R_2 = \text{size ratio} 
    3131    \end{eqnarray} 
     
    6969**Author:** N/A **on:** 
    7070 
    71 **Modified by:** Paul Butler **on:** March 18, 2016 
     71**Last Modified by:** Paul Butler **on:** March 20, 2016 
    7272 
    73 **Reviewed by:** Paul Butler **on:** March 18, 2016 
     73**Last Reviewed by:** Paul Butler **on:** March 20, 2016 
    7474""" 
    7575 
    76 import numpy as np 
    77 from numpy import pi, inf 
     76from numpy import inf 
     77 
     78category = "shape:sphere" 
     79single = False  # double precision only! 
    7880 
    7981name = "binary_hard_sphere" 
     
    9092        sld_solvent: solvent scattering length density. 
    9193""" 
    92 category = "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(scale=1, background=0, 
    115             sld_lg=3.5, sld_sm=0.5, sld_solvent=6.36, 
     114demo = dict(sld_lg=3.5, sld_sm=0.5, sld_solvent=6.36, 
    116115            radius_lg=100, radius_sm=20, 
    117116            volfraction_lg=0.1, volfraction_sm=0.2) 
     
    125124 
    126125# NOTE: test results taken from values returned by SasView 3.1.2 
    127 tests = [[{'scale':1.0}, 0.001, 25.8927262013]] 
     126tests = [[{}, 0.001, 25.8927262013]] 
    128127 
Note: See TracChangeset for help on using the changeset viewer.