Changes in / [9eb5eca:e1ea6b5] in sasmodels
- Location:
- sasmodels
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
rfe25eda r8c65a33 1063 1063 # Evaluate preset parameter expressions 1064 1064 context = MATH.copy() 1065 context['np'] = np1066 1065 context.update(pars) 1067 1066 context.update((k,v) for k,v in presets.items() if isinstance(v, float)) -
sasmodels/details.py
rccd5f01 r6dc78e4 230 230 npars = kernel.info.parameters.npars 231 231 nvalues = kernel.info.parameters.nvalues 232 scalars = [ (v[0] if len(v) else np.NaN) for v, win pairs]232 scalars = [v[0][0] for v in pairs] 233 233 values, weights = zip(*pairs[2:npars+2]) if npars else ((),()) 234 234 length = np.array([len(w) for w in weights]) -
sasmodels/models/be_polyelectrolyte.py
rbf9de53 r5df888c 67 67 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 68 68 * **Last Modified by:** Paul Kienzle **Date:** July 24, 2016 69 * **Last Reviewed by:** Paul Butler and Richard Heenan **Date:** 70 October 07, 2016 69 * **Last Reviewed by:** Piotr rozyczko **Date:** January 27, 2016 71 70 """ 72 71 -
sasmodels/models/core_multi_shell.py
r2d73a53 rb0c4271 13 13 14 14 The 2D scattering intensity is the same as $P(q)$ above, regardless of the 15 orientation of the $ \vecq$ vector which is defined as15 orientation of the $q$ vector which is defined as 16 16 17 17 .. math:: … … 29 29 30 30 Our model uses the form factor calculations implemented in a c-library provided 31 by the NIST Center for Neutron Research (Kline, 2006) [#kline]_.31 by the NIST Center for Neutron Research (Kline, 2006). 32 32 33 33 References … … 35 35 36 36 .. [#] See the :ref:`core-shell-sphere` model documentation. 37 .. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 38 .. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 39 Neutron Scattering*, Plenum Press, New York, 1987. 37 .. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, 38 Plenum Press, New York, 1987. 40 39 41 40 Authorship and Verification … … 44 43 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 45 44 * **Last Modified by:** Paul Kienzle **Date:** September 12, 2016 46 * **Last Reviewed by:** Paul Kienzle **Date:** September 12, 201645 * **Last Reviewed by:** Under Review **Date:** as of October 5, 2016 47 46 """ 48 47 -
sasmodels/models/core_shell_cylinder.py
r755ecc2 r40a87fa 1 # core shell cylinder model 2 # Note: model title and parameter table are inserted automatically 1 3 r""" 4 The form factor is normalized by the particle volume. 5 2 6 Definition 3 7 ---------- 4 8 5 9 The output of the 2D scattering intensity function for oriented core-shell 6 cylinders is given by (Kline, 2006 [#kline]_). The form factor is normalized 7 by the particle volume. 10 cylinders is given by (Kline, 2006) 8 11 9 12 .. math:: … … 58 61 The $\theta$ and $\phi$ parameters are not used for the 1D output. 59 62 63 Validation 64 ---------- 65 66 Validation of our code was done by comparing the output of the 1D model to 67 the output of the software provided by the NIST (Kline, 2006). 68 69 Averaging over a distribution of orientation is done by evaluating the 70 equation above. Since we have no other software to compare the 71 implementation of the intensity for fully oriented cylinders, we 72 compared the result of averaging our 2D output using a uniform 73 distribution $p(\theta,\phi) = 1.0$. 74 60 75 Reference 61 76 --------- 77 see, for example, Ian Livsey J. Chem. Soc., Faraday Trans. 2, 1987,83, 1445-1452 62 78 63 .. [#] see, for example, Ian Livsey J. Chem. Soc., Faraday Trans. 2, 1987,83, 64 1445-1452 65 .. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 66 67 Authorship and Verification 68 ---------------------------- 69 70 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 71 * **Last Modified by:** Paul Kienzle **Date:** Aug 8, 2016 72 * **Last Reviewed by:** Richard Heenan **Date:** March 18, 2016 79 2016/03/18 - Description reviewed by RKH 73 80 """ 74 81 … … 151 158 theta_pd=15, theta_pd_n=45, 152 159 phi_pd=15, phi_pd_n=1) 153 160 # ADDED by: RKH ON: 18Mar2016 renamed sld's etc -
sasmodels/models/core_shell_parallelepiped.py
r5810f00 r14838a3 1 # core_shell_parallelepiped model 2 # Note: model title and parameter table are inserted automatically 1 3 r""" 2 Definition3 ----------4 5 4 Calculates the form factor for a rectangular solid with a core-shell structure. 6 5 **The thickness and the scattering length density of the shell or "rim" … … 16 15 of the rectangular solid. 17 16 17 An instrument resolution smeared version of the model is also provided. 18 19 20 Definition 21 ---------- 18 22 19 23 The function calculated is the form factor of the rectangular solid below. … … 37 41 **meaning that there are "gaps" at the corners of the solid.** 38 42 39 The intensity calculated follows the :ref:`parallelepiped` model, with the 40 core-shell intensity being calculated as the square of the sumof the41 amplitudes of thecore and shell, in the same manner as a core-shell model.43 The intensity calculated follows the :ref:`parallelepiped` model, with the core-shell 44 intensity being calculated as the square of the sum of the amplitudes of the 45 core and shell, in the same manner as a core-shell model. 42 46 43 .. math:: 44 45 F_{a}(Q,\alpha,\beta)= 46 \Bigg(\frac{sin(Q(L_A+2t_A)/2sin\alpha sin\beta)}{Q(L_A+2t_A)/2sin\alpha 47 sin\beta)} 48 - \frac{sin(QL_A/2sin\alpha sin\beta)}{QL_A/2sin\alpha sin\beta)} \Bigg) 49 + \frac{sin(QL_B/2sin\alpha sin\beta)}{QL_B/2sin\alpha sin\beta)} 50 + \frac{sin(QL_C/2sin\alpha sin\beta)}{QL_C/2sin\alpha sin\beta)} 51 52 .. note:: 53 54 For the calculation of the form factor to be valid, the sides of the solid 55 MUST be chosen such that** $A < B < C$. 56 If this inequality is not satisfied, the model will not report an error, 57 but the calculation will not be correct and thus the result wrong. 47 **For the calculation of the form factor to be valid, the sides of the solid 48 MUST be chosen such that** $A < B < C$. 49 **If this inequality is not satisfied, the model will not report an error, 50 and the calculation will not be correct.** 58 51 59 52 FITTING NOTES 60 53 If the scale is set equal to the particle volume fraction, |phi|, the returned 61 54 value is the scattered intensity per unit volume, $I(q) = \phi P(q)$. 62 However, **no interparticle interference effects are included in this 63 calculation.** 55 However, **no interparticle interference effects are included in this calculation.** 64 56 65 57 There are many parameters in this model. Hold as many fixed as possible with … … 76 68 and length $(C+2t_C)$ values, and used as the effective radius 77 69 for $S(Q)$ when $P(Q) * S(Q)$ is applied. 70 71 .. Comment by Miguel Gonzalez: 72 The later seems to contradict the previous statement that interparticle interference 73 effects are not included. 78 74 79 75 To provide easy access to the orientation of the parallelepiped, we define the … … 102 98 ---------- 103 99 104 .. [#] P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 105 Equations (1), (13-14). (in German) 106 .. [#] D Singh (2009). *Small angle scattering studies of self assembly in 107 lipid mixtures*, John's Hopkins University Thesis (2009) 223-225. `Available 108 from Proquest <http://search.proquest.com/docview/304915826?accountid 109 =26379>`_ 100 P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 101 Equations (1), (13-14). (in German) 110 102 111 Authorship and Verification112 ----------------------------113 114 * **Author:** NIST IGOR/DANSE **Date:** pre 2010115 * **Last Modified by:** Paul Butler **Date:** September 30, 2016116 * **Last Reviewed by:** Miguel Gonzales **Date:** March 21, 2016117 103 """ 118 104 -
sasmodels/models/fractal_core_shell.c
rbdd08df r217590b 16 16 double cor_length) 17 17 { 18 //The radius for the building block of the core shell particle that is 19 //needed by the Teixeira fractal S(q) is the radius of the whole particle. 20 const double cs_radius = radius + thickness; 21 const double sq = fractal_sq(q, cs_radius, fractal_dim, cor_length); 18 const double sq = fractal_sq(q, radius, fractal_dim, cor_length); 22 19 const double pq = core_shell_kernel(q, radius, thickness, 23 20 core_sld, shell_sld, solvent_sld); -
sasmodels/models/fractal_core_shell.py
rd6f60c3 r217590b 1 1 r""" 2 Calculates the scattering from a fractal structure with a primary building 3 block of core-shell spheres, as opposed to just homogeneous spheres in 4 the fractal model. 5 This model could find use for aggregates of coated particles, or aggregates 6 of vesicles. 7 2 8 Definition 3 9 ---------- 4 Calculates the scattering from a fractal structure with a primary building5 block of core-shell spheres, as opposed to just homogeneous spheres in6 the fractal model. It is an extension of the well known Teixeira\ [#teixeira]_7 fractal model replacing the $P(q)$ of a solid sphere with that of a core-shell8 sphere. This model could find use for aggregates of coated particles, or9 aggregates of vesicles for example.10 10 11 11 .. math:: 12 12 13 I(q) = P(q)S(q) + \text{background}13 I(q) = \text{background} + P(q)S(q) 14 14 15 Where $P(q)$ is the core-shell form factor and $S(q)$ is the 16 Teixeira\ [#teixeira]_ fractal structure factor both of which are given again 17 below: 15 The form factor $P(q)$ is that from core_shell model with $bkg$ = 0 16 18 17 19 18 .. math:: 20 19 21 P(q) &= \frac{\phi}{V_s}\left[3V_c(\rho_c-\rho_s)20 P(q)=\frac{scale}{V_s}\left[3V_c(\rho_c-\rho_s) 22 21 \frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+ 23 22 3V_s(\rho_s-\rho_{solv}) 24 23 \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 25 24 26 S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q\xi)^2]^{(D_f-1)/2}}27 \frac{\sin[(D_f-1)\tan^{-1}(q\xi)]}{(qr_s)^{D_f}}28 25 29 where $\phi$ is the volume fraction of particles, $V_s$ is the volume of the 30 whole particle, $V_c$ is the volume of the core, $\rho_c$, $\rho_s$, and 31 $\rho_{solv}$ are the scattering length densities of the core, shell, and 32 solvent respectively, $r_c$ and $r_s$ are the radius of the core and the radius 33 of the whole particle respectively, $D_f$ is the fractal dimension, and |xi| the 34 correlation length. 35 36 Polydispersity of radius and thickness are also provided for. 26 while the fractal structure factor $S(q)$ is 37 27 38 This model does not allow for anisotropy and thus the 2D scattering intensity 39 is calculated in the same way as 1D, where the $q$ vector is defined as 28 .. math:: 29 30 S(q) = \frac{D_f\Gamma(D_f-1)\sin((D_f-1)\tan^{-1}(q\xi))} 31 {(qr_c)^{D_f}\left(1+\frac{1}{q^2\xi ^2} \right)^{\frac{D_f-1}{2}}} 32 33 where $D_f$ = fractal_dim, |xi| = cor_length, $r_c$ = (core) radius, and 34 $scale$ = volume fraction. 35 36 The fractal structure is as documented in the fractal model. 37 Polydispersity of radius and thickness is provided for. 38 39 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 40 where the $q$ vector is defined as 40 41 41 42 .. math:: … … 43 44 q = \sqrt{q_x^2 + q_y^2} 44 45 45 Our model is derived from the form factor calculations implemented in IGOR46 macros by the NIST Center for Neutron Research\ [#Kline]_47 48 46 References 49 47 ---------- 50 48 51 .. [#teixeira] J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785 52 .. [#Kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 53 54 Authorship and Verification 55 ---------------------------- 56 57 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 58 * **Last Modified by:** Paul Butler and Paul Kienzle **on:** November 27, 2016 59 * **Last Reviewed by:** Paul Butler and Paul Kienzle **on:** November 27, 2016 49 See the core_shell and fractal model descriptions 60 50 61 51 """ … … 64 54 65 55 name = "fractal_core_shell" 66 title = "Scattering from a fractal structure formed from core shell spheres" 67 description = """\ 68 Model for fractal aggregates of core-shell primary particles. It is based on 69 the Teixeira model for the S(q) of a fractal * P(q) for a core-shell sphere 56 title = "" 57 description = """ 70 58 71 radius = the radius of the core 72 thickness = thickness of the shell 73 thick_layer = thickness of a layer 74 sld_core = the SLD of the core 75 sld_shell = the SLD of the shell 76 sld_solvent = the SLD of the solvent 77 volfraction = volume fraction of core-shell particles 78 fractal_dim = fractal dimension 79 cor_length = correlation length of the fractal like aggretates 80 """ 59 """ 81 60 category = "shape-independent" 82 61 … … 128 107 129 108 tests = [[{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0], 130 [{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704] ]109 [{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704], 131 110 132 # # The SasView test result was 0.00169, with a background of 0.001 133 # # They are however wrong as we now know. IGOR might be a more 134 # # appropriate source. Otherwise will just have to assume this is now 135 # # correct and self generate a correct answer for the future. Until we 136 # # figure it out leave the tests commented out 137 # [{'radius': 60.0, 138 # 'thickness': 10.0, 139 # 'sld_core': 1.0, 140 # 'sld_shell': 2.0, 141 # 'sld_solvent': 3.0, 142 # 'background': 0.0 143 # }, 0.015211, 692.84]] 111 # The SasView test result was 0.00169, with a background of 0.001 112 [{'radius': 60.0, 113 'thickness': 10.0, 114 'sld_core': 1.0, 115 'sld_shell': 2.0, 116 'sld_solvent': 3.0, 117 'background': 0.0 118 }, 0.4, 0.00070126]] -
sasmodels/models/stacked_disks.c
r98ce141 r3ac4e1b 71 71 // loop for the structure factor S(q) 72 72 double qd_cos_alpha = q*d*cos_alpha; 73 //d*cos_alpha is the projection of d onto q (in other words the component74 //of d that is parallel to q.75 73 double debye_arg = -0.5*square(qd_cos_alpha*sigma_dnn); 76 74 double sq=0.0; … … 81 79 sq = 1.0 + 2.0*sq/n_stacking; 82 80 83 return pq * sq * n_stacking; 84 // volume normalization should be per disk not per stack but form_volume 85 // is per stack so correct here for now. Could change form_volume but 86 // if one ever wants to use P*S we need the ER based on the total volume 81 return pq * sq; 87 82 } 88 83 -
sasmodels/models/stacked_disks.py
r07300ea ref5a314 1 1 r""" 2 This model provides the form factor, $P(q)$, for stacked discs (tactoids) 3 with a core/layer structure where the form factor is normalized by the volume 4 of the cylinder. Assuming the next neighbor distance (d-spacing) in a stack 5 of parallel discs obeys a Gaussian distribution, a structure factor $S(q)$ 6 proposed by Kratky and Porod in 1949 is used in this function. 7 8 Note that the resolution smearing calculation uses 76 Gauss quadrature points 9 to properly smear the model since the function is HIGHLY oscillatory, 10 especially around the q-values that correspond to the repeat distance of 11 the layers. 12 13 The 2D scattering intensity is the same as 1D, regardless of the orientation 14 of the q vector which is defined as 15 16 .. math:: q = \sqrt{q_x^2 + q_y^2} 17 2 18 Definition 3 19 ---------- 4 20 5 This model provides the form factor, $P(q)$, for stacked discs (tactoids)6 with a core/layer structure which is constructed itself as $P(q) S(Q)$7 multiplying a $P(q)$ for individual core/layer disks by a structure factor8 $S(q)$ proposed by Kratky and Porod in 1949\ [#CIT1949]_ assuming the next9 neighbor distance (d-spacing) in the stack of parallel discs obeys a Gaussian10 distribution. As such the normalization of this "composite" form factor is11 relative to the individual disk volume, not the volume of the stack of disks.12 This model is appropriate for example for non non exfoliated clay particles such13 as Laponite.14 15 21 .. figure:: img/stacked_disks_geometry.png 16 22 17 Geometry of a single core/layer disk18 19 23 The scattered intensity $I(q)$ is calculated as 20 24 … … 22 26 23 27 I(q) = N\int_{0}^{\pi /2}\left[ \Delta \rho_t 24 \left( V_t f_t(q,\alpha) - V_c f_c(q,\alpha)\right) + \Delta 25 \rho_c V_c f_c(q,\alpha)\right]^2 S(q,\alpha)\sin{\alpha}\ d\alpha 26 + \text{background} 28 \left( V_t f_t(q) - V_c f_c(q)\right) + \Delta \rho_c V_c f_c(q) 29 \right]^2 S(q)\sin{\alpha}\ d\alpha + \text{background} 27 30 28 31 where the contrast … … 32 35 \Delta \rho_i = \rho_i - \rho_\text{solvent} 33 36 34 and $N$ is the number of individual (single) discs per unit volume, $\alpha$ is 35 the angle between the axis of the disc and $q$, and $V_t$ and $V_c$ are the 36 total volume and the core volume of a single disc, respectively, and 37 38 .. math:: 39 40 f_t(q,\alpha) = 37 and $N$ is the number of discs per unit volume, 38 $\alpha$ is the angle between the axis of the disc and $q$, 39 and $V_t$ and $V_c$ are the total volume and the core volume of 40 a single disc, respectively. 41 42 .. math:: 43 44 \left\langle f_{t}^2(q)\right\rangle_{\alpha} = 45 \int_{0}^{\pi/2}\left[ 41 46 \left(\frac{\sin(q(d+h)\cos{\alpha})}{q(d+h)\cos{\alpha}}\right) 42 47 \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right) 43 44 f_c(q,\alpha) = 48 \right]^2 \sin{\alpha}\ d\alpha 49 50 \left\langle f_{c}^2(q)\right\rangle_{\alpha} = 51 \int_{0}^{\pi/2}\left[ 45 52 \left(\frac{\sin(qh)\cos{\alpha})}{qh\cos{\alpha}}\right) 46 53 \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}}\right) 54 \right]^2 \sin{\alpha}\ d\alpha 47 55 48 56 where $d$ = thickness of the layer (*thick_layer*), … … 51 59 .. math:: 52 60 53 S(q ,\alpha) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})}54 \exp\left[ -k(q )^2(D\cos{\alpha}~\sigma_d)^2/2\right]61 S(q) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})} 62 \exp\left[ -k(q\cos{\alpha})^2\sigma_d/2\right] 55 63 56 64 where $n$ is the total number of the disc stacked (*n_stacking*), 57 65 $D = 2(d+h)$ is the next neighbor center-to-center distance (d-spacing), 58 66 and $\sigma_d$ = the Gaussian standard deviation of the d-spacing (*sigma_d*). 59 Note that $D\cos(\alpha)$ is the component of $D$ parallel to $q$ and the last60 term in the equation above is effectively a Debye-Waller factor term.61 67 62 68 .. note:: 63 64 1. Each assembly in the stack is layer/core/layer, so the spacing of the 69 Each assembly in the stack is layer/core/layer, so the spacing of the 65 70 cores is core plus two layers. The 2nd virial coefficient of the cylinder 66 71 is calculated based on the *radius* and *length* … … 69 74 is applied. 70 75 71 2. the resolution smearing calculation uses 76 Gaussian quadrature points72 to properly smear the model since the function is HIGHLY oscillatory,73 especially around the q-values that correspond to the repeat distance of74 the layers.75 76 76 To provide easy access to the orientation of the stacked disks, we define 77 77 the axis of the cylinder using two angles $\theta$ and $\varphi$. … … 79 79 .. figure:: img/cylinder_angle_definition.jpg 80 80 81 Examples of the angles against the detector plane. 82 83 84 Our model is derived from the form factor calculations implemented in a 85 c-library provided by the NIST Center for Neutron Research\ [#CIT_Kline]_ 81 Examples of the angles against 82 the detector plane. 83 84 85 Our model uses the form factor calculations implemented in a c-library provided 86 by the NIST Center for Neutron Research (Kline, 2006) 86 87 87 88 References 88 89 ---------- 89 90 90 .. [#CIT1949] O Kratky and G Porod, *J. Colloid Science*, 4, (1949) 35 91 .. [#CIT_Kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 89592 .. [#] J S Higgins and H C Benoit, *Polymers and Neutron Scattering*, 93 Clarendon, Oxford, 1994 94 .. [#] A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, 95 John Wiley and Sons, New York, 1955 96 97 Authorship and Verification 98 ---------------------------- 99 100 * **Author:** NIST IGOR/DANSE **Date:** pre 2010101 * **Last Modified by:** Paul Butler and Paul Kienzle **on:** November 26, 2016 102 * **Last Reviewed by:** Paul Butler and Paul Kienzle **on:** November 26, 201691 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, 92 John Wiley and Sons, New York, 1955 93 94 O Kratky and G Porod, *J. Colloid Science*, 4, (1949) 35 95 96 J S Higgins and H C Benoit, *Polymers and Neutron Scattering*, 97 Clarendon, Oxford, 1994 98 99 **Author:** NIST IGOR/DANSE **on:** pre 2010 100 101 **Last Modified by:** Piotr Rozyczko **on:** February 18, 2016 102 103 **Last Reviewed by:** Richard Heenan **on:** March 22, 2016 103 104 """ 104 105 … … 106 107 107 108 name = "stacked_disks" 108 title = " Form factor for a stacked set of non exfoliated core/shell disks"109 title = "" 109 110 description = """\ 110 111 One layer of disk consists of a core, a top layer, and a bottom layer.
Note: See TracChangeset
for help on using the changeset viewer.