Changeset db1d9d5 in sasmodels
- Timestamp:
- Mar 28, 2019 5:16:51 PM (6 years ago)
- Branches:
- master, ticket-1257-vesicle-product, ticket_1156, ticket_822_more_unit_tests
- Children:
- 8795b6f
- Parents:
- a34b811
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/plugin.rst
re5cb3df rdb1d9d5 1161 1161 and a check that the model runs. 1162 1162 1163 If you are not using sasmodels from SasView, skip this step.1164 1165 1163 Recommended Testing 1166 1164 ................... 1165 1166 **NB: For now, this more detailed testing is only possible if you have a 1167 SasView build environment available!** 1167 1168 1168 1169 If the model compiles and runs, you can next run the unit tests that -
doc/guide/resolution.rst
r0db85af rdb1d9d5 1 .. sm_help.rst2 3 .. This is a port of the original SasView html help file to ReSTructured text4 .. 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. 5 5 6 6 … … 17 17 resolution contribution into a model calculation/simulation (which by definition 18 18 will be exact) to make it more representative of what has been measured 19 experimentally - a process called *smearing*. Sasmodels does the latter. 19 experimentally - a process called *smearing*. The Sasmodels component of SasView 20 does the latter. 20 21 21 22 Both smearing and desmearing rely on functions to describe the resolution … … 29 30 for the instrument and stored with the data file. If not, they will need to 30 31 be 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. 31 47 32 48 -
sasmodels/conversion_table.py
re65c3ba rdb1d9d5 854 854 "TwoPowerLawModel", 855 855 ], 856 "unified_power_ Rg": [856 "unified_power_rg": [ 857 857 "UnifiedPowerRg", 858 858 dict(((field_new+str(index), field_old+str(index)) -
sasmodels/convert.py
rb297ba9 rdb1d9d5 606 606 if pars['volfraction_a'] > 0.5: 607 607 pars['volfraction_a'] = 1.0 - pars['volfraction_a'] 608 elif name == 'unified_power_ Rg':608 elif name == 'unified_power_rg': 609 609 pars['level'] = int(pars['level']) 610 610 -
sasmodels/models/core_shell_cylinder.py
ra34b811 rdb1d9d5 46 46 density of the solvent, and *background* is the background level. The outer 47 47 radius of the shell is given by $R+T$ and the total length of the outer 48 shell is given by $L+2T$. $J 1$ is the first order Bessel function.48 shell is given by $L+2T$. $J_1$ is the first order Bessel function. 49 49 50 50 .. _core-shell-cylinder-geometry: -
sasmodels/models/core_shell_ellipsoid.py
ra34b811 rdb1d9d5 3 3 ---------- 4 4 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. 5 Parameters for this model are the core axial ratio $X_{core}$ and a shell 6 thickness $t_{shell}$, which are more often what we would like to determine 7 and make the model better behaved, particularly when polydispersity is 8 applied, than the four independent radii used in the original parameterization 9 of this model. 9 10 10 11 … … 15 16 the poles, of a prolate ellipsoid. 16 17 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)$. 18 When $X_{core}$ < 1 the core is oblate; when $X_{core}$ > 1 it is prolate. 19 $X_{core}$ = 1 is a spherical core. 20 21 For a fixed shell thickness $X_{polar shell}$ = 1, to scale $t_{shell}$ 22 pro-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)$. 30 33 31 34 If SAS data are in absolute units, and the SLDs are correct, then scale should … … 43 46 where 44 47 48 .. In following equation SK changed radius\_equat\_core to R_e 49 45 50 .. math:: 46 51 :nowrap: 47 52 48 53 \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) 52 57 \end{align*} 53 58 … … 71 76 $V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the 72 77 polar 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)$. 78 equatorial radius perpendicular to the rotational axis of the ellipsoid, 79 $t_{shell}$ is the thickness of the shell at the equator, 80 and $\Delta \rho$ (the contrast) is the scattering length density difference, 81 either $(\rho_{core} - \rho_{shell})$ or $(\rho_{shell} - \rho_{solvent})$. 76 82 77 83 For randomly oriented particles: … … 104 110 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 105 111 * **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 106 * **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016112 * **Last Reviewed by:** Steve King **Date:** March 27, 2019 107 113 * **Source added by :** Steve King **Date:** March 25, 2019 108 114 """ -
sasmodels/models/flexible_cylinder.py
r0507e09 rdb1d9d5 30 30 The Kuhn length $(b = 2*l_p)$ is also used to describe the stiffness of a chain. 31 31 32 The returned value is in units of $cm^{-1}$, on absolute scale.33 34 32 In the parameters, the sld and sld\_solvent represent the SLD of the cylinder 35 33 and solvent respectively. 36 34 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: 35 Our model uses the form factor calculations in reference [1] as implemented in a 36 c-library provided by the NIST Center for Neutron Research (Kline, 2006). This states: 42 37 43 38 'Method 3 With Excluded Volume' is used. … … 46 41 pseudocontinuous limit. 47 42 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 64 reader is strongly encouraged to read reference [1] before use.** 48 65 49 66 References … … 63 80 `flexible_cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder.c>`_ 64 81 82 `wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ 83 65 84 Authorship and Verification 66 85 ---------------------------- 67 86 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 71 90 * **Source added by :** Steve King **Date:** March 25, 2019 72 91 """ … … 76 95 77 96 name = "flexible_cylinder" 78 title = "Flexible cylinder where the form factor is normalized by the volume " \97 title = "Flexible cylinder where the form factor is normalized by the volume " \ 79 98 "of the cylinder." 80 99 description = """Note : scale and contrast = (sld - sld_solvent) are both -
sasmodels/models/flexible_cylinder_elliptical.py
r0507e09 rdb1d9d5 4 4 The non-negligible diameter of the cylinder is included by accounting 5 5 for excluded volume interactions within the walk of a single cylinder. 6 **Inter-cylinder interactions are NOT provided for.** 7 6 8 The form factor is normalized by the particle volume such that 7 9 … … 24 26 ----------- 25 27 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". 28 The 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 28 32 The model is a parameterization of simulations of a discrete representation of 29 33 the worm-like chain model of Kratky and Porod applied in the pseudo-continuous … … 33 37 34 38 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 notably39 by WRC [2]. Details of the corrections are in the reference below. Most notably 36 40 37 41 - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ … … 41 45 code. 42 46 43 - Equation (27) should be $q0 = max(a3/ sqrt(RgSquare),3)$ instead of44 $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)$ 45 49 46 50 - The scattering function is negative for a range of parameter values and … … 58 62 59 63 The 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 be64 The major radius is larger, so of course, **the axis_ratio must be 61 65 greater than one.** Simple constraints should be applied during curve fitting to 62 66 maintain this inequality. 63 64 The returned value is in units of $cm^{-1}$, on absolute scale.65 67 66 68 In the parameters, the $sld$ and $sld\_solvent$ represent the SLD of the … … 69 71 these parameters must be held fixed during model fitting. 70 72 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 74 reader is strongly encouraged to read reference [1] before use.** 72 75 73 76 References … … 87 90 `flexible_cylinder_elliptical.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/flexible_cylinder_elliptical.c>`_ 88 91 92 `wrc_cyl.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lib/wrc_cyl.c>`_ 93 89 94 Authorship and Verification 90 95 ---------------------------- 91 96 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 95 100 * **Source added by :** Steve King **Date:** March 25, 2019 96 101 """ -
sasmodels/models/guinier_porod.py
r0507e09 rdb1d9d5 5 5 such as rods or platelets, and shapes intermediate between spheres 6 6 and rods or between rods and platelets, and overcomes some of the 7 deficiencies of the (Beaucage) Unified_Power_Rgmodel (see Hammouda, 2010).7 deficiencies of the (Beaucage) :ref:`unified-power-rg` model (see Hammouda, 2010). 8 8 9 9 Definition -
sasmodels/models/hardsphere.py
r0507e09 rdb1d9d5 1 1 # Note: model title and parameter table are inserted automatically 2 r"""Calculate the interparticle structure factor for monodisperse 2 r""" 3 Calculates the interparticle structure factor for monodisperse 3 4 spherical 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). 5 interactions. This $S(q)$ may also be a reasonable approximation for 6 other particle shapes that freely rotate (but see the note below), 7 and 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. 8 19 9 20 radius_effective is the effective hard sphere radius. 10 21 volfraction is the volume fraction occupied by the spheres. 11 22 12 In sasview the effective radius may be calculated from the parameters23 In SasView the effective radius may be calculated from the parameters 13 24 used in the form factor $P(q)$ that this $S(q)$ is combined with. 14 25 15 26 For numerical stability the computation uses a Taylor series expansion 16 at very small $qR$, there may be a very minor glitch at the transition point17 in some circumstances.27 at very small $qR$, but there may be a very minor glitch at the 28 transition point in some circumstances. 18 29 19 Th e S(Q) uses the Percus-Yevick closure where the interparticle20 potentialis30 This S(q) uses the Percus-Yevick closure relationship [2] where the 31 interparticle potential $U(r)$ is 21 32 22 33 .. math:: … … 27 38 \end{cases} 28 39 29 where $r$ is the distance from the center of thesphere of a radius $R$.40 where $r$ is the distance from the center of a sphere of a radius $R$. 30 41 31 42 For a 2D plot, the wave transfer is defined as … … 39 50 ---------- 40 51 52 .. [#] M Kotlarchyk & S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 53 41 54 .. [#] J K Percus, J Yevick, *J. Phys. Rev.*, 110, (1958) 1 42 55 … … 49 62 ---------------------------- 50 63 51 * **Author:** 52 * **Last Modified by:** 53 * **Last Reviewed by:** 64 * **Author:** 65 * **Last Modified by:** 66 * **Last Reviewed by:** 54 67 * **Source added by :** Steve King **Date:** March 25, 2019 55 68 """ … … 63 76 [Hard sphere structure factor, with Percus-Yevick closure] 64 77 Interparticle S(Q) for random, non-interacting spheres. 65 May be a reasonable approximation for other shapes of66 particles that freely rotate, and for moderately polydisperse67 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. 69 82 radius_effective is the hard sphere radius 70 83 volfraction is the volume fraction occupied by the spheres. -
sasmodels/models/hayter_msa.py
r0507e09 rdb1d9d5 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 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. 3 Calculates the interparticle structure factor for a system of charged, 4 spheroidal, objects in a dielectric medium [1,2]. When combined with an 5 appropriate form factor $P(q)$, this allows for inclusion of the 6 interparticle interference effects due to screened Coulombic 7 repulsion between the charged particles. 9 8 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. 13 21 14 22 The 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 present16 there is no provision for entering the ionic strength directly nor for use17 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.23 which in turn is used to compute the Debye screening length. There is no 24 provision for entering the ionic strength directly. **At present the 25 counterions are assumed to be monovalent**, though it should be possible 26 to simulate the effect of multivalent counterions by increasing the salt 27 concentration. 20 28 21 In sasview the effective radius may be calculated from the parameters 29 Over the range 0 - 100 C the dielectric constant $\kappa$ of water may be 30 approximated with a maximum deviation of 0.01 units by the empirical 31 formula [4] 32 33 .. math:: 34 35 \kappa = 87.740 - 0.40008 T + 9.398x10^{-4} T^2 - 1.410x10^{-6} T^3 36 37 where $T$ is the temperature in celsius. 38 39 In SasView the effective radius may be calculated from the parameters 22 40 used in the form factor $P(q)$ that this $S(q)$ is combined with. 23 41 … … 38 56 39 57 .. [#] J B Hayter and J Penfold, *Molecular Physics*, 42 (1981) 109-118 58 40 59 .. [#] 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 41 64 42 65 Source … … 50 73 ---------------------------- 51 74 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 55 78 * **Source added by :** Steve King **Date:** March 25, 2019 56 79 """ … … 74 97 75 98 name = "hayter_msa" 76 title = "Hayter-Penfold rescaled MSA, charged sphere, interparticle S(Q) structure factor"99 title = "Hayter-Penfold Rescaled Mean Spherical Approximation (RMSA) structure factor for charged spheres" 77 100 description = """\ 78 101 [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. 84 106 """ 85 107 … … 87 109 # pylint: disable=bad-whitespace, line-too-long 88 110 # [ "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 # 89 118 parameters = [ 90 119 ["radius_effective", "Ang", 20.75, [0, inf], "volume", "effective radius of charged sphere"], 91 120 ["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)"], 93 122 ["temperature", "K", 318.16, [0, 450], "", "temperature, in Kelvin, for Debye length calculation"], 94 123 ["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"] 96 125 ] 97 126 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/lib/wrc_cyl.c
r18a2bfc rdb1d9d5 1 1 /* 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 3 7 */ 4 8 -
sasmodels/models/multilayer_vesicle.py
ra34b811 rdb1d9d5 113 113 * **Converted to sasmodels by:** Piotr Rozyczko **Date:** Feb 24, 2016 114 114 * **Last Modified by:** Paul Kienzle **Date:** Feb 7, 2017 115 * **Last Reviewed by:** Paul Butler **Date:** March 12, 2017115 * **Last Reviewed by:** Steve King **Date:** March 28, 2019 116 116 * **Source added by :** Steve King **Date:** March 25, 2019 117 117 """ … … 121 121 122 122 name = "multilayer_vesicle" 123 title = " P(Q) for a Multi-lamellar vesicle"123 title = "Calculate form factor for a multi-lamellar vesicle" 124 124 description = """ 125 125 multilayer_vesicle model parameters; … … 145 145 ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", "solvent scattering length density"], 146 146 ["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)"], 148 148 ] 149 149 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/onion.py
ra34b811 rdb1d9d5 6 6 solvent. We currently provide up to 9 shells with this model. 7 7 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$. 10 12 11 13 Definition … … 56 58 j_1(x) = \frac{\sin(x)}{x^2} - \frac{\cos(x)}{x} 57 59 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 60 and the volume is $V(r) = \frac{4\pi}{3}r^3$. 61 62 The volume of the particle is determined by the radius of the outer 63 shell, so $V_\text{particle} = V(r_N)$. 64 65 Now consider the SLD of a shell defined by 62 66 63 67 .. math:: … … 74 78 thickness of the $k^\text{th}$ shell in the equation above, respectively. 75 79 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$): 77 86 78 87 .. math:: … … 87 96 - 3CV(r_{\text{shell}-1}) \frac{j_1(\beta_\text{in})}{\beta_\text{in}} 88 97 89 for 98 where 90 99 91 100 .. math:: … … 95 104 B&=\frac{\rho_\text{out} - \rho_\text{in}}{e^A-1} 96 105 & C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\ 106 97 107 \alpha_\text{in} &= A\frac{r_{\text{shell}-1}}{\Delta t_\text{shell}} 98 108 & \alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\ 109 99 110 \beta_\text{in} &= qr_{\text{shell}-1} 100 111 & \beta_\text{out} &= qr_\text{shell} \\ 101 112 \end{align*} 102 113 103 where $h$ is 114 and 104 115 105 116 .. math:: 106 117 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} 108 119 - \frac{(x^2-y^2)\sin(y) - 2xy\cos(y)}{(x^2+y^2)^2y} 109 120 110 121 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 125 For small $A$, say, $A = -0.0001$, the function converges to that of of a linear 126 SLD profile with 127 128 $\rho_\text{shell}(r) \approx A(r-r_{\text{shell}-1})/\Delta t_\text{shell})+B$, 129 130 which is equivalent to 115 131 116 132 .. math:: … … 140 156 \end{align*} 141 157 142 For $A = 0$, the exponential function has no dependence on the radius (so that 158 159 **Constant SLD** ($A = 0$): 160 161 When $A = 0$ the exponential function has no dependence on the radius (meaning 143 162 $\rho_\text{out}$ is ignored in this case) and becomes flat. We set the constant 144 163 to $\rho_\text{in}$ for convenience, and thus the form factor contributed by … … 153 172 \frac{j_1(qr_\text{in})}{qr_\text{in}} 154 173 155 .. figure:: img/onion_geometry.png156 157 Example of an onion model profile.158 159 174 The 2D scattering intensity is the same as $P(q)$ above, regardless of the 160 175 orientation of the $q$ vector which is defined as … … 184 199 * **Author:** 185 200 * **Last Modified by:** 186 * **Last Reviewed by:** 201 * **Last Reviewed by:** Steve King **Date:** March 28, 2019 187 202 * **Source added by :** Steve King **Date:** March 25, 2019 188 203 """ … … 284 299 285 300 description = """\ 286 Form factor of mu tishells normalized by the volume. Here each shell is301 Form factor of multishells normalized by the volume. Here each shell is 287 302 described by an exponential function; 288 303 … … 297 312 II) For the exact point of A_shell == 0, 298 313 f(r) = sld_in ,i.e., it crosses over flat function 299 Note that the 'sld_out' bec aomes NULL in this case.314 Note that the 'sld_out' becomes NULL in this case. 300 315 301 316 background:background, … … 312 327 # TODO: n is a volume parameter that is not polydisperse 313 328 329 # NOTE: Joachim Wuttke has suggested an alternative parameterisation 330 # in Ticket #1107 331 314 332 # pylint: disable=bad-whitespace, line-too-long 315 333 # ["name", "units", default, [lower, upper], "type","description"], … … 318 336 ["radius_core", "Ang", 200., [0, inf], "volume", "Radius of the core"], 319 337 ["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)"], 321 339 ["sld_in[n_shells]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", "scattering length density at the inner radius of shell k"], 322 340 ["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 25 25 .. math:: 26 26 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\}+ 30 30 \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[ 33 33 \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] \\ 35 35 \psi(q) &= 3 \cdot \frac{sin(qR)-(qR)\cdot cos(qR)}{(qR)^3} \\ 36 36 \Lambda(q) &= \frac{\int_0^{ql}\frac{sin(t)}{t}dt}{ql} \\ … … 40 40 (volume of the *N* pearls/rods). *V* is the total volume of the necklace. 41 41 42 .. note:: 43 44 *num_pearls* must be an integer. 45 42 46 The 2D scattering intensity is the same as $P(q)$ above, regardless of the 43 47 orientation of the *q* vector. 44 45 The returned value is scaled to units of |cm^-1| and the parameters of the46 pearl_necklace model are the following47 48 NB: *num_pearls* must be an integer.49 48 50 49 References … … 52 51 53 52 .. [#] 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 55 55 .. [#] L. Onsager, *Ann. New York Acad. Sci.*, 51 (1949) 627-659 56 56 … … 66 66 67 67 * **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 70 70 * **Source added by :** Steve King **Date:** March 25, 2019 71 71 """ -
sasmodels/models/rpa.py
r0507e09 rdb1d9d5 30 30 These case numbers are different from those in the NIST SANS package! 31 31 32 The models are based on the papers by Akcasu *et al.* and by33 Hammouda assuming the polymer follows Gaussian statistics such32 The models are based on the papers by Akcasu *et al.* [1] and by 33 Hammouda [2] assuming the polymer follows Gaussian statistics such 34 34 that $R_g^2 = n b^2/6$ where $b$ is the statistical segment length and $n$ is 35 35 the 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 Boualem37 Hammouda's 'SANS Toolbox'.36 constructed and implemented can be found in chapters 28, 31 and 34, and Part H, 37 of Hammouda's 'SANS Toolbox' [3]. 38 38 39 In brief the macroscopic cross sections are derived from the general forms40 for homopolymer scattering and the multiblock cross-terms while the inter 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, 41 41 polymer cross terms are described in the usual way by the $\chi$ parameter. 42 42 … … 48 48 * **Component D is assumed to be the "background" component (ie, all contrasts 49 49 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`. 51 51 * Depending on which case is being used, the number of fitting parameters can 52 52 vary. … … 80 80 * **Converted to sasmodels by:** Paul Kienzle **Date:** July 18, 2016 81 81 * **Last Modified by:** Paul Butler **Date:** March 12, 2017 82 * **Last Reviewed by:** Paul Butler **Date:** March 12, 201782 * **Last Reviewed by:** Steve King **Date:** March 27, 2019 83 83 * **Source added by :** Steve King **Date:** March 25, 2019 84 84 """ -
sasmodels/models/squarewell.py
r0507e09 rdb1d9d5 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 3 This calculates the interparticle structure factor for a square wellfluid4 spherical particles. The mean spherical approximation (MSA) closure was 5 used for this calculation, and is not the most appropriate closure for 6 a n attractive interparticle potential. This solution has been compared7 t o Monte Carlo simulations for a square well fluid, showing this calculation8 to be limited in applicability to well depths $\epsilon < 1.5$ kT and 9 volume fractions $\phi < 0.08$.3 Calculates the interparticle structure factor for a hard sphere fluid 4 with a narrow, attractive, square well potential. **The Mean Spherical 5 Approximation (MSA) closure relationship is used, but it is not the most 6 appropriate closure for an attractive interparticle potential.** However, 7 the solution has been compared to Monte Carlo simulations for a square 8 well fluid and these show the MSA calculation to be limited to well 9 depths $\epsilon < 1.5$ kT and volume fractions $\phi < 0.08$. 10 10 11 11 Positive well depths correspond to an attractive potential well. Negative 12 12 well 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$. 13 physically reasonable. The :ref:`stickyhardsphere` model may be a better 14 choice in some circumstances. 15 16 Computed 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. 15 23 16 24 The well width $(\lambda)$ is defined as multiples of the particle diameter … … 18 26 19 27 The interaction potential is: 20 21 .. image:: img/squarewell.png22 28 23 29 .. math:: … … 29 35 \end{cases} 30 36 31 where $r$ is the distance from the center of thesphere of a radius $R$.37 where $r$ is the distance from the center of a sphere of a radius $R$. 32 38 33 In sasview the effective radius may be calculated from the parameters39 In SasView the effective radius may be calculated from the parameters 34 40 used in the form factor $P(q)$ that this $S(q)$ is combined with. 35 41 … … 46 52 .. [#] R V Sharma, K C Sharma, *Physica*, 89A (1977) 213 47 53 54 .. [#] M Kotlarchyk and S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 55 48 56 Source 49 57 ------ … … 54 62 ---------------------------- 55 63 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 59 67 * **Source added by :** Steve King **Date:** March 25, 2019 60 68 """ … … 64 72 65 73 name = "squarewell" 66 title = "Square well structure factor , with MSAclosure"74 title = "Square well structure factor with Mean Spherical Approximation closure" 67 75 description = """\ 68 76 [Square well structure factor, with MSA closure] 69 Interparticle structure factor S(Q) for a hard sphere fluid with70 a narrow attractive well. Fits are prone to deliver non-physical71 parameters, use with care and read the references in the full manual.72 In sasview the effective radius will be calculated from the73 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. 74 82 """ 75 83 category = "structure-factor" -
sasmodels/models/stickyhardsphere.py
r0507e09 rdb1d9d5 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 3 This calculates the interparticle structure factor for a hard sphere fluid4 with a narrow attractive well. A perturbative solution of the Percus-Yevick5 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 that16 smaller $\tau$ meansstronger attraction.3 Calculates the interparticle structure factor for a hard sphere fluid 4 with a narrow, attractive, potential well. Unlike the :ref:`squarewell` 5 model, here a perturbative solution of the Percus-Yevick closure 6 relationship is used. The strength of the attractive well is described 7 in terms of "stickiness" as defined below. 8 9 The perturbation parameter (perturb), $\tau$, should be fixed between 0.01 10 and 0.1 and the "stickiness", $\epsilon$, allowed to vary to adjust the 11 interaction strength. The "stickiness" is defined in the equation below and is 12 a 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)$, 14 the width of the square well, $\Delta$ (having the same units as $R$\ ), 15 and the depth of the well, $U_o$, in units of $kT$. From the definition, it 16 is clear that smaller $\epsilon$ means a stronger attraction. 17 17 18 18 .. math:: 19 19 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) 22 22 23 23 where the interaction potential is … … 31 31 \end{cases} 32 32 33 The Percus-Yevick (PY) closure was used for this calculation, and is an34 adequate closure for an attractive interparticle potential. Th issolution33 The Percus-Yevick (PY) closure is used for this calculation, and is an 34 adequate closure for an attractive interparticle potential. The solution 35 35 has been compared to Monte Carlo simulations for a square well fluid, with 36 36 good agreement. 37 37 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 38 The true particle volume fraction, $\phi$, is not equal to $h$ which appears 39 in most of reference [1]. The two are related in equation (24). Reference 40 [1] also describes the relationship between this perturbative solution and 41 the 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 60 In SasView the effective radius may be calculated from the parameters 52 61 used in the form factor $P(q)$ that this $S(q)$ is combined with. 53 62 … … 65 74 .. [#] S V G Menon, C Manohar, and K S Rao, *J. Chem. Phys.*, 95(12) (1991) 9186-9190 66 75 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 67 80 Source 68 81 ------ … … 73 86 ---------------------------- 74 87 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 78 91 * **Source added by :** Steve King **Date:** March 25, 2019 79 92 """ … … 85 98 86 99 name = "stickyhardsphere" 87 title = " Sticky hard sphere structure factor,with Percus-Yevick closure"100 title = "'Sticky' hard sphere structure factor with Percus-Yevick closure" 88 101 description = """\ 89 102 [Sticky hard sphere structure factor, with Percus-Yevick closure] 90 Interparticle structure factor S(Q) for a hard sphere fluid with91 a narrow attractive well. Fits are prone to deliver non-physical92 parameters, use with care and read the references in the full manual.93 In sasview the effective radius will be calculated from the94 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. 95 108 """ 96 109 category = "structure-factor" … … 107 120 "volume fraction of hard spheres"], 108 121 ["perturb", "", 0.05, [0.01, 0.1], "", 109 "perturbation parameter, epsilon"],122 "perturbation parameter, tau"], 110 123 ["stickiness", "", 0.20, [-inf, inf], "", 111 "stickiness, tau"],124 "stickiness, epsilon"], 112 125 ] 113 126 -
sasmodels/models/unified_power_Rg.py
r0507e09 rdb1d9d5 22 22 artefacts that appear as kinks in the fitted model function. 23 23 24 Also see the Guinier_Porodmodel.24 Also see the :ref:`guinier-porod` model. 25 25 26 26 The empirical fit function is: … … 70 70 ------ 71 71 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>`_ 73 73 74 74 Authorship and Verification … … 88 88 89 89 category = "shape-independent" 90 name = "unified_power_ Rg"90 name = "unified_power_rg" 91 91 title = "Unified Power Rg" 92 92 description = """
Note: See TracChangeset
for help on using the changeset viewer.