# source:sasmodels/sasmodels/models/hollow_cylinder.py@ec2ca99

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since ec2ca99 was ec2ca99, checked in by piotr, 8 years ago

more fun with pylint

• Property mode set to 100644
File size: 5.1 KB
Line
1r"""
2This model provides the form factor, $P(q)$, for a monodisperse hollow right
3angle circular cylinder (tube) where the form factor is normalized by the
4volume of the tube
5
6.. math::
7
8    P(q) = \text{scale} \left<F^2\right>/V_\text{shell} + \text{background}
9
10where the averaging $\left<\ldots\right>$ is applied only for the 1D calculation.
11
12The inside and outside of the hollow cylinder are assumed have the same SLD.
13
14Definition
15----------
16
17The 1D scattering intensity is calculated in the following way (Guinier, 1955)
18
19.. math::
20
21    P(q)           &= (\text{scale})V_\text{shell}\Delta\rho^2
22            \int_0^{1}\Psi^2
23            \left[q_z, R_\text{shell}(1-x^2)^{1/2},
24                       R_\text{core}(1-x^2)^{1/2}\right]
25            \left[\frac{\sin(qHx)}{qHx}\right]^2 dx \\
26    \Psi[q,y,z]    &= \frac{1}{1-\gamma^2}
27            \left[ \Lambda(qy) - \gamma^2\Lambda(qz) \right] \\
28    \Lambda(a)     &= 2 J_1(a) / a \\
29    \gamma         &= R_\text{core} / R_\text{shell} \\
30    V_\text{shell} &= \pi \left(R_\text{shell}^2 - R_\text{core}^2 \right)L \\
31    J_1(x)         &= (\sin(x)-x\cdot \cos(x)) / x^2
32
33where *scale* is a scale factor and $J_1$ is the 1st order
34Bessel function.
35
36To provide easy access to the orientation of the core-shell cylinder, we define
37the axis of the cylinder using two angles $\theta$ and $\phi$. As for the case
38of the cylinder, those angles are defined in Figure 2 of the CylinderModel.
39
40**NB**: The 2nd virial coefficient of the cylinder is calculated
41based on the radius and 2 length values, and used as the effective radius
42for $S(q)$ when $P(q) \cdot S(q)$ is applied.
43
44In the parameters, the contrast represents SLD :sub:shell - SLD :sub:solvent
45and the *radius* is $R_\text{shell}$ while *core_radius* is $R_\text{core}$.
46
47.. figure:: img/hollow_cylinder_1d.jpg
48
49    1D plot using the default values (w/1000 data point).
50
51.. figure:: img/orientation.jpg
52
53    Definition of the angles for the oriented hollow_cylinder model.
54
55.. figure:: img/orientation2.jpg
56
57    Examples of the angles for oriented pp against the detector plane.
58
59References
60----------
61
62L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and
63Neutron Scattering*, Plenum Press, New York, (1987)
64"""
65
66from numpy import pi, inf
67
68name = "hollow_cylinder"
69title = ""
70description = """
71P(q) = scale*<f*f>/Vol + background, where f is the scattering amplitude.
74length = the total length of the cylinder
75sld = SLD of the shell
76solvent_sld = SLD of the solvent
77background = incoherent background
78"""
79category = "shape:cylinder"
81#   ["name", "units", default, [lower, upper], "type","description"],
82parameters = [
85    ["length",      "Ang",    400.0, [0, inf],    "volume",      "Cylinder length"],
86    ["sld",         "1/Ang^2",  6.3, [-inf, inf], "",            "Cylinder sld"],
87    ["solvent_sld", "1/Ang^2",  1,   [-inf, inf], "",            "Solvent sld"],
88    ["theta",       "degrees", 90,   [-360, 360], "orientation", "Theta angle"],
89    ["phi",         "degrees",  0,   [-360, 360], "orientation", "Phi angle"],
90    ]
92
93source = ["lib/J1.c", "lib/gauss76.c", "hollow_cylinder.c"]
94
96    """
99    :param length:      Cylinder length
101    """
102    if radius == 0 or length == 0:
103        return 0.0
105    len2 = length/2.0
106    term1 = len1*len1*2.0*len2/2.0
107    term2 = 1.0 + (len2/len1)*(1.0 + 1/len2/2.0)*(1.0 + pi*len1/len2/2.0)
108    ddd = 3.0*term1*term2
109    diam = pow(ddd, (1.0/3.0))
110    return diam
111
113    """
116    :param length:      Cylinder length
117    :return:            Volf ratio for P(q)*S(q)
118    """
121    vol_shell = vol_total - vol_core
122    return vol_shell, vol_total
123
124# parameters for demo
125demo = dict(scale=1.0, background=0.0, length=400.0, radius=30.0,
126            core_radius=20.0, sld=6.3, solvent_sld=1, theta=90, phi=0,
128            length_pd=.2, length_pd_n=10,
130            theta_pd=10, theta_pd_n=5,
131           )
132
133# For testing against the old sasview models, include the converted parameter
134# names and the target sasview model name.
135oldname = 'HollowCylinderModel'