Changes in / [e1ea6b5:9eb5eca] in sasmodels
- Location:
- sasmodels
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r8c65a33 rfe25eda 1063 1063 # Evaluate preset parameter expressions 1064 1064 context = MATH.copy() 1065 context['np'] = np 1065 1066 context.update(pars) 1066 1067 context.update((k,v) for k,v in presets.items() if isinstance(v, float)) -
sasmodels/details.py
r6dc78e4 rccd5f01 230 230 npars = kernel.info.parameters.npars 231 231 nvalues = kernel.info.parameters.nvalues 232 scalars = [ v[0][0] for vin pairs]232 scalars = [(v[0] if len(v) else np.NaN) for v, w 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
r5df888c rbf9de53 67 67 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 68 68 * **Last Modified by:** Paul Kienzle **Date:** July 24, 2016 69 * **Last Reviewed by:** Piotr rozyczko **Date:** January 27, 2016 69 * **Last Reviewed by:** Paul Butler and Richard Heenan **Date:** 70 October 07, 2016 70 71 """ 71 72 -
sasmodels/models/core_multi_shell.py
rb0c4271 r2d73a53 13 13 14 14 The 2D scattering intensity is the same as $P(q)$ above, regardless of the 15 orientation of the $ q$ vector which is defined as15 orientation of the $\vec 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) .31 by the NIST Center for Neutron Research (Kline, 2006) [#kline]_. 32 32 33 33 References … … 35 35 36 36 .. [#] See the :ref:`core-shell-sphere` model documentation. 37 .. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, 38 Plenum Press, New York, 1987. 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. 39 40 40 41 Authorship and Verification … … 43 44 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 44 45 * **Last Modified by:** Paul Kienzle **Date:** September 12, 2016 45 * **Last Reviewed by:** Under Review **Date:** as of October 5, 201646 * **Last Reviewed by:** Paul Kienzle **Date:** September 12, 2016 46 47 """ 47 48 -
sasmodels/models/core_shell_cylinder.py
r40a87fa r755ecc2 1 # core shell cylinder model2 # Note: model title and parameter table are inserted automatically3 1 r""" 4 The form factor is normalized by the particle volume.5 6 2 Definition 7 3 ---------- 8 4 9 5 The output of the 2D scattering intensity function for oriented core-shell 10 cylinders is given by (Kline, 2006) 6 cylinders is given by (Kline, 2006 [#kline]_). The form factor is normalized 7 by the particle volume. 11 8 12 9 .. math:: … … 61 58 The $\theta$ and $\phi$ parameters are not used for the 1D output. 62 59 63 Validation64 ----------65 66 Validation of our code was done by comparing the output of the 1D model to67 the output of the software provided by the NIST (Kline, 2006).68 69 Averaging over a distribution of orientation is done by evaluating the70 equation above. Since we have no other software to compare the71 implementation of the intensity for fully oriented cylinders, we72 compared the result of averaging our 2D output using a uniform73 distribution $p(\theta,\phi) = 1.0$.74 75 60 Reference 76 61 --------- 77 see, for example, Ian Livsey J. Chem. Soc., Faraday Trans. 2, 1987,83, 1445-145278 62 79 2016/03/18 - Description reviewed by RKH 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 80 73 """ 81 74 … … 158 151 theta_pd=15, theta_pd_n=45, 159 152 phi_pd=15, phi_pd_n=1) 160 # ADDED by: RKH ON: 18Mar2016 renamed sld's etc 153 -
sasmodels/models/core_shell_parallelepiped.py
r14838a3 r5810f00 1 # core_shell_parallelepiped model2 # Note: model title and parameter table are inserted automatically3 1 r""" 2 Definition 3 ---------- 4 4 5 Calculates the form factor for a rectangular solid with a core-shell structure. 5 6 **The thickness and the scattering length density of the shell or "rim" … … 15 16 of the rectangular solid. 16 17 17 An instrument resolution smeared version of the model is also provided.18 19 20 Definition21 ----------22 18 23 19 The function calculated is the form factor of the rectangular solid below. … … 41 37 **meaning that there are "gaps" at the corners of the solid.** 42 38 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. 46 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.** 39 The intensity calculated follows the :ref:`parallelepiped` model, with the 40 core-shell intensity being calculated as the square of the sum of the 41 amplitudes of the core and shell, in the same manner as a core-shell model. 42 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. 51 58 52 59 FITTING NOTES 53 60 If the scale is set equal to the particle volume fraction, |phi|, the returned 54 61 value is the scattered intensity per unit volume, $I(q) = \phi P(q)$. 55 However, **no interparticle interference effects are included in this calculation.** 62 However, **no interparticle interference effects are included in this 63 calculation.** 56 64 57 65 There are many parameters in this model. Hold as many fixed as possible with … … 68 76 and length $(C+2t_C)$ values, and used as the effective radius 69 77 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 interference73 effects are not included.74 78 75 79 To provide easy access to the orientation of the parallelepiped, we define the … … 98 102 ---------- 99 103 100 P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 101 Equations (1), (13-14). (in German) 102 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>`_ 110 111 Authorship and Verification 112 ---------------------------- 113 114 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 115 * **Last Modified by:** Paul Butler **Date:** September 30, 2016 116 * **Last Reviewed by:** Miguel Gonzales **Date:** March 21, 2016 103 117 """ 104 118 -
sasmodels/models/fractal_core_shell.c
r217590b rbdd08df 16 16 double cor_length) 17 17 { 18 const double sq = fractal_sq(q, radius, fractal_dim, cor_length); 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); 19 22 const double pq = core_shell_kernel(q, radius, thickness, 20 23 core_sld, shell_sld, solvent_sld); -
sasmodels/models/fractal_core_shell.py
r217590b rd6f60c3 1 1 r""" 2 Definition 3 ---------- 2 4 Calculates the scattering from a fractal structure with a primary building 3 5 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 8 Definition 9 ---------- 6 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-shell 8 sphere. This model could find use for aggregates of coated particles, or 9 aggregates of vesicles for example. 10 10 11 11 .. math:: 12 12 13 I(q) = \text{background} + P(q)S(q)13 I(q) = P(q)S(q) + \text{background} 14 14 15 The form factor $P(q)$ is that from core_shell model with $bkg$ = 0 16 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: 17 18 18 19 .. math:: 19 20 20 P(q) =\frac{scale}{V_s}\left[3V_c(\rho_c-\rho_s)21 P(q) &= \frac{\phi}{V_s}\left[3V_c(\rho_c-\rho_s) 21 22 \frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+ 22 23 3V_s(\rho_s-\rho_{solv}) 23 24 \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 24 25 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}} 25 28 26 while the fractal structure factor $S(q)$ is 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. 27 37 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 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 41 40 42 41 .. math:: … … 44 43 q = \sqrt{q_x^2 + q_y^2} 45 44 45 Our model is derived from the form factor calculations implemented in IGOR 46 macros by the NIST Center for Neutron Research\ [#Kline]_ 47 46 48 References 47 49 ---------- 48 50 49 See the core_shell and fractal model descriptions 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 50 60 51 61 """ … … 54 64 55 65 name = "fractal_core_shell" 56 title = "" 57 description = """ 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 58 70 59 """ 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 """ 60 81 category = "shape-independent" 61 82 … … 107 128 108 129 tests = [[{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0], 109 [{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704] ,130 [{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704]] 110 131 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]] 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]] -
sasmodels/models/stacked_disks.c
r3ac4e1b r98ce141 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 component 74 //of d that is parallel to q. 73 75 double debye_arg = -0.5*square(qd_cos_alpha*sigma_dnn); 74 76 double sq=0.0; … … 79 81 sq = 1.0 + 2.0*sq/n_stacking; 80 82 81 return pq * sq; 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 82 87 } 83 88 -
sasmodels/models/stacked_disks.py
ref5a314 r07300ea 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 volume4 of the cylinder. Assuming the next neighbor distance (d-spacing) in a stack5 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 points9 to properly smear the model since the function is HIGHLY oscillatory,10 especially around the q-values that correspond to the repeat distance of11 the layers.12 13 The 2D scattering intensity is the same as 1D, regardless of the orientation14 of the q vector which is defined as15 16 .. math:: q = \sqrt{q_x^2 + q_y^2}17 18 2 Definition 19 3 ---------- 20 4 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 factor 8 $S(q)$ proposed by Kratky and Porod in 1949\ [#CIT1949]_ assuming the next 9 neighbor distance (d-spacing) in the stack of parallel discs obeys a Gaussian 10 distribution. As such the normalization of this "composite" form factor is 11 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 such 13 as Laponite. 14 21 15 .. figure:: img/stacked_disks_geometry.png 22 16 17 Geometry of a single core/layer disk 18 23 19 The scattered intensity $I(q)$ is calculated as 24 20 … … 26 22 27 23 I(q) = N\int_{0}^{\pi /2}\left[ \Delta \rho_t 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} 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} 30 27 31 28 where the contrast … … 35 32 \Delta \rho_i = \rho_i - \rho_\text{solvent} 36 33 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[ 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) = 46 41 \left(\frac{\sin(q(d+h)\cos{\alpha})}{q(d+h)\cos{\alpha}}\right) 47 42 \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right) 48 \right]^2 \sin{\alpha}\ d\alpha 49 50 \left\langle f_{c}^2(q)\right\rangle_{\alpha} = 51 \int_{0}^{\pi/2}\left[ 43 44 f_c(q,\alpha) = 52 45 \left(\frac{\sin(qh)\cos{\alpha})}{qh\cos{\alpha}}\right) 53 46 \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}}\right) 54 \right]^2 \sin{\alpha}\ d\alpha55 47 56 48 where $d$ = thickness of the layer (*thick_layer*), … … 59 51 .. math:: 60 52 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]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] 63 55 64 56 where $n$ is the total number of the disc stacked (*n_stacking*), 65 57 $D = 2(d+h)$ is the next neighbor center-to-center distance (d-spacing), 66 58 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 last 60 term in the equation above is effectively a Debye-Waller factor term. 67 61 68 62 .. note:: 69 Each assembly in the stack is layer/core/layer, so the spacing of the 63 64 1. Each assembly in the stack is layer/core/layer, so the spacing of the 70 65 cores is core plus two layers. The 2nd virial coefficient of the cylinder 71 66 is calculated based on the *radius* and *length* … … 74 69 is applied. 75 70 71 2. the resolution smearing calculation uses 76 Gaussian quadrature points 72 to properly smear the model since the function is HIGHLY oscillatory, 73 especially around the q-values that correspond to the repeat distance of 74 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 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) 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]_ 87 86 88 87 References 89 88 ---------- 90 89 91 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, 92 John Wiley and Sons, New York, 195593 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, 2016102 103 * *Last Reviewed by:** Richard Heenan **on:** March 22, 201690 .. [#CIT1949] O Kratky and G Porod, *J. Colloid Science*, 4, (1949) 35 91 .. [#CIT_Kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 92 .. [#] 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 2010 101 * **Last Modified by:** Paul Butler and Paul Kienzle **on:** November 26, 2016 102 * **Last Reviewed by:** Paul Butler and Paul Kienzle **on:** November 26, 2016 104 103 """ 105 104 … … 107 106 108 107 name = "stacked_disks" 109 title = " "108 title = "Form factor for a stacked set of non exfoliated core/shell disks" 110 109 description = """\ 111 110 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.