Changeset fcb33e4 in sasmodels for sasmodels/models/cylinder.py


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.