Ignore:
Timestamp:
Aug 8, 2016 9:24:11 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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:
2472141
Parents:
2d65d51
Message:

lint and latex cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/elliptical_cylinder.py

    r42356c8 r40a87fa  
    11# pylint: disable=line-too-long 
    22r""" 
    3 This function calculates the scattering from an elliptical cylinder. 
    4  
    53Definition for 2D (orientated system) 
    64------------------------------------- 
    75 
    8 The angles |theta| and |phi| define the orientation of the axis of the cylinder. The angle |bigpsi| is defined as the 
    9 orientation of the major axis of the ellipse with respect to the vector *Q*\ . A gaussian polydispersity can be added 
    10 to any of the orientation angles, and also for the minor radius and the ratio of the ellipse radii. 
     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. 
    1111 
    1212.. figure:: img/elliptical_cylinder_geometry.png 
    1313 
    14    Elliptical cylinder geometry $a$ = $r_{minor}$ and \ |nu|\  = $axis\_ratio$ = $r_{major} / r_{minor}$ 
     14   Elliptical cylinder geometry $a = r_\text{minor}$ 
     15   and $\nu = r_\text{major} / r_\text{minor}$ is the *axis_ratio*. 
    1516 
    1617The function calculated is 
     
    1819.. math:: 
    1920 
    20     I(\mathbf{q})=\frac{1}{V_{cyl}}\int{d\psi}\int{d\phi}\int{p(\theta,\phi,\psi)F^2(\mathbf{q},\alpha,\psi)\sin(\theta)d\theta} 
     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} 
    2123 
    2224with the functions 
     
    2426.. math:: 
    2527 
    26     F(\mathbf{q},\alpha,\psi)=2\frac{J_1(a)\sin(b)}{ab} 
    27     \\ 
    28     where  a = \mathbf{q}\sin(\alpha)\left[ r^2_{major}\sin^2(\psi)+r^2_{minor}\cos(\psi) \right]^{1/2} 
    29     \\ 
    30     b=\mathbf{q}\frac{L}{2}\cos(\alpha) 
     28    F(\vec q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 
    3129 
    32 and the angle |bigpsi| is defined as the orientation of the major axis of the ellipse with respect to the vector $\vec q$ . 
    33 The angle $\alpha$ is the angle between the axis of the cylinder and $\vec q$. 
     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) 
     38 
     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$. 
    3442 
    3543 
     
    3745-------------------------------------------- 
    3846 
    39 The form factor is averaged over all possible orientation before normalized by the particle volume 
     47The form factor is averaged over all possible orientation before normalized 
     48by the particle volume 
    4049 
    4150.. math:: 
    42     P(q) = scale  <F^2> / V 
    4351 
    44 To provide easy access to the orientation of the elliptical cylinder, we define the axis of the cylinder using two 
    45 angles |theta|, |phi| and |bigpsi| (see :ref:`cylinder orientation <cylinder-angle-definition>`). 
    46 The angle |bigpsi| is the rotational angle around its own long_c axis against the *q* plane. 
    47 For example, |bigpsi| = 0 when the *r_minor* axis is parallel to the *x*\ -axis of the detector. 
     52    P(q) = \text{scale}  <F^2> / V 
    4853 
    49 All angle parameters are valid and given only for 2D calculation; ie, an oriented system. 
     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. 
    5063 
    5164.. figure:: img/elliptical_cylinder_angle_definition.jpg 
     
    5568.. figure:: img/cylinder_angle_projection.jpg 
    5669 
    57     Examples of the angles for oriented elliptical cylinders against the detector plane. 
     70    Examples of the angles for oriented elliptical cylinders against the 
     71    detector plane. 
    5872 
    59 NB: The 2nd virial coefficient of the cylinder is calculated based on the averaged radius (= sqrt(*r_minor*\ :sup:`2` \* *axis_ratio*)) 
    60 and length values, and used as the effective radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied. 
     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. 
    6176 
    6277 
     
    6479---------- 
    6580 
    66 Validation of our code was done by comparing the output of the 1D calculation to the  
    67 angular average of the output of the 2D calculation over all possible angles.  
     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. 
    6884 
    69 In the 2D average, more binning in the angle |phi| is necessary to get the proper result.  
    70 The following figure shows the results of the averaging by varying the number of angular bins. 
     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. 
    7188 
    7289.. figure:: img/elliptical_cylinder_averaging.png 
     
    7794---------- 
    7895 
    79 L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum, 
    80 New York, (1987) 
     96L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
     97Neutron Scattering*, Plenum, New York, (1987) 
    8198""" 
    8299 
     
    104121# pylint: enable=bad-whitespace, line-too-long 
    105122 
    106 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c", "elliptical_cylinder.c"] 
     123source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c", 
     124          "elliptical_cylinder.c"] 
    107125 
    108126demo = dict(scale=1, background=0, r_minor=100, axis_ratio=1.5, length=400.0, 
    109             sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, theta_pd=10, phi_pd=2, psi_pd=3) 
     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) 
    110129 
    111130def ER(r_minor, axis_ratio, length): 
     
    117136    """ 
    118137    radius = sqrt(r_minor * r_minor * axis_ratio) 
    119     ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) 
     138    ddd = 0.75 * radius * (2 * radius * length 
     139                           + (length + radius) * (length + pi * radius)) 
    120140    return 0.5 * (ddd) ** (1. / 3.) 
    121141 
    122 tests = [[{'r_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 
    123          [{'r_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 
     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], 
    124145 
    125          # The SasView test result was 0.00169, with a background of 0.001 
    126          [{'r_minor': 20.0, 
    127            'axis_ratio': 1.5, 
    128            'sld': 4.0, 
    129            'length':400.0, 
    130            'sld_solvent':1.0, 
    131            'background':0.0 
    132           }, 0.001, 675.504402]] 
     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 TracChangeset for help on using the changeset viewer.