source: sasmodels/sasmodels/models/ellipsoid.py @ 5d4777d

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 5d4777d was 5d4777d, checked in by Paul Kienzle <pkienzle@…>, 10 years ago

reorganize, check and update models

  • Property mode set to 100644
File size: 5.7 KB
Line 
1# ellipsoid model
2# Note: model title and parameter table are inserted automatically
3r"""
4The form factor is normalized by the particle volume.
5
6Definition
7----------
8
9The output of the 2D scattering intensity function for oriented ellipsoids
10is given by (Feigin, 1987)
11
12.. math::
13
14    P(q,\alpha) = \frac{\text{scale}}{V} f^2(q) + \text{background}
15
16where
17
18.. math::
19
20    f(q) = \frac{3 (\Delta rho)) V (\sin[qr(R_p,R_e,\alpha)] \
21                 - \cos[qr(R_p,R_e,\alpha)])}{[qr(R_q,R_b,\alpha)]^3}
22
23and
24
25.. math::
26
27    r(R_p,R_e,\alpha) = \left[ R_e^2 \sin^2 \alpha + R_p^2 \cos^2 \alpha \right]^{1/2}
28
29
30$\alpha$ is the angle between the axis of the ellipsoid and $\vec q$,
31$V$ is the volume of the ellipsoid, $R_p$ is the polar radius along the
32rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular
33to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the
34scattering length density difference between the scatterer and the solvent.
35
36To provide easy access to the orientation of the ellipsoid, we define
37the rotation axis of the ellipsoid using two angles $\theta$ and $\phi$.
38These angles are defined in Figure :num:`figure #cylinder-orientation`.
39For the ellipsoid, $\theta$ is the angle between the rotational axis
40and the $z$-axis.
41
42NB: The 2nd virial coefficient of the solid ellipsoid is calculated based
43on the $R_p$ and $R_e$ values, and used as the effective radius for
44$S(Q)$ when $P(Q) \dot S(Q)$ is applied.
45
46.. figure:: img/image121.JPG
47
48    The output of the 1D scattering intensity function for randomly oriented
49    ellipsoids given by the equation above.
50
51
52The $\theta$ and $\phi$ parameters are not used for the 1D output. Our
53implementation of the scattering kernel and the 1D scattering intensity
54use the c-library from NIST.
55
56.. figure:: img/image122.JPG
57
58    The angles for oriented ellipsoid.
59
60Validation
61----------
62
63Validation of our code was done by comparing the output of the 1D model
64to the output of the software provided by the NIST (Kline, 2006).
65Figure :num:`figure ellipsoid-comparison-1d` below shows a comparison of
66the 1D output of our model and the output of the NIST software.
67
68.. _ellipsoid-comparison-1d:
69
70.. figure:: img/image123.JPG
71
72    Comparison of the SasView scattering intensity for an ellipsoid
73    with the output of the NIST SANS analysis software.  The parameters
74    were set to: *scale=1.0*, *a=20 |Ang|*, *b=400 |Ang|*,
75    *sld-solvent_sld=3e-6 |Ang^-2|*, and *background=0.01 |cm^-1|*.
76
77Averaging over a distribution of orientation is done by evaluating the
78equation above. Since we have no other software to compare the
79implementation of the intensity for fully oriented ellipsoids, we can
80compare the result of averaging our 2D output using a uniform distribution
81$p(\theta,\phi) = 1.0$.  Figure :num:`figure #ellipsoid-comparison-2d`
82shows the result of such a cross-check.
83
84.. _ellipsoid-comparison-2d:
85
86.. figure:: img/image124.jpg
87
88    Comparison of the intensity for uniformly distributed ellipsoids
89    calculated from our 2D model and the intensity from the NIST SANS
90    analysis software. The parameters used were: *scale=1.0*,
91    *a=20 |Ang|*, *b=400 |Ang|*, *sld-solvent_sld=3e-6 |Ang^-2|*,
92    and *background=0.0 |cm^-1|*.
93
94The discrepancy above *q=0.3 |cm^-1|* is due to the way the form factors
95are calculated in the c-library provided by NIST. A numerical integration
96has to be performed to obtain *P(q)* for randomly oriented particles.
97The NIST software performs that integration with a 76-point Gaussian
98quadrature rule, which will become imprecise at high q where the amplitude
99varies quickly as a function of $q$. The SasView result shown has been
100obtained by summing over 501 equidistant points. Our result was found
101to be stable over the range of *q* shown for a number of points higher
102than 500.
103
104REFERENCE
105
106L A Feigin and D I Svergun. *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum,
107New York, 1987.
108"""
109
110from numpy import pi, inf
111
112name = "ellipsoid"
113title = "Ellipsoid of revolution with uniform scattering length density."
114
115description = """\
116P(q.alpha)= scale*f(q)^2 + background, where f(q)= 3*(sld
117                - solvent_sld)*V*[sin(q*r(Rp,Re,alpha))
118                -q*r*cos(qr(Rp,Re,alpha))]
119                /[qr(Rp,Re,alpha)]^3"
120
121     r(Rp,Re,alpha)= [Re^(2)*(sin(alpha))^2
122                + Rp^(2)*(cos(alpha))^2]^(1/2)
123
124                sld: SLD of the ellipsoid
125                solvent_sld: SLD of the solvent
126                V: volume of the ellipsoid
127                Rp: polar radius of the ellipsoid
128                Re: equatorial radius of the ellipsoid
129"""
130
131parameters = [
132#   [ "name", "units", default, [lower, upper], "type",
133#     "description" ],
134    [ "sld", "1e-6/Ang^2", 4, [-inf,inf], "",
135      "Ellipsoid scattering length density" ],
136    [ "solvent_sld", "1e-6/Ang^2", 1, [-inf,inf], "",
137      "Solvent scattering length density" ],
138    [ "rpolar", "Ang",  20, [0, inf], "volume",
139      "Polar radius" ],
140    [ "requatorial", "Ang",  400, [0, inf], "volume",
141      "Equatorial radius" ],
142    [ "theta", "degrees", 60, [-inf, inf], "orientation",
143      "In plane angle" ],
144    [ "phi", "degrees", 60, [-inf, inf], "orientation",
145      "Out of plane angle" ],
146    ]
147
148source = [ "lib/J1.c", "lib/gauss76.c", "ellipsoid.c"]
149
150def ER(rpolar, requatorial):
151    import numpy as np
152
153    ee = np.empty_like(rpolar)
154    idx = rpolar > requatorial
155    ee[idx] = (rpolar[idx]**2 - requatorial[idx]**2)/rpolar[idx]**2
156    idx = rpolar < requatorial
157    ee[idx] = (requatorial[idx]**2 - rpolar[idx]**2)/requatorial[idx]**2
158    idx = rpolar == requatorial
159    ee[idx] = 2*rpolar[idx]
160    valid = (rpolar*requatorial != 0)
161    bd = 1.0-ee[valid]
162    e1 = np.sqrt(ee[valid])
163    b1 = 1.0 + np.arcsin(e1)/(e1*np.sqrt(bd))
164    bL = (1.0+e1)/(1.0-e1)
165    b2 = 1.0 + bd/2/e1*np.log(bL)
166    delta = 0.75*b1*b2
167
168    ddd = np.zeros_like(rpolar)
169    ddd[valid] = 2.0*(delta+1.0)*rpolar*requatorial**2
170    return 0.5*ddd**(1.0/3.0)
Note: See TracBrowser for help on using the repository browser.