# Changeset 19dcb933 in sasmodels

Ignore:
Timestamp:
Sep 3, 2014 3:16:10 AM (6 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:
1c7ffdc
Parents:
87985ca
Message:

build docs for models

Files:
10 edited
1 moved

### Legend:

Unmodified
Removed

 r5d4777d Sasmodels ========= Theory models for small angle scattering. The models provided are usable directly in the bumps fitting package and in the sasview analysis package.  If OpenCL is available, the models will run much faster.  If not, then precompiled versions will be included with the distributed package.  New models can be added if OpenCL or a C compiler is available. cylinder.c + cylinder.py is the cylinder model with renamed variables and sld scaled by 1e6 so the numbers are nicer.  The model name is "cylinder" Note: may want to rename form_volume to calc_volume and Iq/Iqxy to calc_Iq/calc_Iqxy. Similarly ER/VR go to calc_ER/calc_VR. calc_Iq/calc_Iqxy in model interface. Similarly ER/VR go to calc_ER/calc_VR. Note: It is possible to translate python code automatically to opencl, using something like numba, clyther, shedskin or pypy, so maybe the kernel functions could be implemented without any C syntax. Note: angular dispersion in theta is probably not calculated correctly, but is left this way for compatibility with sasview. Magnetism hasn't been implemented yet.  We may want a separate Imagnetic in the same data set. Need to write code to generate the polydispersity loops in python for kernels that are only implemented in python.  Also, need to implement an example kernel directly in python. Need to implement an example kernel directly in python.  Polydispersity loops should be generated automatically as they are for the OpenCL models. The kernels should be vectorized across Q.  These will need vectorized versions of numerical quadrature if we want to get reasonable performance.
• ## sasmodels/__init__.py

 r14de349 __version__ = "0.9"
• ## sasmodels/gen.py

 rf4cf580 # Headers for the parameters tables in th sphinx documentation PARTABLE_HEADERS = [ "Parameter name", "Parameter", "Description", "Units", "Default value", DOC_HEADER=""".. _%(name)s: %(name)s %(label)s ======================================================= return kernel def make_partable(info): def make_partable(pars): """ Generate the parameter table to include in the sphinx documentation. """ pars = info['parameters'] pars = COMMON_PARAMETERS + pars column_widths = [ max(len(p[0]) for p in pars), max(len(p[-1]) for p in pars), max(len(RST_UNITS[p[1]]) for p in pars), PARTABLE_VALUE_WIDTH, lines.append(" ".join([ "%-*s"%(column_widths[0],p[0]), "%-*s"%(column_widths[1],RST_UNITS[p[1]]), "%*g"%(column_widths[2],p[2]), "%-*s"%(column_widths[1],p[-1]), "%-*s"%(column_widths[2],RST_UNITS[p[1]]), "%*g"%(column_widths[3],p[2]), ])) lines.append(sep) Return the documentation for the model. """ subst = dict(name=kernel_module.name, subst = dict(name=kernel_module.name.replace('_','-'), label=" ".join(kernel_module.name.split('_')).capitalize(), title=kernel_module.title, parameters=make_partable(kernel_module.parameters), doc=kernel_module.__doc__) docs=kernel_module.__doc__) return DOC_HEADER%subst
• ## sasmodels/models/capped_cylinder.py

 rf4cf580 The capped cylinder geometry is defined as .. image:: img/image112.JPG .. image:: img/capped_cylinder_geometry.jpg where $r$ is the radius of the cylinder. All other parameters are as defined h = - \sqrt{R^2 - r^2} The scattered intensity $I(q)$ is calculated as The scattered intensity $I(Q)$ is calculated as .. math:: I(q) = \frac{(\Delta \rho)^2}{V} left I(Q) = \frac{(\Delta \rho)^2}{V} \left< A^2(Q)\right> where the amplitude $A(q)$ is given as where the amplitude $A(Q)$ is given as .. math:: A(Q) = \pi r^2L \frac{sin(Q(L/2) \cos \theta)}{Q(L/2) \cos \theta} \ \frac{2 J_1(Q r \sin \theta)}{Q r \sin \theta} \ + 4 \pi R^3 \int_{-h/R}^1{dt \cos [ Q cos\theta (Rt + h + L/2)] \ x (1-t^2)\frac{J_1[Q R \sin \theta (1-t^2)^{1/2}]}{Q R \sin \theta (1-t^2)^{1/2} A(Q) =&\ \pi r^2L {\sin\left(\tfrac12 QL\cos\theta\right) \over \tfrac12 QL\cos\theta} {2 J_1(Qr\sin\theta) \over Qr\sin\theta} \\ &\ + 4 \pi R^3 \int_{-h/R}^1 dt \cos\left[ Q\cos\theta \left(Rt + h + {\tfrac12} L\right)\right] \times (1-t^2) {J_1\left[QR\sin\theta \left(1-t^2\right)^{1/2}\right] \over QR\sin\theta \left(1-t^2\right)^{1/2}} The $\left< \ldots \right>$ brackets denote an average of the structure over all orientations. $\left< A^2(q)\right>$ is then the form factor, $P(q)$. all orientations. $\left< A^2(Q)\right>$ is then the form factor, $P(Q)$. The scale factor is equivalent to the volume fraction of cylinders, each of volume, $V$. Contrast is the difference of scattering length densities of .. math:: V = \pi r_c^2 L + \frac{2\pi}{3}(R-h)^2(2R + h) V = \pi r_c^2 L + \tfrac{2\pi}{3}(R-h)^2(2R + h) and its radius-of-gyration is R_g^2 = \left[ \frac{12}{5}R^5 + R^4(6h+\frac{3}{2}L) \ + R^2(4h^2 + L^2 + 4Lh) + R^2(3Lh^2 + [frac{3}{2}L^2h) \ + \frac{2}{5}h^5 - \frac{1}{2}Lh^4 - \frac{1}{2}L^2h^3 \ + \frac{1}{4}L^3r^2 + \frac{3}{2}Lr^4\right] \ (4R^3 6R^2h - 2h^3 + 3r^2L)^{-1} .. math:: R_g^2 =&\ \left[ \tfrac{12}{5}R^5 + R^4\left(6h+\tfrac32 L\right) + R^2\left(4h^2 + L^2 + 4Lh\right) + R^2\left(3Lh^2 + \tfrac32 L^2h\right) \right. \\ &\ \left. + \tfrac25 h^5 - \tfrac12 Lh^4 - \tfrac12 L^2h^3 + \tfrac14 L^3r^2 + \tfrac32 Lr^4 \right] \left( 4R^3 6R^2h - 2h^3 + 3r^2L \right)^{-1} **The requirement that $R \ge r$ is not enforced in the model! It is up to you to restrict this during analysis.** .. note:: Figure :num:figure #capped-cylinder-1d shows the output produced by The requirement that $R \ge r$ is not enforced in the model! It is up to you to restrict this during analysis. :num:Figure #capped-cylinder-1d shows the output produced by a running the 1D capped cylinder model, using *qmin* = 0.001 |Ang^-1|, *qmax* = 0.7 |Ang^-1| and  the default values of the parameters. .. _capped-cylinder-1d: .. figure:: img/image117.jpg .. figure:: img/capped_cylinder_1d.jpg 1D plot using the default values (w/256 data point). The 2D scattering intensity is calculated similar to the 2D cylinder model. Figure :num:figure #capped-cylinder-2d shows the output for $\theta=45^\circ$ :num:Figure #capped-cylinder-2d shows the output for $\theta=45^\circ$ and $\phi=0^\circ$ with default values for the other parameters. .. _capped-cylinder-2d: .. figure:: img/image118.JPG .. figure:: img/capped_cylinder_2d.jpg 2D plot (w/(256X265) data points). .. figure:: img/image061.JPG .. figure:: img/orientation.jpg Definition of the angles for oriented 2D cylinders. .. figure:: img/image062.jpg .. figure:: img/orientation2.jpg Examples of the angles for oriented pp against the detector plane.
• ## sasmodels/models/core_shell_cylinder.py

 r5d4777d .. math:: P(q,\alpha) = \frac{\text{scale}}{V_s} f^2(q) + \text{background} P(Q,\alpha) = {\text{scale} \over V_s} F^2(Q) + \text{background} where .. math:: f(q) = (\rho_c - \rho_s) V_c \ \frac{\sin( Q L/2 \cos \alpha)}{Q L/2 \cos \alpha} \ \frac{2 J_1 (Q R \sin \alpha)}{Q R \sin \alpha} + (\rho_s - \rho_\text{solv}) V_s \ \frac{\sin( Q (L/2+T) \cos \alpha)}{Q (L/2+T) \cos \alpha} \frac{2 J_1 (Q (R+T) \sin \alpha)}{Q (R+T) \sin \alpha} F(Q) = &\ (\rho_c - \rho_s) V_c {\sin \left( Q \tfrac12 L\cos\alpha \right) \over Q \tfrac12 L\cos\alpha } {2 J_1 \left( QR\sin\alpha \right) \over QR\sin\alpha } \\ &\ + (\rho_s - \rho_\text{solv}) V_s {\sin \left( Q \left(\tfrac12 L+T\right) \cos\alpha \right) \over Q \left(\tfrac12 L +T \right) \cos\alpha } { 2 J_1 \left( Q(R+T)\sin\alpha \right) \over Q(R+T)\sin\alpha } and .. math:: V_s = \pi (R + T)^2 \dot (L + 2T) V_s = \pi (R + T)^2 (L + 2T) and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, shell is given by $L+2T$. $J1$ is the first order Bessel function. .. figure:: img/image069.JPG .. _core-shell-cylinder-geometry: .. figure:: img/core_shell_cylinder_geometry.jpg Core shell cylinder schematic. define the axis of the cylinder using two angles $\theta$ and $\phi$. As for the case of the cylinder, those angles are defined in Figure :num:figure #cylinder-orientation. :num:figure #cylinder-orientation. NB: The 2nd virial coefficient of the cylinder is calculated based on the radius and 2 length values, and used as the effective radius for $S(Q)$ when $P(Q) \dot S(Q)$ is applied. $S(Q)$ when $P(Q) \cdot S(Q)$ is applied. The $\theta$ and $\phi$ parameters are not used for the 1D output. Our Validation of our code was done by comparing the output of the 1D model to the output of the software provided by the NIST (Kline, 2006). Figure :num:figure #core-shell-cylinder-comparison-1d shows a comparison :num:Figure #core-shell-cylinder-1d shows a comparison of the 1D output of our model and the output of the NIST software. .. _core-shell-cylinder-comparison-1d: .. _core-shell-cylinder-1d: .. figure:: img/image070.JPG .. figure:: img/core_shell_cylinder_1d.jpg Comparison of the SasView scattering intensity for a core-shell cylinder with the output of the NIST SANS analysis software. The parameters were set to: *scale=1.0 |Ang|*, *radius=20 |Ang|*, *thickness=10 |Ang|*, *length=400 |Ang|*, *core_sld=1e-6 |Ang^-2|*, *shell_sld=4e-6 |Ang^-2|*, *solvent_sld=1e-6 |Ang^-2|*, and *background=0.01 |cm^-1|*. set to: *scale* = 1.0 |Ang|, *radius* = 20 |Ang|, *thickness* = 10 |Ang|, *length* =400 |Ang|, *core_sld* =1e-6 |Ang^-2|, *shell_sld* = 4e-6 |Ang^-2|, *solvent_sld* = 1e-6 |Ang^-2|, and *background* = 0.01 |cm^-1|. Averaging over a distribution of orientation is done by evaluating the implementation of the intensity for fully oriented cylinders, we can compare the result of averaging our 2D output using a uniform distribution $p(\theta,\phi)* = 1.0$. Figure :num:figure #core-shell-cylinder-comparison-2d shows the result distribution $p(\theta,\phi) = 1.0$. :num:Figure #core-shell-cylinder-2d shows the result of such a cross-check. .. _core-shell-cylinder-comparison-2d: .. _core-shell-cylinder-2d: .. figure:: img/image071.JPG .. figure:: img/core_shell_cylinder_2d.jpg Comparison of the intensity for uniformly distributed core-shell cylinders calculated from our 2D model and the intensity from the NIST SANS analysis software. The parameters used were: *scale*=1.0*, *radius=20 |Ang|*, *thickness=10 |Ang|*, *length*=400 |Ang|*, *core_sld=1e-6 |Ang^-2|*, *shell_sld=4e-6 |Ang^-2|*, *solvent_sld=1e-6 |Ang^-2|*, and *background=0.0 |cm^-1|*. NIST SANS analysis software. The parameters used were: *scale* = 1.0, *radius* = 20 |Ang|, *thickness* = 10 |Ang|, *length* = 400 |Ang|, *core_sld* = 1e-6 |Ang^-2|, *shell_sld* = 4e-6 |Ang^-2|, *solvent_sld* = 1e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. 2013/11/26 - Description reviewed by Heenan, R. from numpy import pi, inf name = "cylinder" name = "core_shell_cylinder" title = "Right circular cylinder with a core-shell scattering length density profile." description = """
• ## sasmodels/models/cylinder.py

 r5d4777d .. math:: P(q,\alpha) = \frac{\text{scale}}{V}f^2(q) + \text{bkg} P(Q,\alpha) = {\text{scale} \over V} F^2(Q) + \text{background} where .. math:: f(q) = 2 (\Delta \rho) V \frac{\sin (q L/2 \cos \alpha)}{q L/2 \cos \alpha} \frac{J_1 (q r \sin \alpha)}{q r \sin \alpha} F(Q) = 2 (\Delta \rho) V {\sin \left(Q\tfrac12 L\cos\alpha \right) \over Q\tfrac12 L \cos \alpha} {J_1 \left(Q R \sin \alpha\right) \over Q R \sin \alpha} and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ is the volume of the cylinder, $L$ is the length of the cylinder, $r$ is the radius of the cylinder, and $d\rho$ (contrast) is the scattering length density difference between the scatterer and the solvent. $J_1$ is the first order Bessel function. is the volume of the cylinder, $L$ is the length of the cylinder, $R$ is the radius of the cylinder, and $\Delta\rho$ (contrast) is the scattering length density difference between the scatterer and the solvent. $J_1$ is the first order Bessel function. To provide easy access to the orientation of the cylinder, we define the axis of the cylinder using two angles $\theta$ and $\phi$. Those angles are defined in Figure :num:figure #cylinder-orientation. are defined in :num:figure #cylinder-orientation. .. _cylinder-orientation: .. figure:: img/image061.JPG   (should be img/cylinder-1.jpg, or img/cylinder-orientation.jpg) .. figure:: img/orientation.jpg Definition of the angles for oriented cylinders. .. figure:: img/image062.JPG .. figure:: img/orientation2.jpg Examples of the angles for oriented pp against the detector plane. .. math:: P(q) = \frac{\text{scale}}{V} \int_0^{\pi/2} f^2(q,\alpha) \sin \alpha d\alpha + \text{background} P(Q) = {\text{scale} \over V} \int_0^{\pi/2} F^2(Q,\alpha) \sin \alpha\ d\alpha + \text{background} The *theta* and *phi* parameters are not used for the 1D output. Our Validation of our code was done by comparing the output of the 1D model to the output of the software provided by the NIST (Kline, 2006). Figure :num:figure #cylinder-compare shows a comparison of :num:Figure #cylinder-compare shows a comparison of the 1D output of our model and the output of the NIST software. .. _cylinder-compare: .. figure:: img/image065.JPG .. figure:: img/cylinder_compare.jpg Comparison of the SasView scattering intensity for a cylinder with the output of the NIST SANS analysis software. The parameters were set to: *Scale* = 1.0, *Radius* = 20 |Ang|, *Length* = 400 |Ang|, *Contrast* = 3e-6 |Ang^-2|, and *Background* = 0.01 |cm^-1|. The parameters were set to: *scale* = 1.0, *radius* = 20 |Ang|, *length* = 400 |Ang|, *contrast* = 3e-6 |Ang^-2|, and *background* = 0.01 |cm^-1|. In general, averaging over a distribution of orientations is done by .. math:: P(q) = \int_0^{\pi/2} d\phi \int_0^\pi p(\theta, \phi) P_0(q,\alpha) \sin \theta d\theta P(Q) = \int_0^{\pi/2} d\phi \int_0^\pi p(\theta, \phi) P_0(Q,\alpha) \sin \theta\ d\theta where $p(\theta,\phi)$ is the probability distribution for the orientation and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented and $P_0(Q,\alpha)$ is the scattering intensity for the fully oriented system. Since we have no other software to compare the implementation of the intensity for fully oriented cylinders, we can compare the result of averaging our 2D output using a uniform distribution $p(\theta, \phi) = 1.0$. Figure :num:figure #cylinder-crosscheck shows the result of :num:Figure #cylinder-crosscheck shows the result of such a cross-check. .. _cylinder-crosscheck: .. figure:: img/image066.JPG .. figure:: img/cylinder_crosscheck.jpg Comparison of the intensity for uniformly distributed cylinders calculated from our 2D model and the intensity from the NIST SANS analysis software. The parameters used were: *Scale* = 1.0, *Radius* = 20 |Ang|, *Length* = 400 |Ang|, *Contrast* = 3e-6 |Ang^-2|, and *Background* = 0.0 |cm^-1|. The parameters used were: *scale* = 1.0, *radius* = 20 |Ang|, *length* = 400 |Ang|, *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. """
• ## sasmodels/models/cylinder_clone.py

 r5d4777d r""" CylinderModel ============= This model provides the form factor for a right circular cylinder with uniform scattering length density. The form factor is normalized by the particle volume. For information about polarised and magnetic scattering, click here_. Definition ---------- The output of the 2D scattering intensity function for oriented cylinders is given by (Guinier, 1955) .. math:: P(q,\alpha) = \frac{\text{scale}}{V}f^2(q) + \text{bkg} where .. math:: f(q) = 2 (\Delta \rho) V \frac{\sin (q L/2 \cos \alpha)}{q L/2 \cos \alpha} \frac{J_1 (q r \sin \alpha)}{q r \sin \alpha} and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ is the volume of the cylinder, $L$ is the length of the cylinder, $r$ is the radius of the cylinder, and $d\rho$ (contrast) is the scattering length density difference between the scatterer and the solvent. $J_1$ is the first order Bessel function. To provide easy access to the orientation of the cylinder, we define the axis of the cylinder using two angles $\theta$ and $\phi$. Those angles are defined in Figure :num:figure #CylinderModel-orientation. .. _CylinderModel-orientation: .. figure:: img/image061.JPG Definition of the angles for oriented cylinders. .. figure:: img/image062.JPG Examples of the angles for oriented pp against the detector plane. NB: The 2nd virial coefficient of the cylinder is calculated based on the radius and length values, and used as the effective radius for $S(Q)$ when $P(Q) \cdot S(Q)$ is applied. The returned value is scaled to units of |cm^-1| and the parameters of the CylinderModel are the following: %(parameters)s The output of the 1D scattering intensity function for randomly oriented cylinders is then given by .. math:: P(q) = \frac{\text{scale}}{V} \int_0^{\pi/2} f^2(q,\alpha) \sin \alpha d\alpha + \text{background} The *theta* and *phi* parameters are not used for the 1D output. Our implementation of the scattering kernel and the 1D scattering intensity use the c-library from NIST. Validation of the CylinderModel ------------------------------- Validation of our code was done by comparing the output of the 1D model to the output of the software provided by the NIST (Kline, 2006). Figure :num:figure #CylinderModel-compare shows a comparison of the 1D output of our model and the output of the NIST software. .. _CylinderModel-compare: .. figure:: img/image065.JPG Comparison of the SasView scattering intensity for a cylinder with the output of the NIST SANS analysis software. The parameters were set to: *Scale* = 1.0, *Radius* = 20 |Ang|, *Length* = 400 |Ang|, *Contrast* = 3e-6 |Ang^-2|, and *Background* = 0.01 |cm^-1|. In general, averaging over a distribution of orientations is done by evaluating the following .. math:: P(q) = \int_0^{\pi/2} d\phi \int_0^\pi p(\theta, \phi) P_0(q,\alpha) \sin \theta d\theta where $p(\theta,\phi)$ is the probability distribution for the orientation and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented system. Since we have no other software to compare the implementation of the intensity for fully oriented cylinders, we can compare the result of averaging our 2D output using a uniform distribution $p(\theta, \phi) = 1.0$. Figure :num:figure #CylinderModel-crosscheck shows the result of such a cross-check. .. _CylinderModel-crosscheck: .. figure:: img/image066.JPG Comparison of the intensity for uniformly distributed cylinders calculated from our 2D model and the intensity from the NIST SANS analysis software. The parameters used were: *Scale* = 1.0, *Radius* = 20 |Ang|, *Length* = 400 |Ang|, *Contrast* = 3e-6 |Ang^-2|, and *Background* = 0.0 |cm^-1|. """ from numpy import pi, inf
• ## sasmodels/models/ellipsoid.py

 r5d4777d .. math:: P(q,\alpha) = \frac{\text{scale}}{V} f^2(q) + \text{background} P(Q,\alpha) = {\text{scale} \over V} F^2(Q) + \text{background} where .. math:: f(q) = \frac{3 (\Delta rho)) V (\sin[qr(R_p,R_e,\alpha)] \ - \cos[qr(R_p,R_e,\alpha)])}{[qr(R_q,R_b,\alpha)]^3} F(Q) = {3 (\Delta rho)) V (\sin[Qr(R_p,R_e,\alpha)] - \cos[Qr(R_p,R_e,\alpha)]) \over [Qr(R_p,R_e,\alpha)]^3 } and .. math:: r(R_p,R_e,\alpha) = \left[ R_e^2 \sin^2 \alpha + R_p^2 \cos^2 \alpha \right]^{1/2} r(R_p,R_e,\alpha) = \left[ R_e^2 \sin^2 \alpha + R_p^2 \cos^2 \alpha \right]^{1/2} To provide easy access to the orientation of the ellipsoid, we define the rotation axis of the ellipsoid using two angles $\theta$ and $\phi$. These angles are defined in Figure :num:figure #cylinder-orientation. These angles are defined in the :ref:cylinder orientation figure . For the ellipsoid, $\theta$ is the angle between the rotational axis and the $z$-axis. NB: The 2nd virial coefficient of the solid ellipsoid is calculated based on the $R_p$ and $R_e$ values, and used as the effective radius for $S(Q)$ when $P(Q) \dot S(Q)$ is applied. $S(Q)$ when $P(Q) \cdot S(Q)$ is applied. .. figure:: img/image121.JPG .. _ellipsoid-1d: .. figure:: img/ellipsoid_1d.JPG The output of the 1D scattering intensity function for randomly oriented use the c-library from NIST. .. figure:: img/image122.JPG .. _ellipsoid-geometry: .. figure:: img/ellipsoid_geometry.JPG The angles for oriented ellipsoid. Validation of our code was done by comparing the output of the 1D model to the output of the software provided by the NIST (Kline, 2006). Figure :num:figure ellipsoid-comparison-1d below shows a comparison of :num:Figure ellipsoid-comparison-1d below shows a comparison of the 1D output of our model and the output of the NIST software. .. _ellipsoid-comparison-1d: .. figure:: img/image123.JPG .. figure:: img/ellipsoid_comparison_1d.jpg Comparison of the SasView scattering intensity for an ellipsoid with the output of the NIST SANS analysis software.  The parameters were set to: *scale=1.0*, *a=20 |Ang|*, *b=400 |Ang|*, *sld-solvent_sld=3e-6 |Ang^-2|*, and *background=0.01 |cm^-1|*. were set to: *scale* = 1.0, *rpolar* = 20 |Ang|, *requatorial* =400 |Ang|, *contrast* = 3e-6 |Ang^-2|, and *background* = 0.01 |cm^-1|. Averaging over a distribution of orientation is done by evaluating the implementation of the intensity for fully oriented ellipsoids, we can compare the result of averaging our 2D output using a uniform distribution $p(\theta,\phi) = 1.0$.  Figure :num:figure #ellipsoid-comparison-2d $p(\theta,\phi) = 1.0$.  :num:Figure #ellipsoid-comparison-2d shows the result of such a cross-check. .. _ellipsoid-comparison-2d: .. figure:: img/image124.jpg .. figure:: img/ellipsoid_comparison_2d.jpg Comparison of the intensity for uniformly distributed ellipsoids calculated from our 2D model and the intensity from the NIST SANS analysis software. The parameters used were: *scale=1.0*, *a=20 |Ang|*, *b=400 |Ang|*, *sld-solvent_sld=3e-6 |Ang^-2|*, and *background=0.0 |cm^-1|*. analysis software. The parameters used were: *scale* = 1.0, *rpolar* = 20 |Ang|, *requatorial* = 400 |Ang|, *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. The discrepancy above *q=0.3 |cm^-1|* is due to the way the form factors The discrepancy above *q* = 0.3 |cm^-1| is due to the way the form factors are calculated in the c-library provided by NIST. A numerical integration has to be performed to obtain *P(q)* for randomly oriented particles. has to be performed to obtain $P(Q)$ for randomly oriented particles. The NIST software performs that integration with a 76-point Gaussian quadrature rule, which will become imprecise at high q where the amplitude varies quickly as a function of $q$. The SasView result shown has been quadrature rule, which will become imprecise at high $Q$ where the amplitude varies quickly as a function of $Q$. The SasView result shown has been obtained by summing over 501 equidistant points. Our result was found to be stable over the range of *q* shown for a number of points higher to be stable over the range of $Q$ shown for a number of points higher than 500.
• ## sasmodels/models/lamellar.py

 r5d4777d ---------- The scattering intensity *I(q)* is The scattering intensity *I(Q)* is .. math:: I(q) = 2\pi\frac{P(q){\delta q^2} I(Q) = 2\pi{P(Q) \over \delta Q^2} .. math:: P(q) = \frac{2\Delta\rho^2}{q^2}(1-cos(q\delta) P(Q) = {2\Delta\rho^2 \over Q^2}(1-cos(Q\delta)) where |delta| = bilayer thickness. The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as The 2D scattering intensity is calculated in the same way as 1D, where the $Q$ vector is defined as .. math:: q = \sqrt{q_x^2 q_y^2} Q = \sqrt{Q_x^2 + Q_y^2} (Kline, 2006). .. figure:: img/image135.jpg .. figure:: img/lamellar_1d.jpg 1D plot using the default values (w/1000 data point).
• ## sasmodels/models/sphere.py

 rf4cf580 r""" For information about polarised and magnetic scattering, click here_. .. _here: polar_mag_help.html Definition ---------- The 1D scattering intensity is calculated in the following way (Guinier, 1955) .. math:: I(Q) = \frac{\text{scale}}{V} \cdot \left[ \ 3V(\Delta\rho) \cdot \frac{\sin(QR) - QR\cos(QR))}{(QR)^3} \ \right]^2 + \text{background} where *scale* is a volume fraction, $V$ is the volume of the scatterer, $R$ is the radius of the sphere, *background* is the background level and *sld* and *solvent_sld* are the scattering length densities (SLDs) of the scatterer and the solvent respectively. Note that if your data is in absolute scale, the *scale* should represent the volume fraction (which is unitless) if you have a good fit. If not, it should represent the volume fraction times a factor (by which your data might need to be rescaled). The 2D scattering intensity is the same as above, regardless of the orientation of $\vec q$. Our model uses the form factor calculations as defined in the IGOR package provided by the NIST Center for Neutron Research (Kline, 2006). Validation ---------- Validation of our code was done by comparing the output of the 1D model to the output of the software provided by the NIST (Kline, 2006). Figure :num:figure #sphere-comparison shows a comparison of the output of our model and the output of the NIST software. .. _sphere-comparison: .. figure:: img/sphere_comparison.jpg Comparison of the DANSE scattering intensity for a sphere with the output of the NIST SANS analysis software. The parameters were set to: *scale* = 1.0, *radius* = 60 |Ang|, *contrast* = 1e-6 |Ang^-2|, and *background* = 0.01 |cm^-1|. Reference --------- A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, (1955) *2013/09/09 and 2014/01/06 - Description reviewed by S King and P Parker.* """ name = "sphere" title = "Spheres with uniform SLD" title = "Spheres with uniform scattering length density" description = """\ [Sphere Form Factor] P(q)=(scale/V)*[3V(sld-solvent_sld)*(sin(qR)-qRcos(qR)) /(qR)^3]^2 + background R: radius of sphere V: The volume of the scatter sld: the SLD of the sphere solvent_sld: the SLD of the solvent """
• ## sasmodels/models/triaxial_ellipsoid.py

 r5d4777d .. math:: P(q) = \text{scale} V \left< f^2(q) \right> + \text{background} P(Q) = \text{scale} V \left< F^2(Q) \right> + \text{background} where the volume $V = 4/3 \pi R_a R_b R_c$, and the averaging $\left< \cdots \right>$ is applied over all orientations for 1D. .. figure:: img/image128.JPG .. figure:: img/triaxial_ellipsoid_geometry.jpg Ellipsoid schematic. .. math:: P(q) = \frac{\text{scale}}{V}\int_0^1\int_0^1 \ \Phi^2(qR_a^2\cos^2( \pi x/2) + qR_b^2\sin^2(\pi y/2)(1-y^2) + c^2y^2) \ P(Q) = \frac{\text{scale}}{V}\int_0^1\int_0^1 \Phi^2(QR_a^2\cos^2( \pi x/2) + QR_b^2\sin^2(\pi y/2)(1-y^2) + c^2y^2) dx dy we define the axis of the cylinder using the angles $\theta$, $\phi$ and $\psi$. These angles are defined on Figure :num:figure #triaxial-ellipsoid-angles. :num:figure #triaxial-ellipsoid-angles. The angle $\psi$ is the rotational angle around its own $c$ axis against the $q$ plane. For example, $\psi = 0$ when the against the $Q$ plane. For example, $\psi = 0$ when the $a$ axis is parallel to the $x$ axis of the detector. .. _triaxial-ellipsoid-angles: .. figure:: img/image132.JPG .. figure:: img/triaxial_ellipsoid_angles.jpg The angles for oriented ellipsoid. The radius-of-gyration for this system is  $Rg^2 = (R_a R_b R_c)^2/5$. The radius-of-gyration for this system is  $R_g^2 = (R_a R_b R_c)^2/5$. The contrast is defined as SLD(ellipsoid) - SLD(solvent).  In the calculated based on the polar radius $R_p = R_c$ and equatorial radius $R_e = \sqrt{R_a R_b}$, and used as the effective radius for $S(Q)$ when $P(Q) \dot S(Q)$ is applied. $S(Q)$ when $P(Q) \cdot S(Q)$ is applied. .. figure:: img/image130.JPG .. figure:: img/triaxial_ellipsoid_1d.jpg 1D plot using the default values (w/1000 data point). 1D calculation to the angular average of the output of 2D calculation over all possible angles. Figure :num:figure #triaxial-ellipsoid-compare shows the comparison where :num:Figure #triaxial-ellipsoid-comparison shows the comparison where the solid dot refers to averaged 2D while the line represents the result of 1D calculation (for 2D averaging, 76, 180, and 76 points are taken for the angles of $\theta$, $\phi$, and $\psi$ respectively). .. _triaxial-ellipsoid-compare: .. _triaxial-ellipsoid-comparison: .. figure:: img/image131.GIF .. figure:: img/triaxial_ellipsoid_comparison.png Comparison between 1D and averaged 2D.
Note: See TracChangeset for help on using the changeset viewer.