Changeset fcb33e4 in sasmodels


Ignore:
Timestamp:
Jan 4, 2017 6:09:53 AM (7 years ago)
Author:
richardh
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
473a9f1, b7e8b94
Parents:
64614ad
Message:

new model core_shell_bicelle_elliptical, not tested for 2d, docu changes for other cylinder models

Location:
sasmodels/models
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/barbell.py

    r0d6e865 rfcb33e4  
    2020.. math:: 
    2121 
    22     I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> 
     22    I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q,\alpha).sin(\alpha)\right> 
    2323 
    24 where the amplitude $A(q)$ is given as 
     24where the amplitude $A(q,\alpha)$ with the rod axis at angle $\alpha$ to $q$ is given as 
    2525 
    2626.. math:: 
    2727 
    2828    A(q) =&\ \pi r^2L 
    29         \frac{\sin\left(\tfrac12 qL\cos\theta\right)} 
    30              {\tfrac12 qL\cos\theta} 
    31         \frac{2 J_1(qr\sin\theta)}{qr\sin\theta} \\ 
     29        \frac{\sin\left(\tfrac12 qL\cos\alpha\right)} 
     30             {\tfrac12 qL\cos\alpha} 
     31        \frac{2 J_1(qr\sin\alpha)}{qr\sin\alpha} \\ 
    3232        &\ + 4 \pi R^3 \int_{-h/R}^1 dt 
    33         \cos\left[ q\cos\theta 
     33        \cos\left[ q\cos\alpha 
    3434            \left(Rt + h + {\tfrac12} L\right)\right] 
    3535        \times (1-t^2) 
    36         \frac{J_1\left[qR\sin\theta \left(1-t^2\right)^{1/2}\right]} 
    37              {qR\sin\theta \left(1-t^2\right)^{1/2}} 
     36        \frac{J_1\left[qR\sin\alpha \left(1-t^2\right)^{1/2}\right]} 
     37             {qR\sin\alpha \left(1-t^2\right)^{1/2}} 
    3838 
    3939The $\left<\ldots\right>$ brackets denote an average of the structure over 
    40 all orientations. $\left<A^2(q)\right>$ is then the form factor, $P(q)$. 
     40all orientations. $\left<A^2(q,\alpha)\right>$ is then the form factor, $P(q)$. 
    4141The scale factor is equivalent to the volume fraction of cylinders, each of 
    4242volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length 
     
    8585* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    8686* **Last Modified by:** Paul Butler **Date:** March 20, 2016 
    87 * **Last Reviewed by:** Paul Butler **Date:** March 20, 2016 
     87* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
    8888""" 
    8989from numpy import inf 
  • sasmodels/models/capped_cylinder.py

    r0d6e865 rfcb33e4  
    2121.. math:: 
    2222 
    23     I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> 
     23    I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q,\alpha).sin(\alpha)\right> 
    2424 
    25 where the amplitude $A(q)$ is given as 
     25where the amplitude $A(q,\alpha)$ with the rod axis at angle $\alpha$ to $q$ is given as 
    2626 
    2727.. math:: 
    2828 
    2929    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} \\ 
     30        \frac{\sin\left(\tfrac12 qL\cos\alpha\right)} 
     31            {\tfrac12 qL\cos\alpha} 
     32        \frac{2 J_1(qr\sin\alpha)}{qr\sin\alpha} \\ 
    3333        &\ + 4 \pi R^3 \int_{-h/R}^1 dt 
    34         \cos\left[ q\cos\theta 
     34        \cos\left[ q\cos\alpha 
    3535            \left(Rt + h + {\tfrac12} L\right)\right] 
    3636        \times (1-t^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}} 
     37        \frac{J_1\left[qR\sin\alpha \left(1-t^2\right)^{1/2}\right]} 
     38             {qR\sin\alpha \left(1-t^2\right)^{1/2}} 
    3939 
    4040The $\left<\ldots\right>$ brackets denote an average of the structure over 
     
    8888* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    8989* **Last Modified by:** Paul Butler **Date:** September 30, 2016 
    90 * **Last Reviewed by:** Richard Heenan **Date:** March 19, 2016 
     90* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
     91 
    9192""" 
    9293from numpy import inf 
  • sasmodels/models/core_shell_bicelle.py

    ra23639a rfcb33e4  
    4141 
    4242    I(Q,\alpha) = \frac{\text{scale}}{V_t} \cdot 
    43         F(Q,\alpha)^2 + \text{background} 
     43        F(Q,\alpha)^2.sin(\alpha) + \text{background} 
    4444 
    4545where 
     
    8585* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    8686* **Last Modified by:** Paul Butler **Date:** September 30, 2016 
    87 * **Last Reviewed by:** Richard Heenan **Date:** October 5, 2016 
     87* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
    8888""" 
    8989 
  • sasmodels/models/core_shell_cylinder.py

    r755ecc2 rfcb33e4  
    99.. math:: 
    1010 
    11     I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q) + \text{background} 
     11    I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background} 
    1212 
    1313where 
     
    1515.. math:: 
    1616 
    17     F(q) = &\ (\rho_c - \rho_s) V_c 
     17    F(q,\alpha) = &\ (\rho_c - \rho_s) V_c 
    1818           \frac{\sin \left( q \tfrac12 L\cos\alpha \right)} 
    1919                {q \tfrac12 L\cos\alpha} 
  • sasmodels/models/core_shell_ellipsoid.py

    r73e08ae rfcb33e4  
    166166qy = q*sin(phi) 
    167167# After redefinition of angles find new reasonable values for unit test 
    168 #tests = [ 
    169 #    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
    170 #    [{'radius_equat_core': 200.0, 
    171 #      'x_core': 0.1, 
    172 #      'thick_shell': 50.0, 
    173 #      'x_polar_shell': 0.2, 
    174 #      'sld_core': 2.0, 
    175 #      'sld_shell': 1.0, 
    176 #      'sld_solvent': 6.3, 
    177 #      'background': 0.001, 
    178 #      'scale': 1.0, 
    179 #     }, 1.0, 0.00189402], 
     168tests = [ 
     169     # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
     170    [{'radius_equat_core': 200.0, 
     171      'x_core': 0.1, 
     172      'thick_shell': 50.0, 
     173      'x_polar_shell': 0.2, 
     174      'sld_core': 2.0, 
     175      'sld_shell': 1.0, 
     176      'sld_solvent': 6.3, 
     177      'background': 0.001, 
     178      'scale': 1.0, 
     179     }, 1.0, 0.00189402], 
    180180 
    181181    # Additional tests with larger range of parameters 
    182 #    [{'background': 0.01}, 0.1, 11.6915], 
    183  
    184 #    [{'radius_equat_core': 20.0, 
    185 #      'x_core': 200.0, 
    186 #      'thick_shell': 54.0, 
    187 #      'x_polar_shell': 3.0, 
    188 #      'sld_core': 20.0, 
    189 #      'sld_shell': 10.0, 
    190 #      'sld_solvent': 6.0, 
    191 #      'background': 0.0, 
    192 #      'scale': 1.0, 
    193 #     }, 0.01, 8688.53], 
    194  
    195 #   [{'background': 0.001}, (0.4, 0.5), 0.00690673], 
    196  
    197 #   [{'radius_equat_core': 20.0, 
    198 #      'x_core': 200.0, 
    199 #      'thick_shell': 54.0, 
    200 #      'x_polar_shell': 3.0, 
    201 #      'sld_core': 20.0, 
    202 #      'sld_shell': 10.0, 
    203 #      'sld_solvent': 6.0, 
    204 #      'background': 0.01, 
    205 #      'scale': 0.01, 
    206 #     }, (qx, qy), 0.0100002], 
    207 #    ] 
     182    [{'background': 0.01}, 0.1, 11.6915], 
     183 
     184    [{'radius_equat_core': 20.0, 
     185      'x_core': 200.0, 
     186      'thick_shell': 54.0, 
     187      'x_polar_shell': 3.0, 
     188      'sld_core': 20.0, 
     189      'sld_shell': 10.0, 
     190      'sld_solvent': 6.0, 
     191      'background': 0.0, 
     192      'scale': 1.0, 
     193     }, 0.01, 8688.53], 
     194 
     195    [{'background': 0.001}, (0.4, 0.5), 0.00690673], 
     196 
     197   [{'radius_equat_core': 20.0, 
     198      'x_core': 200.0, 
     199      'thick_shell': 54.0, 
     200      'x_polar_shell': 3.0, 
     201      'sld_core': 20.0, 
     202      'sld_shell': 10.0, 
     203      'sld_solvent': 6.0, 
     204      'background': 0.01, 
     205      'scale': 0.01, 
     206# assuming theta and phi zero here? 
     207     }, (qx, qy), 0.01000025], 
     208    ] 
  • sasmodels/models/cylinder.py

    r4cdd0cc rfcb33e4  
    22# Note: model title and parameter table are inserted automatically 
    33r""" 
    4 The form factor is normalized by the particle volume V = \piR^2L. 
     4 
    55For information about polarised and magnetic scattering, see 
    66the :ref:`magnetism` documentation. 
     
    1414.. math:: 
    1515 
    16     P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background} 
     16    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha).sin(\alpha) + \text{background} 
    1717 
    1818where 
     
    2525           \frac{J_1 \left(q R \sin \alpha\right)}{q R \sin \alpha} 
    2626 
    27 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ 
     27and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V =\pi R^2L$ 
    2828is the volume of the cylinder, $L$ is the length of the cylinder, $R$ is the 
    2929radius of the cylinder, and $\Delta\rho$ (contrast) is the scattering length 
     
    3535.. math:: 
    3636 
    37     F^2(q)=\int_{0}^{\pi/2}{F^2(q,\theta)\sin(\theta)d\theta} 
     37    F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}=\int_{0}^{1}{F^2(q,u)du} 
    3838 
    3939 
    40 To provide easy access to the orientation of the cylinder, we define the 
    41 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 
     40Numerical integration is simplified by a change of variable to $u = cos(\alpha)$ with  
     41$sin(\alpha)=\sqrt{1-u^2}$.  
     42 
     43The output of the 1D scattering intensity function for randomly oriented 
     44cylinders is thus given by 
     45 
     46.. math:: 
     47 
     48    P(q) = \frac{\text{scale}}{V} 
     49        \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 
     50 
     51 
     52NB: The 2nd virial coefficient of the cylinder is calculated based on the 
     53radius and length values, and used as the effective radius for $S(q)$ 
     54when $P(q) \cdot S(q)$ is applied. 
     55 
     56For oriented cylinders, we define the direction of the 
     57axis of the cylinder using two angles $\theta$ (note this is not the 
     58same as the scattering angle used in q) and $\phi$. Those angles 
    4259are defined in :numref:`cylinder-angle-definition` . 
    4360 
     
    4865    Definition of the angles for oriented cylinders. 
    4966 
    50  
    51 NB: The 2nd virial coefficient of the cylinder is calculated based on the 
    52 radius and length values, and used as the effective radius for $S(q)$ 
    53 when $P(q) \cdot S(q)$ is applied. 
    54  
    55 The output of the 1D scattering intensity function for randomly oriented 
    56 cylinders is then given by 
    57  
    58 .. math:: 
    59  
    60     P(q) = \frac{\text{scale}}{V} 
    61         \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 
    62  
    63 The $\theta$ and $\phi$ parameters are not used for the 1D output. 
     67The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 
    6468 
    6569Validation 
     
    7478 
    7579    P(q) = \int_0^{\pi/2} d\phi 
    76         \int_0^\pi p(\alpha) P_0(q,\alpha) \sin \alpha\ d\alpha 
     80        \int_0^\pi p(\theta) P_0(q,\theta) \sin \theta\ d\theta 
    7781 
    7882 
    7983where $p(\theta,\phi) = 1$ is the probability distribution for the orientation 
    80 and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented 
     84and $P_0(q,\theta)$ is the scattering intensity for the fully oriented 
    8185system, and then comparing to the 1D result. 
    8286 
     
    145149 
    146150qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    147 # After redefinition of angles, find new tests values  
    148 #tests = [[{}, 0.2, 0.042761386790780453], 
    149 #         [{}, [0.2], [0.042761386790780453]], 
    150 #         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
    151 #         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
    152 #        ] 
     151# After redefinition of angles, find new tests values.  Was 10 10 in old coords 
     152tests = [[{}, 0.2, 0.042761386790780453], 
     153        [{}, [0.2], [0.042761386790780453]], 
     154#  expect new      [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 
     155#         [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 
     156# old, but calcs .0344268         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
     157#                       [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
     158        ] 
    153159del qx, qy  # not necessary to delete, but cleaner 
    154160# ADDED by:  RKH  ON: 18Mar2016 renamed sld's etc 
  • sasmodels/models/elliptical_cylinder.py

    ra807206 rfcb33e4  
    2020 
    2121    I(\vec q)=\frac{1}{V_\text{cyl}}\int{d\psi}\int{d\phi}\int{ 
    22         p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\theta)d\theta} 
     22        p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\alpha)d\alpha} 
    2323 
    2424with the functions 
     
    2626.. math:: 
    2727 
    28     F(\vec q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 
     28    F(q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 
    2929 
    3030where 
     
    3232.. math:: 
    3333 
    34     a &= \vec q\sin(\alpha)\left[ 
    35         r^2_\text{major}\sin^2(\psi)+r^2_\text{minor}\cos(\psi) \right]^{1/2} 
     34    a = qr'\sin(\alpha) 
     35     
     36    b = q\frac{L}{2}\cos(\alpha) 
     37     
     38    r'=\frac{r_{minor}}{\sqrt{2}}\sqrt{(1+\nu^{2}) + (1-\nu^{2})cos(\psi)} 
    3639 
    37     b &= \vec q\frac{L}{2}\cos(\alpha) 
    3840 
    39 and the angle $\Psi$ is defined as the orientation of the major axis of the 
     41and the angle $\psi$ is defined as the orientation of the major axis of the 
    4042ellipse with respect to the vector $\vec q$. The angle $\alpha$ is the angle 
    4143between the axis of the cylinder and $\vec q$. 
     
    9597 
    9698L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
    97 Neutron Scattering*, Plenum, New York, (1987) 
     99Neutron Scattering*, Plenum, New York, (1987) [see table 3.4] 
     100 
     101Authorship and Verification 
     102---------------------------- 
     103 
     104* **Author:** 
     105* **Last Modified by:**  
     106* **Last Reviewed by:**  Richard Heenan - corrected equation in docs **Date:** December 21, 2016 
     107 
    98108""" 
    99109 
Note: See TracChangeset for help on using the changeset viewer.