source: sasmodels/sasmodels/models/hollow_cylinder.py @ a807206

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

updating more parameter names addressing #649

  • Property mode set to 100644
File size: 4.4 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, $H = L/2$ and $J_1$ is the 1st order
34Bessel function.
35
36**NB**: The 2nd virial coefficient of the cylinder is calculated
37based on the radius and 2 length values, and used as the effective radius
38for $S(q)$ when $P(q) \cdot S(q)$ is applied.
39
40In the parameters, the contrast represents SLD :sub:`shell` - SLD :sub:`solvent`
41and the *radius* is $R_\text{shell}$ while *radius_core* is $R_\text{core}$.
42
43To provide easy access to the orientation of the core-shell cylinder, we define
44the axis of the cylinder using two angles $\theta$ and $\phi$
45(see :ref:`cylinder model <cylinder-angle-definition>`).
46
47References
48----------
49
50L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and
51Neutron Scattering*, Plenum Press, New York, (1987)
52"""
53
54from numpy import pi, inf
55
56name = "hollow_cylinder"
57title = ""
58description = """
59P(q) = scale*<f*f>/Vol + background, where f is the scattering amplitude.
60radius_core = the radius of core
61radius = the radius of shell
62length = the total length of the cylinder
63sld = SLD of the shell
64sld_solvent = SLD of the solvent
65background = incoherent background
66"""
67category = "shape:cylinder"
68# pylint: disable=bad-whitespace, line-too-long
69#   ["name", "units", default, [lower, upper], "type","description"],
70parameters = [
71    ["radius",      "Ang",     30.0, [0, inf],    "volume",      "Cylinder radius"],
72    ["radius_core", "Ang",     20.0, [0, inf],    "volume",      "Hollow core radius"],
73    ["length",      "Ang",    400.0, [0, inf],    "volume",      "Cylinder length"],
74    ["sld",         "1/Ang^2",  6.3, [-inf, inf], "sld",         "Cylinder sld"],
75    ["sld_solvent", "1/Ang^2",  1,   [-inf, inf], "sld",         "Solvent sld"],
76    ["theta",       "degrees", 90,   [-360, 360], "orientation", "Theta angle"],
77    ["phi",         "degrees",  0,   [-360, 360], "orientation", "Phi angle"],
78    ]
79# pylint: enable=bad-whitespace, line-too-long
80
81source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"]
82
83# pylint: disable=W0613
84def ER(radius, radius_core, length):
85    """
86    :param radius:      Cylinder radius
87    :param radius_core: Hollow core radius, UNUSED
88    :param length:      Cylinder length
89    :return:            Effective radius
90    """
91    if radius == 0 or length == 0:
92        return 0.0
93    len1 = radius
94    len2 = length/2.0
95    term1 = len1*len1*2.0*len2/2.0
96    term2 = 1.0 + (len2/len1)*(1.0 + 1/len2/2.0)*(1.0 + pi*len1/len2/2.0)
97    ddd = 3.0*term1*term2
98    diam = pow(ddd, (1.0/3.0))
99    return diam
100
101def VR(radius, radius_core, length):
102    """
103    :param radius:      Cylinder radius
104    :param radius_core: Hollow core radius
105    :param length:      Cylinder length
106    :return:            Volf ratio for P(q)*S(q)
107    """
108    vol_core = pi*radius_core*radius_core*length
109    vol_total = pi*radius*radius*length
110    vol_shell = vol_total - vol_core
111    return vol_shell, vol_total
112
113# parameters for demo
114demo = dict(scale=1.0, background=0.0, length=400.0, radius=30.0,
115            radius_core=20.0, sld=6.3, sld_solvent=1, theta=90, phi=0,
116            radius_pd=.2, radius_pd_n=9,
117            length_pd=.2, length_pd_n=10,
118            radius_core_pd=.2, radius_core_pd_n=9,
119            theta_pd=10, theta_pd_n=5,
120           )
121
122# Parameters for unit tests
123tests = [
124    [{"radius": 30.0}, 0.00005, 1764.926],
125    [{}, 'VR', 1.8],
126    [{}, 0.001, 1756.76]
127    ]
Note: See TracBrowser for help on using the repository browser.