source: sasmodels/sasmodels/models/barbell.py @ 0706431

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0706431 was 0706431, checked in by ajj, 9 years ago

Fixed barbell model - now giving same result as sasview model

  • Property mode set to 100644
File size: 5.5 KB
Line 
1#barbell model
2# cylinder model
3# Note: model title and parameter table are inserted automatically
4r"""
5
6Calculates the scattering from a barbell-shaped cylinder (This model simply becomes the DumBellModel when the length of
7the cylinder, *L*, is set to zero). That is, a sphereocylinder with spherical end caps that have a radius larger than
8that of the cylinder and the center of the end cap radius lies outside of the cylinder. All dimensions of the BarBell
9are considered to be monodisperse. See the diagram for the details of the geometry and restrictions on parameter values.
10
11Definition
12----------
13
14The returned value is scaled to units of |cm^-1|\ |sr^-1|, absolute scale.
15
16The barbell geometry is defined as
17
18.. image:: img/image105.jpg
19
20where *r* is the radius of the cylinder. All other parameters are as defined in the diagram.
21
22Since the end cap radius
23*R* >= *r* and by definition for this geometry *h* < 0, *h* is then defined by *r* and *R* as
24
25*h* = -1 \* sqrt(*R*\ :sup:`2` - *r*\ :sup:`2`)
26
27The scattered intensity *I(q)* is calculated as
28
29.. math::
30
31    I(Q) = \frac{(\Delta \rho)^2}{V} \left< A^2(Q)\right>
32
33where the amplitude *A(q)* is given as
34
35.. math::
36
37    A(Q) =&\ \pi r^2L
38        {\sin\left(\tfrac12 QL\cos\theta\right)
39            \over \tfrac12 QL\cos\theta}
40        {2 J_1(Qr\sin\theta) \over Qr\sin\theta} \\
41        &\ + 4 \pi R^3 \int_{-h/R}^1 dt
42        \cos\left[ Q\cos\theta
43            \left(Rt + h + {\tfrac12} L\right)\right]
44        \times (1-t^2)
45        {J_1\left[QR\sin\theta \left(1-t^2\right)^{1/2}\right]
46             \over QR\sin\theta \left(1-t^2\right)^{1/2}}
47
48The < > brackets denote an average of the structure over all orientations. <*A* :sup:`2`\ *(q)*> is then the form
49factor, *P(q)*. The scale factor is equivalent to the volume fraction of cylinders, each of volume, *V*. Contrast is
50the difference of scattering length densities of the cylinder and the surrounding solvent.
51
52The volume of the barbell is
53
54.. math::
55
56    V = \pi r_c^2 L + 2\pi\left(\tfrac23R^3 + R^2h-\tfrac13h^3\right)
57
58
59and its radius-of-gyration is
60
61.. math::
62
63    R_g^2 =&\ \left[ \tfrac{12}{5}R^5
64        + R^4\left(6h+\tfrac32 L\right)
65        + R^2\left(4h^2 + L^2 + 4Lh\right)
66        + R^2\left(3Lh^2 + \tfrac32 L^2h\right) \right. \\
67        &\ \left. + \tfrac25 h^5 - \tfrac12 Lh^4 - \tfrac12 L^2h^3
68        + \tfrac14 L^3r^2 + \tfrac32 Lr^4 \right]
69        \left( 4R^3 6R^2h - 2h^3 + 3r^2L \right)^{-1}
70
71**The requirement that** *R* >= *r* **is not enforced in the model!** It is up to you to restrict this during analysis.
72
73This example dataset is produced by running the Macro PlotBarbell(), using 200 data points, *qmin* = 0.001 |Ang^-1|,
74*qmax* = 0.7 |Ang^-1| and the following default values
75
76==============  ========  =============
77Parameter name  Units     Default value
78==============  ========  =============
79scale           None      1.0
80len_bar         |Ang|     400.0
81rad_bar         |Ang|     20.0
82rad_bell        |Ang|     40.0
83sld_barbell     |Ang^-2|  1.0e-006
84sld_solv        |Ang^-2|  6.3e-006
85background      |cm^-1|   0
86==============  ========  =============
87
88.. image:: img/image110.jpg
89
90*Figure. 1D plot using the default values (w/256 data point).*
91
92For 2D data: The 2D scattering intensity is calculated similar to the 2D cylinder model. For example, for
93|theta| = 45 deg and |phi| = 0 deg with default values for other parameters
94
95.. image:: img/image111.jpg
96
97*Figure. 2D plot (w/(256X265) data points).*
98
99.. image:: img/orientation.jpg
100
101Figure. Definition of the angles for oriented 2D barbells.
102
103.. image:: img/orientation2.jpg
104
105*Figure. Examples of the angles for oriented pp against the detector plane.*
106
107REFERENCE
108
109H Kaya, *J. Appl. Cryst.*, 37 (2004) 37 223-230
110
111H Kaya and N R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata)
112
113"""
114from numpy import pi, inf
115
116name = "barbell"
117title = "Cylinder with spherical end caps"
118description = """
119        Calculates the scattering from a barbell-shaped cylinder. That is a sphereocylinder with spherical end caps that have a radius larger than that of the cylinder and the center of the end cap
120                radius lies outside of the cylinder.
121                Note: As the length of cylinder(bar) -->0,it becomes a dumbbell. And when rad_bar = rad_bell, it is a spherocylinder.
122                It must be that rad_bar <(=) rad_bell.
123"""
124
125parameters = [
126#   [ "name", "units", default, [lower, upper], "type","description" ],
127    [ "sld", "1e-6/Ang^2", 4, [-inf,inf], "", "Barbell scattering length density" ],
128    [ "solvent_sld", "1e-6/Ang^2", 1, [-inf,inf], "","Solvent scattering length density" ],
129    [ "bell_radius", "Ang",  40, [0, inf], "volume","Spherical bell radius" ],
130    [ "radius", "Ang",  20, [0, inf], "volume","Cylindrical bar radius" ],
131    [ "length", "Ang",  400, [0, inf], "volume","Cylinder bar length" ],
132    [ "theta", "degrees", 60, [-inf, inf], "orientation","In plane angle" ],
133    [ "phi", "degrees", 60, [-inf, inf], "orientation","Out of plane angle" ],
134    ]
135
136source = [ "lib/J1.c", "lib/gauss76.c", "barbell.c" ]
137
138def ER(radius, length):
139    return 1.0
140
141# parameters for demo
142demo = dict(
143    scale=1, background=0,
144    sld=6, solvent_sld=1,
145    bell_radius = 40, radius=20, length=400,
146    theta=60, phi=60,
147    radius_pd=.2, radius_pd_n=5,
148    length_pd=.2,length_pd_n=5,
149    theta_pd=15, theta_pd_n=0,
150    phi_pd=15, phi_pd_n=0,
151    )
152
153# For testing against the old sasview models, include the converted parameter
154# names and the target sasview model name.
155oldname='BarBellModel'
156oldpars=dict(sld='sld_barbell',
157             solvent_sld='sld_solv', bell_radius='rad_bell',
158             radius='rad_bar',length='len_bar')
Note: See TracBrowser for help on using the repository browser.