source: sasmodels/sasmodels/models/elliptical_cylinder.py @ 58c3367

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 58c3367 was 40a87fa, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

lint and latex cleanup

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