Changeset db1d9d5 in sasmodels for sasmodels


Ignore:
Timestamp:
Mar 28, 2019 3:16:51 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ticket-1257-vesicle-product, ticket_1156, ticket_822_more_unit_tests
Children:
8795b6f
Parents:
a34b811
Message:

merge with master

Location:
sasmodels
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/conversion_table.py

    re65c3ba rdb1d9d5  
    854854            "TwoPowerLawModel", 
    855855        ], 
    856         "unified_power_Rg": [ 
     856        "unified_power_rg": [ 
    857857            "UnifiedPowerRg", 
    858858            dict(((field_new+str(index), field_old+str(index)) 
  • sasmodels/convert.py

    rb297ba9 rdb1d9d5  
    606606            if pars['volfraction_a'] > 0.5: 
    607607                pars['volfraction_a'] = 1.0 - pars['volfraction_a'] 
    608         elif name == 'unified_power_Rg': 
     608        elif name == 'unified_power_rg': 
    609609            pars['level'] = int(pars['level']) 
    610610 
  • sasmodels/models/core_shell_cylinder.py

    ra34b811 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: 
  • sasmodels/models/core_shell_ellipsoid.py

    ra34b811 rdb1d9d5  
    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 
     49 
    4550.. math:: 
    4651    :nowrap: 
    4752 
    4853    \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) 
     54    F(q,\alpha) = &f(q,R_e,R_e.x_{core},\alpha) \\ 
     55    &+ f(q,R_e + t_{shell}, 
     56         R_e.x_{core} + t_{shell}.x_{polar shell},\alpha) 
    5257    \end{align*} 
    5358 
     
    7176$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the 
    7277polar 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)$. 
     78equatorial radius perpendicular to the rotational axis of the ellipsoid, 
     79$t_{shell}$ is the thickness of the shell at the equator, 
     80and $\Delta \rho$ (the contrast) is the scattering length density difference, 
     81either $(\rho_{core} - \rho_{shell})$ or $(\rho_{shell} - \rho_{solvent})$. 
    7682 
    7783For randomly oriented particles: 
     
    104110* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    105111* **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 
    106 * **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016 
     112* **Last Reviewed by:** Steve King **Date:** March 27, 2019 
    107113* **Source added by :** Steve King **Date:** March 25, 2019 
    108114""" 
  • sasmodels/models/flexible_cylinder.py

    r0507e09 rdb1d9d5  
    3030The Kuhn length $(b = 2*l_p)$ is also used to describe the stiffness of a chain. 
    3131 
    32 The returned value is in units of $cm^{-1}$, on absolute scale. 
    33  
    3432In the parameters, the sld and sld\_solvent represent the SLD of the cylinder 
    3533and solvent respectively. 
    3634 
    37 Our model uses the form factor calculations implemented in a c-library provided 
    38 by the NIST Center for Neutron Research (Kline, 2006). 
    39  
    40  
    41 From the reference: 
     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: 
    4237 
    4338    'Method 3 With Excluded Volume' is used. 
     
    4641    pseudocontinuous limit. 
    4742    See equations (13,26-27) in the original reference for the details. 
     43 
     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.** 
    4865 
    4966References 
     
    6380`flexible_cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder.c>`_ 
    6481 
     82`wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ 
     83 
    6584Authorship and Verification 
    6685---------------------------- 
    6786 
    68 * **Author:**  
    69 * **Last Modified by:**  
    70 * **Last Reviewed by:**  
     87* **Author:** 
     88* **Last Modified by:** 
     89* **Last Reviewed by:** Steve King **Date:** March 26, 2019 
    7190* **Source added by :** Steve King **Date:** March 25, 2019 
    7291""" 
     
    7695 
    7796name = "flexible_cylinder" 
    78 title = "Flexible cylinder where the form factor is normalized by the volume" \ 
     97title = "Flexible cylinder where the form factor is normalized by the volume " \ 
    7998        "of the cylinder." 
    8099description = """Note : scale and contrast = (sld - sld_solvent) are both 
  • sasmodels/models/flexible_cylinder_elliptical.py

    r0507e09 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. 
    63  
    64 The returned value is in units of $cm^{-1}$, on absolute scale. 
    6567 
    6668In the parameters, the $sld$ and $sld\_solvent$ represent the SLD of the 
     
    6971these parameters must be held fixed during model fitting. 
    7072 
    71 **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.** 
    7275 
    7376References 
     
    8790`flexible_cylinder_elliptical.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder_elliptical.c>`_ 
    8891 
     92`wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ 
     93 
    8994Authorship and Verification 
    9095---------------------------- 
    9196 
    92 * **Author:**  
    93 * **Last Modified by:**  
    94 * **Last Reviewed by:**  
     97* **Author:** 
     98* **Last Modified by:** Richard Heenan **Date:** December, 2016 
     99* **Last Reviewed by:** Steve King **Date:** March 26, 2019 
    95100* **Source added by :** Steve King **Date:** March 25, 2019 
    96101""" 
  • sasmodels/models/guinier_porod.py

    r0507e09 rdb1d9d5  
    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 rdb1d9d5  
    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 4.2.2 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 rdb1d9d5  
    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 4.2.2 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/lib/wrc_cyl.c

    r18a2bfc rdb1d9d5  
    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/multilayer_vesicle.py

    ra34b811 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 
  • sasmodels/models/onion.py

    ra34b811 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 
     
    184199* **Author:** 
    185200* **Last Modified by:** 
    186 * **Last Reviewed 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"], 
  • sasmodels/models/pearl_necklace.py

    ra34b811 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 
     
    6666 
    6767* **Author:** 
    68 * **Last Modified by:** 
    69 * **Last Reviewed by:** 
     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""" 
  • 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/squarewell.py

    r0507e09 rdb1d9d5  
    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 4.2.2 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 rdb1d9d5  
    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 4.2.2 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/unified_power_Rg.py

    r0507e09 rdb1d9d5  
    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: 
     
    7070------ 
    7171 
    72 `unified_power_Rg.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/unified_power_Rg.py>`_ 
     72`unified_power_rg.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/unified_power_rg.py>`_ 
    7373 
    7474Authorship and Verification 
     
    8888 
    8989category = "shape-independent" 
    90 name = "unified_power_Rg" 
     90name = "unified_power_rg" 
    9191title = "Unified Power Rg" 
    9292description = """ 
Note: See TracChangeset for help on using the changeset viewer.