Changeset eb69cce in sasmodels
- Timestamp:
- Nov 30, 2015 9:18:41 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- d18f8a8
- Parents:
- d138d43
- Location:
- sasmodels
- Files:
-
- 2 added
- 4 deleted
- 28 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
rd138d43 reb69cce 258 258 %(parameters)s 259 259 260 The returned value is scaled to units of |cm^-1|. 260 %(returns)s 261 261 262 262 %(docs)s … … 609 609 Return the documentation for the model. 610 610 """ 611 Iq_units = "The returned value is scaled to units of |cm^-1| |sr^-1|, absolute scale." 612 Sq_units = "The returned value is a dimensionless structure factor, $S(q)$." 611 613 info = make_info(kernel_module) 614 is_Sq = ("structure-factor" in info['category']) 612 615 subst = dict(id=info['id'].replace('_', '-'), 613 616 name=info['name'], 614 617 title=info['title'], 615 618 parameters=make_partable(info['parameters']), 619 returns=Sq_units if is_Sq else Iq_units, 616 620 docs=kernel_module.__doc__) 617 621 return DOC_HEADER % subst -
sasmodels/models/HayterMSAsq.py
rcd3dba0 reb69cce 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 correlation function *g(r)*) for a system of 4 charged, spheroidal objects in a dielectric medium. When combined with an appropriate form factor (such as sphere, 5 core+shell, ellipsoid, etc), this allows for inclusion of the interparticle interference effects due to screened coulomb 6 repulsion between charged particles. 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. 7 9 8 **This routine only works for charged particles**. If the charge is set to zero the routine will self-destruct! 9 For non-charged particles use a hard sphere potential. 10 **This routine only works for charged particles**. If the charge is set to 11 zero the routine will self-destruct! For non-charged particles use a hard 12 sphere potential. 10 13 11 The salt concentration is used to compute the ionic strength of the solution which in turn is used to compute the Debye 12 screening length. At present there is no provision for entering the ionic strength directly nor for use of any 13 multivalent salts. The counterions are also assumed to be monovalent. 14 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 present 16 there is no provision for entering the ionic strength directly nor for use 17 of any multivalent salts. The counterions are also assumed to be monovalent. 14 18 15 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as 19 For 2D data, the scattering intensity is calculated in the same way as 1D, 20 where the $q$ vector is defined as 16 21 17 22 .. math:: 18 23 19 Q = \sqrt{Q_x^2 + Q_y^2}24 q = \sqrt{q_x^2 + q_y^2} 20 25 21 ============== ======== ============= 22 Parameter name Units Default value 23 ============== ======== ============= 24 effect_radius |Ang| 20.8 25 charge *e* 19 26 volfraction None 0.2 27 temperature K 318 28 salt conc M 0 29 dielectconst None 71.1 30 ============== ======== ============= 26 .. figure:: img/HayterMSAsq_227.jpg 31 27 32 .. image:: img/HayterMSAsq_227.jpg 28 1D plot using the default values (in linear scale). 33 29 34 *Figure. 1D plot using the default values (in linear scale).* 35 36 REFERENCE 30 References 31 ---------- 37 32 38 33 J B Hayter and J Penfold, *Molecular Physics*, 42 (1981) 109-118 -
sasmodels/models/barbell.py
r5ef0633 reb69cce 1 1 #barbell model 2 # cylinder model3 2 # Note: model title and parameter table are inserted automatically 4 3 r""" 5 6 Calculates the scattering from a barbell-shaped cylinder (This model simply 7 becomes the DumBellModel when the length of the cylinder, *L*, is set to zero). 8 That is, a sphereocylinder with spherical end caps that have a radius larger 9 than that of the cylinder and the center of the end cap radius lies outside 10 of the cylinder. All dimensions of the BarBell are considered to be 11 monodisperse. See the diagram for the details of the geometry and restrictions 12 on parameter values. 4 Calculates the scattering from a barbell-shaped cylinder. Like 5 :ref:`capped-cylinder`, this is a sphereocylinder with spherical end 6 caps that have a radius larger than that of the cylinder, but with the center 7 of the end cap radius lying outside of the cylinder. See the diagram for 8 the details of the geometry and restrictions on parameter values. 13 9 14 10 Definition 15 11 ---------- 16 12 17 The returned value is scaled to units of |cm^-1|\ |sr^-1|, absolute scale. 13 .. figure:: img/barbell_geometry.jpg 18 14 19 The barbell geometry is defined as 15 Barbell geometry, where $r$ is *radius*, $R$ is *bell_radius* and 16 $L$ is *length*. Since the end cap radius $R \geq r$ and by definition 17 for this geometry $h < 0$, $h$ is then defined by $r$ and $R$ as 18 $h = - \sqrt{R^2 - r^2}$ 20 19 21 .. image:: img/barbell_geometry.jpg 22 23 where *r* is the radius of the cylinder. All other parameters are as defined 24 in the diagram. 25 26 Since the end cap radius 27 *R* >= *r* and by definition for this geometry *h* < 0, *h* is then 28 defined by *r* and *R* as 29 30 *h* = -1 \* sqrt(*R*\ :sup:`2` - *r*\ :sup:`2`) 31 32 The scattered intensity *I(q)* is calculated as 20 The scattered intensity $I(q)$ is calculated as 33 21 34 22 .. math:: 35 23 36 I( Q) = \frac{(\Delta \rho)^2}{V} \left< A^2(Q)\right>24 I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> 37 25 38 where the amplitude *A(q)*is given as26 where the amplitude $A(q)$ is given as 39 27 40 28 .. math:: 41 29 42 A( Q) =&\ \pi r^2L43 {\sin\left(\tfrac12 QL\cos\theta\right)44 \over \tfrac12 QL\cos\theta}45 {2 J_1(Qr\sin\theta) \over Qr\sin\theta} \\30 A(q) =&\ \pi r^2L 31 \frac{\sin\left(\tfrac12 qL\cos\theta\right)} 32 {\tfrac12 qL\cos\theta} 33 \frac{2 J_1(qr\sin\theta)}{qr\sin\theta} \\ 46 34 &\ + 4 \pi R^3 \int_{-h/R}^1 dt 47 \cos\left[ Q\cos\theta35 \cos\left[ q\cos\theta 48 36 \left(Rt + h + {\tfrac12} L\right)\right] 49 37 \times (1-t^2) 50 {J_1\left[QR\sin\theta \left(1-t^2\right)^{1/2}\right]51 \over QR\sin\theta \left(1-t^2\right)^{1/2}}38 \frac{J_1\left[qR\sin\theta \left(1-t^2\right)^{1/2}\right]} 39 {qR\sin\theta \left(1-t^2\right)^{1/2}} 52 40 53 The < > brackets denote an average of the structure over all orientations.54 <*A* :sup:`2`\ *(q)*> is then the form factor, *P(q)*. The scale factor is 55 equivalent to the volume fraction of cylinders, each of volume, *V*. Contrast 56 is the difference of scattering length densities of the cylinder and the 57 surrounding solvent.41 The $\left<\ldots\right>$ brackets denote an average of the structure over 42 all orientations. $\left<A^2(q)\right>$ is then the form factor, $P(q)$. 43 The scale factor is equivalent to the volume fraction of cylinders, each of 44 volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length 45 densities of the cylinder and the surrounding solvent. 58 46 59 47 The volume of the barbell is … … 64 52 65 53 66 and its radius -of-gyration is54 and its radius of gyration is 67 55 68 56 .. math:: … … 76 64 \left( 4R^3 6R^2h - 2h^3 + 3r^2L \right)^{-1} 77 65 78 **The requirement that** *R* >= *r* **is not enforced in the model!** It is 79 up to you to restrict this during analysis. 66 .. note:: 67 The requirement that $R \geq r$ is not enforced in the model! It is 68 up to you to restrict this during analysis. 80 69 81 This example dataset is produced by running the Macro PlotBarbell(), 82 using 200 data points, *qmin* = 0.001 |Ang^-1|, *qmax* = 0.7 |Ang^-1|, 83 *sld* = 4e-6 |Ang^-2| and the default model values. 70 .. figure:: img/barbell_1d.jpg 84 71 85 .. image:: img/barbell_1d.jpg 72 1D plot using the default values (w/256 data point). 86 73 87 *Figure. 1D plot using the default values (w/256 data point).* 74 For 2D data, the scattering intensity is calculated similar to the 2D 75 cylinder model. 88 76 89 For 2D data: The 2D scattering intensity is calculated similar to the 2D 90 cylinder model. For example, for |theta| = 45 deg and |phi| = 0 deg with 91 default values for other parameters 77 .. figure:: img/barbell_2d.jpg 92 78 93 .. image:: img/barbell_2d.jpg 79 2D plot (w/(256X265) data points) for $\theta = 45^\circ$ and 80 $\phi = 0^\circ$ with default values for the remaining parameters. 94 81 95 *Figure. 2D plot (w/(256X265) data points).* 82 .. figure:: img/orientation.jpg 96 83 97 .. image:: img/orientation.jpg 84 Definition of the angles for oriented 2D barbells. 98 85 99 Figure. Definition of the angles for oriented 2D barbells. 86 .. figure:: img/orientation2.jpg 100 87 101 .. image:: img/orientation2.jpg 88 Examples of the angles for oriented pp against the detector plane. 102 89 103 *Figure. Examples of the angles for oriented pp against the detector plane.* 104 105 REFERENCE 106 --------- 90 References 91 ---------- 107 92 108 93 H Kaya, *J. Appl. Cryst.*, 37 (2004) 37 223-230 109 94 110 95 H Kaya and N R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata) 111 112 96 """ 113 97 from numpy import inf … … 124 108 125 109 # ["name", "units", default, [lower, upper], "type","description"], 126 parameters = [["sld", " 1e-6/Ang^2", 4, [-inf, inf], "", "Barbell scattering length density"],110 parameters = [["sld", "4e-6/Ang^2", 4, [-inf, inf], "", "Barbell scattering length density"], 127 111 ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", "Solvent scattering length density"], 128 112 ["bell_radius", "Ang", 40, [0, inf], "volume", "Spherical bell radius"], -
sasmodels/models/bcc.py
rd138d43 reb69cce 13 13 The scattering intensity $I(q)$ is calculated as 14 14 15 .. math: 15 .. math:: 16 16 17 I(q) = \frac{\text{scale}}{V_ P} V_\text{lattice} P(q) Z(q)17 I(q) = \frac{\text{scale}}{V_p} V_\text{lattice} P(q) Z(q) 18 18 19 19 20 where *scale* is the volume fraction of spheres, *Vp*is the volume of the21 primary particle, *V(lattice)*is a volume correction for the crystal20 where *scale* is the volume fraction of spheres, $V_p$ is the volume of the 21 primary particle, $V_\text{lattice}$ is a volume correction for the crystal 22 22 structure, $P(q)$ is the form factor of the sphere (normalized), and $Z(q)$ 23 23 is the paracrystalline structure factor for a body-centered cubic structure. 24 24 25 25 Equation (1) of the 1990 reference is used to calculate $Z(q)$, using 26 equations (29)-(31) from the 1987 paper for *Z1*\ , *Z2*\ , and *Z3*\.26 equations (29)-(31) from the 1987 paper for $Z1$, $Z2$, and $Z3$. 27 27 28 28 The lattice correction (the occupied volume of the lattice) for a … … 30 30 separation $D$ is 31 31 32 .. math: 32 .. math:: 33 33 34 34 V_\text{lattice} = \frac{16\pi}{3} \frac{R^3}{\left(D\sqrt{2}\right)^3} … … 38 38 in the calculation of $Z(q)$ 39 39 40 .. math: 40 .. math:: 41 41 42 42 \Delta a = g D … … 51 51 For a crystal, diffraction peaks appear at reduced q-values given by 52 52 53 .. math: 53 .. math:: 54 54 55 55 \frac{qD}{2\pi} = \sqrt{h^2 + k^2 + l^2} … … 60 60 correspond to (just the first 5) 61 61 62 .. math: 62 .. math:: 63 63 64 \begin{ eqnarray}65 &q/q_o&&\quad 1&& \ \sqrt{2} && \ \sqrt{3} && \ \sqrt{4} && \\sqrt{5} \\66 &\text{Indices}&& (110) && (200) && (211) && (220) && (310)67 \end{ eqnarray}64 \begin{array}{lccccc} 65 q/q_o & 1 & \sqrt{2} & \sqrt{3} & \sqrt{4} & \sqrt{5} \\ 66 \text{Indices} & (110) & (200) & (211) & (220) & (310) \\ 67 \end{array} 68 68 69 69 **NB**: The calculation of $Z(q)$ is a double numerical integral that must … … 86 86 model computation. 87 87 88 .. figure:: img/crystal_orientation. gif88 .. figure:: img/crystal_orientation.png 89 89 90 90 Orientation of the crystal with respect to the scattering plane. … … 94 94 2D plot using the default values (w/200X200 pixels).* 95 95 96 Reference 97 --------- 96 References 97 ---------- 98 98 99 99 Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 -
sasmodels/models/broad_peak.py
rd138d43 reb69cce 10 10 spherical morphologies, or for bicontinuous structures). 11 11 12 The returned value is scaled to units of |cm^-1|, absolute scale.13 14 12 Definition 15 13 ---------- 16 14 17 The scattering intensity *I(q)*is calculated as15 The scattering intensity $I(q)$ is calculated as 18 16 19 .. math: 17 .. math:: 20 18 21 I(q) = \frac{A}{ Q^n} + \frac{C}{1 + (Q\xi}^m} + B19 I(q) = \frac{A}{q^n} + \frac{C}{1 + (q\xi)^m} + B 22 20 23 Here the peak position is related to the d-spacing as *Q0* = 2|pi| / *d0*.21 Here the peak position is related to the d-spacing as $q_o = 2\pi / d_o$. 24 22 25 For 2D data : The 2Dscattering intensity is calculated in the same way as 1D,26 where the *q*vector is defined as23 For 2D data the scattering intensity is calculated in the same way as 1D, 24 where the $q$ vector is defined as 27 25 28 .. math: 26 .. math:: 29 27 30 28 q = \sqrt{q_x^2 + q_y^2} … … 35 33 1D plot using the default values (w/200 data point). 36 34 37 R EFERENCE38 --------- 35 References 36 ---------- 39 37 40 38 None. … … 75 73 / (1.0 + (abs(q - peak_pos) * lorentz_length) ** lorentz_exp)) 76 74 return inten 77 Iq.vectorized = True # Iq accepts an array of Qvalues75 Iq.vectorized = True # Iq accepts an array of q values 78 76 79 77 def Iqxy(qx, qy, *args): 80 78 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 81 Iqxy.vectorized = True # Iqxy accepts an array of Qx, Qy values79 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 82 80 83 81 -
sasmodels/models/capped_cylinder.py
r485aee2 reb69cce 1 1 r""" 2 2 Calculates the scattering from a cylinder with spherical section end-caps. 3 This model simply becomes the a convex lens when the length of the cylinder 4 $L=0$, that is, a sphereocylinder with end caps that have a radius larger 5 than that of the cylinder and the center of the end cap radius lies within 6 the cylinder. See the diagram for the details of the geometry and 7 restrictions on parameter values.3 Like :ref:`barbell`, this is a sphereocylinder with end caps that have a 4 radius larger than that of the cylinder, but with the center of the end cap 5 radius lying within the cylinder. This model simply becomes the a convex 6 lens when the length of the cylinder $L=0$. See the diagram for the details 7 of the geometry and restrictions on parameter values. 8 8 9 9 Definitions 10 10 ----------- 11 11 12 The returned value is scaled to units of |cm^-1|\ |sr^-1|, absolute scale. 12 .. figure:: img/capped_cylinder_geometry.jpg 13 13 14 The capped cylinder geometry is defined as 14 Capped cylinder geometry, where $r$ is *radius*, $R$ is *bell_radius* and 15 $L$ is *length*. Since the end cap radius $R \geq r$ and by definition 16 for this geometry $h < 0$, $h$ is then defined by $r$ and $R$ as 17 $h = - \sqrt{R^2 - r^2}$ 15 18 16 .. image:: img/capped_cylinder_geometry.jpg 17 18 where $r$ is the radius of the cylinder. All other parameters are as defined 19 in the diagram. Since the end cap radius $R \ge r$ and by definition for this 20 geometry $h < 0$, $h$ is then defined by $r$ and $R$ as 19 The scattered intensity $I(q)$ is calculated as 21 20 22 21 .. math:: 23 22 24 h = - \sqrt{R^2 - r^2}23 I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> 25 24 26 The scattered intensity $I(Q)$ is calculatedas25 where the amplitude $A(q)$ is given as 27 26 28 27 .. math:: 29 28 30 I(Q) = \frac{(\Delta \rho)^2}{V} \left< A^2(Q)\right> 31 32 where the amplitude $A(Q)$ is given as 33 34 .. math:: 35 36 A(Q) =&\ \pi r^2L 37 {\sin\left(\tfrac12 QL\cos\theta\right) 38 \over \tfrac12 QL\cos\theta} 39 {2 J_1(Qr\sin\theta) \over Qr\sin\theta} \\ 29 A(q) =&\ \pi r^2L 30 \frac{\sin\left(\tfrac12 qL\cos\theta\right)} 31 {\tfrac12 qL\cos\theta} 32 \frac{2 J_1(qr\sin\theta)}{qr\sin\theta} \\ 40 33 &\ + 4 \pi R^3 \int_{-h/R}^1 dt 41 \cos\left[ Q\cos\theta34 \cos\left[ q\cos\theta 42 35 \left(Rt + h + {\tfrac12} L\right)\right] 43 36 \times (1-t^2) 44 {J_1\left[QR\sin\theta \left(1-t^2\right)^{1/2}\right]45 \over QR\sin\theta \left(1-t^2\right)^{1/2}}37 \frac{J_1\left[qR\sin\theta \left(1-t^2\right)^{1/2}\right]} 38 {qR\sin\theta \left(1-t^2\right)^{1/2}} 46 39 47 The $\left< \ldots\right>$ brackets denote an average of the structure over48 all orientations. $\left< A^2( Q)\right>$ is then the form factor, $P(Q)$.40 The $\left<\ldots\right>$ brackets denote an average of the structure over 41 all orientations. $\left< A^2(q)\right>$ is then the form factor, $P(q)$. 49 42 The scale factor is equivalent to the volume fraction of cylinders, each of 50 volume, $V$. Contrast is the difference of scattering length densities of51 the cylinder and the surrounding solvent.43 volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length 44 densities of the cylinder and the surrounding solvent. 52 45 53 46 The volume of the capped cylinder is (with $h$ as a positive value here) … … 58 51 59 52 60 and its radius -of-gyration is53 and its radius of gyration is 61 54 62 55 .. math:: … … 73 66 .. note:: 74 67 75 The requirement that $R \ge r$ is not enforced in the model!68 The requirement that $R \geq r$ is not enforced in the model! 76 69 It is up to you to restrict this during analysis. 77 70 … … 104 97 Examples of the angles for oriented pp against the detector plane. 105 98 106 REFERENCE 99 References 100 ---------- 107 101 108 102 H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230 -
sasmodels/models/core_shell_cylinder.py
r485aee2 reb69cce 12 12 .. math:: 13 13 14 P( Q,\alpha) = {\text{scale} \over V_s} F^2(Q) + \text{background}14 P(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q) + \text{background} 15 15 16 16 where … … 18 18 .. math:: 19 19 20 F( Q) = &\ (\rho_c - \rho_s) V_c21 {\sin \left( Q \tfrac12 L\cos\alpha \right)22 \over Q \tfrac12 L\cos\alpha}23 {2 J_1 \left( QR\sin\alpha \right)24 \over QR\sin\alpha} \\20 F(q) = &\ (\rho_c - \rho_s) V_c 21 \frac{\sin \left( q \tfrac12 L\cos\alpha \right)} 22 {q \tfrac12 L\cos\alpha} 23 \frac{2 J_1 \left( qR\sin\alpha \right)} 24 {qR\sin\alpha} \\ 25 25 &\ + (\rho_s - \rho_\text{solv}) V_s 26 {\sin \left( Q \left(\tfrac12 L+T\right) \cos\alpha \right)27 \over Q \left(\tfrac12 L +T \right) \cos\alpha}28 { 2 J_1 \left( Q(R+T)\sin\alpha \right)29 \over Q(R+T)\sin\alpha}26 \frac{\sin \left( q \left(\tfrac12 L+T\right) \cos\alpha \right)} 27 {q \left(\tfrac12 L +T \right) \cos\alpha} 28 \frac{ 2 J_1 \left( q(R+T)\sin\alpha \right)} 29 {q(R+T)\sin\alpha} 30 30 31 31 and … … 58 58 NB: The 2nd virial coefficient of the cylinder is calculated based on 59 59 the radius and 2 length values, and used as the effective radius for 60 $S( Q)$ when $P(Q) \cdot S(Q)$ is applied.60 $S(q)$ when $P(q) \cdot S(q)$ is applied. 61 61 62 The $\theta$ and $\phi$ parameters are not used for the 1D output. Our 63 implementation of the scattering kernel and the 1D scattering intensity 64 use the c-library from NIST. 62 The $\theta$ and $\phi$ parameters are not used for the 1D output. 65 63 66 64 Validation -
sasmodels/models/cylinder.py
rd138d43 reb69cce 12 12 .. math:: 13 13 14 P( Q,\alpha) = {\text{scale} \over V} F^2(Q) + \text{background}14 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q) + \text{background} 15 15 16 16 where … … 18 18 .. math:: 19 19 20 F( Q) = 2 (\Delta \rho) V21 {\sin \left(Q\tfrac12 L\cos\alpha \right)22 \over Q\tfrac12 L \cos \alpha}23 {J_1 \left(Q R \sin \alpha\right) \over QR \sin \alpha}20 F(q) = 2 (\Delta \rho) V 21 \frac{\sin \left(q\tfrac12 L\cos\alpha \right)} 22 {q\tfrac12 L \cos \alpha} 23 \frac{J_1 \left(q R \sin \alpha\right)}{q R \sin \alpha} 24 24 25 25 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ … … 44 44 45 45 NB: The 2nd virial coefficient of the cylinder is calculated based on the 46 radius and length values, and used as the effective radius for $S( Q)$47 when $P( Q) \cdot S(Q)$ is applied.46 radius and length values, and used as the effective radius for $S(q)$ 47 when $P(q) \cdot S(q)$ is applied. 48 48 49 49 The output of the 1D scattering intensity function for randomly oriented … … 52 52 .. math:: 53 53 54 P( Q) = {\text{scale} \overV}55 \int_0^{\pi/2} F^2( Q,\alpha) \sin \alpha\ d\alpha + \text{background}54 P(q) = \frac{\text{scale}}{V} 55 \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 56 56 57 The *theta* and *phi* parameters are not used for the 1D output. Our 58 implementation of the scattering kernel and the 1D scattering intensity 59 use the c-library from NIST. 57 The $\theta$ and $\phi$ parameters are not used for the 1D output. 60 58 61 59 Validation … … 82 80 .. math:: 83 81 84 P( Q) = \int_0^{\pi/2} d\phi85 \int_0^\pi p(\theta, \phi) P_0( Q,\alpha) \sin \theta\ d\theta82 P(q) = \int_0^{\pi/2} d\phi 83 \int_0^\pi p(\theta, \phi) P_0(q,\alpha) \sin \theta\ d\theta 86 84 87 85 88 86 where $p(\theta,\phi)$ is the probability distribution for the orientation 89 and $P_0( Q,\alpha)$ is the scattering intensity for the fully oriented87 and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented 90 88 system. Since we have no other software to compare the implementation of 91 89 the intensity for fully oriented cylinders, we can compare the result of … … 129 127 130 128 # [ "name", "units", default, [lower, upper], "type", "description"], 131 parameters = [["sld", " 1e-6/Ang^2", 4, [-inf, inf], "",129 parameters = [["sld", "4e-6/Ang^2", 4, [-inf, inf], "", 132 130 "Cylinder scattering length density"], 133 131 ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", -
sasmodels/models/dab.py
rf224873 reb69cce 1 1 r""" 2 3 Scattering model class for the DAB (Debye Anderson Brumberger) Model4 5 Definition6 ----------7 2 8 3 Calculates the scattering from a randomly distributed, two-phase system based on … … 11 6 measure of the average spacing between regions of phase 1 and phase 2. **The 12 7 model also assumes smooth interfaces between the phases** and hence exhibits 13 Porod behavior (I ~ *q*\ :sup:`-4`) at large *q* (*QL* >> 1).8 Porod behavior $(I \sim q^{-4})$ at large $q$, $(qL \gg 1)$. 14 9 15 10 The DAB model is ostensibly a development of the earlier Debye-Bueche model. 16 11 17 *Definition* 12 Definition 13 ---------- 18 14 19 .. math:: I(q) = \text{scale}\cdot\frac{L^3}{(1 + (q \cdot L)^2)^2} + \text{background} 15 .. math:: 16 17 I(q) = \text{scale}\cdot\frac{L^3}{(1 + (q\cdot L)^2)^2} + \text{background} 20 18 21 19 where scale is 22 20 23 .. math:: \text{scale} = 8 \pi \phi (1-\phi) (\Delta \rho)^221 .. math:: \text{scale} = 8 \pi \phi (1-\phi) \Delta\rho^2 24 22 25 and the parameter *L*is the correlation length.23 and the parameter $L$ is the correlation length. 26 24 27 For 2D data : The 2Dscattering intensity is calculated in the same way as 1D,28 where the *q*vector is defined as25 For 2D data the scattering intensity is calculated in the same way as 1D, 26 where the $q$ vector is defined as 29 27 30 28 .. math:: q = \sqrt{q_x^2 + q_y^2} 31 32 ============== ======== =============33 Parameter name Units Default value34 ============== ======== =============35 scale None 1.036 corr length L |Ang| 50.037 background |cm^-1| 0.038 ============== ======== =============39 40 29 41 30 .. figure:: img/dab_1d.jpg … … 44 33 45 34 46 Reference 47 --------- 35 References 36 ---------- 48 37 49 38 P Debye, H R Anderson, H Brumberger, *Scattering by an Inhomogeneous Solid. II. -
sasmodels/models/ellipsoid.py
r3e428ec reb69cce 12 12 .. math:: 13 13 14 P( Q,\alpha) = {\text{scale} \over V} F^2(Q) + \text{background}14 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q) + \text{background} 15 15 16 16 where … … 18 18 .. math:: 19 19 20 F( Q) = {3 (\Delta rho)) V (\sin[Qr(R_p,R_e,\alpha)]21 - \cos[ Qr(R_p,R_e,\alpha)])22 \over [Qr(R_p,R_e,\alpha)]^3}20 F(q) = \frac{3 \Delta \rho V (\sin[qr(R_p,R_e,\alpha)] 21 - \cos[qr(R_p,R_e,\alpha)])} 22 {[qr(R_p,R_e,\alpha)]^3} 23 23 24 24 and … … 45 45 NB: The 2nd virial coefficient of the solid ellipsoid is calculated based 46 46 on the $R_p$ and $R_e$ values, and used as the effective radius for 47 $S( Q)$ when $P(Q) \cdot S(Q)$ is applied.47 $S(q)$ when $P(q) \cdot S(q)$ is applied. 48 48 49 49 .. _ellipsoid-1d: 50 50 51 .. figure:: img/ellipsoid_1d. JPG51 .. figure:: img/ellipsoid_1d.jpg 52 52 53 53 The output of the 1D scattering intensity function for randomly oriented … … 55 55 56 56 57 The $\theta$ and $\phi$ parameters are not used for the 1D output. Our 58 implementation of the scattering kernel and the 1D scattering intensity 59 use the c-library from NIST. 57 The $\theta$ and $\phi$ parameters are not used for the 1D output. 60 58 61 59 .. _ellipsoid-geometry: 62 60 63 .. figure:: img/ellipsoid_geometry. JPG61 .. figure:: img/ellipsoid_geometry.jpg 64 62 65 63 The angles for oriented ellipsoid. … … 100 98 *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. 101 99 102 The discrepancy above *q*= 0.3 |cm^-1| is due to the way the form factors100 The discrepancy above $q$ = 0.3 |cm^-1| is due to the way the form factors 103 101 are calculated in the c-library provided by NIST. A numerical integration 104 has to be performed to obtain $P( Q)$ for randomly oriented particles.102 has to be performed to obtain $P(q)$ for randomly oriented particles. 105 103 The NIST software performs that integration with a 76-point Gaussian 106 quadrature rule, which will become imprecise at high $ Q$ where the amplitude107 varies quickly as a function of $ Q$. The SasView result shown has been104 quadrature rule, which will become imprecise at high $q$ where the amplitude 105 varies quickly as a function of $q$. The SasView result shown has been 108 106 obtained by summing over 501 equidistant points. Our result was found 109 to be stable over the range of $ Q$ shown for a number of points higher107 to be stable over the range of $q$ shown for a number of points higher 110 108 than 500. 111 109 112 REFERENCE 110 References 111 ---------- 113 112 114 113 L A Feigin and D I Svergun. *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum, -
sasmodels/models/fcc.py
rd138d43 reb69cce 16 16 .. math:: 17 17 18 I(q) = \frac{\text{scale}}{V_p} P(q) Z(q)18 I(q) = \frac{\text{scale}}{V_p} V_\text{lattice} P(q) Z(q) 19 19 20 20 where *scale* is the volume fraction of spheres, $V_p$ is the volume of 21 the primary particle, *V(lattice)*is a volume correction for the crystal21 the primary particle, $V_\text{lattice}$ is a volume correction for the crystal 22 22 structure, $P(q)$ is the form factor of the sphere (normalized), and $Z(q)$ 23 23 is the paracrystalline structure factor for a face-centered cubic structure. … … 27 27 28 28 The lattice correction (the occupied volume of the lattice) for a 29 face-centered cubic structure of particles of radius *R*and nearest29 face-centered cubic structure of particles of radius $R$ and nearest 30 30 neighbor separation $D$ is 31 31 … … 78 78 1D plot in the linear scale using the default values (w/200 data point). 79 79 80 The 2D (Anisotropic model) is based on the reference below where *I(q)*is80 The 2D (Anisotropic model) is based on the reference below where $I(q)$ is 81 81 approximated for 1d scattering. Thus the scattering pattern for 2D may not 82 82 be accurate. Note that we are not responsible for any incorrectness of the 83 83 2D model computation. 84 84 85 .. figure:: img/crystal_orientation. gif85 .. figure:: img/crystal_orientation.png 86 86 87 87 Orientation of the crystal with respect to the scattering plane. … … 91 91 2D plot using the default values (w/200X200 pixels). 92 92 93 Reference 94 --------- 93 References 94 ---------- 95 95 96 96 Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 -
sasmodels/models/gaussian_peak.py
r0e9048f reb69cce 26 26 1D plot using the default values (w/500 data points). 27 27 28 Reference 29 --------- 28 References 29 ---------- 30 30 31 31 None. -
sasmodels/models/guinier.py
r66ebdd6 reb69cce 1 1 r""" 2 Guinier (Model)3 4 2 Definition 5 3 ---------- … … 7 5 This model fits the Guinier function 8 6 9 .. math:: Q_1=\frac{1}{R_g}\sqrt{\frac{(m-s)(3-s)}{2}}7 .. math:: q_1=\frac{1}{R_g}\sqrt{\frac{(m-s)(3-s)}{2}} 10 8 11 to the data directly without any need for linearisation (*cf*. Ln *I(q)* vs *q*\ :sup:`2`). 9 to the data directly without any need for linearisation 10 (*cf*. $\ln I(q)$ vs $q^2$\ ). 12 11 13 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as 12 For 2D data the scattering intensity is calculated in the same way as 1D, 13 where the $q$ vector is defined as 14 14 15 15 .. math:: q=\sqrt{q_x^2 + q_y^2} 16 16 17 REFERENCE 17 References 18 ---------- 18 19 19 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley & Sons, New York (1955) 20 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, 21 John Wiley & Sons, New York (1955) 20 22 """ 21 23 -
sasmodels/models/hardsphere.py
r3e428ec reb69cce 7 7 potential is 8 8 9 .. math: 9 .. math:: 10 10 11 11 U(r) = \begin{cases} … … 14 14 \end{cases} 15 15 16 where *r* is the distance from the center of the sphere of a radius *R*.16 where $r$ is the distance from the center of the sphere of a radius $R$. 17 17 18 18 For a 2D plot, the wave transfer is defined as … … 23 23 24 24 25 .. image:: img/HardSphere_1d.jpg25 .. figure:: img/HardSphere_1d.jpg 26 26 27 *Figure. 1D plot using the default values (in linear scale).* 27 1D plot using the default values (in linear scale). 28 28 29 REFERENCE 29 References 30 ---------- 30 31 31 32 J K Percus, J Yevick, *J. Phys. Rev.*, 110, (1958) 1 -
sasmodels/models/hollow_cylinder.py
rd138d43 reb69cce 6 6 .. math:: 7 7 8 P(q) = \text{scale} \l angle F^2 \rangle/V_\text{shell} + \text{background}8 P(q) = \text{scale} \left<F^2\right>/V_\text{shell} + \text{background} 9 9 10 where the averaging $\l angle \rangle$ is applied only for the 1D calculation.10 where the averaging $\left<\ldots\right>$ is applied only for the 1D calculation. 11 11 12 12 The inside and outside of the hollow cylinder are assumed have the same SLD. … … 19 19 .. math:: 20 20 21 \begin{eqnarray} 22 P(q) &=& (\text{scale})V_\text{shell}\Delta\rho^2 21 %\begin{align*} % isn't working with pdflatex 22 \begin{array}{rl} 23 P(q) &= (\text{scale})V_\text{shell}\Delta\rho^2 23 24 \int_0^{1}\Psi^2 24 25 \left[q_z, R_\text{shell}(1-x^2)^{1/2}, 25 26 R_\text{core}(1-x^2)^{1/2}\right] 26 27 \left[\frac{\sin(qHx)}{qHx}\right]^2 dx \\ 27 \Psi[q,y,z] &= &\frac{1}{1-\gamma^2}28 \Psi[q,y,z] &= \frac{1}{1-\gamma^2} 28 29 \left[ \Lambda(qy) - \gamma^2\Lambda(qz) \right] \\ 29 \Lambda(a) &= &2 J_1(a) / a \\30 \gamma &= &R_\text{core} / R_\text{shell} \\31 V_\text{shell} &= &\pi \left(R_\text{shell}^2 - R_\text{core}^2 \right)L \\32 J_1(x) &= & \frac{(\sin(x)-x\cdot \cos(x))}{x^2}\\33 \end{ eqnarray}30 \Lambda(a) &= 2 J_1(a) / a \\ 31 \gamma &= R_\text{core} / R_\text{shell} \\ 32 V_\text{shell} &= \pi \left(R_\text{shell}^2 - R_\text{core}^2 \right)L \\ 33 J_1(x) &= (\sin(x)-x\cdot \cos(x)) / x^2 \\ 34 \end{array} 34 35 35 36 where *scale* is a scale factor and $J_1$ is the 1st order … … 42 43 **NB**: The 2nd virial coefficient of the cylinder is calculated 43 44 based on the radius and 2 length values, and used as the effective radius 44 for $S( Q)$ when $P(Q) * S(Q)$ is applied.45 for $S(q)$ when $P(q) \cdot S(q)$ is applied. 45 46 46 47 In the parameters, the contrast represents SLD :sub:`shell` - SLD :sub:`solvent` … … 59 60 Examples of the angles for oriented pp against the detector plane. 60 61 61 Reference 62 --------- 62 References 63 ---------- 63 64 64 65 L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and … … 88 89 ["sld", "1/Ang^2", 6.3, [-inf, inf], "", "Cylinder sld"], 89 90 ["solvent_sld", "1/Ang^2", 1, [-inf, inf], "", "Solvent sld"], 90 ["theta", " [deg]", 90, [-360, 360], "orientation", "Theta angle"],91 ["phi", " [deg]", 0, [-360, 360], "orientation", "Phi angle"],91 ["theta", "degrees", 90, [-360, 360], "orientation", "Theta angle"], 92 ["phi", "degrees", 0, [-360, 360], "orientation", "Phi angle"], 92 93 ] 93 94 -
sasmodels/models/lamellar.py
r38d8774 reb69cce 5 5 ---------- 6 6 7 The scattering intensity *I(Q)*is7 The scattering intensity $I(q)$ is 8 8 9 9 .. math:: 10 10 11 I( Q) = 2\pi{P(Q) \over \delta Q^2}11 I(q) = \frac{2\pi P(q)}{\delta q^2} 12 12 13 13 … … 16 16 .. math:: 17 17 18 P( Q) = {2\Delta\rho^2 \over Q^2}(1-cos(Q\delta))18 P(q) = \frac{2\Delta\rho^2}{q^2}(1-cos(q\delta)) 19 19 20 20 21 where |delta| =bilayer thickness.21 where $\delta$ is the bilayer thickness. 22 22 23 The 2D scattering intensity is calculated in the same way as 1D, where the $Q$ vector is defined as 23 The 2D scattering intensity is calculated in the same way as 1D, where 24 the $q$ vector is defined as 24 25 25 26 .. math:: 26 27 27 Q = \sqrt{Q_x^2 + Q_y^2}28 q = \sqrt{q_x^2 + q_y^2} 28 29 29 30 31 Our model uses the form factor calculations implemented in a c-library provided by the NIST Center for Neutron Research32 (Kline, 2006).33 30 34 31 .. figure:: img/lamellar_1d.jpg … … 37 34 38 35 39 Reference 40 --------- 36 References 37 ---------- 41 38 42 39 F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502 -
sasmodels/models/lamellarCaille.py
r3e428ec reb69cce 3 3 This model provides the scattering intensity, $I(q) = P(q) S(q)$, for a 4 4 lamellar phase where a random distribution in solution are assumed. 5 Here a Caille $S(Q)$ is used for the lamellar stacks. 5 Here a Caille $S(q)$ is used for the lamellar stacks. 6 7 Definition 8 ---------- 6 9 7 10 The scattering intensity $I(q)$ is 8 11 9 .. math: 12 .. math:: 10 13 11 14 I(q) = 2\pi \frac{P(q)S(q)}{\delta q^2} … … 13 16 The form factor is 14 17 15 .. math: 18 .. math:: 16 19 17 20 P(q) = \frac{2\Delta\rho^2}{q^2}\left(1-\cos q\delta \right) … … 19 22 and the structure factor is 20 23 21 .. math: 24 .. math:: 22 25 23 26 S(q) = 1 + 2 \sum_1^{N-1}\left(1-\frac{n}{N}\right) … … 26 29 where 27 30 28 .. math: 31 .. math:: 29 32 30 \begin{eqnarray} 31 \alpha(n) &=& \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right) \\ 32 \gamma_E &=& 0.5772156649 && \text{Euler's constant} \\ 33 \eta_{cp} &=& \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}} && \text{Caille constant} 34 \end{eqnarray} 33 %\begin{align*} % isn't working with pdflatex 34 \begin{array}{rll} 35 \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right) 36 & \\ 37 \gamma_E &= 0.5772156649 38 & \text{Euler's constant} \\ 39 \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}} 40 & \text{Caille constant} \\ 41 & 42 \end{array} 35 43 36 44 Here $d$ = (repeat) spacing, $\delta$ = bilayer thickness, … … 54 62 q = \sqrt{q_x^2 + q_y^2} 55 63 56 The returned value is in units of |cm^-1|, on absolute scale. 64 .. figure:: img/lamellarCaille_1d.jpg 57 65 58 .. image:: img/lamellarCaille_1d.jpg 66 1D plot using the default values (w/6000 data point). 59 67 60 *Figure. 1D plot using the default values (w/6000 data point).* 61 62 Our model uses the form factor calculations as implemented in a c library 63 provided by the NIST Center for Neutron Research (Kline, 2006). 64 65 REFERENCE 66 --------- 68 References 69 ---------- 67 70 68 71 F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502 -
sasmodels/models/lamellarCailleHG.py
r3e428ec reb69cce 2 2 r""" 3 3 This model provides the scattering intensity, $I(q) = P(q)S(q)$, for a lamellar 4 phase where a random distribution in solution are assumed. Here a Caille $S( Q)$4 phase where a random distribution in solution are assumed. Here a Caille $S(q)$ 5 5 is used for the lamellar stacks. 6 6 … … 31 31 .. math:: 32 32 33 \begin{eqnarray} 34 \alpha(n) &=& \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right) \\ 35 \gamma_E &=& 0.5772156649&&\text{Euler's constant} \\ 36 \eta_{cp} &=& \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}} && \text{Caille constant} 37 \end{eqnarray} 33 %\begin{align*} % isn't working with pdflatex 34 \begin{array}{rll} 35 \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right) 36 & \\ 37 \gamma_E &= 0.5772156649 38 & \text{Euler's constant} \\ 39 \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}} 40 & \text{Caille constant} \\ 41 & 42 \end{array} 38 43 39 44 … … 59 64 q = \sqrt{q_x^2 + q_y^2} 60 65 61 The returned value is in units of |cm^-1|, on absolute scale. 66 .. figure:: img/lamellarCailleHG_1d.jpg 62 67 63 .. image:: img/lamellarCailleHG_1d.jpg 68 1D plot using the default values (w/6000 data point). 64 69 65 *Figure. 1D plot using the default values (w/6000 data point).* 66 67 Our model uses the form factor calculations implemented in a C library provided 68 by the NIST Center for Neutron Research (Kline, 2006). 69 70 REFERENCE 70 References 71 ---------- 71 72 72 73 F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502 -
sasmodels/models/lamellarFFHG.py
rd138d43 reb69cce 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 3 This model provides the scattering intensity, *I(q)*, for a lyotropic lamellar3 This model provides the scattering intensity, $I(q)$, for a lyotropic lamellar 4 4 phase where a random distribution in solution are assumed. The SLD of the head 5 5 region is taken to be different from the SLD of the tail region. … … 25 25 \right\rbrace^2 26 26 27 where $\delta_T$ is *tail_length*, \delta_His *head_length*,27 where $\delta_T$ is *tail_length*, $\delta_H$ is *head_length*, 28 28 $\Delta\rho_H$ is the head contrast (*head_sld* $-$ *solvent_sld*), 29 29 and $\Delta\rho_T$ is tail contrast (*sld* $-$ *solvent_sld*). 30 30 31 31 The 2D scattering intensity is calculated in the same way as 1D, where 32 the *q*vector is defined as32 the $q$ vector is defined as 33 33 34 34 .. math:: -
sasmodels/models/lamellarPC.py
rd138d43 reb69cce 23 23 24 24 - *spacing* is the average distance between adjacent layers 25 $\l angle D \rangle$, and25 $\left<D\right>$, and 26 26 27 27 - *spacing_polydisp* is the relative standard deviation of the Gaussian 28 layer distance distribution $\sigma_D / \l angle D \rangle$.28 layer distance distribution $\sigma_D / \left<D\right>$. 29 29 30 30 … … 49 49 50 50 51 Z_N(q) = \frac{1 - w^2}{1 + w^2 - 2w \cos(q \l angle D \rangle)}51 Z_N(q) = \frac{1 - w^2}{1 + w^2 - 2w \cos(q \left<D\right>)} 52 52 + x_N S_N + (1 - x_N) S_{N+1} 53 53 … … 56 56 .. math:: 57 57 58 S_N(q) = \frac{a_N}{N}[1 + w^2 - 2 w \cos(q \l angle D \rangle)]^258 S_N(q) = \frac{a_N}{N}[1 + w^2 - 2 w \cos(q \left<D\right>)]^2 59 59 60 60 and … … 62 62 .. math:: 63 63 64 a_N = 4w^2 - 2(w^3 + w) \cos(q \langle D \rangle) 65 - 4w^{N+2}\cos(Nq \langle D \rangle) 66 + 2 w^{N+3}\cos[(N-1)q \langle D \rangle] 67 + 2w^{N+1}\cos[(N+1)q \langle D \rangle] 64 \begin{array}{rcl} 65 a_N &=& 4w^2 - 2(w^3 + w) \cos(q \left<D\right>) 66 - 4w^{N+2}\cos(Nq \left<D\right>) \\ 67 &&{} + 2 w^{N+3}\cos[(N-1)q \left<D\right>] 68 + 2w^{N+1}\cos[(N+1)q \left<D\right>] 69 \end{array} 68 70 69 71 for the layer spacing distribution $w = \exp(-\sigma_D^2 q^2/2)$. -
sasmodels/models/lorentz.py
rd138d43 reb69cce 7 7 The Ornstein-Zernicke model is defined by 8 8 9 .. math:: I(q)=\frac{\text{scale}}{1+(qL)^2}+\text{b kg}9 .. math:: I(q)=\frac{\text{scale}}{1+(qL)^2}+\text{background} 10 10 11 The parameter *L* is the screening length.11 The parameter $L$ is the screening length *cor_length*. 12 12 13 For 2D data : The 2D scattering intensity is calculated in the same way as 1D,13 For 2D data the scattering intensity is calculated in the same way as 1D, 14 14 where the $q$ vector is defined as 15 15 … … 20 20 1D plot using the default values (w/200 data point). 21 21 22 Reference 23 --------- 22 References 23 ---------- 24 24 25 25 L.S. Qrnstein and F. Zernike, *Proc. Acad. Sci. Amsterdam* 17, 793 (1914), and -
sasmodels/models/parallelepiped.py
rd138d43 reb69cce 7 7 ---------- 8 8 9 This model provides the form factor, *P(q)*, for a rectangular parallelepiped9 This model provides the form factor, $P(q)$, for a rectangular parallelepiped 10 10 (below) where the form factor is normalized by the volume of the 11 11 parallelepiped. If you need to apply polydispersity, see also … … 16 16 .. math:: 17 17 18 P( Q) = {\text{scale} \over V} F^2(Q) + \text{background}18 P(q) = \frac{\text{scale}}{V} F^2(q) + \text{background} 19 19 20 where the volume *V* = *A B C* and the averaging < > is applied over all21 orientations for 1D.20 where the volume $V = A B C$ and the averaging $\left<\ldots\right>$ is 21 applied over all orientations for 1D. 22 22 23 23 .. figure:: img/parallelepiped.jpg … … 25 25 Parallelepiped with the corresponding definition of sides. 26 26 27 The edge of the solid must satisfy the condition that ** *A* < *B* < *C*.28 Then, assuming *a* = *A* / *B* < 1, *b* = *B* / *B* = 1, and29 *c* = *C* / *B* > 1, theform factor is27 The edge of the solid must satisfy the condition that $A < B < C$. 28 Then, assuming $a = A/B < 1$, $b = B /B = 1$, and $c = C/B > 1$, the 29 form factor is 30 30 31 31 .. math:: 32 32 33 P(q) = \frac{\textstyle{scale}}{V}\int_0^1 \phi(\mu \sqrt{1-\sigma^2},a) 34 [S(\mu c \sigma/2)]^2 d\sigma 33 P(q) = \frac{\text{scale}}{V}\int_0^1 34 \phi\left(\mu \sqrt{1-\sigma^2},a\right) 35 \left[S(\mu c \sigma/2)\right]^2 d\sigma 35 36 36 37 with … … 38 39 .. math:: 39 40 40 \phi(\mu,a) = \int_0^1 \{S[\frac{\mu}{2}\cos(\frac{\pi}{2}u)] 41 S[\frac{\mu a}{2}\sin(\frac{\pi}{2}u)]\}^2 du 41 \phi(\mu,a) = \int_0^1 42 \left\{S\left[\frac{\mu}{2}\cos(\frac{\pi}{2}u)\right] 43 S\left[\frac{\mu a}{2}\sin(\frac{\pi}{2}u)\right] 44 \right\}^2 du 42 45 43 46 S(x) = \frac{\sin x}{x} … … 52 55 53 56 The scattering intensity per unit volume is returned in units of |cm^-1|; 54 i e, *I(q)* = |phi| *P(q)*\.57 i.e., $I(q) = \phi P(q)$. 55 58 56 59 NB: The 2nd virial coefficient of the parallelpiped is calculated based on 57 the averaged effective radius (= sqrt(*short_a* \* *short_b* / |pi|))and58 length (= *long_c*)values, and used as the effective radius for59 *S(Q)* when *P(Q)* \* *S(Q)*is applied.60 the averaged effective radius $(=\sqrt{A B / \pi})$ and 61 length $(= C)$ values, and used as the effective radius for 62 $S(q)$ when $P(q) \cdot S(q)$ is applied. 60 63 61 64 To provide easy access to the orientation of the parallelepiped, we define 62 three angles |theta|, |phi| and |bigpsi|. The definition of |theta| and |phi|63 is the same as for the cylinder model (see also figures below).64 The angle |bigpsi| is the rotational angle around the *long_c*axis against65 the *q* plane. For example, |bigpsi| = 0 when the *short_b*axis is parallel66 to the *x*-axis of the detector.65 three angles $\theta$, $\phi$ and $\Psi$. The definition of $\theta$ and 66 $\phi$ is the same as for the cylinder model (see also figures below). 67 The angle $\Psi$ is the rotational angle around the $C$ axis against 68 the $q$ plane. For example, $\Psi = 0$ when the $B$ axis is parallel 69 to the $x$-axis of the detector. 67 70 68 71 … … 85 88 angles. The Figure below shows the comparison where the solid dot refers to 86 89 averaged 2D while the line represents the result of the 1D calculation (for 87 the averaging, 76, 180, 76 points are taken for the angles of |theta|, |phi|,88 and |psi|respectively).90 the averaging, 76, 180, 76 points are taken for the angles of $\theta$, 91 $\phi$, and $\Psi$ respectively). 89 92 90 93 .. _parallelepiped-compare: 91 94 92 .. figure:: img/parallelepiped_compare. gif95 .. figure:: img/parallelepiped_compare.png 93 96 94 97 Comparison between 1D and averaged 2D. -
sasmodels/models/power_law.py
r525f3a9 reb69cce 10 10 .. math:: 11 11 12 I(q) = \text{scale} \cdot q^{- power} + \text{background}12 I(q) = \text{scale} \cdot q^{-\text{power}} + \text{background} 13 13 14 14 Note the minus sign in front of the exponent. The exponent *power* … … 19 19 combining this model with other models. 20 20 21 .. image:: img/power_law_1d.jpg21 .. figure:: img/power_law_1d.jpg 22 22 23 *Figure. 1D plot using the default values (w/200 data point).* 23 1D plot using the default values (w/200 data point). 24 24 25 REFERENCE 25 References 26 ---------- 26 27 27 28 None. … … 47 48 inten = (q**-power) 48 49 return inten 49 Iq.vectorized = True # Iq accepts an array of Qvalues50 Iq.vectorized = True # Iq accepts an array of q values 50 51 51 52 def Iqxy(qx, qy, *args): 52 53 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 53 Iqxy.vectorized = True # Iqxy accepts an array of Qx, Qy values54 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 54 55 55 56 demo = dict(scale=1.0, -
sasmodels/models/sphere.py
r0fa687d reb69cce 11 11 .. math:: 12 12 13 I( Q) = \frac{\text{scale}}{V} \cdot \left[ \14 3V(\Delta\rho) \cdot \frac{\sin( QR) - QR\cos(QR))}{(QR)^3} \13 I(q) = \frac{\text{scale}}{V} \cdot \left[ 14 3V(\Delta\rho) \cdot \frac{\sin(qr) - qr\cos(qr))}{(qr)^3} 15 15 \right]^2 + \text{background} 16 16 17 17 where *scale* is a volume fraction, $V$ is the volume of the scatterer, 18 $ R$ is the radius of the sphere, *background* is the background level and18 $r$ is the radius of the sphere, *background* is the background level and 19 19 *sld* and *solvent_sld* are the scattering length densities (SLDs) of the 20 20 scatterer and the solvent respectively. … … 27 27 The 2D scattering intensity is the same as above, regardless of the 28 28 orientation of $\vec q$. 29 30 Our model uses the form factor calculations as defined in the IGOR31 package provided by the NIST Center for Neutron Research (Kline, 2006).32 29 33 30 Validation … … 49 46 50 47 51 Reference 52 --------- 48 References 49 ---------- 53 50 54 51 A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, … … 63 60 title = "Spheres with uniform scattering length density" 64 61 description = """\ 65 P(q)=(scale/V)*[3V(sld-solvent_sld)*(sin(q R)-qRcos(qR))66 /(q R)^3]^2 + background67 R: radius of sphere62 P(q)=(scale/V)*[3V(sld-solvent_sld)*(sin(qr)-qr cos(qr)) 63 /(qr)^3]^2 + background 64 r: radius of sphere 68 65 V: The volume of the scatter 69 66 sld: the SLD of the sphere … … 93 90 double sn, cn; 94 91 SINCOS(qr, sn, cn); 95 // Use taylor series for low Qto avoid cancellation error. Tested against92 // Use taylor series for low q to avoid cancellation error. Tested against 96 93 // the following expression in quad precision: 97 94 // 3.0*(sn-qr*cn)/(qr*qr*qr); -
sasmodels/models/spherepy.py
rd138d43 reb69cce 11 11 .. math:: 12 12 13 I( Q) = \frac{\text{scale}}{V} \cdot \left[ \14 3V(\Delta\rho) \cdot \frac{\sin( QR) - QR\cos(QR))}{(QR)^3} \13 I(q) = \frac{\text{scale}}{V} \cdot \left[ 14 3V(\Delta\rho) \cdot \frac{\sin(qr) - qr\cos(qr))}{(qr)^3} 15 15 \right]^2 + \text{background} 16 16 17 17 where *scale* is a volume fraction, $V$ is the volume of the scatterer, 18 $ R$ is the radius of the sphere, *background* is the background level and18 $r$ is the radius of the sphere, *background* is the background level and 19 19 *sld* and *solvent_sld* are the scattering length densities (SLDs) of the 20 20 scatterer and the solvent respectively. … … 27 27 The 2D scattering intensity is the same as above, regardless of the 28 28 orientation of $\vec q$. 29 30 Our model uses the form factor calculations as defined in the IGOR31 package provided by the NIST Center for Neutron Research (Kline, 2006).32 29 33 30 Validation … … 49 46 50 47 51 Reference 52 --------- 48 References 49 ---------- 53 50 54 51 A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, … … 64 61 title = "Spheres with uniform scattering length density" 65 62 description = """\ 66 P(q)=(scale/V)*[3V(sld-solvent_sld)*(sin(q R)-qRcos(qR))67 /(q R)^3]^2 + background68 R: radius of sphere63 P(q)=(scale/V)*[3V(sld-solvent_sld)*(sin(qr)-qr cos(qr)) 64 /(qr)^3]^2 + background 65 r: radius of sphere 69 66 V: The volume of the scatter 70 67 sld: the SLD of the sphere … … 101 98 fq = bes * (sld - solvent_sld) * form_volume(radius) 102 99 return 1.0e-4 * fq ** 2 103 Iq.vectorized = True # Iq accepts an array of Qvalues100 Iq.vectorized = True # Iq accepts an array of q values 104 101 105 102 def Iqxy(qx, qy, sld, solvent_sld, radius): 106 103 return Iq(sqrt(qx ** 2 + qy ** 2), sld, solvent_sld, radius) 107 Iqxy.vectorized = True # Iqxy accepts arrays of Qx, Qy values104 Iqxy.vectorized = True # Iqxy accepts arrays of qx, qy values 108 105 109 106 def sesans(z, sld, solvent_sld, radius): -
sasmodels/models/stickyhardsphere.py
r3e428ec reb69cce 4 4 with a narrow attractive well. A perturbative solution of the Percus-Yevick 5 5 closure is used. The strength of the attractive well is described in terms 6 of "stickiness" as defined below. The returned value is a dimensionless 7 structure factor, *S(q)*. 6 of "stickiness" as defined below. 8 7 9 The perturb (perturbation parameter), |epsilon|, should be held between 0.018 The perturb (perturbation parameter), $\epsilon$, should be held between 0.01 10 9 and 0.1. It is best to hold the perturbation parameter fixed and let 11 10 the "stickiness" vary to adjust the interaction strength. The stickiness, 12 |tau|, is defined in the equation below and is a function of both the13 perturbation parameter and the interaction strength. |tau| and |epsilon|14 are defined in terms of the hard sphere diameter (|sigma| = 2\*\ *R*\ ), the15 width of the square well, |bigdelta| (same units as *R*), and the depth of16 the well, *Uo*, in units of kT. From the definition, it is clear that17 smaller |tau|means stronger attraction.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. 18 17 19 .. image:: img/stickyhardsphere_228.PNG 18 .. math:: 19 20 %\begin{align*} % isn't working with pdflatex 21 \begin{array}{rl} 22 \tau &= \frac{1}{12\epsilon} \exp(u_o / kT) \\ 23 \epsilon &= \Delta / (\sigma + \Delta) \\ 24 \end{array} 20 25 21 26 where the interaction potential is 22 27 23 .. image:: img/stickyhardsphere_229.PNG 28 .. math:: 29 30 U(r) = \begin{cases} 31 \infty & r < \sigma \\ 32 -U_o & \sigma \leq r \leq \sigma + \Delta \\ 33 0 & r > \sigma + \Delta 34 \end{cases} 24 35 25 36 The Percus-Yevick (PY) closure was used for this calculation, and is an … … 28 39 good agreement. 29 40 30 The true particle volume fraction, |phi|, is not equal to *h*, which appears41 The true particle volume fraction, $\phi$, is not equal to $h$, which appears 31 42 in most of the reference. The two are related in equation (24) of the 32 43 reference. The reference also describes the relationship between this … … 34 45 sphere) model by Baxter. 35 46 36 NB: The calculation can go haywire for certain combinations of the input47 **NB**: The calculation can go haywire for certain combinations of the input 37 48 parameters, producing unphysical solutions - in this case errors are 38 reported to the command window and the *S(q)*is set to -1 (so it will49 reported to the command window and the $S(q)$ is set to -1 (so it will 39 50 disappear on a log-log plot). Use tight bounds to keep the parameters to 40 51 values that you know are physical (test them) and keep nudging them until … … 42 53 43 54 In sasview the effective radius will be calculated from the parameters 44 used in the form factor P(Q) that this S(Q)is combined with.55 used in the form factor $P(q)$ that this $S(q)$ is combined with. 45 56 46 For 2D data : The 2Dscattering intensity is calculated in the same way47 as 1D, where the *q*vector is defined as57 For 2D data the scattering intensity is calculated in the same way 58 as 1D, where the $q$ vector is defined as 48 59 49 60 .. math:: 50 61 51 Q = \sqrt{Q_x^2 + Q_y^2}62 q = \sqrt{q_x^2 + q_y^2} 52 63 53 ============== ======== ============= 54 Parameter name Units Default value 55 ============== ======== ============= 56 effect_radius |Ang| 50 57 perturb None 0.05 58 volfraction None 0.1 59 stickiness K 0.2 60 ============== ======== ============= 64 .. figure:: img/stickyhardsphere_1d.jpg 61 65 62 .. image:: img/stickyhardsphere_230.jpg 66 1D plot using the default values (in linear scale). 63 67 64 *Figure. 1D plot using the default values (in linear scale).* 65 66 REFERENCE 68 References 69 ---------- 67 70 68 71 S V G Menon, C Manohar, and K S Rao, *J. Chem. Phys.*, 95(12) (1991) 9186-9190 -
sasmodels/models/teubner_strey.py
r0e9048f reb69cce 40 40 1D plot using the default values (w/200 data point). 41 41 42 Reference 43 --------- 42 References 43 ---------- 44 44 45 45 M Teubner, R Strey, *J. Chem. Phys.*, 87 (1987) 3195 … … 77 77 def Iq(q, a2, c1, c2): 78 78 return 1. / np.polyval([c2, c1, a2], q**2) 79 Iq.vectorized = True # Iq accepts an array of Qvalues79 Iq.vectorized = True # Iq accepts an array of q values 80 80 81 81 def Iqxy(qx, qy, a2, c1, c2): 82 82 return Iq(sqrt(qx**2 + qy**2), a2, c1, c2) 83 Iqxy.vectorized = True # Iqxy accepts arrays of Qx, Qy values83 Iqxy.vectorized = True # Iqxy accepts arrays of qx, qy values 84 84 85 85 # ER defaults to 0.0 -
sasmodels/models/triaxial_ellipsoid.py
r3e428ec reb69cce 2 2 # Note: model title and parameter table are inserted automatically 3 3 r""" 4 All three axes are of different lengths with $R_a \le R_b <=R_c$4 All three axes are of different lengths with $R_a \leq R_b \leq R_c$ 5 5 **Users should maintain this inequality for all calculations**. 6 6 7 7 .. math:: 8 8 9 P( Q) = \text{scale} V \left< F^2(Q) \right> + \text{background}9 P(q) = \text{scale} V \left< F^2(q) \right> + \text{background} 10 10 11 11 where the volume $V = 4/3 \pi R_a R_b R_c$, and the averaging 12 $\left< \cdots\right>$ is applied over all orientations for 1D.12 $\left<\ldots\right>$ is applied over all orientations for 1D. 13 13 14 14 .. figure:: img/triaxial_ellipsoid_geometry.jpg 15 15 16 16 Ellipsoid schematic. 17 18 The returned value is in units of |cm^-1|, on absolute scale.19 17 20 18 Definition … … 25 23 .. math:: 26 24 27 P( Q) = \frac{\text{scale}}{V}\int_0^1\int_0^128 \Phi^2( QR_a^2\cos^2( \pi x/2) + QR_b^2\sin^2(\pi y/2)(1-y^2) +c^2y^2)25 P(q) = \frac{\text{scale}}{V}\int_0^1\int_0^1 26 \Phi^2(qR_a^2\cos^2( \pi x/2) + qR_b^2\sin^2(\pi y/2)(1-y^2) + R_c^2y^2) 29 27 dx dy 30 28 … … 40 38 :num:`figure #triaxial-ellipsoid-angles`. 41 39 The angle $\psi$ is the rotational angle around its own $c$ axis 42 against the $ Q$ plane. For example, $\psi = 0$ when the40 against the $q$ plane. For example, $\psi = 0$ when the 43 41 $a$ axis is parallel to the $x$ axis of the detector. 44 42 … … 52 50 53 51 The contrast is defined as SLD(ellipsoid) - SLD(solvent). In the 54 parameters, *a* is the minor equatorial radius, *b*is the major55 equatorial radius, and cis the polar radius of the ellipsoid.52 parameters, $R_a$ is the minor equatorial radius, $R_b$ is the major 53 equatorial radius, and $R_c$ is the polar radius of the ellipsoid. 56 54 57 55 NB: The 2nd virial coefficient of the triaxial solid ellipsoid is 58 56 calculated based on the polar radius $R_p = R_c$ and equatorial 59 57 radius $R_e = \sqrt{R_a R_b}$, and used as the effective radius for 60 $S( Q)$ when $P(Q) \cdot S(Q)$ is applied.58 $S(q)$ when $P(q) \cdot S(q)$ is applied. 61 59 62 60 .. figure:: img/triaxial_ellipsoid_1d.jpg … … 81 79 Comparison between 1D and averaged 2D. 82 80 83 Our model uses the form factor calculations implemented in a c-library provided by the NIST Center for Neutron Research 84 (Kline, 2006) 85 86 REFERENCE 81 References 82 ---------- 87 83 88 84 L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum,
Note: See TracChangeset
for help on using the changeset viewer.