[c612162] | 1 | # pylint: disable=line-too-long |
---|
[a8b3cdb] | 2 | r""" |
---|
| 3 | This function calculates the scattering from an elliptical cylinder. |
---|
| 4 | |
---|
| 5 | Definition for 2D (orientated system) |
---|
| 6 | ------------------------------------- |
---|
| 7 | |
---|
| 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. |
---|
| 11 | |
---|
[5111921] | 12 | .. figure:: img/elliptical_cylinder_geometry.png |
---|
[a8b3cdb] | 13 | |
---|
[0cc31e1] | 14 | Elliptical cylinder geometry $a$ = $r_{minor}$ and \ |nu|\ = $axis\_ratio$ = $r_{major} / r_{minor}$ |
---|
[a8b3cdb] | 15 | |
---|
| 16 | The function calculated is |
---|
| 17 | |
---|
| 18 | .. math:: |
---|
[fa8011eb] | 19 | |
---|
[a8b3cdb] | 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 | |
---|
| 22 | with the functions |
---|
| 23 | |
---|
| 24 | .. math:: |
---|
[fa8011eb] | 25 | |
---|
[b7c2fce] | 26 | F(\mathbf{q},\alpha,\psi)=2\frac{J_1(a)\sin(b)}{ab} |
---|
[a8b3cdb] | 27 | \\ |
---|
[e65a3e7] | 28 | where a = \mathbf{q}\sin(\alpha)\left[ r^2_{major}\sin^2(\psi)+r^2_{minor}\cos(\psi) \right]^{1/2} |
---|
[a8b3cdb] | 29 | \\ |
---|
| 30 | b=\mathbf{q}\frac{L}{2}\cos(\alpha) |
---|
| 31 | |
---|
[b7c2fce] | 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$. |
---|
[a8b3cdb] | 34 | |
---|
| 35 | |
---|
| 36 | Definition for 1D (no preferred orientation) |
---|
| 37 | -------------------------------------------- |
---|
| 38 | |
---|
| 39 | The form factor is averaged over all possible orientation before normalized by the particle volume |
---|
| 40 | |
---|
| 41 | .. math:: |
---|
| 42 | P(q) = scale <F^2> / V |
---|
| 43 | |
---|
| 44 | To provide easy access to the orientation of the elliptical cylinder, we define the axis of the cylinder using two |
---|
[2f0c07d] | 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. |
---|
[a8b3cdb] | 47 | For example, |bigpsi| = 0 when the *r_minor* axis is parallel to the *x*\ -axis of the detector. |
---|
| 48 | |
---|
| 49 | All angle parameters are valid and given only for 2D calculation; ie, an oriented system. |
---|
| 50 | |
---|
[2f0c07d] | 51 | .. figure:: img/elliptical_cylinder_angle_definition.jpg |
---|
[a8b3cdb] | 52 | |
---|
[fa8011eb] | 53 | Definition of angles for 2D |
---|
[a8b3cdb] | 54 | |
---|
[2f0c07d] | 55 | .. figure:: img/cylinder_angle_projection.jpg |
---|
[a8b3cdb] | 56 | |
---|
[fa8011eb] | 57 | Examples of the angles for oriented elliptical cylinders against the detector plane. |
---|
[a8b3cdb] | 58 | |
---|
[74fd96f] | 59 | NB: The 2nd virial coefficient of the cylinder is calculated based on the averaged radius (= sqrt(*r_minor*\ :sup:`2` \* *axis_ratio*)) |
---|
[a8b3cdb] | 60 | and length values, and used as the effective radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied. |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | Validation |
---|
| 64 | ---------- |
---|
| 65 | |
---|
[aa2edb2] | 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. |
---|
[a8b3cdb] | 68 | |
---|
[aa2edb2] | 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. |
---|
[a8b3cdb] | 71 | |
---|
[5111921] | 72 | .. figure:: img/elliptical_cylinder_averaging.png |
---|
[a8b3cdb] | 73 | |
---|
[fa8011eb] | 74 | The intensities averaged from 2D over different numbers of bins and angles. |
---|
[a8b3cdb] | 75 | |
---|
[e65a3e7] | 76 | References |
---|
| 77 | ---------- |
---|
[a8b3cdb] | 78 | |
---|
| 79 | L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum, |
---|
| 80 | New York, (1987) |
---|
| 81 | """ |
---|
| 82 | |
---|
| 83 | import math |
---|
| 84 | from numpy import pi, inf |
---|
| 85 | |
---|
| 86 | name = "elliptical_cylinder" |
---|
| 87 | title = "Form factor for an elliptical cylinder." |
---|
| 88 | description = """ |
---|
[c612162] | 89 | Form factor for an elliptical cylinder. |
---|
| 90 | See L A Feigin and D I Svergun, Structure Analysis by Small-Angle X-Ray and Neutron Scattering, Plenum, New York, (1987). |
---|
[a8b3cdb] | 91 | """ |
---|
| 92 | category = "shape:cylinder" |
---|
| 93 | |
---|
| 94 | # pylint: disable=bad-whitespace, line-too-long |
---|
| 95 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
| 96 | parameters = [["r_minor", "Ang", 20.0, [0, inf], "volume", "Ellipse minor radius"], |
---|
[74fd96f] | 97 | ["axis_ratio", "", 1.5, [1, inf], "volume", "Ratio of major radius over minor radius"], |
---|
[a8b3cdb] | 98 | ["length", "Ang", 400.0, [1, inf], "volume", "Length of the cylinder"], |
---|
| 99 | ["sld", "1e-6/Ang^2", 4.0, [-inf, inf], "", "Cylinder scattering length density"], |
---|
[e65a3e7] | 100 | ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "", "Solvent scattering length density"], |
---|
[a8b3cdb] | 101 | ["theta", "degrees", 90.0, [-360, 360], "orientation", "In plane angle"], |
---|
| 102 | ["phi", "degrees", 0, [-360, 360], "orientation", "Out of plane angle"], |
---|
| 103 | ["psi", "degrees", 0, [-360, 360], "orientation", "Major axis angle relative to Q"]] |
---|
| 104 | |
---|
| 105 | # pylint: enable=bad-whitespace, line-too-long |
---|
| 106 | |
---|
[43b7eea] | 107 | source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c", "elliptical_cylinder.c"] |
---|
[a8b3cdb] | 108 | |
---|
[74fd96f] | 109 | demo = dict(scale=1, background=0, r_minor=100, axis_ratio=1.5, length=400.0, |
---|
[e65a3e7] | 110 | sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, theta_pd=10, phi_pd=2, psi_pd=3) |
---|
[a8b3cdb] | 111 | |
---|
| 112 | oldname = 'EllipticalCylinderModel' |
---|
[74fd96f] | 113 | oldpars = dict(axis_ratio="r_ratio",theta='cyl_theta', phi='cyl_phi', psi='cyl_psi', sld='sldCyl', sld_solvent='sldSolv') |
---|
[a8b3cdb] | 114 | |
---|
[74fd96f] | 115 | def ER(r_minor, axis_ratio, length): |
---|
[a8b3cdb] | 116 | """ |
---|
| 117 | Equivalent radius |
---|
| 118 | @param r_minor: Ellipse minor radius |
---|
[74fd96f] | 119 | @param axis_ratio: Ratio of major radius over minor radius |
---|
[a8b3cdb] | 120 | @param length: Length of the cylinder |
---|
| 121 | """ |
---|
[74fd96f] | 122 | radius = math.sqrt(r_minor * r_minor * axis_ratio) |
---|
[b7c2fce] | 123 | ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) |
---|
[a8b3cdb] | 124 | return 0.5 * (ddd) ** (1. / 3.) |
---|
| 125 | |
---|
[74fd96f] | 126 | tests = [[{'r_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], |
---|
| 127 | [{'r_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], |
---|
[a8b3cdb] | 128 | |
---|
| 129 | # The SasView test result was 0.00169, with a background of 0.001 |
---|
| 130 | [{'r_minor': 20.0, |
---|
[74fd96f] | 131 | 'axis_ratio': 1.5, |
---|
[a8b3cdb] | 132 | 'sld': 4.0, |
---|
| 133 | 'length':400.0, |
---|
[e65a3e7] | 134 | 'sld_solvent':1.0, |
---|
[a8b3cdb] | 135 | 'background':0.0 |
---|
| 136 | }, 0.001, 675.504402]] |
---|