Changeset 7050455 in sasmodels


Ignore:
Timestamp:
Mar 31, 2019 9:30:56 AM (5 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
f64b154, d0b0f5d
Parents:
694c6d0 (diff), da33725 (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.
git-author:
Paul Kienzle <pkienzle@…> (03/31/19 09:30:56)
git-committer:
GitHub <noreply@…> (03/31/19 09:30:56)
Message:

Merge pull request #99 from rprospero/log_sesans

Log sesans

Files:
1 added
89 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sesans.py

    rb297ba9 rda33725  
    1515from numpy import pi  # type: ignore 
    1616from scipy.special import j0 
     17 
    1718 
    1819class SesansTransform(object): 
     
    3839 
    3940    # transform arrays 
    40     _H = None  # type: np.ndarray 
    41     _H0 = None # type: np.ndarray 
     41    _H = None   # type: np.ndarray 
     42    _H0 = None  # type: np.ndarray 
    4243 
    43     def __init__(self, z, SElength, lam, zaccept, Rmax): 
     44    def __init__(self, z, SElength, lam, zaccept, Rmax, log_spacing=1.0003): 
    4445        # type: (np.ndarray, float, float) -> None 
    45         #import logging; logging.info("creating SESANS transform") 
    4646        self.q = z 
     47        self.log_spacing = log_spacing 
    4748        self._set_hankel(SElength, lam, zaccept, Rmax) 
    4849 
     
    5960    def _set_hankel(self, SElength, lam, zaccept, Rmax): 
    6061        # type: (np.ndarray, float, float) -> None 
    61         # Force float32 arrays, otherwise run into memory problems on some machines 
    62         SElength = np.asarray(SElength, dtype='float32') 
    63  
    64         #Rmax = #value in text box somewhere in FitPage? 
     62        SElength = np.asarray(SElength) 
    6563        q_max = 2*pi / (SElength[1] - SElength[0]) 
    6664        q_min = 0.1 * 2*pi / (np.size(SElength) * SElength[-1]) 
    67         q = np.arange(q_min, q_max, q_min, dtype='float32') 
    68         dq = q_min 
     65        q = np.exp(np.arange(np.log(q_min), np.log(q_max), 
     66                             np.log(self.log_spacing))) 
    6967 
    70         H0 = np.float32(dq/(2*pi)) * q 
     68        dq = np.diff(q) 
     69        dq = np.insert(dq, 0, dq[0]) 
    7170 
    72         repq = np.tile(q, (SElength.size, 1)).T 
    73         repSE = np.tile(SElength, (q.size, 1)) 
    74         H = np.float32(dq/(2*pi)) * j0(repSE*repq) * repq 
     71        H0 = dq/(2*pi) * q 
    7572 
    76         replam = np.tile(lam, (q.size, 1)) 
    77         reptheta = np.arcsin(repq*replam/2*np.pi) 
     73        H = np.outer(q, SElength) 
     74        j0(H, out=H) 
     75        H *= (dq * q / (2*pi)).reshape((-1, 1)) 
     76 
     77        reptheta = np.outer(q, lam/(2*pi)) 
     78        np.arcsin(reptheta, out=reptheta) 
    7879        mask = reptheta > zaccept 
    7980        H[mask] = 0 
  • doc/guide/index.rst

    rda5536f rbc69321  
    1212   pd/polydispersity.rst 
    1313   resolution.rst 
     14   plugin.rst 
     15   fitting_sq.rst 
    1416   magnetism/magnetism.rst 
    1517   orientation/orientation.rst 
    1618   sesans/sans_to_sesans.rst 
    1719   sesans/sesans_fitting.rst 
    18    plugin.rst 
    1920   scripting.rst 
    2021   refs.rst 
  • doc/guide/plugin.rst

    rc94ab04 re15a822  
    303303**Note: The order of the parameters in the definition will be the order of the 
    304304parameters in the user interface and the order of the parameters in Fq(), Iq(), 
    305 Iqac(), Iqabc(), form_volume() and shell_volume(). 
     305Iqac(), Iqabc(), radius_effective(), form_volume() and shell_volume(). 
    306306And** *scale* **and** *background* **parameters are implicit to all models, 
    307307so they do not need to be included in the parameter table.** 
     
    387387can take arbitrary values, even for integer parameters, so your model should 
    388388round the incoming parameter value to the nearest integer inside your model 
    389 you should round to the nearest integer.  In C code, you can do this using:: 
     389you should round to the nearest integer.  In C code, you can do this using: 
     390 
     391.. code-block:: c 
    390392 
    391393    static double 
     
    454456............. 
    455457 
     458.. note:: 
     459 
     460   Pure python models do not yet support direct computation of $<F(Q)^2>$ or 
     461   $<F(Q)>^2$. Neither do they support orientational distributions or magnetism 
     462   (use C models if these are required). 
     463 
    456464For pure python models, define the *Iq* function:: 
    457465 
     
    499507Models should define *form_volume(par1, par2, ...)* where the parameter 
    500508list includes the *volume* parameters in order.  This is used for a weighted 
    501 volume normalization so that scattering is on an absolute scale.  If 
    502 *form_volume* is not defined, then the default *form_volume = 1.0* will be 
    503 used. 
     509volume normalization so that scattering is on an absolute scale.  For 
     510solid shapes, the *I(q)* function should use *form_volume* squared 
     511as its scale factor.  If *form_volume* is not defined, then the default 
     512*form_volume = 1.0* will be used. 
    504513 
    505514Hollow shapes, where the volume fraction of particle corresponds to the 
    506515material in the shell rather than the volume enclosed by the shape, must 
    507516also define a *shell_volume(par1, par2, ...)* function.  The parameters 
    508 are the same as for *form_volume*.  The *I(q)* calculation should use 
    509 *shell_volume* squared as its scale factor for the volume normalization. 
    510 The structure factor calculation needs *form_volume* in order to properly 
    511 scale the volume fraction parameter, so both functions are required for 
    512 hollow shapes. 
    513  
    514 **Note: Pure python models do not yet support direct computation of the** 
    515 **average of $F(q)$ and $F^2(q)$. Neither do they support orientational** 
    516 **distributions or magnetism (use C models if these are required).** 
     517are the same as for *form_volume*.  Here the *I(q)* function should use 
     518*shell_volume* squared instead of *form_volume* squared so that the scale 
     519parameter corresponds to the volume fraction of material in the sample. 
     520The structure factor calculation needs the volume fraction of the filled 
     521shapes for its calculation, so the volume fraction parameter in the model 
     522is automatically scaled by *form_volume/shell_volume* prior to calling the 
     523structure factor. 
    517524 
    518525Embedded C Models 
     
    525532    """ 
    526533 
    527 This expands into the equivalent C code:: 
     534This expands into the equivalent C code: 
     535 
     536.. code-block:: c 
    528537 
    529538    double Iq(double q, double par1, double par2, ...); 
     
    536545includes only the volume parameters. 
    537546 
    538 *form_volume* defines the volume of the shell for hollow shapes. As in 
     547*shell_volume* defines the volume of the shell for hollow shapes. As in 
    539548python models, it includes only the volume parameters. 
    540549 
     
    568577Rather than returning NAN from Iq, you must define the *INVALID(v)*.  The 
    569578*v* parameter lets you access all the parameters in the model using 
    570 *v.par1*, *v.par2*, etc. For example:: 
     579*v.par1*, *v.par2*, etc. For example: 
     580 
     581.. code-block:: c 
    571582 
    572583    #define INVALID(v) (v.bell_radius < v.radius) 
     
    583594 
    584595Instead of defining the *Iq* function, models can define *Fq* as 
    585 something like:: 
     596something like: 
     597 
     598.. code-block:: c 
    586599 
    587600    double Fq(double q, double *F1, double *F2, double par1, double par2, ...); 
     
    615628laboratory frame and beam travelling along $-z$. 
    616629 
    617 The oriented C model (oriented pure Python models are not supported)  
     630The oriented C model (oriented pure Python models are not supported) 
    618631is called using *Iqabc(qa, qb, qc, par1, par2, ...)* where 
    619632*par1*, etc. are the parameters to the model.  If the shape is rotationally 
     
    644657 
    645658Using the $z, w$ values for Gauss-Legendre integration in "lib/gauss76.c", the 
    646 numerical integration is then:: 
     659numerical integration is then: 
     660 
     661.. code-block:: c 
    647662 
    648663    double outer_sum = 0.0; 
     
    9871002  memory, and wrong answers computed. The conclusion from a very long and 
    9881003  strange debugging session was that any arrays that you declare in your 
    989   model should be a multiple of four. For example:: 
     1004  model should be a multiple of four. For example: 
     1005 
     1006  .. code-block:: c 
    9901007 
    9911008      double Iq(q, p1, p2, ...) 
     
    10191036structure factor is the *hardsphere* interaction, which 
    10201037uses the effective radius of the form factor as an input to the structure 
    1021 factor model.  The effective radius is the average radius of the 
    1022 form averaged over all the polydispersity values. 
    1023  
    1024 :: 
    1025  
    1026     def ER(radius, thickness): 
    1027         """Effective radius of a core-shell sphere.""" 
    1028         return radius + thickness 
    1029  
    1030 Now consider the *core_shell_sphere*, which has a simple effective radius 
    1031 equal to the radius of the core plus the thickness of the shell, as 
    1032 shown above. Given polydispersity over *(r1, r2, ..., rm)* in radius and 
    1033 *(t1, t2, ..., tn)* in thickness, *ER* is called with a mesh 
    1034 grid covering all possible combinations of radius and thickness. 
    1035 That is, *radius* is *(r1, r2, ..., rm, r1, r2, ..., rm, ...)* 
    1036 and *thickness* is *(t1, t1, ... t1, t2, t2, ..., t2, ...)*. 
    1037 The *ER* function returns one effective radius for each combination. 
    1038 The effective radius calculator weights each of these according to 
    1039 the polydispersity distributions and calls the structure factor 
    1040 with the average *ER*. 
    1041  
    1042 :: 
    1043  
    1044     def VR(radius, thickness): 
    1045         """Sphere and shell volumes for a core-shell sphere.""" 
    1046         whole = 4.0/3.0 * pi * (radius + thickness)**3 
    1047         core = 4.0/3.0 * pi * radius**3 
    1048         return whole, whole - core 
    1049  
    1050 Core-shell type models have an additional volume ratio which scales 
    1051 the structure factor.  The *VR* function returns the volume of 
    1052 the whole sphere and the volume of the shell. Like *ER*, there is 
    1053 one return value for each point in the mesh grid. 
    1054  
    1055 *NOTE: we may be removing or modifying this feature soon. As of the 
    1056 time of writing, core-shell sphere returns (1., 1.) for VR, giving a volume 
    1057 ratio of 1.0.* 
     1038factor model.  The effective radius is the weighted average over all 
     1039values of the shape in polydisperse systems. 
     1040 
     1041There can be many notions of effective radius, depending on the shape.  For 
     1042a sphere it is clearly just the radius, but for an ellipsoid of revolution 
     1043we provide average curvature, equivalent sphere radius, minimum radius and 
     1044maximum radius.  These options are listed as *radius_effective_modes* in 
     1045the python model defintion, and must be computed by the *radius_effective* 
     1046function which takes the *radius_effective_mode* parameter as an integer, 
     1047along with the various model parameters.  Unlike normal C/Python arrays, 
     1048the first mode is 1, the second is 2, etc.  Mode 0 indicates that the 
     1049effective radius from the shape is to be ignored in favour of the the 
     1050effective radius parameter in the structure factor model. 
     1051 
     1052 
     1053Consider the core-shell sphere, which defines the following effective radius 
     1054modes in the python model:: 
     1055 
     1056    radius_effective_modes = [ 
     1057        "outer radius", 
     1058        "core radius", 
     1059    ] 
     1060 
     1061and the following function in the C-file for the model: 
     1062 
     1063.. code-block:: c 
     1064 
     1065    static double 
     1066    radius_effective(int mode, double radius, double thickness) 
     1067    { 
     1068        switch (mode) { 
     1069            case 0: return radius + thickness; 
     1070            case 1: return radius; 
     1071            default: return 0.; 
     1072        } 
     1073    } 
     1074 
     1075    static double 
     1076    form_volume(double radius, double thickness) 
     1077    { 
     1078        return M_4PI_3 * cube(radius + thickness); 
     1079    } 
     1080 
     1081Given polydispersity over *(r1, r2, ..., rm)* in radius and *(t1, t2, ..., tn)* 
     1082in thickness, *radius_effective* is called over a mesh grid covering all 
     1083possible combinations of radius and thickness, with a single *(ri, tj)* pair 
     1084in each call. The weights each of these results according to the 
     1085polydispersity distributions and calls the structure factor with the average 
     1086effective radius.  Similarly, for *form_volume*. 
     1087 
     1088Hollow models have an additional volume ratio which is needed to scale the 
     1089structure factor.  The structure factor uses the volume fraction of the filled 
     1090particles as part of its density estimate, but the scale factor for the 
     1091scattering intensity (as non-solvent volume fraction / volume) is determined 
     1092by the shell volume only.  Therefore the *shell_volume* function is 
     1093needed to compute the form:shell volume ratio, which then scales the 
     1094*volfraction* parameter prior to calling the structure factor calculator. 
     1095In the case of a hollow sphere, this would be: 
     1096 
     1097.. code-block:: c 
     1098 
     1099    static double 
     1100    shell_volume(double radius, double thickness) 
     1101    { 
     1102        double whole = M_4PI_3 * cube(radius + thickness); 
     1103        double core = M_4PI_3 * cube(radius); 
     1104        return whole - core; 
     1105    } 
     1106 
     1107If *shell_volume* is not present, then *form_volume* and *shell_volume* are 
     1108assumed to be equal, and the shape is considered solid. 
    10581109 
    10591110Unit Tests 
     
    11151166................... 
    11161167 
    1117 **NB: For now, this more detailed testing is only possible if you have a  
     1168**NB: For now, this more detailed testing is only possible if you have a 
    11181169SasView build environment available!** 
    11191170 
     
    12531304| 2016-10-25 Steve King 
    12541305| 2017-05-07 Paul Kienzle - Moved from sasview to sasmodels docs 
     1306| 2019-03-28 Paul Kienzle - Update docs for radius_effective and shell_volume 
  • doc/guide/resolution.rst

    r0db85af rdb1d9d5  
    1 .. sm_help.rst 
    2  
    3 .. This is a port of the original SasView html help file to ReSTructured text 
    4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 
     1.. resolution.rst 
     2 
     3.. This is a port of the original SasView html help file sm_help to ReSTructured 
     4.. text by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 
    55 
    66 
     
    1717resolution contribution into a model calculation/simulation (which by definition 
    1818will be exact) to make it more representative of what has been measured 
    19 experimentally - a process called *smearing*. Sasmodels does the latter. 
     19experimentally - a process called *smearing*. The Sasmodels component of SasView 
     20does the latter. 
    2021 
    2122Both smearing and desmearing rely on functions to describe the resolution 
     
    2930for the instrument and stored with the data file.  If not, they will need to 
    3031be set manually before fitting. 
     32 
     33.. note:: 
     34    Problems may be encountered if the data set loaded by SasView is a 
     35    concatenation of SANS data from several detector distances where, of 
     36    course, the worst Q resolution is next to the beam stop at each detector 
     37    distance. (This will also be noticeable in the residuals plot where 
     38    there will be poor overlap). SasView sensibly orders all the input 
     39    data points by increasing Q for nicer-looking plots, however, the dQ 
     40    data can then vary considerably from point to point. If 'Use dQ data' 
     41    smearing is selected then spikes may appear in the model fits, whereas 
     42    if 'None' or 'Custom Pinhole Smear' are selected the fits look normal. 
     43 
     44    In such instances, possible solutions are to simply remove the data 
     45    with poor Q resolution from the shorter detector distances, or to fit 
     46    the data from different detector distances simultaneously. 
    3147 
    3248 
  • explore/beta/sasfit_compare.py

    r119073a ra34b811  
    408408        #radius_effective=12.59921049894873, 
    409409        ) 
    410     target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
     410    target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars) 
    411411    actual = ellipsoid_pe(q, norm='sasview', **pars) 
    412412    title = " ".join(("sasmodels", model, pd_type)) 
  • explore/beta/sasfit_compare_new.py

    rb6422c7 ra34b811  
    360360#polydispersity for hollow_cylinder 
    361361def hollow_cylinder_pe(q,radius=20, thickness=10, length=80, sld=4, sld_solvent=1, volfraction=0.15, 
    362         radius_pd=0.1, thickness_pd=0.2, length_pd=0.05, radius_pd_type="gaussian", length_pd_type="gaussian",  
     362        radius_pd=0.1, thickness_pd=0.2, length_pd=0.05, radius_pd_type="gaussian", length_pd_type="gaussian", 
    363363        thickness_pd_type="gaussian", radius_effective=None, background=0, scale=1, 
    364364                 norm='sasview'): 
     
    595595#       this one is only used locally for "actual" 
    596596        ) 
    597     target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
     597    target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars) 
    598598    actual = sphere_r(q, norm='sasview', **pars) 
    599599    title = " ".join(("sasmodels", model, pd_type)) 
     
    612612        background=0, 
    613613        radius_pd=0.01, thickness_pd=0.01, radius_pd_type=pd_type, thickness_pd_type=pd_type, 
    614         radius_effective=30. )  
     614        radius_effective=30. ) 
    615615        # equivalent average sphere radius for local "actual" to match what sasview uses, use None to compute average outer radius here, 
    616616 
    617     target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
     617    target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars) 
    618618    actual = vesicle_pe(q, norm='sasview', **pars) 
    619619    title = " ".join(("sasmodels", model, pd_type)) 
     
    633633        background=0, 
    634634        radius_pd=0.1, thickness_pd=0.0, length_pd=0.0, radius_pd_type=pd_type, thickness_pd_type=pd_type, length_pd_type=pd_type, 
    635         radius_effective=40.687)   
     635        radius_effective=40.687) 
    636636        # equivalent average sphere radius for local "actual" to match what sasview uses 
    637     target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
     637    target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars) 
    638638    actual = hollow_cylinder_pe(q, norm='sasview', **pars) 
    639639# RKH monodisp was OK,    actual = hollow_cylinder_theta(q,radius=20, thickness=10, length=80, sld=4, sld_solvent=1 ) 
     
    656656# if change radius_effective to some other value, the S(Q) from sasview does not agree 
    657657        ) 
    658     target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
     658    target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars) 
    659659    actual = ellipsoid_pe(q, norm='sasview', **pars) 
    660660# RKH test       actual = ellipsoid_theta(q, radius_polar=20, radius_equatorial=400, sld=4, sld_solvent=1, volfraction=0.15, radius_effective=270.) 
  • sasmodels/core.py

    rb297ba9 r9562dd2  
    376376    # type: () -> None 
    377377    """Check that model load works""" 
     378    from .product import RADIUS_ID, VOLFRAC_ID, STRUCTURE_MODE_ID, RADIUS_MODE_ID 
    378379    #Test the the model produces the parameters that we would expect 
    379380    model = load_model("cylinder@hardsphere*sphere") 
    380381    actual = [p.name for p in model.info.parameters.kernel_parameters] 
    381     target = ("sld sld_solvent radius length theta phi" 
    382               " radius_effective volfraction " 
    383               " structure_factor_mode radius_effective_mode" 
    384               " A_sld A_sld_solvent A_radius").split() 
     382    target = ["sld", "sld_solvent", "radius", "length", "theta", "phi", 
     383              RADIUS_ID, VOLFRAC_ID, STRUCTURE_MODE_ID, RADIUS_MODE_ID, 
     384              "A_sld", "A_sld_solvent", "A_radius"] 
    385385    assert target == actual, "%s != %s"%(target, actual) 
    386386 
  • sasmodels/direct_model.py

    rb297ba9 re220acc  
    5959    """ 
    6060    mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 
    61     #print("pars", list(zip(*mesh))[0]) 
     61    #print("in call_kernel: pars:", list(zip(*mesh))[0]) 
    6262    call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 
    63     #print("values:", values) 
     63    #print("in call_kernel: values:", values) 
    6464    return calculator(call_details, values, cutoff, is_magnetic) 
    6565 
     
    7272 
    7373    Use parameter *radius_effective_mode* to select the effective radius 
    74     calculation. 
     74    calculation to use amongst the *radius_effective_modes* list given in the 
     75    model. 
    7576    """ 
    7677    R_eff_type = int(pars.pop(RADIUS_MODE_ID, 1.0)) 
    7778    mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 
    78     #print("pars", list(zip(*mesh))[0]) 
     79    #print("in call_Fq: pars", list(zip(*mesh))[0]) 
    7980    call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 
    80     #print("values:", values) 
     81    #print("in call_Fq: values:", values) 
    8182    return calculator.Fq(call_details, values, cutoff, is_magnetic, R_eff_type) 
    8283 
     
    118119        active = lambda name: True 
    119120 
    120     #print("pars",[p.id for p in parameters.call_parameters]) 
     121    #print("in get_mesh: pars:",[p.id for p in parameters.call_parameters]) 
    121122    mesh = [_get_par_weights(p, values, active(p.name)) 
    122123            for p in parameters.call_parameters] 
  • sasmodels/generate.py

    rb297ba9 ra34b811  
    2727    which are hollow. 
    2828 
    29     *effective_radius(mode, p1, p2, ...)* returns the effective radius of 
     29    *radius_effective(mode, p1, p2, ...)* returns the effective radius of 
    3030    the form with particular dimensions.  Mode determines the type of 
    3131    effective radius returned, with mode=1 for equivalent volume. 
     
    820820                              for p in partable.kernel_parameters)) 
    821821    # Define the function calls 
    822     call_effective_radius = "#define CALL_EFFECTIVE_RADIUS(_mode, _v) 0.0" 
     822    call_radius_effective = "#define CALL_RADIUS_EFFECTIVE(_mode, _v) 0.0" 
    823823    if partable.form_volume_parameters: 
    824824        refs = _call_pars("_v.", partable.form_volume_parameters) 
     
    833833                "do { _form = _shell = form_volume(%s); } " 
    834834                "while (0)") % (",".join(refs)) 
    835         if model_info.effective_radius_type: 
    836             call_effective_radius = ( 
    837                 "#define CALL_EFFECTIVE_RADIUS(_mode, _v) " 
    838                 "effective_radius(_mode, %s)") % (",".join(refs)) 
     835        if model_info.radius_effective_modes: 
     836            call_radius_effective = ( 
     837                "#define CALL_RADIUS_EFFECTIVE(_mode, _v) " 
     838                "radius_effective(_mode, %s)") % (",".join(refs)) 
    839839    else: 
    840840        # Model doesn't have volume.  We could make the kernel run a little 
     
    845845            "do { _form = _shell = 1.0; } while (0)") 
    846846    source.append(call_volume) 
    847     source.append(call_effective_radius) 
     847    source.append(call_radius_effective) 
    848848    model_refs = _call_pars("_v.", partable.iq_parameters) 
    849849 
  • sasmodels/kernel.py

    rb297ba9 ra34b811  
    7878        """ 
    7979        _, F2, _, shell_volume, _ = self.Fq(call_details, values, cutoff, 
    80                                             magnetic, effective_radius_type=0) 
     80                                            magnetic, radius_effective_mode=0) 
    8181        combined_scale = values[0]/shell_volume 
    8282        background = values[1] 
     
    8585 
    8686    def Fq(self, call_details, values, cutoff, magnetic, 
    87            effective_radius_type=0): 
     87           radius_effective_mode=0): 
    8888        # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray 
    8989        r""" 
     
    143143        volume fraction of the particles.  The model can have several 
    144144        different ways to compute effective radius, with the 
    145         *effective_radius_type* parameter used to select amongst them.  The 
     145        *radius_effective_mode* parameter used to select amongst them.  The 
    146146        volume fraction of particles should be determined from the total 
    147147        volume fraction of the form, not just the shell volume fraction. 
     
    153153        """ 
    154154        self._call_kernel(call_details, values, cutoff, magnetic, 
    155                           effective_radius_type) 
     155                          radius_effective_mode) 
    156156        #print("returned",self.q_input.q, self.result) 
    157157        nout = 2 if self.info.have_Fq and self.dim == '1d' else 1 
     
    165165        form_volume = self.result[nout*self.q_input.nq + 1]/total_weight 
    166166        shell_volume = self.result[nout*self.q_input.nq + 2]/total_weight 
    167         effective_radius = self.result[nout*self.q_input.nq + 3]/total_weight 
     167        radius_effective = self.result[nout*self.q_input.nq + 3]/total_weight 
    168168        if shell_volume == 0.: 
    169169            shell_volume = 1. 
     
    171171              if nout == 2 else None) 
    172172        F2 = self.result[0:nout*self.q_input.nq:nout]/total_weight 
    173         return F1, F2, effective_radius, shell_volume, form_volume/shell_volume 
     173        return F1, F2, radius_effective, shell_volume, form_volume/shell_volume 
    174174 
    175175    def release(self): 
     
    181181 
    182182    def _call_kernel(self, call_details, values, cutoff, magnetic, 
    183                      effective_radius_type): 
     183                     radius_effective_mode): 
    184184        # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray 
    185185        """ 
  • sasmodels/kernel_iq.c

    r12f4c19 rde032da  
    2727//      parameters in the parameter table. 
    2828//  CALL_VOLUME(form, shell, table) : assign form and shell values 
    29 //  CALL_EFFECTIVE_RADIUS(type, table) : call the R_eff function 
     29//  CALL_RADIUS_EFFECTIVE(mode, table) : call the R_eff function 
    3030//  CALL_IQ(q, table) : call the Iq function for 1D calcs. 
    3131//  CALL_IQ_A(q, table) : call the Iq function with |q| for 2D data. 
     
    8585static void set_spin_weights(double in_spin, double out_spin, double weight[6]) 
    8686{ 
     87 
     88  double norm; 
    8789  in_spin = clip(in_spin, 0.0, 1.0); 
    8890  out_spin = clip(out_spin, 0.0, 1.0); 
     
    9496  // However, since the weights are applied to the final intensity and 
    9597  // are not interned inside the I(q) function, we want the full 
    96   // weight and not the square root.  Any function using 
    97   // set_spin_weights as part of calculating an amplitude will need to 
    98   // manually take that square root, but there is currently no such 
    99   // function. 
    100   weight[0] = (1.0-in_spin) * (1.0-out_spin); // dd 
    101   weight[1] = (1.0-in_spin) * out_spin;       // du 
    102   weight[2] = in_spin * (1.0-out_spin);       // ud 
    103   weight[3] = in_spin * out_spin;             // uu 
     98  // weight and not the square root.  Anyway no function will ever use 
     99  // set_spin_weights as part of calculating an amplitude, as the weights are 
     100  // related to polarisation efficiency of the instrument. The weights serve to 
     101  // construct various magnet scattering cross sections, which are linear combinations 
     102  // of the spin-resolved cross sections. The polarisation efficiency e_in and e_out 
     103  // are parameters ranging from 0.5 (unpolarised) beam to 1 (perfect optics). 
     104  // For in_spin or out_spin <0.5 one assumes a CS, where the spin is reversed/flipped 
     105  // with respect to the initial supermirror polariser. The actual polarisation efficiency 
     106  // in this case is however e_in/out = 1-in/out_spin. 
     107 
     108  if (out_spin < 0.5){norm=1-out_spin;} 
     109  else{norm=out_spin;} 
     110 
     111 
     112// The norm is needed to make sure that the scattering cross sections are 
     113//correctly weighted, such that the sum of spin-resolved measurements adds up to 
     114// the unpolarised or half-polarised scattering cross section. No intensity weighting 
     115// needed on the incoming polariser side (assuming that a user), has normalised 
     116// to the incoming flux with polariser in for SANSPOl and unpolarised beam, respectively. 
     117 
     118 
     119  weight[0] = (1.0-in_spin) * (1.0-out_spin) / norm; // dd 
     120  weight[1] = (1.0-in_spin) * out_spin / norm;       // du 
     121  weight[2] = in_spin * (1.0-out_spin) / norm;       // ud 
     122  weight[3] = in_spin * out_spin / norm;             // uu 
    104123  weight[4] = weight[1]; // du.imag 
    105124  weight[5] = weight[2]; // ud.imag 
     
    119138    switch (xs) { 
    120139      default: // keep compiler happy; condition ensures xs in [0,1,2,3] 
    121       case 0: // uu => sld - D M_perpx 
     140      case 0: // dd => sld - D M_perpx 
    122141          return sld - px*perp; 
    123       case 1: // ud.real => -D M_perpy 
     142      case 1: // du.real => -D M_perpy 
    124143          return py*perp; 
    125       case 2: // du.real => -D M_perpy 
     144      case 2: // ud.real => -D M_perpy 
    126145          return py*perp; 
    127       case 3: // dd => sld + D M_perpx 
     146      case 3: // uu => sld + D M_perpx 
    128147          return sld + px*perp; 
    129148    } 
     
    285304    pglobal double *result,       // nq+1 return values, again with padding 
    286305    const double cutoff,          // cutoff in the dispersity weight product 
    287     int32_t effective_radius_type // which effective radius to compute 
     306    int32_t radius_effective_mode // which effective radius to compute 
    288307    ) 
    289308{ 
     
    703722      weighted_form += weight * form; 
    704723      weighted_shell += weight * shell; 
    705       if (effective_radius_type != 0) { 
    706         weighted_radius += weight * CALL_EFFECTIVE_RADIUS(effective_radius_type, local_values.table); 
     724      if (radius_effective_mode != 0) { 
     725        weighted_radius += weight * CALL_RADIUS_EFFECTIVE(radius_effective_mode, local_values.table); 
    707726      } 
    708727      BUILD_ROTATION(); 
  • sasmodels/kernelcl.py

    r069743a r9fac5f5  
    158158ENV = None 
    159159def reset_environment(): 
    160     # type: () -> None 
    161     """ 
    162     Call to create a new OpenCL context, such as after a change to SAS_OPENCL. 
     160    # type: () -> "GpuEnvironment" 
     161    """ 
     162    Return a new OpenCL context, such as after a change to SAS_OPENCL. 
    163163    """ 
    164164    global ENV 
    165165    ENV = GpuEnvironment() if use_opencl() else None 
    166  
     166    return ENV 
    167167 
    168168def environment(): 
     
    577577 
    578578    def _call_kernel(self, call_details, values, cutoff, magnetic, 
    579                      effective_radius_type): 
     579                     radius_effective_mode): 
    580580        # type: (CallDetails, np.ndarray, float, bool, int) -> np.ndarray 
    581581        env = environment() 
     
    601601            self._result_b,   # Result storage. 
    602602            self._as_dtype(cutoff),  # Probability cutoff. 
    603             np.uint32(effective_radius_type),  # R_eff mode. 
     603            np.uint32(radius_effective_mode),  # R_eff mode. 
    604604        ] 
    605605 
  • sasmodels/kernelcuda.py

    rb297ba9 ra34b811  
    473473 
    474474    def _call_kernel(self, call_details, values, cutoff, magnetic, 
    475                      effective_radius_type): 
     475                     radius_effective_mode): 
    476476        # type: (CallDetails, np.ndarray, float, bool, int) -> np.ndarray 
    477477 
     
    492492            self._result_b,   # Result storage. 
    493493            self._as_dtype(cutoff),  # Probability cutoff. 
    494             np.uint32(effective_radius_type),  # R_eff mode. 
     494            np.uint32(radius_effective_mode),  # R_eff mode. 
    495495        ] 
    496496        grid = partition(self.q_input.nq) 
  • sasmodels/kerneldll.py

    rb297ba9 ra34b811  
    403403 
    404404    def _call_kernel(self, call_details, values, cutoff, magnetic, 
    405                      effective_radius_type): 
     405                     radius_effective_mode): 
    406406        # type: (CallDetails, np.ndarray, float, bool, int) -> np.ndarray 
    407407 
     
    417417            self.result.ctypes.data,   # Result storage. 
    418418            self._as_dtype(cutoff),  # Probability cutoff. 
    419             effective_radius_type,  # R_eff mode. 
     419            radius_effective_mode,  # R_eff mode. 
    420420        ] 
    421421 
  • sasmodels/kernelpy.py

    rb297ba9 ra34b811  
    172172        volume = model_info.form_volume 
    173173        shell = model_info.shell_volume 
    174         radius = model_info.effective_radius 
     174        radius = model_info.radius_effective 
    175175        self._volume = ((lambda: (shell(*volume_args), volume(*volume_args))) if shell and volume 
    176176                        else (lambda: [volume(*volume_args)]*2) if volume 
     
    180180                        else (lambda mode: 1.0)) 
    181181 
    182     def _call_kernel(self, call_details, values, cutoff, magnetic, effective_radius_type): 
     182    def _call_kernel(self, call_details, values, cutoff, magnetic, radius_effective_mode): 
    183183        # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 
    184184        if magnetic: 
     
    186186        #print("Calling python kernel") 
    187187        #call_details.show(values) 
    188         radius = ((lambda: 0.0) if effective_radius_type == 0 
    189                   else (lambda: self._radius(effective_radius_type))) 
     188        radius = ((lambda: 0.0) if radius_effective_mode == 0 
     189                  else (lambda: self._radius(radius_effective_mode))) 
    190190        self.result = _loops( 
    191191            self._parameter_vector, self._form, self._volume, radius, 
  • sasmodels/model_test.py

    rb297ba9 r8795b6f  
    240240                    s_name = pars.pop('@S') 
    241241                    ps_test = [pars] + list(test[1:]) 
     242                    #print("PS TEST PARAMS!!!",ps_test) 
    242243                    # build the P@S model 
    243244                    s_info = load_model_info(s_name) 
     
    246247                                           platform=self.platform) 
    247248                    # run the tests 
     249                    #self.info = ps_model.info 
     250                    #print("SELF.INFO PARAMS!!!",[p.id for p in self.info.parameters.call_parameters]) 
     251                    #print("PS MODEL PARAMETERS:",[p.id for p in ps_model.info.parameters.call_parameters]) 
    248252                    results.append(self.run_one(ps_model, ps_test)) 
    249253 
     
    303307            """Run a single test case.""" 
    304308            user_pars, x, y = test[:3] 
    305             pars = expand_pars(self.info.parameters, user_pars) 
    306             invalid = invalid_pars(self.info.parameters, pars) 
     309            #print("PS MODEL PARAMETERS:",[p.id for p in model.info.parameters.call_parameters]) 
     310            pars = expand_pars(model.info.parameters, user_pars) 
     311            invalid = invalid_pars(model.info.parameters, pars) 
    307312            if invalid: 
    308313                raise ValueError("Unknown parameters in test: " + ", ".join(invalid)) 
     
    328333            else: 
    329334                y1 = y 
    330                 y2 = test[3] if not isinstance(test[3], list) else [test[3]] 
    331                 F1, F2, R_eff, volume, volume_ratio = call_Fq(kernel, pars) 
    332                 if F1 is not None:  # F1 is none for models with Iq instead of Fq 
    333                     self._check_vectors(x, y1, F1, 'F') 
    334                 self._check_vectors(x, y2, F2, 'F^2') 
     335                y2 = test[3] if isinstance(test[3], list) else [test[3]] 
     336                F, Fsq, R_eff, volume, volume_ratio = call_Fq(kernel, pars) 
     337                if F is not None:  # F is none for models with Iq instead of Fq 
     338                    self._check_vectors(x, y1, F, 'F') 
     339                self._check_vectors(x, y2, Fsq, 'F^2') 
    335340                self._check_scalar(test[4], R_eff, 'R_eff') 
    336341                self._check_scalar(test[5], volume, 'volume') 
    337342                self._check_scalar(test[6], volume_ratio, 'form:shell ratio') 
    338                 return F2 
     343                return Fsq 
    339344 
    340345        def _check_scalar(self, target, actual, name): 
    341             if target is None: 
    342                 # smoke test --- make sure it runs and produces a value 
    343                 self.assertTrue(not np.isnan(actual), 
    344                                 'invalid %s: %s' % (name, actual)) 
    345             elif np.isnan(target): 
    346                 # make sure nans match 
    347                 self.assertTrue(np.isnan(actual), 
    348                                 '%s: expected:%s; actual:%s' 
    349                                 % (name, target, actual)) 
    350             else: 
    351                 # is_near does not work for infinite values, so also test 
    352                 # for exact values. 
    353                 self.assertTrue(target == actual or is_near(target, actual, 5), 
    354                                 '%s: expected:%s; actual:%s' 
    355                                 % (name, target, actual)) 
     346            self.assertTrue(is_near(target, actual, 5), 
     347                            '%s: expected:%s; actual:%s' 
     348                            % (name, target, actual)) 
    356349 
    357350        def _check_vectors(self, x, target, actual, name='I'): 
     
    363356                             '%s(...) returned wrong length'%name) 
    364357            for xi, yi, actual_yi in zip(x, target, actual): 
    365                 if yi is None: 
    366                     # smoke test --- make sure it runs and produces a value 
    367                     self.assertTrue(not np.isnan(actual_yi), 
    368                                     'invalid %s(%s): %s' % (name, xi, actual_yi)) 
    369                 elif np.isnan(yi): 
    370                     # make sure nans match 
    371                     self.assertTrue(np.isnan(actual_yi), 
    372                                     '%s(%s): expected:%s; actual:%s' 
    373                                     % (name, xi, yi, actual_yi)) 
    374                 else: 
    375                     # is_near does not work for infinite values, so also test 
    376                     # for exact values. 
    377                     self.assertTrue(yi == actual_yi or is_near(yi, actual_yi, 5), 
    378                                     '%s(%s); expected:%s; actual:%s' 
    379                                     % (name, xi, yi, actual_yi)) 
     358                self.assertTrue(is_near(yi, actual_yi, 5), 
     359                                '%s(%s): expected:%s; actual:%s' 
     360                                % (name, xi, target, actual)) 
    380361 
    381362    return ModelTestCase 
     
    389370    invalid = [] 
    390371    for par in sorted(pars.keys()): 
    391         # special handling of R_eff mode, which is not a usual parameter 
     372        # Ignore the R_eff mode parameter when checking for valid parameters. 
     373        # It is an allowed parameter for a model even though it does not exist 
     374        # in the parameter table.  The call_Fq() function pops it from the 
     375        # parameter list and sends it directly to kernel.Fq(). 
    392376        if par == product.RADIUS_MODE_ID: 
    393377            continue 
     
    405389    """ 
    406390    Returns true if *actual* is within *digits* significant digits of *target*. 
    407     """ 
    408     import math 
    409     shift = 10**math.ceil(math.log10(abs(target))) 
    410     return abs(target-actual)/shift < 1.5*10**-digits 
     391 
     392    *taget* zero and inf should match *actual* zero and inf.  If you want to 
     393    accept eps for zero, choose a value such as 1e-10, which must match up to 
     394    +/- 1e-15 when *digits* is the default value of 5. 
     395 
     396    If *target* is None, then just make sure that *actual* is not NaN. 
     397 
     398    If *target* is NaN, make sure *actual* is NaN. 
     399    """ 
     400    if target is None: 
     401        # target is None => actual cannot be NaN 
     402        return not np.isnan(actual) 
     403    elif target == 0.: 
     404        # target is 0. => actual must be 0. 
     405        # Note: if small values are allowed, then use maybe test zero against eps instead? 
     406        return actual == 0. 
     407    elif np.isfinite(target): 
     408        shift = np.ceil(np.log10(abs(target))) 
     409        return abs(target-actual) < 1.5*10**(shift-digits) 
     410    elif target == actual: 
     411        # target is inf => actual must be inf of same sign 
     412        return True 
     413    else: 
     414        # target is NaN => actual must be NaN 
     415        return np.isnan(target) == np.isnan(actual) 
    411416 
    412417# CRUFT: old interface; should be deprecated and removed 
  • sasmodels/modelinfo.py

    rb297ba9 ra34b811  
    265265    other sld parameters. The volume parameters are used for calls 
    266266    to form_volume within the kernel (required for volume normalization), 
    267     to shell_volume (for hollow shapes), and to effective_radius (for 
     267    to shell_volume (for hollow shapes), and to radius_effective (for 
    268268    structure factor interactions) respectively. 
    269269 
     
    841841    info.structure_factor = getattr(kernel_module, 'structure_factor', False) 
    842842    # TODO: find Fq by inspection 
    843     info.effective_radius_type = getattr(kernel_module, 'effective_radius_type', None) 
     843    info.radius_effective_modes = getattr(kernel_module, 'radius_effective_modes', None) 
    844844    info.have_Fq = getattr(kernel_module, 'have_Fq', False) 
    845845    info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) 
     
    848848    info.source = getattr(kernel_module, 'source', []) 
    849849    info.c_code = getattr(kernel_module, 'c_code', None) 
    850     info.effective_radius = getattr(kernel_module, 'effective_radius', None) 
     850    info.radius_effective = getattr(kernel_module, 'radius_effective', None) 
    851851    # TODO: check the structure of the tests 
    852852    info.tests = getattr(kernel_module, 'tests', []) 
     
    961961    #: List of options for computing the effective radius of the shape, 
    962962    #: or None if the model is not usable as a form factor model. 
    963     effective_radius_type = None   # type: List[str] 
     963    radius_effective_modes = None   # type: List[str] 
    964964    #: List of C source files used to define the model.  The source files 
    965965    #: should define the *Iq* function, and possibly *Iqac* or *Iqabc* if the 
     
    989989    #: monodisperse approximation for non-dilute solutions, P@S.  The first 
    990990    #: argument is the integer effective radius mode, with default 0. 
    991     effective_radius = None  # type: Union[None, Callable[[int, np.ndarray], float]] 
     991    radius_effective = None  # type: Union[None, Callable[[int, np.ndarray], float]] 
    992992    #: Returns *I(q, a, b, ...)* for parameters *a*, *b*, etc. defined 
    993993    #: by the parameter table.  *Iq* can be defined as a python function, or 
  • sasmodels/models/_spherepy.py

    r0507e09 ra34b811  
    4848---------------------------- 
    4949 
    50 * **Author: P Kienzle**  
    51 * **Last Modified by:**  
     50* **Author: P Kienzle** 
     51* **Last Modified by:** 
    5252* **Last Reviewed by:** S King and P Parker **Date:** 2013/09/09 and 2014/01/06 
    5353* **Source added by :** Steve King **Date:** March 25, 2019 
     
    8383    return 1.333333333333333 * pi * radius ** 3 
    8484 
    85 def effective_radius(mode, radius): 
     85def radius_effective(mode, radius): 
    8686    """Calculate R_eff for sphere""" 
    87     return radius 
     87    return radius if mode else 0. 
    8888 
    8989def Iq(q, sld, sld_solvent, radius): 
  • sasmodels/models/barbell.c

    r99658f6 ra34b811  
    8585 
    8686static double 
    87 effective_radius(int mode, double radius_bell, double radius, double length) 
     87radius_effective(int mode, double radius_bell, double radius, double length) 
    8888{ 
    8989    switch (mode) { 
  • sasmodels/models/barbell.py

    r0507e09 ra34b811  
    126126source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] 
    127127have_Fq = True 
    128 effective_radius_type = [ 
     128radius_effective_modes = [ 
    129129    "equivalent cylinder excluded volume", "equivalent volume sphere", 
    130130    "radius", "half length", "half total length", 
  • sasmodels/models/capped_cylinder.c

    r99658f6 ra34b811  
    107107 
    108108static double 
    109 effective_radius(int mode, double radius, double radius_cap, double length) 
     109radius_effective(int mode, double radius, double radius_cap, double length) 
    110110{ 
    111111    switch (mode) { 
  • sasmodels/models/capped_cylinder.py

    r0507e09 ra34b811  
    146146source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] 
    147147have_Fq = True 
    148 effective_radius_type = [ 
     148radius_effective_modes = [ 
    149149    "equivalent cylinder excluded volume", "equivalent volume sphere", 
    150150    "radius", "half length", "half total length", 
  • sasmodels/models/core_multi_shell.c

    rd42dd4a ra34b811  
    2626 
    2727static double 
    28 effective_radius(int mode, double core_radius, double fp_n, double thickness[]) 
     28radius_effective(int mode, double core_radius, double fp_n, double thickness[]) 
    2929{ 
    3030  switch (mode) { 
  • sasmodels/models/core_multi_shell.py

    r0507e09 ra34b811  
    108108source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] 
    109109have_Fq = True 
    110 effective_radius_type = ["outer radius", "core radius"] 
     110radius_effective_modes = ["outer radius", "core radius"] 
    111111 
    112112def random(): 
  • sasmodels/models/core_shell_bicelle.c

    r99658f6 ra34b811  
    6060 
    6161static double 
    62 effective_radius(int mode, double radius, double thick_rim, double thick_face, double length) 
     62radius_effective(int mode, double radius, double thick_rim, double thick_face, double length) 
    6363{ 
    6464    switch (mode) { 
  • sasmodels/models/core_shell_bicelle.py

    r0507e09 ra34b811  
    165165          "core_shell_bicelle.c"] 
    166166have_Fq = True 
    167 effective_radius_type = [ 
     167radius_effective_modes = [ 
    168168    "excluded volume", "equivalent volume sphere", "outer rim radius", 
    169169    "half outer thickness", "half diagonal", 
  • sasmodels/models/core_shell_bicelle_elliptical.c

    r99658f6 ra34b811  
    3535 
    3636static double 
    37 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 
     37radius_effective(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 
    3838{ 
    3939    switch (mode) { 
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r0507e09 ra34b811  
    155155          "core_shell_bicelle_elliptical.c"] 
    156156have_Fq = True 
    157 effective_radius_type = [ 
     157radius_effective_modes = [ 
    158158    "equivalent cylinder excluded volume", "equivalent volume sphere", 
    159159    "outer rim average radius", "outer rim min radius", 
  • sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c

    r99658f6 ra34b811  
    3636 
    3737static double 
    38 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 
     38radius_effective(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 
    3939{ 
    4040    switch (mode) { 
  • sasmodels/models/core_shell_bicelle_elliptical_belt_rough.py

    r0507e09 ra34b811  
    168168          "core_shell_bicelle_elliptical_belt_rough.c"] 
    169169have_Fq = True 
    170 effective_radius_type = [ 
     170radius_effective_modes = [ 
    171171    "equivalent cylinder excluded volume", "equivalent volume sphere", 
    172172    "outer rim average radius", "outer rim min radius", 
  • sasmodels/models/core_shell_cylinder.c

    r99658f6 ra34b811  
    3737 
    3838static double 
    39 effective_radius(int mode, double radius, double thickness, double length) 
     39radius_effective(int mode, double radius, double thickness, double length) 
    4040{ 
    4141    switch (mode) { 
  • sasmodels/models/core_shell_cylinder.py

    r0507e09 rdb1d9d5  
    4646density of the solvent, and *background* is the background level.  The outer 
    4747radius of the shell is given by $R+T$ and the total length of the outer 
    48 shell is given by $L+2T$. $J1$ is the first order Bessel function. 
     48shell is given by $L+2T$. $J_1$ is the first order Bessel function. 
    4949 
    5050.. _core-shell-cylinder-geometry: 
     
    141141source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] 
    142142have_Fq = True 
    143 effective_radius_type = [ 
     143radius_effective_modes = [ 
    144144    "excluded volume", "equivalent volume sphere", "outer radius", "half outer length", 
    145145    "half min outer dimension", "half max outer dimension", "half outer diagonal", 
  • sasmodels/models/core_shell_ellipsoid.c

    r99658f6 ra34b811  
    6868 
    6969static double 
    70 effective_radius(int mode, double radius_equat_core, double x_core, double thick_shell, double x_polar_shell) 
     70radius_effective(int mode, double radius_equat_core, double x_core, double thick_shell, double x_polar_shell) 
    7171{ 
    7272    const double radius_equat_tot = radius_equat_core + thick_shell; 
  • sasmodels/models/core_shell_ellipsoid.py

    r0507e09 r830cf6b  
    33---------- 
    44 
    5 Parameters for this model are the core axial ratio X and a shell thickness, 
    6 which are more often what we would like to determine and makes the model 
    7 better behaved, particularly when polydispersity is applied than the four 
    8 independent radii used in the original parameterization of this model. 
     5Parameters for this model are the core axial ratio $X_{core}$ and a shell 
     6thickness $t_{shell}$, which are more often what we would like to determine 
     7and make the model better behaved, particularly when polydispersity is 
     8applied, than the four independent radii used in the original parameterization 
     9of this model. 
    910 
    1011 
     
    1516the poles, of a prolate ellipsoid. 
    1617 
    17 When *X_core < 1* the core is oblate; when *X_core > 1* it is prolate. 
    18 *X_core = 1* is a spherical core. 
    19  
    20 For a fixed shell thickness *XpolarShell = 1*, to scale the shell thickness 
    21 pro-rata with the radius set or constrain *XpolarShell = X_core*. 
    22  
    23 When including an $S(q)$, the radius in $S(q)$ is calculated to be that of 
    24 a sphere with the same 2nd virial coefficient of the outer surface of the 
    25 ellipsoid. This may have some undesirable effects if the aspect ratio of the 
    26 ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$ 
    27 - which assumes spheres - will not in any case be valid.  Generating a 
    28 custom product model will enable separate effective volume fraction and 
    29 effective radius in the $S(q)$. 
     18When $X_{core}$ < 1 the core is oblate; when $X_{core}$ > 1 it is prolate. 
     19$X_{core}$ = 1 is a spherical core. 
     20 
     21For a fixed shell thickness $X_{polar shell}$ = 1, to scale $t_{shell}$ 
     22pro-rata with the radius set or constrain $X_{polar shell}$ = $X_{core}$. 
     23 
     24.. note:: 
     25 
     26   When including an $S(q)$, the radius in $S(q)$ is calculated to be that of 
     27   a sphere with the same 2nd virial coefficient of the outer surface of the 
     28   ellipsoid. This may have some undesirable effects if the aspect ratio of the 
     29   ellipsoid is large (ie, if $X << 1$ or $X >> 1$), when the $S(q)$ 
     30   - which assumes spheres - will not in any case be valid.  Generating a 
     31   custom product model will enable separate effective volume fraction and 
     32   effective radius in the $S(q)$. 
    3033 
    3134If SAS data are in absolute units, and the SLDs are correct, then scale should 
     
    4346where 
    4447 
     48.. In following equation SK changed radius\_equat\_core to R_e 
    4549.. math:: 
    4650    :nowrap: 
    4751 
    4852    \begin{align*} 
    49     F(q,\alpha) = &f(q,radius\_equat\_core,radius\_equat\_core.x\_core,\alpha) \\ 
    50     &+ f(q,radius\_equat\_core + thick\_shell, 
    51          radius\_equat\_core.x\_core + thick\_shell.x\_polar\_shell,\alpha) 
     53    F(q,\alpha) = &f(q,R_e,R_e.x_{core},\alpha) \\ 
     54    &+ f(q,R_e + t_{shell}, 
     55         R_e.x_{core} + t_{shell}.x_{polar shell},\alpha) 
    5256    \end{align*} 
    5357 
     
    7175$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the 
    7276polar radius along the rotational axis of the ellipsoid, $R_e$ is the 
    73 equatorial radius perpendicular to the rotational axis of the ellipsoid 
    74 and $\Delta \rho$ (contrast) is the scattering length density difference, 
    75 either $(sld\_core - sld\_shell)$ or $(sld\_shell - sld\_solvent)$. 
     77equatorial radius perpendicular to the rotational axis of the ellipsoid, 
     78$t_{shell}$ is the thickness of the shell at the equator, 
     79and $\Delta \rho$ (the contrast) is the scattering length density difference, 
     80either $(\rho_{core} - \rho_{shell})$ or $(\rho_{shell} - \rho_{solvent})$. 
    7681 
    7782For randomly oriented particles: 
     
    104109* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    105110* **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 
    106 * **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016 
     111* **Last Reviewed by:** Steve King **Date:** March 27, 2019 
    107112* **Source added by :** Steve King **Date:** March 25, 2019 
    108113""" 
     
    155160source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] 
    156161have_Fq = True 
    157 effective_radius_type = [ 
     162radius_effective_modes = [ 
    158163    "average outer curvature", "equivalent volume sphere", 
    159164    "min outer radius", "max outer radius", 
  • sasmodels/models/core_shell_parallelepiped.c

    r99658f6 ra34b811  
    7575 
    7676static double 
    77 effective_radius(int mode, double length_a, double length_b, double length_c, 
     77radius_effective(int mode, double length_a, double length_b, double length_c, 
    7878                 double thick_rim_a, double thick_rim_b, double thick_rim_c) 
    7979{ 
  • sasmodels/models/core_shell_parallelepiped.py

    r0507e09 ra34b811  
    236236source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] 
    237237have_Fq = True 
    238 effective_radius_type = [ 
     238radius_effective_modes = [ 
    239239    "equivalent cylinder excluded volume", 
    240240    "equivalent volume sphere", 
  • sasmodels/models/core_shell_sphere.c

    rd42dd4a ra34b811  
    66 
    77static double 
    8 effective_radius(int mode, double radius, double thickness) 
     8radius_effective(int mode, double radius, double thickness) 
    99{ 
    1010    switch (mode) { 
  • sasmodels/models/core_shell_sphere.py

    r0507e09 ra34b811  
    6060---------------------------- 
    6161 
    62 * **Author:**  
    63 * **Last Modified by:**  
    64 * **Last Reviewed by:**  
     62* **Author:** 
     63* **Last Modified by:** 
     64* **Last Reviewed by:** 
    6565* **Source added by :** Steve King **Date:** March 25, 2019 
    6666""" 
     
    9292source = ["lib/sas_3j1x_x.c", "lib/core_shell.c", "core_shell_sphere.c"] 
    9393have_Fq = True 
    94 effective_radius_type = ["outer radius", "core radius"] 
     94radius_effective_modes = ["outer radius", "core radius"] 
    9595 
    9696demo = dict(scale=1, background=0, radius=60, thickness=10, 
  • sasmodels/models/cylinder.c

    r99658f6 ra34b811  
    3232 
    3333static double 
    34 effective_radius(int mode, double radius, double length) 
     34radius_effective(int mode, double radius, double length) 
    3535{ 
    3636    switch (mode) { 
  • sasmodels/models/cylinder.py

    r0507e09 ra34b811  
    110110---------------------------- 
    111111 
    112 * **Author:**  
    113 * **Last Modified by:**  
    114 * **Last Reviewed by:**  
     112* **Author:** 
     113* **Last Modified by:** 
     114* **Last Reviewed by:** 
    115115* **Source added by :** Steve King **Date:** March 25, 2019 
    116116""" 
     
    155155source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 
    156156have_Fq = True 
    157 effective_radius_type = [ 
     157radius_effective_modes = [ 
    158158    "excluded volume", "equivalent volume sphere", "radius", 
    159159    "half length", "half min dimension", "half max dimension", "half diagonal", 
     
    184184            phi_pd=10, phi_pd_n=5) 
    185185 
    186 # pylint: disable=bad-whitespace, line-too-long 
     186# Test 1-D and 2-D models 
    187187qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    188 # After redefinition of angles, find new tests values.  Was 10 10 in old coords 
     188theta, phi = 80.1534480601659, 10.1510817110481  # (10, 10) in sasview 3.x 
    189189tests = [ 
    190190    [{}, 0.2, 0.042761386790780453], 
    191191    [{}, [0.2], [0.042761386790780453]], 
    192     #  new coords 
    193     [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 
    194     [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 
    195     # old coords 
    196     #[{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
    197     #[{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
     192    [{'theta': theta, 'phi': phi}, (qx, qy), 0.03514647218513852], 
     193    [{'theta': theta, 'phi': phi}, [(qx, qy)], [0.03514647218513852]], 
    198194] 
    199 del qx, qy  # not necessary to delete, but cleaner 
    200  
    201 # Default radius and length 
    202 def calc_volume(radius, length): 
    203     """Return form volume for cylinder.""" 
    204     return pi*radius**2*length 
    205 def calc_r_effs(radius, length): 
    206     """Return effective radii for modes 0-7 of cylinder.""" 
    207     return [ 
     195del qx, qy, theta, phi  # not necessary to delete, but cleaner 
     196 
     197def _extend_with_reff_tests(radius, length): 
     198    """Test R_eff and form volume calculations""" 
     199    # V and Vr are the same for each R_eff mode 
     200    V = pi*radius**2*length  # shell volume = form volume for solid objects 
     201    Vr = 1.0  # form:shell volume ratio 
     202    # Use test value for I(0.2) from above to check Fsq value.  Need to 
     203    # remove scale and background before testing. 
     204    q = 0.2 
     205    scale, background = V, 0.001 
     206    Fsq = (0.042761386790780453 - background)*scale 
     207    F = None  # Need target value for <F> 
     208    # Various values for R_eff, depending on mode 
     209    r_effs = [ 
    208210        0., 
    209211        0.5*(0.75*radius*(2.0*radius*length 
     
    216218        np.sqrt(4*radius**2 + length**2)/2., 
    217219    ] 
    218 r_effs = calc_r_effs(parameters[2][2], parameters[3][2]) 
    219 cyl_vol = calc_volume(parameters[2][2], parameters[3][2]) 
    220 tests.extend([ 
    221     ({'radius_effective_mode': 0}, 0.1, None, None, r_effs[0], cyl_vol, 1.0), 
    222     ({'radius_effective_mode': 1}, 0.1, None, None, r_effs[1], None, None), 
    223     ({'radius_effective_mode': 2}, 0.1, None, None, r_effs[2], None, None), 
    224     ({'radius_effective_mode': 3}, 0.1, None, None, r_effs[3], None, None), 
    225     ({'radius_effective_mode': 4}, 0.1, None, None, r_effs[4], None, None), 
    226     ({'radius_effective_mode': 5}, 0.1, None, None, r_effs[5], None, None), 
    227     ({'radius_effective_mode': 6}, 0.1, None, None, r_effs[6], None, None), 
    228     ({'radius_effective_mode': 7}, 0.1, None, None, r_effs[7], None, None), 
    229 ]) 
    230 del r_effs, cyl_vol 
    231 # pylint: enable=bad-whitespace, line-too-long 
     220    tests.extend([ 
     221        ({'radius_effective_mode': 0}, q, F, Fsq, r_effs[0], V, Vr), 
     222        ({'radius_effective_mode': 1}, q, F, Fsq, r_effs[1], V, Vr), 
     223        ({'radius_effective_mode': 2}, q, F, Fsq, r_effs[2], V, Vr), 
     224        ({'radius_effective_mode': 3}, q, F, Fsq, r_effs[3], V, Vr), 
     225        ({'radius_effective_mode': 4}, q, F, Fsq, r_effs[4], V, Vr), 
     226        ({'radius_effective_mode': 5}, q, F, Fsq, r_effs[5], V, Vr), 
     227        ({'radius_effective_mode': 6}, q, F, Fsq, r_effs[6], V, Vr), 
     228        ({'radius_effective_mode': 7}, q, F, Fsq, r_effs[7], V, Vr), 
     229    ]) 
     230 
     231# Test Reff and volume with default model parameters 
     232_extend_with_reff_tests(parameters[2][2], parameters[3][2]) 
     233del _extend_with_reff_tests 
    232234 
    233235# ADDED by:  RKH  ON: 18Mar2016 renamed sld's etc 
  • sasmodels/models/ellipsoid.c

    r99658f6 ra34b811  
    3232 
    3333static double 
    34 effective_radius(int mode, double radius_polar, double radius_equatorial) 
     34radius_effective(int mode, double radius_polar, double radius_equatorial) 
    3535{ 
    3636    switch (mode) { 
  • sasmodels/models/ellipsoid.py

    r0507e09 ra34b811  
    167167source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"] 
    168168have_Fq = True 
    169 effective_radius_type = [ 
     169radius_effective_modes = [ 
    170170    "average curvature", "equivalent volume sphere", "min radius", "max radius", 
    171171    ] 
  • sasmodels/models/elliptical_cylinder.c

    r99658f6 ra34b811  
    4141 
    4242static double 
    43 effective_radius(int mode, double radius_minor, double r_ratio, double length) 
     43radius_effective(int mode, double radius_minor, double r_ratio, double length) 
    4444{ 
    4545    switch (mode) { 
  • sasmodels/models/elliptical_cylinder.py

    r0507e09 ra34b811  
    131131source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "elliptical_cylinder.c"] 
    132132have_Fq = True 
    133 effective_radius_type = [ 
     133radius_effective_modes = [ 
    134134    "equivalent cylinder excluded volume", 
    135135    "equivalent volume sphere", "average radius", "min radius", "max radius", 
  • sasmodels/models/flexible_cylinder.py

    r598a354 r830cf6b  
    3333and solvent respectively. 
    3434 
    35 Our model uses the form factor calculations implemented in a c-library provided 
    36 by the NIST Center for Neutron Research (Kline, 2006). This states: 
     35Our model uses the form factor calculations in reference [1] as implemented in a 
     36c-library provided by the NIST Center for Neutron Research (Kline, 2006). This states: 
    3737 
    3838    'Method 3 With Excluded Volume' is used. 
     
    4242    See equations (13,26-27) in the original reference for the details. 
    4343 
     44.. note:: 
     45 
     46    There are several typos in the original reference that have been corrected 
     47    by WRC [2]. Details of the corrections are in the reference below. Most notably 
     48 
     49    - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ 
     50 
     51    - Equations (23) and (24) are incorrect; WRC has entered these into 
     52      Mathematica and solved analytically. The results were then converted to 
     53      code. 
     54 
     55    - Equation (27) should be $q0 = max(a3/(Rg^2)^{1/2},3)$ instead of 
     56      $max(a3*b(Rg^2)^{1/2},3)$ 
     57 
     58    - The scattering function is negative for a range of parameter values and 
     59      q-values that are experimentally accessible. A correction function has been 
     60      added to give the proper behavior. 
     61 
     62 
     63**This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 
     64reader is strongly encouraged to read reference [1] before use.** 
     65 
     66.. note:: 
     67 
     68    There are several typos in the original reference that have been corrected 
     69    by WRC [2]. Details of the corrections are in the reference below. Most notably 
     70 
     71    - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ 
     72 
     73    - Equations (23) and (24) are incorrect; WRC has entered these into 
     74      Mathematica and solved analytically. The results were then converted to 
     75      code. 
     76 
     77    - Equation (27) should be $q0 = max(a3/(Rg^2)^{1/2},3)$ instead of 
     78      $max(a3*b(Rg^2)^{1/2},3)$ 
     79 
     80    - The scattering function is negative for a range of parameter values and 
     81      q-values that are experimentally accessible. A correction function has been 
     82      added to give the proper behavior. 
     83 
     84 
     85**This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 
     86reader is strongly encouraged to read reference [1] before use.** 
     87 
    4488References 
    4589---------- 
     
    58102`flexible_cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder.c>`_ 
    59103 
     104`wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ 
     105 
    60106Authorship and Verification 
    61107---------------------------- 
    62108 
    63 * **Author:**  
    64 * **Last Modified by:**  
    65 * **Last Reviewed by:**  
     109* **Author:** 
     110* **Last Modified by:** 
     111* **Last Reviewed by:** Steve King **Date:** March 26, 2019 
    66112* **Source added by :** Steve King **Date:** March 25, 2019 
    67113""" 
  • sasmodels/models/flexible_cylinder_elliptical.py

    r598a354 rdb1d9d5  
    44The non-negligible diameter of the cylinder is included by accounting 
    55for excluded volume interactions within the walk of a single cylinder. 
     6**Inter-cylinder interactions are NOT provided for.** 
     7 
    68The form factor is normalized by the particle volume such that 
    79 
     
    2426----------- 
    2527 
    26 The function calculated in a similar way to that for the flexible_cylinder model 
    27 from the reference given below using the author's "Method 3 With Excluded Volume". 
     28The function is calculated in a similar way to that for the 
     29:ref:`flexible-cylinder` model in reference [1] below using the author's 
     30"Method 3 With Excluded Volume". 
     31 
    2832The model is a parameterization of simulations of a discrete representation of 
    2933the worm-like chain model of Kratky and Porod applied in the pseudo-continuous 
     
    3337 
    3438    There are several typos in the original reference that have been corrected 
    35     by WRC. Details of the corrections are in the reference below. Most notably 
     39    by WRC [2]. Details of the corrections are in the reference below. Most notably 
    3640 
    3741    - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ 
     
    4145      code. 
    4246 
    43     - Equation (27) should be $q0 = max(a3/sqrt(RgSquare),3)$ instead of 
    44       $max(a3*b/sqrt(RgSquare),3)$ 
     47    - Equation (27) should be $q0 = max(a3/(Rg^2)^{1/2},3)$ instead of 
     48      $max(a3*b(Rg^2)^{1/2},3)$ 
    4549 
    4650    - The scattering function is negative for a range of parameter values and 
     
    5862 
    5963The cross section of the cylinder is elliptical, with minor radius $a$ . 
    60 The major radius is larger, so of course, **the axis ratio (parameter 5) must be 
     64The major radius is larger, so of course, **the axis_ratio must be 
    6165greater than one.** Simple constraints should be applied during curve fitting to 
    6266maintain this inequality. 
     
    6771these parameters must be held fixed during model fitting. 
    6872 
    69 **No inter-cylinder interference effects are included in this calculation.** 
     73**This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 
     74reader is strongly encouraged to read reference [1] before use.** 
    7075 
    7176References 
     
    8590`flexible_cylinder_elliptical.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder_elliptical.c>`_ 
    8691 
     92`wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ 
     93 
    8794Authorship and Verification 
    8895---------------------------- 
    8996 
    90 * **Author:**  
    91 * **Last Modified by:**  
    92 * **Last Reviewed by:**  
     97* **Author:** 
     98* **Last Modified by:** Richard Heenan **Date:** December, 2016 
     99* **Last Reviewed by:** Steve King **Date:** March 26, 2019 
    93100* **Source added by :** Steve King **Date:** March 25, 2019 
    94101""" 
  • sasmodels/models/fuzzy_sphere.c

    rd42dd4a ra34b811  
    55 
    66static double 
    7 effective_radius(int mode, double radius, double fuzziness) 
     7radius_effective(int mode, double radius, double fuzziness) 
    88{ 
    99    switch (mode) { 
  • sasmodels/models/fuzzy_sphere.py

    r0507e09 ra34b811  
    6363---------------------------- 
    6464 
    65 * **Author:**  
    66 * **Last Modified by:**  
    67 * **Last Reviewed by:**  
     65* **Author:** 
     66* **Last Modified by:** 
     67* **Last Reviewed by:** 
    6868* **Source added by :** Steve King **Date:** March 25, 2019 
    6969""" 
     
    9898source = ["lib/sas_3j1x_x.c", "fuzzy_sphere.c"] 
    9999have_Fq = True 
    100 effective_radius_type = ["radius", "radius + fuzziness"] 
     100radius_effective_modes = ["radius", "radius + fuzziness"] 
    101101 
    102102def random(): 
  • sasmodels/models/guinier_porod.py

    r0507e09 r7a5f8af  
    55such as rods or platelets, and shapes intermediate between spheres 
    66and rods or between rods and platelets, and overcomes some of the 
    7 deficiencies of the (Beaucage) Unified_Power_Rg model (see Hammouda, 2010). 
     7deficiencies of the (Beaucage) :ref:`unified-power-rg` model (see Hammouda, 2010). 
    88 
    99Definition 
  • sasmodels/models/hardsphere.py

    r0507e09 r4d00de6  
    11# Note: model title and parameter table are inserted automatically 
    2 r"""Calculate the interparticle structure factor for monodisperse 
     2r""" 
     3Calculates the interparticle structure factor for monodisperse 
    34spherical particles interacting through hard sphere (excluded volume) 
    4 interactions. 
    5 May be a reasonable approximation for other shapes of particles that 
    6 freely rotate, and for moderately polydisperse systems. Though strictly 
    7 the maths needs to be modified (no \Beta(Q) correction yet in sasview). 
     5interactions. This $S(q)$ may also be a reasonable approximation for 
     6other particle shapes that freely rotate (but see the note below), 
     7and for moderately polydisperse systems. 
     8 
     9.. note:: 
     10 
     11   This routine is intended for uncharged particles! For charged 
     12   particles try using the :ref:`hayter-msa` $S(q)$ instead. 
     13 
     14.. note:: 
     15 
     16   Earlier versions of SasView did not incorporate the so-called 
     17   $\beta(q)$ ("beta") correction [1] for polydispersity and non-sphericity. 
     18   This is only available in SasView versions 5.0 and higher. 
    819 
    920radius_effective is the effective hard sphere radius. 
    1021volfraction is the volume fraction occupied by the spheres. 
    1122 
    12 In sasview the effective radius may be calculated from the parameters 
     23In SasView the effective radius may be calculated from the parameters 
    1324used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    1425 
    1526For numerical stability the computation uses a Taylor series expansion 
    16 at very small $qR$, there may be a very minor glitch at the transition point 
    17 in some circumstances. 
     27at very small $qR$, but there may be a very minor glitch at the 
     28transition point in some circumstances. 
    1829 
    19 The S(Q) uses the Percus-Yevick closure where the interparticle 
    20 potential is 
     30This S(q) uses the Percus-Yevick closure relationship [2] where the 
     31interparticle potential $U(r)$ is 
    2132 
    2233.. math:: 
     
    2738    \end{cases} 
    2839 
    29 where $r$ is the distance from the center of the sphere of a radius $R$. 
     40where $r$ is the distance from the center of a sphere of a radius $R$. 
    3041 
    3142For a 2D plot, the wave transfer is defined as 
     
    3950---------- 
    4051 
     52.. [#] M Kotlarchyk & S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 
     53 
    4154.. [#] J K Percus, J Yevick, *J. Phys. Rev.*, 110, (1958) 1 
    4255 
     
    4962---------------------------- 
    5063 
    51 * **Author:**  
    52 * **Last Modified by:**  
    53 * **Last Reviewed by:**  
     64* **Author:** 
     65* **Last Modified by:** 
     66* **Last Reviewed by:** 
    5467* **Source added by :** Steve King **Date:** March 25, 2019 
    5568""" 
     
    6376    [Hard sphere structure factor, with Percus-Yevick closure] 
    6477        Interparticle S(Q) for random, non-interacting spheres. 
    65     May be a reasonable approximation for other shapes of 
    66     particles that freely rotate, and for moderately polydisperse 
    67         systems. Though strictly the maths needs to be modified - 
    68     which sasview does not do yet. 
     78    May be a reasonable approximation for other particle shapes 
     79    that freely rotate, and for moderately polydisperse systems 
     80    . The "beta(q)" correction is available in versions 4.2.2 
     81    and higher. 
    6982    radius_effective is the hard sphere radius 
    7083    volfraction is the volume fraction occupied by the spheres. 
  • sasmodels/models/hayter_msa.py

    r0507e09 r4d00de6  
    11# Note: model title and parameter table are inserted automatically 
    22r""" 
    3 This calculates the structure factor (the Fourier transform of the pair 
    4 correlation function $g(r)$) for a system of charged, spheroidal objects 
    5 in a dielectric medium. When combined with an appropriate form factor 
    6 (such as sphere, core+shell, ellipsoid, etc), this allows for inclusion 
    7 of the interparticle interference effects due to screened coulomb repulsion 
    8 between charged particles. 
     3Calculates the interparticle structure factor for a system of charged, 
     4spheroidal, objects in a dielectric medium [1,2]. When combined with an 
     5appropriate form factor $P(q)$, this allows for inclusion of the 
     6interparticle interference effects due to screened Coulombic 
     7repulsion between the charged particles. 
    98 
    10 **This routine only works for charged particles**. If the charge is set to 
    11 zero the routine may self-destruct! For non-charged particles use a hard 
    12 sphere potential. 
     9.. note:: 
     10 
     11   This routine only works for charged particles! If the charge is set 
     12   to zero the routine may self-destruct! For uncharged particles use 
     13   the :ref:`hardsphere` $S(q)$ instead. The upper limit for the charge 
     14   is limited to 200e to avoid numerical instabilities. 
     15 
     16.. note:: 
     17 
     18   Earlier versions of SasView did not incorporate the so-called 
     19   $\beta(q)$ ("beta") correction [3] for polydispersity and non-sphericity. 
     20   This is only available in SasView versions 5.0 and higher. 
    1321 
    1422The salt concentration is used to compute the ionic strength of the solution 
    15 which in turn is used to compute the Debye screening length. At present 
    16 there is no provision for entering the ionic strength directly nor for use 
    17 of any multivalent salts, though it should be possible to simulate the effect 
    18 of this by increasing the salt concentration. The counterions are also 
    19 assumed to be monovalent. 
     23which in turn is used to compute the Debye screening length. There is no 
     24provision for entering the ionic strength directly. **At present the 
     25counterions are assumed to be monovalent**, though it should be possible 
     26to simulate the effect of multivalent counterions by increasing the salt 
     27concentration. 
    2028 
    21 In sasview the effective radius may be calculated from the parameters 
     29Over the range 0 - 100 C the dielectric constant $\kappa$ of water may be 
     30approximated with a maximum deviation of 0.01 units by the empirical 
     31formula [4] 
     32 
     33.. math:: 
     34 
     35    \kappa = 87.740 - 0.40008 T + 9.398x10^{-4} T^2 - 1.410x10^{-6} T^3 
     36 
     37where $T$ is the temperature in celsius. 
     38 
     39In SasView the effective radius may be calculated from the parameters 
    2240used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    2341 
     
    3856 
    3957.. [#] J B Hayter and J Penfold, *Molecular Physics*, 42 (1981) 109-118 
     58 
    4059.. [#] J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 
     60 
     61.. [#] M Kotlarchyk and S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 
     62 
     63.. [#] C G Malmberg and A A Maryott, *J. Res. Nat. Bureau Standards*, 56 (1956) 2641 
    4164 
    4265Source 
     
    5073---------------------------- 
    5174 
    52 * **Author:**  
    53 * **Last Modified by:**  
    54 * **Last Reviewed by:**  
     75* **Author:** 
     76* **Last Modified by:** 
     77* **Last Reviewed by:** Steve King **Date:** March 28, 2019 
    5578* **Source added by :** Steve King **Date:** March 25, 2019 
    5679""" 
     
    7497 
    7598name = "hayter_msa" 
    76 title = "Hayter-Penfold rescaled MSA, charged sphere, interparticle S(Q) structure factor" 
     99title = "Hayter-Penfold Rescaled Mean Spherical Approximation (RMSA) structure factor for charged spheres" 
    77100description = """\ 
    78101    [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor] 
    79         Interparticle structure factor S(Q)for a charged hard spheres. 
    80         Routine takes absolute value of charge, use HardSphere if charge 
    81         goes to zero. 
    82         In sasview the effective radius and volume fraction may be calculated 
    83         from the parameters used in P(Q). 
     102        Interparticle structure factor S(Q) for charged hard spheres. 
     103    This routine only works for charged particles! For uncharged particles 
     104    use the hardsphere S(q) instead. The "beta(q)" correction is available 
     105    in versions 4.2.2 and higher. 
    84106""" 
    85107 
     
    87109# pylint: disable=bad-whitespace, line-too-long 
    88110#             [ "name", "units", default, [lower, upper], "type", "description" ], 
     111# 
     112# NOTE: SMK, 28Mar19 The upper limit for charge is set to 200 to avoid instabilities noted by PK in 
     113#       Ticket #1152. Also see the thread in Ticket 859. The docs above also note that charge=0 will 
     114#       cause problems, yet the default parameters allowed it! After discussions with PK I have 
     115#       changed it to (an arbitarily) small but non-zero value.  But I haven't changed the low limit 
     116#       in function random() below. 
     117# 
    89118parameters = [ 
    90119    ["radius_effective", "Ang", 20.75,   [0, inf],    "volume", "effective radius of charged sphere"], 
    91120    ["volfraction",   "None",     0.0192, [0, 0.74],   "", "volume fraction of spheres"], 
    92     ["charge",        "e",   19.0,    [0, 200],    "", "charge on sphere (in electrons)"], 
     121    ["charge",        "e",   19.0,    [0.000001, 200],    "", "charge on sphere (in electrons)"], 
    93122    ["temperature",   "K",  318.16,   [0, 450],    "", "temperature, in Kelvin, for Debye length calculation"], 
    94123    ["concentration_salt",      "M",    0.0,    [0, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 
    95     ["dielectconst",  "None",    71.08,   [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] 
     124    ["dielectconst",  "None",    71.08,   [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, kappa, default water, for Debye length"] 
    96125    ] 
    97126# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/hollow_cylinder.c

    r99658f6 ra34b811  
    3434 
    3535static double 
    36 effective_radius(int mode, double radius, double thickness, double length) 
     36radius_effective(int mode, double radius, double thickness, double length) 
    3737{ 
    3838    switch (mode) { 
  • sasmodels/models/hollow_cylinder.py

    r0507e09 ra34b811  
    110110source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 
    111111have_Fq = True 
    112 effective_radius_type = [ 
     112radius_effective_modes = [ 
    113113    "excluded volume", "equivalent outer volume sphere", 
    114114    "outer radius", "half length", 
  • sasmodels/models/hollow_rectangular_prism.c

    r99658f6 ra34b811  
    3030 
    3131static double 
    32 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio, double thickness) 
     32radius_effective(int mode, double length_a, double b2a_ratio, double c2a_ratio, double thickness) 
    3333// NOTE length_a is external dimension! 
    3434{ 
  • sasmodels/models/hollow_rectangular_prism.py

    r0507e09 ra34b811  
    157157source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 
    158158have_Fq = True 
    159 effective_radius_type = [ 
     159radius_effective_modes = [ 
    160160    "equivalent cylinder excluded volume", "equivalent outer volume sphere", 
    161161    "half length_a", "half length_b", "half length_c", 
  • sasmodels/models/hollow_rectangular_prism_thin_walls.c

    r99658f6 ra34b811  
    2626 
    2727static double 
    28 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
     28radius_effective(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
    2929{ 
    3030    switch (mode) { 
  • sasmodels/models/hollow_rectangular_prism_thin_walls.py

    r0507e09 ra34b811  
    117117source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] 
    118118have_Fq = True 
    119 effective_radius_type = [ 
     119radius_effective_modes = [ 
    120120    "equivalent cylinder excluded volume", "equivalent outer volume sphere", 
    121121    "half length_a", "half length_b", "half length_c", 
  • sasmodels/models/lib/wrc_cyl.c

    r18a2bfc rdb1c84b  
    11/* 
    2     Functions for WRC implementation of flexible cylinders 
     2    Functions for WRC implementation of flexible cylinders. See 
     3    W R Chen, P D Butler and L J Magid, 
     4    Incorporating Intermicellar Interactions in the Fitting of 
     5    SANS Data from Cationic Wormlike Micelles. 
     6    Langmuir, 22(15) 2006 6539-6548 
    37*/ 
    48 
  • sasmodels/models/mono_gauss_coil.c

    r153f8f6 ra34b811  
    66 
    77static double 
    8 effective_radius(int mode, double rg) 
     8radius_effective(int mode, double rg) 
    99{ 
    1010    switch (mode) { 
  • sasmodels/models/mono_gauss_coil.py

    r0507e09 ra34b811  
    5959---------------------------- 
    6060 
    61 * **Author:**  
    62 * **Last Modified by:**  
    63 * **Last Reviewed by:**  
     61* **Author:** 
     62* **Last Modified by:** 
     63* **Last Reviewed by:** 
    6464* **Source added by :** Steve King **Date:** March 25, 2019""" 
    6565 
     
    8686source = ["mono_gauss_coil.c"] 
    8787have_Fq = False 
    88 effective_radius_type = ["R_g", "2R_g", "3R_g", "sqrt(5/3)*R_g"] 
     88radius_effective_modes = ["R_g", "2R_g", "3R_g", "sqrt(5/3)*R_g"] 
    8989 
    9090 
  • sasmodels/models/multilayer_vesicle.c

    ree60aa7 ra34b811  
    4848 
    4949static double 
    50 effective_radius(int mode, double radius, double thick_shell, double thick_solvent, double fp_n_shells) 
     50radius_effective(int mode, double radius, double thick_shell, double thick_solvent, double fp_n_shells) 
    5151{ 
    5252    // case 1: outer radius 
  • sasmodels/models/multilayer_vesicle.py

    r0507e09 rdb1d9d5  
    113113* **Converted to sasmodels by:** Piotr Rozyczko **Date:** Feb 24, 2016 
    114114* **Last Modified by:** Paul Kienzle **Date:** Feb 7, 2017 
    115 * **Last Reviewed by:** Paul Butler **Date:** March 12, 2017 
     115* **Last Reviewed by:** Steve King **Date:** March 28, 2019 
    116116* **Source added by :** Steve King **Date:** March 25, 2019 
    117117""" 
     
    121121 
    122122name = "multilayer_vesicle" 
    123 title = "P(Q) for a Multi-lamellar vesicle" 
     123title = "Calculate form factor for a multi-lamellar vesicle" 
    124124description = """ 
    125125    multilayer_vesicle model parameters; 
     
    145145    ["sld_solvent",    "1e-6/Ang^2",  6.4, [-inf, inf], "sld", "solvent scattering length density"], 
    146146    ["sld",   "1e-6/Ang^2",  0.4, [-inf, inf], "sld", "Shell scattering length density"], 
    147     ["n_shells",     "",            2.0, [1.0, inf],  "volume", "Number of shell plus solvent layer pairs"], 
     147    ["n_shells",     "",            2.0, [1.0, inf],  "volume", "Number of shell plus solvent layer pairs (must be integer)"], 
    148148    ] 
    149149# pylint: enable=bad-whitespace, line-too-long 
     
    154154source = ["lib/sas_3j1x_x.c", "multilayer_vesicle.c"] 
    155155have_Fq = True 
    156 effective_radius_type = ["outer radius"] 
     156radius_effective_modes = ["outer radius"] 
    157157 
    158158def random(): 
  • sasmodels/models/onion.c

    ree60aa7 ra34b811  
    4747 
    4848static double 
    49 effective_radius(int mode, double radius_core, double n_shells, double thickness[]) 
     49radius_effective(int mode, double radius_core, double n_shells, double thickness[]) 
    5050{ 
    5151  // case 1: outer radius 
  • sasmodels/models/onion.py

    r0507e09 rdb1d9d5  
    66solvent. We currently provide up to 9 shells with this model. 
    77 
    8 NB: *radius* represents the core radius $r_0$ and 
    9 *thickness[k]* represents the thickness of the shell, $r_{k+1} - r_k$. 
     8.. note:: 
     9 
     10    *radius* represents the core radius $r_0$ and *thickness[k]* represents 
     11    the thickness of the shell, $r_{k+1} - r_k$. 
    1012 
    1113Definition 
     
    5658    j_1(x) = \frac{\sin(x)}{x^2} - \frac{\cos(x)}{x} 
    5759 
    58 and the volume is $V(r) = \frac{4\pi}{3}r^3$. The volume of the particle 
    59 is determined by the radius of the outer shell, so $V_\text{particle} = V(r_N)$. 
    60  
    61 Now lets consider the SLD of a shell defined by 
     60and the volume is $V(r) = \frac{4\pi}{3}r^3$. 
     61 
     62The volume of the particle is determined by the radius of the outer 
     63shell, so $V_\text{particle} = V(r_N)$. 
     64 
     65Now consider the SLD of a shell defined by 
    6266 
    6367.. math:: 
     
    7478thickness of the $k^\text{th}$ shell in the equation above, respectively. 
    7579 
    76 For $A > 0$, 
     80.. figure:: img/onion_geometry.png 
     81 
     82    Example of an onion model profile. 
     83 
     84 
     85**Exponential SLD profiles** ($A > 0$ or $A < 0$): 
    7786 
    7887.. math:: 
     
    8796        - 3CV(r_{\text{shell}-1}) \frac{j_1(\beta_\text{in})}{\beta_\text{in}} 
    8897 
    89 for 
     98where 
    9099 
    91100.. math:: 
     
    95104    B&=\frac{\rho_\text{out} - \rho_\text{in}}{e^A-1} 
    96105         & C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\ 
     106 
    97107    \alpha_\text{in} &= A\frac{r_{\text{shell}-1}}{\Delta t_\text{shell}} 
    98108         & \alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\ 
     109 
    99110    \beta_\text{in} &= qr_{\text{shell}-1} 
    100111        & \beta_\text{out} &= qr_\text{shell} \\ 
    101112    \end{align*} 
    102113 
    103 where $h$ is 
     114and 
    104115 
    105116 .. math:: 
    106117 
    107     h(x,y) = \frac{x \sin(y) - y\cos(y)}{(x^2+y^2)y} 
     118     h(x,y) = \frac{x \sin(y) - y\cos(y)}{(x^2+y^2)y} 
    108119               - \frac{(x^2-y^2)\sin(y) - 2xy\cos(y)}{(x^2+y^2)^2y} 
    109120 
    110121 
    111 For $A \sim 0$, e.g., $A = -0.0001$, this function converges to that of the 
    112 linear SLD profile with 
    113 $\rho_\text{shell}(r) \approx A(r-r_{\text{shell}-1})/\Delta t_\text{shell})+B$, 
    114 so this case is equivalent to 
     122 
     123**Linear SLD profile** ($A \sim 0$): 
     124 
     125For small $A$, say, $A = -0.0001$, the function converges to that of of a linear 
     126SLD profile with 
     127 
     128     $\rho_\text{shell}(r) \approx A(r-r_{\text{shell}-1})/\Delta t_\text{shell})+B$, 
     129 
     130which is equivalent to 
    115131 
    116132.. math:: 
     
    140156    \end{align*} 
    141157 
    142 For $A = 0$, the exponential function has no dependence on the radius (so that 
     158 
     159**Constant SLD** ($A = 0$): 
     160 
     161When $A = 0$ the exponential function has no dependence on the radius (meaning 
    143162$\rho_\text{out}$ is ignored in this case) and becomes flat. We set the constant 
    144163to $\rho_\text{in}$ for convenience, and thus the form factor contributed by 
     
    153172            \frac{j_1(qr_\text{in})}{qr_\text{in}} 
    154173 
    155 .. figure:: img/onion_geometry.png 
    156  
    157     Example of an onion model profile. 
    158  
    159174The 2D scattering intensity is the same as $P(q)$ above, regardless of the 
    160175orientation of the $q$ vector which is defined as 
     
    182197---------------------------- 
    183198 
    184 * **Author:**  
    185 * **Last Modified by:**  
    186 * **Last Reviewed by:**  
     199* **Author:** 
     200* **Last Modified by:** 
     201* **Last Reviewed by:** Steve King **Date:** March 28, 2019 
    187202* **Source added by :** Steve King **Date:** March 25, 2019 
    188203""" 
     
    284299 
    285300description = """\ 
    286 Form factor of mutishells normalized by the volume. Here each shell is 
     301Form factor of multishells normalized by the volume. Here each shell is 
    287302described by an exponential function; 
    288303 
     
    297312        II) For the exact point of A_shell == 0, 
    298313                f(r) = sld_in ,i.e., it crosses over flat function 
    299         Note that the 'sld_out' becaomes NULL in this case. 
     314        Note that the 'sld_out' becomes NULL in this case. 
    300315 
    301316        background:background, 
     
    312327# TODO: n is a volume parameter that is not polydisperse 
    313328 
     329# NOTE: Joachim Wuttke has suggested an alternative parameterisation 
     330#       in Ticket #1107 
     331 
    314332# pylint: disable=bad-whitespace, line-too-long 
    315333#   ["name", "units", default, [lower, upper], "type","description"], 
     
    318336    ["radius_core", "Ang", 200., [0, inf], "volume", "Radius of the core"], 
    319337    ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", "Solvent scattering length density"], 
    320     ["n_shells", "", 1, [0, 10], "volume", "number of shells"], 
     338    ["n_shells", "", 1, [0, 10], "volume", "number of shells (must be integer)"], 
    321339    ["sld_in[n_shells]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", "scattering length density at the inner radius of shell k"], 
    322340    ["sld_out[n_shells]", "1e-6/Ang^2", 2.0, [-inf, inf], "sld", "scattering length density at the outer radius of shell k"], 
     
    329347single = False 
    330348have_Fq = True 
    331 effective_radius_type = ["outer radius"] 
     349radius_effective_modes = ["outer radius"] 
    332350 
    333351profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] 
  • sasmodels/models/parallelepiped.c

    r99658f6 ra34b811  
    3737 
    3838static double 
    39 effective_radius(int mode, double length_a, double length_b, double length_c) 
     39radius_effective(int mode, double length_a, double length_b, double length_c) 
    4040{ 
    4141    switch (mode) { 
  • sasmodels/models/parallelepiped.py

    r0507e09 ra34b811  
    240240source = ["lib/gauss76.c", "parallelepiped.c"] 
    241241have_Fq = True 
    242 effective_radius_type = [ 
     242radius_effective_modes = [ 
    243243    "equivalent cylinder excluded volume", "equivalent volume sphere", 
    244244    "half length_a", "half length_b", "half length_c", 
  • sasmodels/models/pearl_necklace.c

    r9b5fd42 ra34b811  
    8686 
    8787static double 
    88 effective_radius(int mode, double radius, double edge_sep, double thick_string, double fp_num_pearls) 
     88radius_effective(int mode, double radius, double edge_sep, double thick_string, double fp_num_pearls) 
    8989{ 
    9090    switch (mode) { 
  • sasmodels/models/pearl_necklace.py

    r0507e09 rdb1d9d5  
    2525.. math:: 
    2626 
    27     S_{ss}(q) &= sm_s^2\psi^2(q)[\frac{N}{1-sin(qA)/qA}-\frac{N}{2}- 
    28         \frac{1-(sin(qA)/qA)^N}{(1-sin(qA)/qA)^2}\cdot\frac{sin(qA)}{qA}] \\ 
    29     S_{ff}(q) &= sm_r^2[M\{2\Lambda(q)-(\frac{sin(ql/2)}{ql/2})\}+ 
     27    S_{ss}(q) &= 2m_s^2\psi^2(q)\left[\frac{N}{1-sin(qA)/qA}-\frac{N}{2}- 
     28        \frac{1-(sin(qA)/qA)^N}{(1-sin(qA)/qA)^2}\cdot\frac{sin(qA)}{qA}\right] \\ 
     29    S_{ff}(q) &= m_r^2\left[M\left\{2\Lambda(q)-\left(\frac{sin(ql/2)}{ql/2}\right)\right\}+ 
    3030        \frac{2M\beta^2(q)}{1-sin(qA)/qA}-2\beta^2(q)\cdot 
    31         \frac{1-(sin(qA)/qA)^M}{(1-sin(qA)/qA)^2}] \\ 
    32     S_{fs}(q) &= m_r \beta (q) \cdot m_s \psi (q) \cdot 4[ 
     31        \frac{1-(sin(qA)/qA)^M}{(1-sin(qA)/qA)^2}\right] \\ 
     32    S_{fs}(q) &= m_r \beta (q) \cdot m_s \psi (q) \cdot 4\left[ 
    3333        \frac{N-1}{1-sin(qA)/qA}-\frac{1-(sin(qA)/qA)^{N-1}}{(1-sin(qA)/qA)^2} 
    34         \cdot \frac{sin(qA)}{qA}] \\ 
     34        \cdot \frac{sin(qA)}{qA}\right] \\ 
    3535    \psi(q) &= 3 \cdot \frac{sin(qR)-(qR)\cdot cos(qR)}{(qR)^3} \\ 
    3636    \Lambda(q) &= \frac{\int_0^{ql}\frac{sin(t)}{t}dt}{ql} \\ 
     
    4040(volume of the *N* pearls/rods). *V* is the total volume of the necklace. 
    4141 
     42.. note:: 
     43 
     44   *num_pearls* must be an integer. 
     45 
    4246The 2D scattering intensity is the same as $P(q)$ above, regardless of the 
    4347orientation of the *q* vector. 
    44  
    45 The returned value is scaled to units of |cm^-1| and the parameters of the 
    46 pearl_necklace model are the following 
    47  
    48 NB: *num_pearls* must be an integer. 
    4948 
    5049References 
     
    5251 
    5352.. [#] R Schweins and K Huber, *Particle Scattering Factor of Pearl Necklace Chains*, 
    54 *Macromol. Symp.* 211 (2004) 25-42 2004 
     53       *Macromol. Symp.* 211 (2004) 25-42 2004 
     54 
    5555.. [#] L. Onsager, *Ann. New York Acad. Sci.*, 51 (1949) 627-659 
    5656 
     
    6565---------------------------- 
    6666 
    67 * **Author:**  
    68 * **Last Modified by:**  
    69 * **Last Reviewed by:**  
     67* **Author:** 
     68* **Last Modified by:** Andrew Jackson **Date:** March 28, 2019 
     69* **Last Reviewed by:** Steve King **Date:** March 28, 2019 
    7070* **Source added by :** Steve King **Date:** March 25, 2019 
    7171""" 
     
    111111source = ["lib/sas_Si.c", "lib/sas_3j1x_x.c", "pearl_necklace.c"] 
    112112single = False  # use double precision unless told otherwise 
    113 effective_radius_type = ["equivalent volume sphere"] 
     113radius_effective_modes = ["equivalent volume sphere"] 
    114114 
    115115def random(): 
  • sasmodels/models/poly_gauss_coil.py

    r0507e09 ra34b811  
    5858---------------------------- 
    5959 
    60 * **Author:**  
    61 * **Last Modified by:**  
    62 * **Last Reviewed by:**  
     60* **Author:** 
     61* **Last Modified by:** 
     62* **Last Reviewed by:** 
    6363* **Source added by :** Steve King **Date:** March 25, 2019 
    6464""" 
  • sasmodels/models/pringle.c

    r99658f6 ra34b811  
    111111 
    112112static double 
    113 effective_radius(int mode, double radius, double thickness, double alpha, double beta) 
     113radius_effective(int mode, double radius, double thickness, double alpha, double beta) 
    114114{ 
    115115    switch (mode) { 
  • sasmodels/models/pringle.py

    r0507e09 ra34b811  
    8585source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", 
    8686          "lib/sas_JN.c", "lib/gauss76.c", "pringle.c"] 
    87 effective_radius_type = [ 
     87radius_effective_modes = [ 
    8888    "equivalent cylinder excluded volume", 
    8989    "equivalent volume sphere", 
  • sasmodels/models/raspberry.c

    rd42dd4a ra34b811  
    1515 
    1616static double 
    17 effective_radius(int mode, double radius_lg, double radius_sm, double penetration) 
     17radius_effective(int mode, double radius_lg, double radius_sm, double penetration) 
    1818{ 
    1919    switch (mode) { 
  • sasmodels/models/raspberry.py

    r0507e09 ra34b811  
    161161 
    162162source = ["lib/sas_3j1x_x.c", "raspberry.c"] 
    163 effective_radius_type = ["radius_large", "radius_outer"] 
     163radius_effective_modes = ["radius_large", "radius_outer"] 
    164164 
    165165def random(): 
  • sasmodels/models/rectangular_prism.c

    r99658f6 ra34b811  
    1414 
    1515static double 
    16 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
     16radius_effective(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
    1717{ 
    1818    switch (mode) { 
  • sasmodels/models/rectangular_prism.py

    r0507e09 ra34b811  
    110110---------------------------- 
    111111 
    112 * **Author:**  
    113 * **Last Modified by:**  
    114 * **Last Reviewed by:**  
     112* **Author:** 
     113* **Last Modified by:** 
     114* **Last Reviewed by:** 
    115115* **Source added by :** Steve King **Date:** March 25, 2019 
    116116""" 
     
    151151source = ["lib/gauss76.c", "rectangular_prism.c"] 
    152152have_Fq = True 
    153 effective_radius_type = [ 
     153radius_effective_modes = [ 
    154154    "equivalent cylinder excluded volume", "equivalent volume sphere", 
    155155    "half length_a", "half length_b", "half length_c", 
  • sasmodels/models/rpa.py

    r0507e09 rdb1d9d5  
    3030    These case numbers are different from those in the NIST SANS package! 
    3131 
    32 The models are based on the papers by Akcasu *et al.* and by 
    33 Hammouda assuming the polymer follows Gaussian statistics such 
     32The models are based on the papers by Akcasu *et al.* [1] and by 
     33Hammouda [2] assuming the polymer follows Gaussian statistics such 
    3434that $R_g^2 = n b^2/6$ where $b$ is the statistical segment length and $n$ is 
    3535the number of statistical segment lengths. A nice tutorial on how these are 
    36 constructed and implemented can be found in chapters 28 and 39 of Boualem 
    37 Hammouda's 'SANS Toolbox'. 
     36constructed and implemented can be found in chapters 28, 31 and 34, and Part H, 
     37of Hammouda's 'SANS Toolbox' [3]. 
    3838 
    39 In brief the macroscopic cross sections are derived from the general forms 
    40 for homopolymer scattering and the multiblock cross-terms while the inter 
     39In brief, the macroscopic cross sections are derived from the general forms 
     40for homopolymer scattering and the multiblock cross-terms while the inter, 
    4141polymer cross terms are described in the usual way by the $\chi$ parameter. 
    4242 
     
    4848* **Component D is assumed to be the "background" component (ie, all contrasts 
    4949  are calculated with respect to component D).** So the scattering contrast 
    50   for a C/D blend = [SLD(component C) - SLD(component D)]\ :sup:`2`. 
     50  for a C/D blend $\rho_{C/D} = [\rho_C - \rho_D]$\ :sup:`2`. 
    5151* Depending on which case is being used, the number of fitting parameters can 
    5252  vary. 
     
    8080* **Converted to sasmodels by:** Paul Kienzle **Date:** July 18, 2016 
    8181* **Last Modified by:** Paul Butler **Date:** March 12, 2017 
    82 * **Last Reviewed by:** Paul Butler **Date:** March 12, 2017 
     82* **Last Reviewed by:** Steve King **Date:** March 27, 2019 
    8383* **Source added by :** Steve King **Date:** March 25, 2019 
    8484""" 
  • sasmodels/models/sphere.c

    ree60aa7 ra34b811  
    55 
    66static double 
    7 effective_radius(int mode, double radius) 
     7radius_effective(int mode, double radius) 
    88{ 
    99    // case 1: radius 
  • sasmodels/models/sphere.py

    r0507e09 r934a001  
    3636References 
    3737---------- 
    38  
    39 .. [#] A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, (1955) 
     38  
     39.. [#] A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, 
     40   John Wiley and Sons, New York, (1955) 
    4041 
    4142Source 
     
    4950---------------------------- 
    5051 
    51 * **Author:**  
    52 * **Last Modified by:**  
     52* **Author:** 
     53* **Last Modified by:** 
    5354* **Last Reviewed by:** S King and P Parker **Date:** 2013/09/09 and 2014/01/06 
    5455* **Source added by :** Steve King **Date:** March 25, 2019 
     
    8182source = ["lib/sas_3j1x_x.c", "sphere.c"] 
    8283have_Fq = True 
    83 effective_radius_type = ["radius"] 
     84radius_effective_modes = ["radius"] 
    8485 
    8586def random(): 
     
    9091    ) 
    9192    return pars 
    92  
     93#2345678901234567890123456789012345678901234567890123456789012345678901234567890 
    9394tests = [ 
    94     [{}, 0.2, 0.726362], 
     95     [{}, 0.2, 0.726362], # each test starts with default parameter values  
     96     #            inside { }, unless modified. Then Q and expected value of I(Q) 
     97     # putting None for an expected result will pass the test if there are no  
     98     # errors from the routine, but without any check on the value of the result 
    9599    [{"scale": 1., "background": 0., "sld": 6., "sld_solvent": 1., 
    96       "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    97      0.2, 0.228843], 
     100       "radius": 120.}, [0.01,0.1,0.2],  
     101     [1.34836265e+04, 6.20114062e+00, 1.04733914e-01]], 
     102     [{"scale": 1., "background": 0., "sld": 6., "sld_solvent": 1., 
     103     #  careful tests here R=120 Pd=.2, then with S(Q) at default Reff=50  
     104     #  (but this gets changed to 120) phi=0,2 
     105       "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
     106      [0.01,0.1,0.2], [1.74395295e+04, 3.68016987e+00, 2.28843099e-01]],   
     107     # a list of Q values and list of expected results is also possible 
     108    [{"scale": 1., "background": 0., "sld": 6., "sld_solvent": 1., 
     109     "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
     110      0.01, 335839.88055473, 1.41045057e+11, 120.0, 8087664.122641933, 1.0],  
     111     # the longer list here checks  F1, F2, R_eff, volume, volume_ratio  
    98112    [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    99      0.1, None, None, 120., None, 1.0], 
    100     [{"@S": "hardsphere"}, 0.1, None], 
     113      0.1, 482.93824329, 29763977.79867414, 120.0, 8087664.122641933, 1.0],  
     114    [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
     115      0.2, 1.23330406, 1850806.1197361, 120.0, 8087664.122641933, 1.0], 
     116   #  But note P(Q) = F2/volume 
     117   #  F and F^2 are "unscaled", with for  n <F F*>S(q) or for beta approx  
     118   #          I(q) = n [<F F*> + <F><F*> (S(q) - 1)] 
     119   #  for n the number density and <.> the orientation average, and  
     120   #  F = integral rho(r) exp(i q . r) dr. 
     121   #  The number density is volume fraction divided by particle volume. 
     122   #  Effectively, this leaves F = V drho form, where form is the usual  
     123   #  3 j1(qr)/(qr) or whatever depending on the shape. 
     124   # @S RESULTS using F1 and F2 from the longer test strng above: 
     125   # 
     126   # I(Q) = (F2 + F1^2*(S(Q) -1))*volfraction*scale/Volume  + background 
     127   # 
     128   # with by default scale=1.0, background=0.001 
     129   # NOTE currently S(Q) volfraction is also included in scaling 
     130   #  structure_factor_mode 0 = normal decoupling approx,  
     131   #                        1 = beta(Q) approx 
     132   # radius_effective_mode  0 is for free choice,  
     133   #                        1 is use radius from F2(Q) 
     134   #    (sphere only has two choices, other models may have more) 
     135    [{"@S": "hardsphere", 
     136     "radius": 120., "radius_pd": 0.2, "radius_pd_n":45,"volfraction":0.2, 
     137     #"radius_effective":50.0,    # hard sphere structure factor 
     138     "structure_factor_mode": 1,  # mode 0 = normal decoupling approx,  
     139     #                                   1 = beta(Q) approx 
     140     "radius_effective_mode": 0   # this used default hardsphere Reff=50     
     141     }, [0.01,0.1,0.2], [1.32473756e+03, 7.36633631e-01, 4.67686201e-02]  ], 
     142    [{"@S": "hardsphere", 
     143     "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 
     144     "volfraction":0.2, 
     145     "radius_effective":45.0,     # explicit Reff over rides either 50 or 120 
     146     "structure_factor_mode": 1,  # beta approx 
     147     "radius_effective_mode": 0   #  
     148     }, 0.01, 1316.2990966463444 ], 
     149    [{"@S": "hardsphere", 
     150     "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 
     151     "volfraction":0.2, 
     152     "radius_effective":120.0,    # over ride Reff 
     153     "structure_factor_mode": 1,  # beta approx 
     154     "radius_effective_mode": 0   # (mode=1 here also uses 120)  
     155     }, [0.01,0.1,0.2], [1.57928589e+03, 7.37067923e-01, 4.67686197e-02  ]], 
     156    [{"@S": "hardsphere", 
     157     "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 
     158     "volfraction":0.2, 
     159     #"radius_effective":120.0,   # hard sphere structure factor 
     160     "structure_factor_mode": 0,  # normal decoupling approximation 
     161     "radius_effective_mode": 1   # this uses 120 from the form factor 
     162     }, [0.01,0.1,0.2], [1.10112335e+03, 7.41366536e-01, 4.66630207e-02]], 
     163    [{"@S": "hardsphere", 
     164     "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 
     165     "volfraction":0.2, 
     166     #"radius_effective":50.0,    # hard sphere structure factor 
     167     "structure_factor_mode": 0,  # normal decoupling approximation 
     168     "radius_effective_mode": 0   # this used 50 the default for hardsphere 
     169     }, [0.01,0.1,0.2], [7.82803598e+02, 6.85943611e-01, 4.71586457e-02 ]] 
    101170] 
     171# 
  • sasmodels/models/spherical_sld.c

    ree60aa7 ra34b811  
    1919 
    2020static double 
    21 effective_radius(int mode, double fp_n_shells, double thickness[], double interface[]) 
     21radius_effective(int mode, double fp_n_shells, double thickness[], double interface[]) 
    2222{ 
    2323    // case 1: outer radius 
  • sasmodels/models/spherical_sld.py

    r0507e09 r627b68b  
    1818sub-shell is described by a line function, with *n_steps* sub-shells per 
    1919interface. The form factor is normalized by the total volume of the sphere. 
     20 
     21.. note:: 
     22 
     23   *n_shells* must be an integer. *n_steps* must be an ODD integer. 
    2024 
    2125Interface shapes are as follows: 
     
    7377    3 \rho_\text{solvent} V(r_N) 
    7478    \Big[ \frac{\sin(qr_N) - qr_N \cos(qr_N)} {qr_N^3} \Big] 
    75  
    7679 
    7780Here we assumed that the SLDs of the core and solvent are constant in $r$. 
     
    156159    \end{align*} 
    157160 
    158  
    159161We assume $\rho_{\text{inter}_j} (r)$ is approximately linear 
    160162within the sub-shell $j$. 
     
    179181    when $P(Q) * S(Q)$ is applied. 
    180182 
    181  
    182183References 
    183184---------- 
     
    194195 
    195196Authorship and Verification 
    196 ---------------------------- 
     197--------------------------- 
    197198 
    198199* **Author:** Jae-Hie Cho **Date:** Nov 1, 2010 
    199200* **Last Modified by:** Paul Kienzle **Date:** Dec 20, 2016 
    200 * **Last Reviewed by:** Paul Butler **Date:** September 8, 2018 
     201* **Last Reviewed by:** Steve King **Date:** March 29, 2019 
    201202* **Source added by :** Steve King **Date:** March 25, 2019 
    202203""" 
     
    207208 
    208209name = "spherical_sld" 
    209 title = "Sperical SLD intensity calculation" 
     210title = "Spherical SLD intensity calculation" 
    210211description = """ 
    211212            I(q) = 
     
    219220# pylint: disable=bad-whitespace, line-too-long 
    220221#            ["name", "units", default, [lower, upper], "type", "description"], 
    221 parameters = [["n_shells",             "",           1,      [1, 10],        "volume", "number of shells"], 
     222parameters = [["n_shells",             "",           1,      [1, 10],        "volume", "number of shells (must be integer)"], 
    222223              ["sld_solvent",          "1e-6/Ang^2", 1.0,    [-inf, inf],    "sld", "solvent sld"], 
    223224              ["sld[n_shells]",        "1e-6/Ang^2", 4.06,   [-inf, inf],    "sld", "sld of the shell"], 
     
    232233single = False  # TODO: fix low q behaviour 
    233234have_Fq = True 
    234 effective_radius_type = ["outer radius"] 
     235radius_effective_modes = ["outer radius"] 
    235236 
    236237profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] 
  • sasmodels/models/squarewell.py

    r0507e09 r4d00de6  
    11# Note: model title and parameter table are inserted automatically 
    22r""" 
    3 This calculates the interparticle structure factor for a square well fluid 
    4 spherical particles. The mean spherical approximation (MSA) closure was 
    5 used for this calculation, and is not the most appropriate closure for 
    6 an attractive interparticle potential. This solution has been compared 
    7 to Monte Carlo simulations for a square well fluid, showing this calculation 
    8 to be limited in applicability to well depths $\epsilon < 1.5$ kT and 
    9 volume fractions $\phi < 0.08$. 
     3Calculates the interparticle structure factor for a hard sphere fluid 
     4with a narrow, attractive, square well potential. **The Mean Spherical 
     5Approximation (MSA) closure relationship is used, but it is not the most 
     6appropriate closure for an attractive interparticle potential.** However, 
     7the solution has been compared to Monte Carlo simulations for a square 
     8well fluid and these show the MSA calculation to be limited to well 
     9depths $\epsilon < 1.5$ kT and volume fractions $\phi < 0.08$. 
    1010 
    1111Positive well depths correspond to an attractive potential well. Negative 
    1212well depths correspond to a potential "shoulder", which may or may not be 
    13 physically reasonable. The stickyhardsphere model may be a better choice in 
    14 some circumstances. Computed values may behave badly at extremely small $qR$. 
     13physically reasonable. The :ref:`stickyhardsphere` model may be a better 
     14choice in some circumstances. 
     15 
     16Computed values may behave badly at extremely small $qR$. 
     17 
     18.. note:: 
     19 
     20   Earlier versions of SasView did not incorporate the so-called 
     21   $\beta(q)$ ("beta") correction [2] for polydispersity and non-sphericity. 
     22   This is only available in SasView versions 5.0 and higher. 
    1523 
    1624The well width $(\lambda)$ is defined as multiples of the particle diameter 
     
    1826 
    1927The interaction potential is: 
    20  
    21   .. image:: img/squarewell.png 
    2228 
    2329.. math:: 
     
    2935    \end{cases} 
    3036 
    31 where $r$ is the distance from the center of the sphere of a radius $R$. 
     37where $r$ is the distance from the center of a sphere of a radius $R$. 
    3238 
    33 In sasview the effective radius may be calculated from the parameters 
     39In SasView the effective radius may be calculated from the parameters 
    3440used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    3541 
     
    4652.. [#] R V Sharma, K C Sharma, *Physica*, 89A (1977) 213 
    4753 
     54.. [#] M Kotlarchyk and S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 
     55 
    4856Source 
    4957------ 
     
    5462---------------------------- 
    5563 
    56 * **Author:**  
    57 * **Last Modified by:**  
    58 * **Last Reviewed by:**  
     64* **Author:** 
     65* **Last Modified by:** 
     66* **Last Reviewed by:** Steve King **Date:** March 27, 2019 
    5967* **Source added by :** Steve King **Date:** March 25, 2019 
    6068""" 
     
    6472 
    6573name = "squarewell" 
    66 title = "Square well structure factor, with MSA closure" 
     74title = "Square well structure factor with Mean Spherical Approximation closure" 
    6775description = """\ 
    6876    [Square well structure factor, with MSA closure] 
    69         Interparticle structure factor S(Q)for a hard sphere fluid with 
    70         a narrow attractive well. Fits are prone to deliver non-physical 
    71         parameters, use with care and read the references in the full manual. 
    72         In sasview the effective radius will be calculated from the 
    73         parameters used in P(Q). 
     77        Interparticle structure factor S(Q) for a hard sphere fluid 
     78    with a narrow attractive well. Fits are prone to deliver non- 
     79    physical parameters; use with care and read the references in 
     80    the model documentation.The "beta(q)" correction is available 
     81    in versions 4.2.2 and higher. 
    7482""" 
    7583category = "structure-factor" 
  • sasmodels/models/stickyhardsphere.py

    r0507e09 r4d00de6  
    11# Note: model title and parameter table are inserted automatically 
    22r""" 
    3 This calculates the interparticle structure factor for a hard sphere fluid 
    4 with a narrow attractive well. A perturbative solution of the Percus-Yevick 
    5 closure is used. The strength of the attractive well is described in terms 
    6 of "stickiness" as defined below. 
    7  
    8 The perturb (perturbation parameter), $\epsilon$, should be held between 0.01 
    9 and 0.1. It is best to hold the perturbation parameter fixed and let 
    10 the "stickiness" vary to adjust the interaction strength. The stickiness, 
    11 $\tau$, is defined in the equation below and is a function of both the 
    12 perturbation parameter and the interaction strength. $\tau$ and $\epsilon$ 
    13 are defined in terms of the hard sphere diameter $(\sigma = 2 R)$, the 
    14 width of the square well, $\Delta$ (same units as $R$\ ), and the depth of 
    15 the well, $U_o$, in units of $kT$. From the definition, it is clear that 
    16 smaller $\tau$ means stronger attraction. 
     3Calculates the interparticle structure factor for a hard sphere fluid 
     4with a narrow, attractive, potential well. Unlike the :ref:`squarewell` 
     5model, here a perturbative solution of the Percus-Yevick closure 
     6relationship is used. The strength of the attractive well is described 
     7in terms of "stickiness" as defined below. 
     8 
     9The perturbation parameter (perturb), $\tau$, should be fixed between 0.01 
     10and 0.1 and the "stickiness", $\epsilon$, allowed to vary to adjust the 
     11interaction strength. The "stickiness" is defined in the equation below and is 
     12a function of both the perturbation parameter and the interaction strength. 
     13$\epsilon$ and $\tau$ are defined in terms of the hard sphere diameter $(\sigma = 2 R)$, 
     14the width of the square well, $\Delta$ (having the same units as $R$\ ), 
     15and the depth of the well, $U_o$, in units of $kT$. From the definition, it 
     16is clear that smaller $\epsilon$ means a stronger attraction. 
    1717 
    1818.. math:: 
    1919 
    20     \tau     &= \frac{1}{12\epsilon} \exp(u_o / kT) \\ 
    21     \epsilon &= \Delta / (\sigma + \Delta) 
     20    \epsilon     &= \frac{1}{12\tau} \exp(u_o / kT) \\ 
     21    \tau &= \Delta / (\sigma + \Delta) 
    2222 
    2323where the interaction potential is 
     
    3131        \end{cases} 
    3232 
    33 The Percus-Yevick (PY) closure was used for this calculation, and is an 
    34 adequate closure for an attractive interparticle potential. This solution 
     33The Percus-Yevick (PY) closure is used for this calculation, and is an 
     34adequate closure for an attractive interparticle potential. The solution 
    3535has been compared to Monte Carlo simulations for a square well fluid, with 
    3636good agreement. 
    3737 
    38 The true particle volume fraction, $\phi$, is not equal to $h$, which appears 
    39 in most of the reference. The two are related in equation (24) of the 
    40 reference. The reference also describes the relationship between this 
    41 perturbation solution and the original sticky hard sphere (or adhesive 
    42 sphere) model by Baxter. 
    43  
    44 **NB**: The calculation can go haywire for certain combinations of the input 
    45 parameters, producing unphysical solutions - in this case errors are 
    46 reported to the command window and the $S(q)$ is set to -1 (so it will 
    47 disappear on a log-log plot). Use tight bounds to keep the parameters to 
    48 values that you know are physical (test them) and keep nudging them until 
    49 the optimization does not hit the constraints. 
    50  
    51 In sasview the effective radius may be calculated from the parameters 
     38The true particle volume fraction, $\phi$, is not equal to $h$ which appears 
     39in most of reference [1]. The two are related in equation (24). Reference 
     40[1] also describes the relationship between this perturbative solution and 
     41the original sticky hard sphere (or "adhesive sphere") model of Baxter [2]. 
     42 
     43.. note:: 
     44 
     45   The calculation can go haywire for certain combinations of the input 
     46   parameters, producing unphysical solutions. In this case errors are 
     47   reported to the command window and $S(q)$ is set to -1 (so it will 
     48   disappear on a log-log plot!). 
     49 
     50   Use tight bounds to keep the parameters to values that you know are 
     51   physical (test them), and keep nudging them until the optimization 
     52   does not hit the constraints. 
     53 
     54.. note:: 
     55 
     56   Earlier versions of SasView did not incorporate the so-called 
     57   $\beta(q)$ ("beta") correction [3] for polydispersity and non-sphericity. 
     58   This is only available in SasView versions 5.0 and higher. 
     59 
     60In SasView the effective radius may be calculated from the parameters 
    5261used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    5362 
     
    6574.. [#] S V G Menon, C Manohar, and K S Rao, *J. Chem. Phys.*, 95(12) (1991) 9186-9190 
    6675 
     76.. [#] R J Baxter, *J. Chem. Phys.*, 49 (1968), 2770-2774 
     77 
     78.. [#] M Kotlarchyk and S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 
     79 
    6780Source 
    6881------ 
     
    7386---------------------------- 
    7487 
    75 * **Author:**  
    76 * **Last Modified by:**  
    77 * **Last Reviewed by:**  
     88* **Author:** 
     89* **Last Modified by:** 
     90* **Last Reviewed by:** Steve King **Date:** March 27, 2019 
    7891* **Source added by :** Steve King **Date:** March 25, 2019 
    7992""" 
     
    8598 
    8699name = "stickyhardsphere" 
    87 title = "Sticky hard sphere structure factor, with Percus-Yevick closure" 
     100title = "'Sticky' hard sphere structure factor with Percus-Yevick closure" 
    88101description = """\ 
    89102    [Sticky hard sphere structure factor, with Percus-Yevick closure] 
    90         Interparticle structure factor S(Q)for a hard sphere fluid with 
    91         a narrow attractive well. Fits are prone to deliver non-physical 
    92         parameters, use with care and read the references in the full manual. 
    93         In sasview the effective radius will be calculated from the 
    94         parameters used in P(Q). 
     103        Interparticle structure factor S(Q) for a hard sphere fluid 
     104    with a narrow attractive well. Fits are prone to deliver non- 
     105    physical parameters; use with care and read the references in 
     106    the model documentation.The "beta(q)" correction is available 
     107    in versions 4.2.2 and higher. 
    95108""" 
    96109category = "structure-factor" 
     
    107120     "volume fraction of hard spheres"], 
    108121    ["perturb", "", 0.05, [0.01, 0.1], "", 
    109      "perturbation parameter, epsilon"], 
     122     "perturbation parameter, tau"], 
    110123    ["stickiness", "", 0.20, [-inf, inf], "", 
    111      "stickiness, tau"], 
     124     "stickiness, epsilon"], 
    112125    ] 
    113126 
  • sasmodels/models/triaxial_ellipsoid.c

    r99658f6 ra34b811  
    7676 
    7777static double 
    78 effective_radius(int mode, double radius_equat_minor, double radius_equat_major, double radius_polar) 
     78radius_effective(int mode, double radius_equat_minor, double radius_equat_major, double radius_polar) 
    7979{ 
    8080    switch (mode) { 
  • sasmodels/models/triaxial_ellipsoid.py

    r0507e09 ra34b811  
    164164source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 
    165165have_Fq = True 
    166 effective_radius_type = [ 
     166radius_effective_modes = [ 
    167167    "equivalent biaxial ellipsoid average curvature", 
    168168    "equivalent volume sphere", "min radius", "max radius", 
  • sasmodels/models/unified_power_Rg.py

    r0507e09 rb606805  
    2222artefacts that appear as kinks in the fitted model function. 
    2323 
    24 Also see the Guinier_Porod model. 
     24Also see the :ref:`guinier-porod` model. 
    2525 
    2626The empirical fit function is: 
  • sasmodels/models/vesicle.c

    r12f4c19 ra34b811  
    1313 
    1414static double 
    15 effective_radius(int mode, double radius, double thickness) 
     15radius_effective(int mode, double radius, double thickness) 
    1616{ 
    1717    // case 1: outer radius 
  • sasmodels/models/vesicle.py

    r0507e09 ra34b811  
    107107source = ["lib/sas_3j1x_x.c", "vesicle.c"] 
    108108have_Fq = True 
    109 effective_radius_type = ["outer radius"] 
     109radius_effective_modes = ["outer radius"] 
    110110 
    111111def random(): 
  • sasmodels/product.py

    rb297ba9 r065d77d  
    3131# pylint: enable=unused-import 
    3232 
    33 # TODO: make estimates available to constraints 
     33# TODO: make shape averages available to constraints 
    3434#ESTIMATED_PARAMETERS = [ 
    35 #    ["est_radius_effective", "A", 0.0, [0, np.inf], "", "Estimated effective radius"], 
    36 #    ["est_volume_ratio", "", 1.0, [0, np.inf], "", "Estimated volume ratio"], 
     35#    ["mean_radius_effective", "A", 0.0, [0, np.inf], "", "mean effective radius"], 
     36#    ["mean_volume", "A", 0.0, [0, np.inf], "", "mean volume"], 
     37#    ["mean_volume_ratio", "", 1.0, [0, np.inf], "", "mean form: mean shell volume ratio"], 
    3738#] 
    38  
    3939STRUCTURE_MODE_ID = "structure_factor_mode" 
    4040RADIUS_MODE_ID = "radius_effective_mode" 
     
    4444    # type: (ModelInfo) -> List[Parameter] 
    4545    """ 
    46     Create parameters for structure_factor_mode and radius_effective_mode. 
     46    Create parameters for structure factor and effective radius modes. 
    4747    """ 
    4848    pars = [] 
     
    5656            "Structure factor calculation") 
    5757        pars.append(par) 
    58     if p_info.effective_radius_type is not None: 
     58    if p_info.radius_effective_modes is not None: 
    5959        par = parse_parameter( 
    6060            RADIUS_MODE_ID, 
    6161            "", 
    6262            1, 
    63             [["unconstrained"] + p_info.effective_radius_type], 
     63            [["unconstrained"] + p_info.radius_effective_modes], 
    6464            "", 
    6565            "Effective radius calculation") 
     
    177177        S,                # type: np.ndarray 
    178178        scale,            # type: float 
    179         effective_radius, # type: float 
     179        radius_effective, # type: float 
    180180        beta_mode,        # type: bool 
    181181    ): 
     
    185185    The result may be an array or a float. 
    186186    """ 
     187    # CRUFT: remove effective_radius once SasView 5.0 is released. 
    187188    if beta_mode: 
    188189        # TODO: 1. include calculated Q vector 
     
    193194            ("beta(Q)", F1**2 / F2), 
    194195            ("S_eff(Q)", 1 + (F1**2 / F2)*(S-1)), 
    195             ("effective_radius", effective_radius), 
     196            ("effective_radius", radius_effective), 
     197            ("radius_effective", radius_effective), 
    196198            # ("I(Q)", scale*(F2 + (F1**2)*(S-1)) + bg), 
    197199        )) 
     
    200202            ("P(Q)", scale*F2), 
    201203            ("S(Q)", S), 
    202             ("effective_radius", effective_radius), 
     204            ("effective_radius", radius_effective), 
     205            ("radius_effective", radius_effective), 
    203206        )) 
    204207    return parts 
     
    281284        # R_eff type parameter is the second parameter after P and S parameters 
    282285        # unless the model doesn't support beta mode, in which case it is first 
    283         have_radius_type = p_info.effective_radius_type is not None 
     286        have_radius_type = p_info.radius_effective_modes is not None 
     287        #print(p_npars,s_npars) 
    284288        radius_type_offset = 2+p_npars+s_npars + (1 if have_beta_mode else 0) 
     289        #print(values[radius_type_offset]) 
    285290        radius_type = int(values[radius_type_offset]) if have_radius_type else 0 
    286291 
     
    331336        # Call the form factor kernel to compute <F> and <F^2>. 
    332337        # If the model doesn't support Fq the returned <F> will be None. 
    333         F1, F2, effective_radius, shell_volume, volume_ratio = self.p_kernel.Fq( 
     338        F1, F2, radius_effective, shell_volume, volume_ratio = self.p_kernel.Fq( 
    334339            p_details, p_values, cutoff, magnetic, radius_type) 
    335340 
     
    341346        # implementation details in kernel_iq.c. 
    342347        #print("R_eff=%d:%g, volfrac=%g, volume ratio=%g" 
    343         #      % (radius_type, effective_radius, volfrac, volume_ratio)) 
     348        #      % (radius_type, radius_effective, volfrac, volume_ratio)) 
    344349        if radius_type > 0: 
    345350            # set the value to the model R_eff and set the weight to 1 
    346             s_values[2] = s_values[2+s_npars+s_offset[0]] = effective_radius 
     351            s_values[2] = s_values[2+s_npars+s_offset[0]] = radius_effective 
    347352            s_values[2+s_npars+s_offset[0]+nweights] = 1.0 
    348353        s_values[3] = s_values[2+s_npars+s_offset[1]] = volfrac*volume_ratio 
     
    370375        # the results directly rather than through a lazy evaluator. 
    371376        self.results = lambda: _intermediates( 
    372             F1, F2, S, combined_scale, effective_radius, beta_mode) 
     377            F1, F2, S, combined_scale, radius_effective, beta_mode) 
    373378 
    374379        return final_result 
  • sasmodels/sasview_model.py

    rb297ba9 ra34b811  
    299299    attrs['category'] = model_info.category 
    300300    attrs['is_structure_factor'] = model_info.structure_factor 
    301     attrs['is_form_factor'] = model_info.effective_radius_type is not None 
     301    attrs['is_form_factor'] = model_info.radius_effective_modes is not None 
    302302    attrs['is_multiplicity_model'] = variants[0] > 1 
    303303    attrs['multiplicity_info'] = variants 
     
    763763        #    if er_mode > 0: 
    764764        #        res = calculator.Fq(call_details, values, cutoff=self.cutoff, 
    765         #                            magnetic=False, effective_radius_type=mode) 
     765        #                            magnetic=False, radius_effective_mode=mode) 
    766766        #        R_eff, form_shell_ratio = res[2], res[4] 
    767767        #        return R_eff, form_shell_ratio 
Note: See TracChangeset for help on using the changeset viewer.