Changes in / [646eeaa:765d025] in sasmodels


Ignore:
Files:
1 deleted
44 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/scripting.rst

    r23df833 rbd7630d  
    188188python kernel.  Once the kernel is in hand, we can then marshal a set of 
    189189parameters into a :class:`sasmodels.details.CallDetails` object and ship it to 
    190 the kernel using the :func:`sansmodels.direct_model.call_kernel` function.  To 
    191 accesses the underlying $<F(q)>$ and $<F^2(q)>$, use 
    192 :func:`sasmodels.direct_model.call_Fq` instead. 
    193  
    194 The following example should 
    195 help, *example/cylinder_eval.py*:: 
    196  
    197     from numpy import logspace, sqrt 
     190the kernel using the :func:`sansmodels.direct_model.call_kernel` function.  An 
     191example should help, *example/cylinder_eval.py*:: 
     192 
     193    from numpy import logspace 
    198194    from matplotlib import pyplot as plt 
    199195    from sasmodels.core import load_model 
    200     from sasmodels.direct_model import call_kernel, call_Fq 
     196    from sasmodels.direct_model import call_kernel 
    201197 
    202198    model = load_model('cylinder') 
    203199    q = logspace(-3, -1, 200) 
    204200    kernel = model.make_kernel([q]) 
    205     pars = {'radius': 200, 'radius_pd': 0.1, 'scale': 2} 
    206     Iq = call_kernel(kernel, pars) 
    207     F, Fsq, Reff, V, Vratio = call_Fq(kernel, pars) 
    208  
    209     plt.loglog(q, Iq, label='2 I(q)') 
    210     plt.loglog(q, F**2/V, label='<F(q)>^2/V') 
    211     plt.loglog(q, Fsq/V, label='<F^2(q)>/V') 
    212     plt.xlabel('q (1/A)') 
    213     plt.ylabel('I(q) (1/cm)') 
    214     plt.title('Cylinder with radius 200.') 
    215     plt.legend() 
     201    Iq = call_kernel(kernel, dict(radius=200.)) 
     202    plt.loglog(q, Iq) 
    216203    plt.show() 
    217204 
    218 .. figure:: direct_call.png 
    219  
    220     Comparison between $I(q)$, $<F(q)>$ and $<F^2(q)>$ for cylinder model. 
    221  
    222 This compares $I(q)$ with $<F(q)>$ and $<F^2(q)>$ for a cylinder 
    223 with *radius=200 +/- 20* and *scale=2*. Note that *call_Fq* does not 
    224 include scale and background, nor does it normalize by the average volume. 
    225 The definition of $F = \rho V \hat F$ scaled by the contrast and 
    226 volume, compared to the canonical cylinder $\hat F$, with $\hat F(0) = 1$. 
    227 Integrating over polydispersity and orientation, the returned values are 
    228 $\sum_{r,w\in N(r_o, r_o/10)} \sum_\theta w F(q,r_o,\theta)\sin\theta$ and 
    229 $\sum_{r,w\in N(r_o, r_o/10)} \sum_\theta w F^2(q,r_o,\theta)\sin\theta$. 
    230  
    231 On windows, this example can be called from the cmd prompt using sasview as 
    232 as the python interpreter:: 
     205On windows, this can be called from the cmd prompt using sasview as:: 
    233206 
    234207    SasViewCom example/cylinder_eval.py 
  • example/cylinder_eval.py

    r23df833 r2e66ef5  
    33""" 
    44 
    5 from numpy import logspace, sqrt 
     5from numpy import logspace 
    66from matplotlib import pyplot as plt 
    77from sasmodels.core import load_model 
    8 from sasmodels.direct_model import call_kernel, call_Fq 
     8from sasmodels.direct_model import call_kernel 
    99 
    1010model = load_model('cylinder') 
    1111q = logspace(-3, -1, 200) 
    1212kernel = model.make_kernel([q]) 
    13 pars = {'radius': 200, 'radius_pd': 0.1, 'scale': 2} 
    14 Iq = call_kernel(kernel, pars) 
    15 F, Fsq, Reff, V, Vratio = call_Fq(kernel, pars) 
    16 plt.loglog(q, Iq, label='2 I(q)') 
    17 plt.loglog(q, F**2/V, label='<F(q)>^2/V') 
    18 plt.loglog(q, Fsq/V, label='<F^2(q)>/V') 
     13Iq = call_kernel(kernel, dict(radius=200.)) 
     14plt.loglog(q, Iq) 
    1915plt.xlabel('q (1/A)') 
    20 plt.ylabel('I(q) (1/cm)') 
     16plt.ylabel('I(q)') 
    2117plt.title('Cylinder with radius 200.') 
    22 plt.legend() 
    2318plt.show() 
  • sasmodels/direct_model.py

    r5024a56 r304c775  
    3232from .details import make_kernel_args, dispersion_mesh 
    3333from .modelinfo import DEFAULT_BACKGROUND 
    34 from .product import RADIUS_MODE_ID 
    3534 
    3635# pylint: disable=unused-import 
     
    6867    # type: (Kernel, ParameterSet, float, bool) -> np.ndarray 
    6968    """ 
    70     Like :func:`call_kernel`, but returning F, F^2, R_eff, V_shell, V_form/V_shell. 
    71  
    72     For solid objects V_shell is equal to V_form and the volume ratio is 1. 
    73  
    74     Use parameter *radius_effective_mode* to select the effective radius 
    75     calculation. 
    76     """ 
    77     R_eff_type = int(pars.pop(RADIUS_MODE_ID, 1.0)) 
     69    Like :func:`call_kernel`, but returning F, F^2, R_eff, V, V_form/V_shell. 
     70    """ 
     71    R_eff_type = int(pars.pop('radius_effective_type', 1.0)) 
    7872    mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 
    7973    #print("pars", list(zip(*mesh))[0]) 
     
    8276    return calculator.Fq(call_details, values, cutoff, is_magnetic, R_eff_type) 
    8377 
    84 def call_profile(model_info, pars=None): 
    85     # type: (ModelInfo, ParameterSet) -> Tuple[np.ndarray, np.ndarray, Tuple[str, str]] 
     78def call_profile(model_info, **pars): 
     79    # type: (ModelInfo, ...) -> Tuple[np.ndarray, np.ndarray, Tuple[str, str]] 
    8680    """ 
    8781    Returns the profile *x, y, (xlabel, ylabel)* representing the model. 
    8882    """ 
    89     if pars is None: 
    90         pars = {} 
    9183    args = {} 
    9284    for p in model_info.parameters.kernel_parameters: 
     
    385377        Generate a plottable profile. 
    386378        """ 
    387         return call_profile(self.model.info, pars) 
     379        return call_profile(self.model.info, **pars) 
    388380 
    389381def main(): 
  • sasmodels/model_test.py

    r5024a56 r81751c2  
    386386    for par in sorted(pars.keys()): 
    387387        # special handling of R_eff mode, which is not a usual parameter 
    388         if par == product.RADIUS_MODE_ID: 
     388        if par == 'radius_effective_type': 
    389389            continue 
    390390        parts = par.split('_pd') 
  • sasmodels/models/barbell.c

    r99658f6 rd42dd4a  
    6363 
    6464static double 
    65 radius_from_excluded_volume(double radius_bell, double radius, double length) 
    66 { 
    67     const double hdist = sqrt(square(radius_bell) - square(radius)); 
    68     const double length_tot = length + 2.0*(hdist+ radius); 
    69     return 0.5*cbrt(0.75*radius_bell*(2.0*radius_bell*length_tot + (radius_bell + length_tot)*(M_PI*radius_bell + length_tot))); 
    70 } 
    71  
    72 static double 
    7365radius_from_volume(double radius_bell, double radius, double length) 
    7466{ 
     
    8981    switch (mode) { 
    9082    default: 
    91     case 1: // equivalent cylinder excluded volume 
    92         return radius_from_excluded_volume(radius_bell, radius , length); 
    93     case 2: // equivalent volume sphere 
     83    case 1: // equivalent sphere 
    9484        return radius_from_volume(radius_bell, radius , length); 
    95     case 3: // radius 
     85    case 2: // radius 
    9686        return radius; 
    97     case 4: // half length 
     87    case 3: // half length 
    9888        return 0.5*length; 
    99     case 5: // half total length 
     89    case 4: // half total length 
    10090        return radius_from_totallength(radius_bell,radius,length); 
    10191    } 
  • sasmodels/models/barbell.py

    r99658f6 ree60aa7  
    7979.. [#] H Kaya and N R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda 
    8080   and errata) 
    81 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    8281 
    8382Authorship and Verification 
     
    117116 
    118117source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] 
    119 have_Fq = True  
     118have_Fq = True 
    120119effective_radius_type = [ 
    121     "equivalent cylinder excluded volume","equivalent volume sphere", "radius", "half length", "half total length", 
     120    "equivalent sphere", "radius", "half length", "half total length", 
    122121    ] 
    123122 
  • sasmodels/models/capped_cylinder.c

    r99658f6 rd42dd4a  
    8585 
    8686static double 
    87 radius_from_excluded_volume(double radius, double radius_cap, double length) 
    88 { 
    89     const double hc = radius_cap - sqrt(radius_cap*radius_cap - radius*radius); 
    90     const double length_tot = length + 2.0*hc; 
    91     return 0.5*cbrt(0.75*radius*(2.0*radius*length_tot + (radius + length_tot)*(M_PI*radius + length_tot))); 
    92 } 
    93  
    94 static double 
    9587radius_from_volume(double radius, double radius_cap, double length) 
    9688{ 
     
    111103    switch (mode) { 
    112104    default: 
    113     case 1: // equivalent cylinder excluded volume 
    114         return radius_from_excluded_volume(radius, radius_cap, length); 
    115     case 2: // equivalent volume sphere 
     105    case 1: // equivalent sphere 
    116106        return radius_from_volume(radius, radius_cap, length); 
    117     case 3: // radius 
     107    case 2: // radius 
    118108        return radius; 
    119     case 4: // half length 
     109    case 3: // half length 
    120110        return 0.5*length; 
    121     case 5: // half total length 
     111    case 4: // half total length 
    122112        return radius_from_totallength(radius, radius_cap,length); 
    123113    } 
  • sasmodels/models/capped_cylinder.py

    r99658f6 ree60aa7  
    8282.. [#] H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda 
    8383   and errata) 
    84 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    8584 
    8685Authorship and Verification 
     
    139138have_Fq = True 
    140139effective_radius_type = [ 
    141     "equivalent cylinder excluded volume", "equivalent volume sphere", "radius", "half length", "half total length", 
     140    "equivalent sphere", "radius", "half length", "half total length", 
    142141    ] 
    143142 
  • sasmodels/models/core_shell_bicelle.c

    r99658f6 rd42dd4a  
    3737 
    3838static double 
    39 radius_from_excluded_volume(double radius, double thick_rim, double thick_face, double length) 
    40 { 
    41     const double radius_tot = radius + thick_rim; 
    42     const double length_tot = length + 2.0*thick_face; 
    43     return 0.5*cbrt(0.75*radius_tot*(2.0*radius_tot*length_tot + (radius_tot + length_tot)*(M_PI*radius_tot + length_tot))); 
    44 } 
    45  
    46 static double 
    4739radius_from_volume(double radius, double thick_rim, double thick_face, double length) 
    4840{ 
     
    6456    switch (mode) { 
    6557    default: 
    66     case 1: // equivalent cylinder excluded volume 
    67         return radius_from_excluded_volume(radius, thick_rim, thick_face, length); 
    68     case 2: // equivalent sphere 
     58    case 1: // equivalent sphere 
    6959        return radius_from_volume(radius, thick_rim, thick_face, length); 
    70     case 3: // outer rim radius 
     60    case 2: // outer rim radius 
    7161        return radius + thick_rim; 
    72     case 4: // half outer thickness 
     62    case 3: // half outer thickness 
    7363        return 0.5*length + thick_face; 
    74     case 5: // half diagonal 
     64    case 4: // half diagonal 
    7565        return radius_from_diagonal(radius,thick_rim,thick_face,length); 
    7666    } 
  • sasmodels/models/core_shell_bicelle.py

    r99658f6 ree60aa7  
    8989   from Proquest <http://search.proquest.com/docview/304915826?accountid 
    9090   =26379>`_ 
    91     
    92    L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    9391 
    9492Authorship and Verification 
     
    158156have_Fq = True 
    159157effective_radius_type = [ 
    160     "excluded volume","equivalent volume sphere", "outer rim radius", 
     158    "equivalent sphere", "outer rim radius", 
    161159    "half outer thickness", "half diagonal", 
    162160    ] 
  • sasmodels/models/core_shell_bicelle_elliptical.c

    r99658f6 rd42dd4a  
    88{ 
    99    return M_PI*(r_minor+thick_rim)*(r_minor*x_core+thick_rim)*(length+2.0*thick_face); 
    10 } 
    11  
    12 static double 
    13 radius_from_excluded_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length) 
    14 { 
    15     const double r_equiv     = sqrt((r_minor + thick_rim)*(r_minor*x_core + thick_rim)); 
    16     const double length_tot  = length + 2.0*thick_face; 
    17     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_tot + (r_equiv + length_tot)*(M_PI*r_equiv + length_tot))); 
    1810} 
    1911 
     
    3931    switch (mode) { 
    4032    default: 
    41     case 1: // equivalent cylinder excluded volume 
    42         return radius_from_excluded_volume(r_minor, x_core, thick_rim, thick_face, length); 
    43     case 2: // equivalent volume sphere 
     33    case 1: // equivalent sphere 
    4434        return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); 
    45     case 3: // outer rim average radius 
     35    case 2: // outer rim average radius 
    4636        return 0.5*r_minor*(1.0 + x_core) + thick_rim; 
    47     case 4: // outer rim min radius 
     37    case 3: // outer rim min radius 
    4838        return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 
    49     case 5: // outer max radius 
     39    case 4: // outer max radius 
    5040        return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 
    51     case 6: // half outer thickness 
     41    case 5: // half outer thickness 
    5242        return 0.5*length + thick_face; 
    53     case 7: // half diagonal 
     43    case 6: // half diagonal 
    5444        return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); 
    5545    } 
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r99658f6 r304c775  
    100100 
    101101.. [#] 
    102 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    103102 
    104103Authorship and Verification 
     
    149148have_Fq = True 
    150149effective_radius_type = [ 
    151     "equivalent cylinder excluded volume", "equivalent volume sphere", "outer rim average radius", "outer rim min radius", 
     150    "equivalent sphere", "outer rim average radius", "outer rim min radius", 
    152151    "outer max radius", "half outer thickness", "half diagonal", 
    153152    ] 
  • sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c

    r99658f6 rd42dd4a  
    99    return M_PI*(  (r_minor + thick_rim)*(r_minor*x_core + thick_rim)* length + 
    1010                 square(r_minor)*x_core*2.0*thick_face  ); 
    11 } 
    12  
    13 static double 
    14 radius_from_excluded_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length) 
    15 { 
    16     const double r_equiv     = sqrt((r_minor + thick_rim)*(r_minor*x_core + thick_rim)); 
    17     const double length_tot  = length + 2.0*thick_face; 
    18     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_tot + (r_equiv + length_tot)*(M_PI*r_equiv + length_tot))); 
    1911} 
    2012 
     
    4032    switch (mode) { 
    4133    default: 
    42     case 1: // equivalent cylinder excluded volume 
    43         return radius_from_excluded_volume(r_minor, x_core, thick_rim, thick_face, length); 
    44     case 2: // equivalent sphere 
     34    case 1: // equivalent sphere 
    4535        return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); 
    46     case 3: // outer rim average radius 
     36    case 2: // outer rim average radius 
    4737        return 0.5*r_minor*(1.0 + x_core) + thick_rim; 
    48     case 4: // outer rim min radius 
     38    case 3: // outer rim min radius 
    4939        return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 
    50     case 5: // outer max radius 
     40    case 4: // outer max radius 
    5141        return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 
    52     case 6: // half outer thickness 
     42    case 5: // half outer thickness 
    5343        return 0.5*length + thick_face; 
    54     case 7: // half diagonal (this ignores the missing "corners", so may give unexpected answer if thick_face 
     44    case 6: // half diagonal (this ignores the missing "corners", so may give unexpected answer if thick_face 
    5545            //  or thick_rim is extremely large) 
    5646        return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); 
  • sasmodels/models/core_shell_bicelle_elliptical_belt_rough.py

    r99658f6 r304c775  
    112112 
    113113.. [#] 
    114 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    115114 
    116115Authorship and Verification 
     
    162161have_Fq = True 
    163162effective_radius_type = [ 
    164     "equivalent cylinder excluded volume", "equivalent volume sphere", "outer rim average radius", "outer rim min radius", 
     163    "equivalent sphere", "outer rim average radius", "outer rim min radius", 
    165164    "outer max radius", "half outer thickness", "half diagonal", 
    166165    ] 
  • sasmodels/models/core_shell_cylinder.c

    r99658f6 rd42dd4a  
    1111{ 
    1212    return M_PI*square(radius+thickness)*(length+2.0*thickness); 
    13 } 
    14  
    15 static double 
    16 radius_from_excluded_volume(double radius, double thickness, double length) 
    17 { 
    18     const double radius_tot = radius + thickness; 
    19     const double length_tot = length + 2.0*thickness; 
    20     return 0.5*cbrt(0.75*radius_tot*(2.0*radius_tot*length_tot + (radius_tot + length_tot)*(M_PI*radius_tot + length_tot))); 
    2113} 
    2214 
     
    4133    switch (mode) { 
    4234    default: 
    43     case 1: //cylinder excluded volume 
    44         return radius_from_excluded_volume(radius, thickness, length); 
    45     case 2: // equivalent volume sphere 
     35    case 1: // equivalent sphere 
    4636        return radius_from_volume(radius, thickness, length); 
    47     case 3: // outer radius 
     37    case 2: // outer radius 
    4838        return radius + thickness; 
    49     case 4: // half outer length 
     39    case 3: // half outer length 
    5040        return 0.5*length + thickness; 
    51     case 5: // half min outer length 
     41    case 4: // half min outer length 
    5242        return (radius < 0.5*length ? radius + thickness : 0.5*length + thickness); 
    53     case 6: // half max outer length 
     43    case 5: // half max outer length 
    5444        return (radius > 0.5*length ? radius + thickness : 0.5*length + thickness); 
    55     case 7: // half outer diagonal 
     45    case 6: // half outer diagonal 
    5646        return radius_from_diagonal(radius,thickness,length); 
    5747    } 
  • sasmodels/models/core_shell_cylinder.py

    r99658f6 ree60aa7  
    7070   1445-1452 
    7171.. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 
    72 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    7372 
    7473Authorship and Verification 
     
    134133have_Fq = True 
    135134effective_radius_type = [ 
    136     "excluded volume", "equivalent volume sphere", "outer radius", "half outer length", 
    137     "half min outer dimension", "half max outer dimension", "half outer diagonal", 
     135    "equivalent sphere", "outer radius", "half outer length", 
     136    "half min outer dimension", "half max outer dimension", 
     137    "half outer diagonal", 
    138138    ] 
    139139 
  • sasmodels/models/core_shell_ellipsoid.c

    r99658f6 rd42dd4a  
    7575    switch (mode) { 
    7676    default: 
    77     case 1: // average outer curvature 
     77    case 1: // equivalent sphere 
     78        return radius_from_volume(radius_equat_core, x_core, thick_shell, x_polar_shell); 
     79    case 2: // average outer curvature 
    7880        return radius_from_curvature(radius_equat_core, x_core, thick_shell, x_polar_shell); 
    79     case 2: // equivalent volume sphere 
    80         return radius_from_volume(radius_equat_core, x_core, thick_shell, x_polar_shell); 
    8181    case 3: // min outer radius 
    8282        return (radius_polar_tot < radius_equat_tot ? radius_polar_tot : radius_equat_tot); 
  • sasmodels/models/core_shell_ellipsoid.py

    r99658f6 ree60aa7  
    147147have_Fq = True 
    148148effective_radius_type = [ 
    149     "average outer curvature", "equivalent volume sphere",      
     149    "equivalent sphere", "average outer curvature", 
    150150    "min outer radius", "max outer radius", 
    151151    ] 
  • sasmodels/models/core_shell_parallelepiped.c

    r99658f6 rd42dd4a  
    2828 
    2929static double 
    30 radius_from_excluded_volume(double length_a, double length_b, double length_c, 
    31                    double thick_rim_a, double thick_rim_b, double thick_rim_c) 
    32 { 
    33     double r_equiv, length; 
    34     double lengths[3] = {length_a+thick_rim_a, length_b+thick_rim_b, length_c+thick_rim_c}; 
    35     double lengthmax = fmax(lengths[0],fmax(lengths[1],lengths[2])); 
    36     double length_1 = lengthmax; 
    37     double length_2 = lengthmax; 
    38     double length_3 = lengthmax; 
    39  
    40     for(int ilen=0; ilen<3; ilen++) { 
    41         if (lengths[ilen] < length_1) { 
    42             length_2 = length_1; 
    43             length_1 = lengths[ilen]; 
    44             } else { 
    45                 if (lengths[ilen] < length_2) { 
    46                         length_2 = lengths[ilen]; 
    47                 } 
    48             } 
    49     } 
    50     if(length_2-length_1 > length_3-length_2) { 
    51         r_equiv = sqrt(length_2*length_3/M_PI); 
    52         length  = length_1; 
    53     } else  { 
    54         r_equiv = sqrt(length_1*length_2/M_PI); 
    55         length  = length_3; 
    56     } 
    57  
    58     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length + (r_equiv + length)*(M_PI*r_equiv + length))); 
    59 } 
    60  
    61 static double 
    6230radius_from_volume(double length_a, double length_b, double length_c, 
    6331                   double thick_rim_a, double thick_rim_b, double thick_rim_c) 
     
    8048    switch (mode) { 
    8149    default: 
    82     case 1: // equivalent cylinder excluded volume 
    83         return radius_from_excluded_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 
    84     case 2: // equivalent volume sphere 
     50    case 1: // equivalent sphere 
    8551        return radius_from_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 
    86     case 3: // half outer length a 
     52    case 2: // half outer length a 
    8753        return 0.5 * length_a + thick_rim_a; 
    88     case 4: // half outer length b 
     54    case 3: // half outer length b 
    8955        return 0.5 * length_b + thick_rim_b; 
    90     case 5: // half outer length c 
     56    case 4: // half outer length c 
    9157        return 0.5 * length_c + thick_rim_c; 
    92     case 6: // equivalent circular cross-section 
     58    case 5: // equivalent circular cross-section 
    9359        return radius_from_crosssection(length_a, length_b, thick_rim_a, thick_rim_b); 
    94     case 7: // half outer ab diagonal 
     60    case 6: // half outer ab diagonal 
    9561        return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b)); 
    96     case 8: // half outer diagonal 
     62    case 7: // half outer diagonal 
    9763        return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b) + square(length_c+ 2.0*thick_rim_c)); 
    9864    } 
  • sasmodels/models/core_shell_parallelepiped.py

    r99658f6 ree60aa7  
    173173   from Proquest <http://search.proquest.com/docview/304915826?accountid 
    174174   =26379>`_ 
    175 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    176175 
    177176Authorship and Verification 
     
    229228have_Fq = True 
    230229effective_radius_type = [ 
    231     "equivalent cylinder excluded volume",  
    232     "equivalent volume sphere", 
     230    "equivalent sphere", 
    233231    "half outer length_a", "half outer length_b", "half outer length_c", 
    234232    "equivalent circular cross-section", 
  • sasmodels/models/cylinder.c

    r99658f6 rd42dd4a  
    1111{ 
    1212    return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length); 
    13 } 
    14  
    15 static double 
    16 radius_from_excluded_volume(double radius, double length) 
    17 { 
    18     return 0.5*cbrt(0.75*radius*(2.0*radius*length + (radius + length)*(M_PI*radius + length))); 
    1913} 
    2014 
     
    3731    default: 
    3832    case 1: 
    39         return radius_from_excluded_volume(radius, length); 
     33        return radius_from_volume(radius, length); 
    4034    case 2: 
    41         return radius_from_volume(radius, length); 
     35        return radius; 
    4236    case 3: 
    43         return radius; 
     37        return 0.5*length; 
    4438    case 4: 
    45         return 0.5*length; 
     39        return (radius < 0.5*length ? radius : 0.5*length); 
    4640    case 5: 
    47         return (radius < 0.5*length ? radius : 0.5*length); 
     41        return (radius > 0.5*length ? radius : 0.5*length); 
    4842    case 6: 
    49         return (radius > 0.5*length ? radius : 0.5*length); 
    50     case 7: 
    5143        return radius_from_diagonal(radius,length); 
    5244    } 
  • sasmodels/models/cylinder.py

    r99658f6 r304c775  
    9898J. S. Pedersen, Adv. Colloid Interface Sci. 70, 171-210 (1997). 
    9999G. Fournet, Bull. Soc. Fr. Mineral. Cristallogr. 74, 39-113 (1951). 
    100 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    101100""" 
    102101 
     
    141140have_Fq = True 
    142141effective_radius_type = [ 
    143     "excluded volume", "equivalent volume sphere", "radius", 
     142    "equivalent sphere", "radius", 
    144143    "half length", "half min dimension", "half max dimension", "half diagonal", 
    145144    ] 
     
    186185radius, length = parameters[2][2], parameters[3][2] 
    187186tests.extend([ 
    188     ({'radius_effective_mode': 0}, 0.1, None, None, 0., pi*radius**2*length, 1.0),    
    189     ({'radius_effective_mode': 1}, 0.1, None, None, 0.5*(0.75*radius*(2.0*radius*length + (radius + length)*(pi*radius + length)))**(1./3.), None, None),     
    190     ({'radius_effective_mode': 2}, 0.1, None, None, (0.75*radius**2*length)**(1./3.), None, None), 
    191     ({'radius_effective_mode': 3}, 0.1, None, None, radius, None, None), 
    192     ({'radius_effective_mode': 4}, 0.1, None, None, length/2., None, None), 
    193     ({'radius_effective_mode': 5}, 0.1, None, None, min(radius, length/2.), None, None), 
    194     ({'radius_effective_mode': 6}, 0.1, None, None, max(radius, length/2.), None, None), 
    195     ({'radius_effective_mode': 7}, 0.1, None, None, np.sqrt(4*radius**2 + length**2)/2., None, None), 
     187    ({'radius_effective_type': 0}, 0.1, None, None, 0., pi*radius**2*length, 1.0), 
     188    ({'radius_effective_type': 1}, 0.1, None, None, (0.75*radius**2*length)**(1./3.), None, None), 
     189    ({'radius_effective_type': 2}, 0.1, None, None, radius, None, None), 
     190    ({'radius_effective_type': 3}, 0.1, None, None, length/2., None, None), 
     191    ({'radius_effective_type': 4}, 0.1, None, None, min(radius, length/2.), None, None), 
     192    ({'radius_effective_type': 5}, 0.1, None, None, max(radius, length/2.), None, None), 
     193    ({'radius_effective_type': 6}, 0.1, None, None, np.sqrt(4*radius**2 + length**2)/2., None, None), 
    196194]) 
    197195del radius, length 
  • sasmodels/models/ellipsoid.c

    r99658f6 rd42dd4a  
    3636    switch (mode) { 
    3737    default: 
    38     case 1: // average curvature 
     38    case 1: // equivalent sphere 
     39        return radius_from_volume(radius_polar, radius_equatorial); 
     40    case 2: // average curvature 
    3941        return radius_from_curvature(radius_polar, radius_equatorial); 
    40     case 2: // equivalent volume sphere 
    41         return radius_from_volume(radius_polar, radius_equatorial); 
    4242    case 3: // min radius 
    4343        return (radius_polar < radius_equatorial ? radius_polar : radius_equatorial); 
  • sasmodels/models/ellipsoid.py

    r99658f6 ree60aa7  
    170170have_Fq = True 
    171171effective_radius_type = [ 
    172     "average curvature", "equivalent volume sphere", "min radius", "max radius", 
     172    "equivalent sphere", "average curvature", "min radius", "max radius", 
    173173    ] 
    174174 
  • sasmodels/models/elliptical_cylinder.c

    r99658f6 rd42dd4a  
    33{ 
    44    return M_PI * radius_minor * radius_minor * r_ratio * length; 
    5 } 
    6  
    7 static double 
    8 radius_from_excluded_volume(double radius_minor, double r_ratio, double length) 
    9 { 
    10     const double r_equiv = sqrt(radius_minor*radius_minor*r_ratio); 
    11     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length + (r_equiv + length)*(M_PI*r_equiv + length))); 
    125} 
    136 
     
    4538    switch (mode) { 
    4639    default: 
    47     case 1: // equivalent cylinder excluded volume 
    48         return radius_from_excluded_volume(radius_minor, r_ratio, length); 
    49     case 2: // equivalent volume sphere 
     40    case 1: // equivalent sphere 
    5041        return radius_from_volume(radius_minor, r_ratio, length); 
    51     case 3: // average radius 
     42    case 2: // average radius 
    5243        return 0.5*radius_minor*(1.0 + r_ratio); 
    53     case 4: // min radius 
     44    case 3: // min radius 
    5445        return (r_ratio > 1.0 ? radius_minor : r_ratio*radius_minor); 
    55     case 5: // max radius 
     46    case 4: // max radius 
    5647        return (r_ratio < 1.0 ? radius_minor : r_ratio*radius_minor); 
    57     case 6: // equivalent circular cross-section 
     48    case 5: // equivalent circular cross-section 
    5849        return sqrt(radius_minor*radius_minor*r_ratio); 
    59     case 7: // half length 
     50    case 6: // half length 
    6051        return 0.5*length; 
    61     case 8: // half min dimension 
     52    case 7: // half min dimension 
    6253        return radius_from_min_dimension(radius_minor,r_ratio,0.5*length); 
    63     case 9: // half max dimension 
     54    case 8: // half max dimension 
    6455        return radius_from_max_dimension(radius_minor,r_ratio,0.5*length); 
    65     case 10: // half diagonal 
     56    case 9: // half diagonal 
    6657        return radius_from_diagonal(radius_minor,r_ratio,length); 
    6758    } 
  • sasmodels/models/elliptical_cylinder.py

    r99658f6 ree60aa7  
    8888L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
    8989Neutron Scattering*, Plenum, New York, (1987) [see table 3.4] 
    90 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    9190 
    9291Authorship and Verification 
     
    125124have_Fq = True 
    126125effective_radius_type = [ 
    127     "equivalent cylinder excluded volume", "equivalent volume sphere", "average radius", "min radius", "max radius", 
     126    "equivalent sphere", "average radius", "min radius", "max radius", 
    128127    "equivalent circular cross-section", 
    129128    "half length", "half min dimension", "half max dimension", "half diagonal", 
  • sasmodels/models/hollow_cylinder.c

    r99658f6 rd42dd4a  
    1111{ 
    1212    return M_PI*length*square(radius+thickness); 
    13 } 
    14  
    15 static double 
    16 radius_from_excluded_volume(double radius, double thickness, double length) 
    17 { 
    18     const double radius_tot = radius + thickness; 
    19     return 0.5*cbrt(0.75*radius_tot*(2.0*radius_tot*length + (radius_tot + length)*(M_PI*radius_tot + length))); 
    2013} 
    2114 
     
    3831    switch (mode) { 
    3932    default: 
    40     case 1: // excluded volume 
    41         return radius_from_excluded_volume(radius, thickness, length); 
    42     case 2: // equivalent volume sphere 
     33    case 1: // equivalent sphere 
    4334        return radius_from_volume(radius, thickness, length); 
    44     case 3: // outer radius 
     35    case 2: // outer radius 
    4536        return radius + thickness; 
    46     case 4: // half length 
     37    case 3: // half length 
    4738        return 0.5*length; 
    48     case 5: // half outer min dimension 
     39    case 4: // half outer min dimension 
    4940        return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length); 
    50     case 6: // half outer max dimension 
     41    case 5: // half outer max dimension 
    5142        return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length); 
    52     case 7: // half outer diagonal 
     43    case 6: // half outer diagonal 
    5344        return radius_from_diagonal(radius,thickness,length); 
    5445    } 
  • sasmodels/models/hollow_cylinder.py

    r99658f6 r304c775  
    6060.. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
    6161   Neutron Scattering*, Plenum Press, New York, (1987) 
    62 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    6362 
    6463Authorship and Verification 
     
    103102have_Fq = True 
    104103effective_radius_type = [ 
    105     "excluded volume", "equivalent outer volume sphere", "outer radius", "half length", 
     104    "equivalent sphere", "outer radius", "half length", 
    106105    "half outer min dimension", "half outer max dimension", 
    107106    "half outer diagonal", 
     
    141140    [{}, 0.00005, 1764.926], 
    142141    [{}, 0.1, None, None, 
    143      0.5*(0.75*(radius+thickness)*(2.0*(radius+thickness)*length + ((radius+thickness) + length)*(pi*(radius+thickness) + length)))**(1./3.),  # R_eff from excluded volume 
     142     (3./4*(radius+thickness)**2*length)**(1./3),  # R_eff from volume 
    144143     pi*((radius+thickness)**2-radius**2)*length,  # shell volume 
    145144     (radius+thickness)**2/((radius+thickness)**2 - radius**2), # form:shell ratio 
  • sasmodels/models/hollow_rectangular_prism.c

    r99658f6 rd42dd4a  
    2222 
    2323static double 
    24 radius_from_excluded_volume(double length_a, double b2a_ratio, double c2a_ratio) 
    25 { 
    26     const double r_equiv = sqrt(length_a*length_a*b2a_ratio/M_PI); 
    27     const double length_c = length_a*c2a_ratio; 
    28     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_c + (r_equiv + length_c)*(M_PI*r_equiv + length_c))); 
    29 } 
    30  
    31 static double 
    3224effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio, double thickness) 
    3325// NOTE length_a is external dimension! 
     
    3527    switch (mode) { 
    3628    default: 
    37     case 1: // equivalent cylinder excluded volume 
    38         return radius_from_excluded_volume(length_a, b2a_ratio, c2a_ratio); 
    39     case 2: // equivalent outer volume sphere 
     29    case 1: // equivalent sphere 
    4030        return cbrt(cube(length_a)*b2a_ratio*c2a_ratio/M_4PI_3); 
    41     case 3: // half length_a 
     31    case 2: // half length_a 
    4232        return 0.5 * length_a; 
    43     case 4: // half length_b 
     33    case 3: // half length_b 
    4434        return 0.5 * length_a*b2a_ratio; 
    45     case 5: // half length_c 
     35    case 4: // half length_c 
    4636        return 0.5 * length_a*c2a_ratio; 
    47     case 6: // equivalent outer circular cross-section 
     37    case 5: // equivalent outer circular cross-section 
    4838        return length_a*sqrt(b2a_ratio/M_PI); 
    49     case 7: // half ab diagonal 
     39    case 6: // half ab diagonal 
    5040        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 
    51     case 8: // half diagonal 
     41    case 7: // half diagonal 
    5242        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 
    5343    } 
  • sasmodels/models/hollow_rectangular_prism.py

    r99658f6 ree60aa7  
    9898 
    9999.. [#Nayuk2012] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    100 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    101100 
    102101 
     
    151150have_Fq = True 
    152151effective_radius_type = [ 
    153     "equivalent cylinder excluded volume", "equivalent outer volume sphere",  
    154     "half length_a", "half length_b", "half length_c", 
     152    "equivalent sphere", "half length_a", "half length_b", "half length_c", 
    155153    "equivalent outer circular cross-section", 
    156154    "half ab diagonal", "half diagonal", 
  • sasmodels/models/hollow_rectangular_prism_thin_walls.c

    r99658f6 rd42dd4a  
    1818 
    1919static double 
    20 radius_from_excluded_volume(double length_a, double b2a_ratio, double c2a_ratio) 
    21 { 
    22     const double r_equiv = sqrt(length_a*length_a*b2a_ratio/M_PI); 
    23     const double length_c = length_a*c2a_ratio; 
    24     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_c + (r_equiv + length_c)*(M_PI*r_equiv + length_c))); 
    25 } 
    26  
    27 static double 
    2820effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
    2921{ 
    3022    switch (mode) { 
    3123    default: 
    32     case 1: // equivalent cylinder excluded volume 
    33         return radius_from_excluded_volume(length_a, b2a_ratio, c2a_ratio); 
    34     case 2: // equivalent outer volume sphere 
     24    case 1: // equivalent sphere 
    3525        return cbrt(cube(length_a)*b2a_ratio*c2a_ratio/M_4PI_3); 
    36     case 3: // half length_a 
     26    case 2: // half length_a 
    3727        return 0.5 * length_a; 
    38     case 4: // half length_b 
     28    case 3: // half length_b 
    3929        return 0.5 * length_a*b2a_ratio; 
    40     case 5: // half length_c 
     30    case 4: // half length_c 
    4131        return 0.5 * length_a*c2a_ratio; 
    42     case 6: // equivalent outer circular cross-section 
     32    case 5: // equivalent outer circular cross-section 
    4333        return length_a*sqrt(b2a_ratio/M_PI); 
    44     case 7: // half ab diagonal 
     34    case 6: // half ab diagonal 
    4535        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 
    46     case 8: // half diagonal 
     36    case 7: // half diagonal 
    4737        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 
    4838    } 
  • sasmodels/models/hollow_rectangular_prism_thin_walls.py

    r99658f6 ree60aa7  
    7272 
    7373.. [#Nayuk2012] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    74 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    7574 
    7675 
     
    111110have_Fq = True 
    112111effective_radius_type = [ 
    113     "equivalent cylinder excluded volume", "equivalent outer volume sphere",  
    114     "half length_a", "half length_b", "half length_c", 
     112    "equivalent sphere", "half length_a", "half length_b", "half length_c", 
    115113    "equivalent outer circular cross-section", 
    116114    "half ab diagonal", "half diagonal", 
  • sasmodels/models/parallelepiped.c

    r99658f6 rd42dd4a  
    66 
    77static double 
    8 radius_from_excluded_volume(double length_a, double length_b, double length_c) 
    9 { 
    10     double r_equiv, length; 
    11     double lengths[3] = {length_a, length_b, length_c}; 
    12     double lengthmax = fmax(lengths[0],fmax(lengths[1],lengths[2])); 
    13     double length_1 = lengthmax; 
    14     double length_2 = lengthmax; 
    15     double length_3 = lengthmax; 
    16  
    17     for(int ilen=0; ilen<3; ilen++) { 
    18         if (lengths[ilen] < length_1) { 
    19             length_2 = length_1; 
    20             length_1 = lengths[ilen]; 
    21             } else { 
    22                 if (lengths[ilen] < length_2) { 
    23                         length_2 = lengths[ilen]; 
    24                 } 
    25             } 
    26     } 
    27     if(length_2-length_1 > length_3-length_2) { 
    28         r_equiv = sqrt(length_2*length_3/M_PI); 
    29         length  = length_1; 
    30     } else  { 
    31         r_equiv = sqrt(length_1*length_2/M_PI); 
    32         length  = length_3; 
    33     } 
    34  
    35     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length + (r_equiv + length)*(M_PI*r_equiv + length))); 
    36 } 
    37  
    38 static double 
    398effective_radius(int mode, double length_a, double length_b, double length_c) 
    409{ 
    4110    switch (mode) { 
    4211    default: 
    43     case 1: // equivalent cylinder excluded volume 
    44         return radius_from_excluded_volume(length_a,length_b,length_c); 
    45     case 2: // equivalent volume sphere 
     12    case 1: // equivalent sphere 
    4613        return cbrt(length_a*length_b*length_c/M_4PI_3); 
    47     case 3: // half length_a 
     14    case 2: // half length_a 
    4815        return 0.5 * length_a; 
    49     case 4: // half length_b 
     16    case 3: // half length_b 
    5017        return 0.5 * length_b; 
    51     case 5: // half length_c 
     18    case 4: // half length_c 
    5219        return 0.5 * length_c; 
    53     case 6: // equivalent circular cross-section 
     20    case 5: // equivalent circular cross-section 
    5421        return sqrt(length_a*length_b/M_PI); 
    55     case 7: // half ab diagonal 
     22    case 6: // half ab diagonal 
    5623        return 0.5*sqrt(length_a*length_a + length_b*length_b); 
    57     case 8: // half diagonal 
     24    case 7: // half diagonal 
    5825        return 0.5*sqrt(length_a*length_a + length_b*length_b + length_c*length_c); 
    5926    } 
  • sasmodels/models/parallelepiped.py

    r99658f6 ree60aa7  
    180180   14 (1961) 185-211 
    181181.. [#] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    182 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    183182 
    184183Authorship and Verification 
     
    233232have_Fq = True 
    234233effective_radius_type = [ 
    235     "equivalent cylinder excluded volume", "equivalent volume sphere",  
    236     "half length_a", "half length_b", "half length_c", 
     234    "equivalent sphere", "half length_a", "half length_b", "half length_c", 
    237235    "equivalent circular cross-section", "half ab diagonal", "half diagonal", 
    238236    ] 
  • sasmodels/models/pearl_necklace.c

    r99658f6 r3f853beb  
    6767} 
    6868 
    69 double form_volume(double radius, double edge_sep, double thick_string, double fp_num_pearls) 
     69double form_volume(double radius, double edge_sep, 
     70    double thick_string, double fp_num_pearls) 
    7071{ 
    7172    const int num_pearls = (int)(fp_num_pearls + 0.5); //Force integer number of pearls 
     
    7677 
    7778    return volume; 
    78 } 
    79  
    80 static double 
    81 radius_from_volume(double radius, double edge_sep, double thick_string, double fp_num_pearls) 
    82 { 
    83     const int num_pearls = (int) fp_num_pearls +0.5; 
    84     const double vol_tot = form_volume(radius, edge_sep, thick_string, fp_num_pearls); 
    85     return cbrt(vol_tot/M_4PI_3); 
    86 } 
    87  
    88 static double 
    89 effective_radius(int mode, double radius, double edge_sep, double thick_string, double fp_num_pearls) 
    90 { 
    91     switch (mode) { 
    92     default: 
    93     case 1: 
    94         return radius_from_volume(radius, edge_sep, thick_string, fp_num_pearls); 
    95     } 
    9679} 
    9780 
  • sasmodels/models/pearl_necklace.py

    rcf3d0ce r2cc8aa2  
    5353R Schweins and K Huber, *Particle Scattering Factor of Pearl Necklace Chains*, 
    5454*Macromol. Symp.* 211 (2004) 25-42 2004 
    55 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    5655""" 
    5756 
     
    9695source = ["lib/sas_Si.c", "lib/sas_3j1x_x.c", "pearl_necklace.c"] 
    9796single = False  # use double precision unless told otherwise 
    98 effective_radius_type = [ 
    99     "equivalent volume sphere",  
    100     ] 
    101      
     97 
     98def volume(radius, edge_sep, thick_string, num_pearls): 
     99    """ 
     100    Calculates the total particle volume of the necklace. 
     101    Redundant with form_volume. 
     102    """ 
     103    num_pearls = int(num_pearls + 0.5) 
     104    number_of_strings = num_pearls - 1.0 
     105    string_vol = edge_sep * pi * pow((thick_string / 2.0), 2.0) 
     106    pearl_vol = 4.0 /3.0 * pi * pow(radius, 3.0) 
     107    total_vol = number_of_strings * string_vol 
     108    total_vol += num_pearls * pearl_vol 
     109    return total_vol 
     110 
     111def ER(radius, edge_sep, thick_string, num_pearls): 
     112    """ 
     113    Calculation for effective radius. 
     114    """ 
     115    num_pearls = int(num_pearls + 0.5) 
     116    tot_vol = volume(radius, edge_sep, thick_string, num_pearls) 
     117    rad_out = (tot_vol/(4.0/3.0*pi)) ** (1./3.) 
     118    return rad_out 
     119 
    102120def random(): 
    103121    radius = 10**np.random.uniform(1, 3) # 1 - 1000 
  • sasmodels/models/pringle.c

    r99658f6 rd42dd4a  
    105105 
    106106static double 
    107 radius_from_excluded_volume(double radius, double thickness) 
    108 { 
    109     return 0.5*cbrt(0.75*radius*(2.0*radius*thickness + (radius + thickness)*(M_PI*radius + thickness))); 
    110 } 
    111  
    112 static double 
    113107effective_radius(int mode, double radius, double thickness, double alpha, double beta) 
    114108{ 
    115109    switch (mode) { 
    116110    default: 
    117     case 1: // equivalent cylinder excluded volume 
    118         return radius_from_excluded_volume(radius, thickness); 
    119     case 2: // equivalent volume sphere 
     111    case 1: // equivalent sphere 
    120112        return cbrt(M_PI*radius*radius*thickness/M_4PI_3); 
    121     case 3: // radius 
     113    case 2: // radius 
    122114        return radius; 
    123115    } 
  • sasmodels/models/pringle.py

    r99658f6 ree60aa7  
    4242Karen Edler, Universtiy of Bath, Private Communication. 2012. 
    4343Derivation by Stefan Alexandru Rautu. 
    44 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949). 
    4544 
    4645* **Author:** Andrew Jackson **Date:** 2008 
     
    7574source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", 
    7675          "lib/sas_JN.c", "lib/gauss76.c", "pringle.c"] 
    77 effective_radius_type = ["equivalent cylinder excluded volume", "equivalent volume sphere", "radius"] 
     76effective_radius_type = ["equivalent sphere", "radius"] 
    7877 
    7978def random(): 
  • sasmodels/models/rectangular_prism.c

    r99658f6 rd42dd4a  
    66 
    77static double 
    8 radius_from_excluded_volume(double length_a, double b2a_ratio, double c2a_ratio) 
    9 { 
    10     double const r_equiv   = sqrt(length_a*length_a*b2a_ratio/M_PI); 
    11     double const length_c  = c2a_ratio*length_a; 
    12     return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_c + (r_equiv + length_c)*(M_PI*r_equiv + length_c))); 
    13 } 
    14  
    15 static double 
    168effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
    179{ 
    1810    switch (mode) { 
    1911    default: 
    20     case 1: // equivalent cylinder excluded volume 
    21         return radius_from_excluded_volume(length_a,b2a_ratio,c2a_ratio); 
    22     case 2: // equivalent volume sphere 
     12    case 1: // equivalent sphere 
    2313        return cbrt(cube(length_a)*b2a_ratio*c2a_ratio/M_4PI_3); 
    24     case 3: // half length_a 
     14    case 2: // half length_a 
    2515        return 0.5 * length_a; 
    26     case 4: // half length_b 
     16    case 3: // half length_b 
    2717        return 0.5 * length_a*b2a_ratio; 
    28     case 5: // half length_c 
     18    case 4: // half length_c 
    2919        return 0.5 * length_a*c2a_ratio; 
    30     case 6: // equivalent circular cross-section 
     20    case 5: // equivalent circular cross-section 
    3121        return length_a*sqrt(b2a_ratio/M_PI); 
    32     case 7: // half ab diagonal 
     22    case 6: // half ab diagonal 
    3323        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 
    34     case 8: // half diagonal 
     24    case 7: // half diagonal 
    3525        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 
    3626    } 
  • sasmodels/models/rectangular_prism.py

    r99658f6 ree60aa7  
    9999 
    100100R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    101  
    102 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
    103  
    104101""" 
    105102 
     
    140137have_Fq = True 
    141138effective_radius_type = [ 
    142     "equivalent cylinder excluded volume", "equivalent volume sphere",  
    143     "half length_a", "half length_b", "half length_c", 
     139    "equivalent sphere", "half length_a", "half length_b", "half length_c", 
    144140    "equivalent circular cross-section", "half ab diagonal", "half diagonal", 
    145141    ] 
  • sasmodels/models/triaxial_ellipsoid.c

    r99658f6 rd42dd4a  
    55{ 
    66    return M_4PI_3*radius_equat_minor*radius_equat_major*radius_polar; 
    7 } 
    8  
    9 static double 
    10 radius_from_curvature(double radius_equat_minor, double radius_equat_major, double radius_polar) 
    11 { 
    12     // Trivial cases 
    13     if (radius_equat_minor == radius_equat_major == radius_polar) return radius_polar; 
    14     if (radius_equat_minor * radius_equat_major * radius_polar == 0.)  return 0.; 
    15  
    16  
    17     double r_equat_equiv, r_polar_equiv; 
    18     double radii[3] = {radius_equat_minor, radius_equat_major, radius_polar}; 
    19     double radmax = fmax(radii[0],fmax(radii[1],radii[2])); 
    20  
    21     double radius_1 = radmax; 
    22     double radius_2 = radmax; 
    23     double radius_3 = radmax; 
    24  
    25     for(int irad=0; irad<3; irad++) { 
    26         if (radii[irad] < radius_1) { 
    27             radius_3 = radius_2; 
    28             radius_2 = radius_1; 
    29             radius_1 = radii[irad]; 
    30             } else { 
    31                 if (radii[irad] < radius_2) { 
    32                         radius_2 = radii[irad]; 
    33                 } 
    34             } 
    35     } 
    36     if(radius_2-radius_1 > radius_3-radius_2) { 
    37         r_equat_equiv = sqrt(radius_2*radius_3); 
    38         r_polar_equiv = radius_1; 
    39     } else  { 
    40         r_equat_equiv = sqrt(radius_1*radius_2); 
    41         r_polar_equiv = radius_3; 
    42     } 
    43  
    44     // see equation (26) in A.Isihara, J.Chem.Phys. 18(1950)1446-1449 
    45     const double ratio = (r_polar_equiv < r_equat_equiv 
    46                           ? r_polar_equiv / r_equat_equiv 
    47                           : r_equat_equiv / r_polar_equiv); 
    48     const double e1 = sqrt(1.0 - ratio*ratio); 
    49     const double b1 = 1.0 + asin(e1) / (e1 * ratio); 
    50     const double bL = (1.0 + e1) / (1.0 - e1); 
    51     const double b2 = 1.0 + 0.5 * ratio * ratio / e1 * log(bL); 
    52     const double delta = 0.75 * b1 * b2; 
    53     const double ddd = 2.0 * (delta + 1.0) * r_polar_equiv * r_equat_equiv * r_equat_equiv; 
    54     return 0.5 * cbrt(ddd); 
    557} 
    568 
     
    8032    switch (mode) { 
    8133    default: 
    82     case 1: // equivalent biaxial ellipsoid average curvature 
    83         return radius_from_curvature(radius_equat_minor,radius_equat_major, radius_polar); 
    84     case 2: // equivalent volume sphere 
     34    case 1: // equivalent sphere 
    8535        return radius_from_volume(radius_equat_minor,radius_equat_major, radius_polar); 
    86     case 3: // min radius 
     36    case 2: // min radius 
    8737        return radius_from_min_dimension(radius_equat_minor,radius_equat_major, radius_polar); 
    88     case 4: // max radius 
     38    case 3: // max radius 
    8939        return radius_from_max_dimension(radius_equat_minor,radius_equat_major, radius_polar); 
    9040    } 
  • sasmodels/models/triaxial_ellipsoid.py

    r99658f6 ree60aa7  
    158158source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 
    159159have_Fq = True 
    160 effective_radius_type = ["equivalent biaxial ellipsoid average curvature", "equivalent volume sphere", "min radius", "max radius"] 
     160effective_radius_type = ["equivalent sphere", "min radius", "max radius"] 
    161161 
    162162def random(): 
  • sasmodels/product.py

    r99658f6 r39a06c9  
    3737#] 
    3838 
    39 STRUCTURE_MODE_ID = "structure_factor_mode" 
    40 RADIUS_MODE_ID = "radius_effective_mode" 
    4139RADIUS_ID = "radius_effective" 
    4240VOLFRAC_ID = "volfraction" 
     
    4543    if p_info.have_Fq: 
    4644        par = parse_parameter( 
    47                 STRUCTURE_MODE_ID, 
     45                "structure_factor_mode", 
    4846                "", 
    4947                0, 
     
    5452    if p_info.effective_radius_type is not None: 
    5553        par = parse_parameter( 
    56                 RADIUS_MODE_ID, 
     54                "radius_effective_mode", 
    5755                "", 
    58                 1, 
     56                0, 
    5957                [["unconstrained"] + p_info.effective_radius_type], 
    6058                "", 
  • sasmodels/sasview_model.py

    r5024a56 r39a06c9  
    859859    P = _make_standard_model('cylinder')() 
    860860    model = MultiplicationModel(P, S) 
    861     model.setParam(product.RADIUS_MODE_ID, 1.0) 
     861    model.setParam('radius_effective_mode', 1.0) 
    862862    value = model.evalDistribution([0.1, 0.1]) 
    863863    if np.isnan(value): 
Note: See TracChangeset for help on using the changeset viewer.