source: sasmodels/sasmodels/models/elliptical_cylinder.py @ 15a90c1

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 15a90c1 was 15a90c1, checked in by richardh, 7 years ago

more changes for new axes, and a bug in cylinder.py docs

  • Property mode set to 100644
File size: 5.9 KB
RevLine 
[c612162]1# pylint: disable=line-too-long
[a8b3cdb]2r"""
3Definition for 2D (orientated system)
4-------------------------------------
5
[40a87fa]6The angles $\theta$ and $\phi$ define the orientation of the axis of the
7cylinder. The angle $\Psi$ is defined as the orientation of the major
8axis of the ellipse with respect to the vector $Q$. A gaussian polydispersity
9can be added to any of the orientation angles, and also for the minor
10radius and the ratio of the ellipse radii.
[a8b3cdb]11
[5111921]12.. figure:: img/elliptical_cylinder_geometry.png
[a8b3cdb]13
[40a87fa]14   Elliptical cylinder geometry $a = r_\text{minor}$
15   and $\nu = r_\text{major} / r_\text{minor}$ is the *axis_ratio*.
[a8b3cdb]16
17The function calculated is
18
19.. math::
[fa8011eb]20
[40a87fa]21    I(\vec q)=\frac{1}{V_\text{cyl}}\int{d\psi}\int{d\phi}\int{
[fcb33e4]22        p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\alpha)d\alpha}
[a8b3cdb]23
24with the functions
25
26.. math::
[fa8011eb]27
[fcb33e4]28    F(q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab}
[40a87fa]29
30where
31
32.. math::
33
[fcb33e4]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)}
[40a87fa]39
[a8b3cdb]40
[fcb33e4]41and the angle $\psi$ is defined as the orientation of the major axis of the
[40a87fa]42ellipse with respect to the vector $\vec q$. The angle $\alpha$ is the angle
43between the axis of the cylinder and $\vec q$.
[a8b3cdb]44
45
46Definition for 1D (no preferred orientation)
47--------------------------------------------
48
[40a87fa]49The form factor is averaged over all possible orientation before normalized
50by the particle volume
[a8b3cdb]51
52.. math::
53
[40a87fa]54    P(q) = \text{scale}  <F^2> / V
[a8b3cdb]55
[40a87fa]56To provide easy access to the orientation of the elliptical cylinder, we
57define the axis of the cylinder using two angles $\theta$, $\phi$ and $\Psi$
58(see :ref:`cylinder orientation <cylinder-angle-definition>`). The angle
59$\Psi$ is the rotational angle around its own long_c axis against the $q$ plane.
60For example, $\Psi = 0$ when the $r_\text{minor}$ axis is parallel to the
61$x$ axis of the detector.
62
63All angle parameters are valid and given only for 2D calculation; ie, an
64oriented system.
[a8b3cdb]65
[15a90c1]66.. figure:: img/elliptical_cylinder_angle_definition.png
[a8b3cdb]67
[15a90c1]68    Definition of angles for oriented elliptical cylinder, where axis_ratio >1,
69    and angle $\Psi$ is a rotation around the axis of the cylinder.
[a8b3cdb]70
[15a90c1]71.. figure:: img/elliptical_cylinder_angle_projection.png
[a8b3cdb]72
[40a87fa]73    Examples of the angles for oriented elliptical cylinders against the
[15a90c1]74    detector plane, with $\Psi$ = 0.
[a8b3cdb]75
[40a87fa]76NB: The 2nd virial coefficient of the cylinder is calculated based on the
77averaged radius $(=\sqrt{r_\text{minor}^2 * \text{axis ratio}})$ and length
78values, and used as the effective radius for $S(Q)$ when $P(Q)*S(Q)$ is applied.
[a8b3cdb]79
80
81Validation
82----------
83
[40a87fa]84Validation of our code was done by comparing the output of the 1D calculation
85to the angular average of the output of the 2D calculation over all possible
86angles.
[a8b3cdb]87
[40a87fa]88In the 2D average, more binning in the angle $\phi$ is necessary to get the
89proper result. The following figure shows the results of the averaging by
90varying the number of angular bins.
[a8b3cdb]91
[5111921]92.. figure:: img/elliptical_cylinder_averaging.png
[a8b3cdb]93
[fa8011eb]94    The intensities averaged from 2D over different numbers of bins and angles.
[a8b3cdb]95
[e65a3e7]96References
97----------
[a8b3cdb]98
[40a87fa]99L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and
[fcb33e4]100Neutron Scattering*, Plenum, New York, (1987) [see table 3.4]
101
102Authorship and Verification
103----------------------------
104
105* **Author:**
106* **Last Modified by:**
107* **Last Reviewed by:**  Richard Heenan - corrected equation in docs **Date:** December 21, 2016
108
[a8b3cdb]109"""
110
[416609b]111from numpy import pi, inf, sqrt
[a8b3cdb]112
113name = "elliptical_cylinder"
114title = "Form factor for an elliptical cylinder."
115description = """
[c612162]116    Form factor for an elliptical cylinder.
117    See L A Feigin and D I Svergun, Structure Analysis by Small-Angle X-Ray and Neutron Scattering, Plenum, New York, (1987).
[a8b3cdb]118"""
119category = "shape:cylinder"
120
121# pylint: disable=bad-whitespace, line-too-long
122#             ["name", "units", default, [lower, upper], "type","description"],
[a807206]123parameters = [["radius_minor",     "Ang",        20.0,  [0, inf],    "volume",      "Ellipse minor radius"],
[42356c8]124              ["axis_ratio",   "",          1.5,   [1, inf],    "volume",      "Ratio of major radius over minor radius"],
[a8b3cdb]125              ["length",      "Ang",        400.0, [1, inf],    "volume",      "Length of the cylinder"],
[42356c8]126              ["sld",         "1e-6/Ang^2", 4.0,   [-inf, inf], "sld",         "Cylinder scattering length density"],
127              ["sld_solvent", "1e-6/Ang^2", 1.0,   [-inf, inf], "sld",         "Solvent scattering length density"],
[a8b3cdb]128              ["theta",       "degrees",    90.0,  [-360, 360], "orientation", "In plane angle"],
129              ["phi",         "degrees",    0,     [-360, 360], "orientation", "Out of plane angle"],
130              ["psi",         "degrees",    0,     [-360, 360], "orientation", "Major axis angle relative to Q"]]
131
132# pylint: enable=bad-whitespace, line-too-long
133
[40a87fa]134source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c",
135          "elliptical_cylinder.c"]
[a8b3cdb]136
[a807206]137demo = dict(scale=1, background=0, radius_minor=100, axis_ratio=1.5, length=400.0,
[40a87fa]138            sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30,
139            theta_pd=10, phi_pd=2, psi_pd=3)
[a8b3cdb]140
[a807206]141def ER(radius_minor, axis_ratio, length):
[a8b3cdb]142    """
143        Equivalent radius
[a807206]144        @param radius_minor: Ellipse minor radius
[74fd96f]145        @param axis_ratio: Ratio of major radius over minor radius
[a8b3cdb]146        @param length: Length of the cylinder
147    """
[a807206]148    radius = sqrt(radius_minor * radius_minor * axis_ratio)
[40a87fa]149    ddd = 0.75 * radius * (2 * radius * length
150                           + (length + radius) * (length + pi * radius))
[a8b3cdb]151    return 0.5 * (ddd) ** (1. / 3.)
152
[40a87fa]153tests = [
[a807206]154    [{'radius_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024],
155    [{'radius_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1],
[40a87fa]156
157    # The SasView test result was 0.00169, with a background of 0.001
[a807206]158    [{'radius_minor': 20.0, 'axis_ratio': 1.5, 'sld': 4.0, 'length':400.0,
[40a87fa]159      'sld_solvent':1.0, 'background':0.0},
160     0.001, 675.504402],
161]
Note: See TracBrowser for help on using the repository browser.