source: sasmodels/sasmodels/models/hollow_rectangular_prism.py @ deb7ee0

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

Added four parallelepiped-like models

  • Property mode set to 100644
File size: 6.0 KB
Line 
1# rectangular_prism model
2# Note: model title and parameter table are inserted automatically
3r"""
4
5This model provides the form factor, *P(q)*, for a hollow rectangular
6parallelepiped with a wall of thickness |bigdelta|.
7It computes only the 1D scattering, not the 2D.
8
9Definition
10----------
11
12The 1D scattering intensity for this model is calculated by forming
13the difference of the amplitudes of two massive parallelepipeds
14differing in their outermost dimensions in each direction by the
15same length increment :math:`2\Delta` (Nayuk, 2012).
16
17As in the case of the massive parallelepiped model (:ref:`rectangular-prism`),
18the scattering amplitude is computed for a particular orientation of the
19parallelepiped with respect to the scattering vector and then averaged over all
20possible orientations, giving
21
22.. math::
23  P(q) =  \frac{1}{V^2} \frac{2}{\pi} \times \, \int_0^{\frac{\pi}{2}} \,
24  \int_0^{\frac{\pi}{2}} A_{P\Delta}^2(q) \, \sin\theta \, d\theta \, d\phi
25
26where |theta| is the angle between the *z* axis and the longest axis
27of the parallelepiped, |phi| is the angle between the scattering vector
28(lying in the *xy* plane) and the *y* axis, and
29
30.. math::
31  \begin{align}
32  A_{P\Delta}(q) & =  A B C
33    \left[\frac{\sin \bigl( q \frac{C}{2} \cos\theta \bigr)}
34    {\left( q \frac{C}{2} \cos\theta \right)} \right]
35    \left[\frac{\sin \bigl( q \frac{A}{2} \sin\theta \sin\phi \bigr)}
36    {\left( q \frac{A}{2} \sin\theta \sin\phi \right)}\right]
37    \left[\frac{\sin \bigl( q \frac{B}{2} \sin\theta \cos\phi \bigr)}
38    {\left( q \frac{B}{2} \sin\theta \cos\phi \right)}\right] \\
39    & - 8
40    \left(\frac{A}{2}-\Delta\right) \left(\frac{B}{2}-\Delta\right) \left(\frac{C}{2}-\Delta\right)
41    \left[ \frac{\sin \bigl[ q \bigl(\frac{C}{2}-\Delta\bigr) \cos\theta \bigr]}
42    {q \bigl(\frac{C}{2}-\Delta\bigr) \cos\theta} \right]
43    \left[ \frac{\sin \bigl[ q \bigl(\frac{A}{2}-\Delta\bigr) \sin\theta \sin\phi \bigr]}
44    {q \bigl(\frac{A}{2}-\Delta\bigr) \sin\theta \sin\phi} \right]
45    \left[ \frac{\sin \bigl[ q \bigl(\frac{B}{2}-\Delta\bigr) \sin\theta \cos\phi \bigr]}
46    {q \bigl(\frac{B}{2}-\Delta\bigr) \sin\theta \cos\phi} \right]
47  \end{align}
48
49where *A*, *B* and *C* are the external sides of the parallelepiped fulfilling
50:math:`A \le B \le C`, and the volume *V* of the parallelepiped is
51
52.. math::
53  V = A B C \, - \, (A - 2\Delta) (B - 2\Delta) (C - 2\Delta)
54
55The 1D scattering intensity is then calculated as
56
57.. math::
58  I(q) = \mbox{scale} \times V \times (\rho_{\mbox{p}} -
59  \rho_{\mbox{solvent}})^2 \times P(q)
60
61where :math:`\rho_{\mbox{p}}` is the scattering length of the parallelepiped,
62:math:`\rho_{\mbox{solvent}}` is the scattering length of the solvent,
63and (if the data are in absolute units) *scale* represents the volume fraction
64(which is unitless).
65
66**The 2D scattering intensity is not computed by this model.**
67
68
69Validation
70----------
71
72Validation of the code was conducted by qualitatively comparing the output
73of the 1D model to the curves shown in (Nayuk, 2012).
74
75REFERENCES
76
77R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854
78
79"""
80
81from numpy import pi, inf, sqrt
82
83name = "hollow_rectangular_prism"
84title = "Hollow rectangular parallelepiped with uniform scattering length density."
85description = """
86    I(q)= scale*V*(sld - solvent_sld)^2*P(q,theta,phi)+background
87        P(q,theta,phi) = (2/pi/V^2) * double integral from 0 to pi/2 of ...
88           (AP1-AP2)^2(q)*sin(theta)*dtheta*dphi
89        AP1 = S(q*C*cos(theta)/2) * S(q*A*sin(theta)*sin(phi)/2) * S(q*B*sin(theta)*cos(phi)/2)
90        AP2 = S(q*C'*cos(theta)) * S(q*A'*sin(theta)*sin(phi)) * S(q*B'*sin(theta)*cos(phi))
91        C' = (C/2-thickness)
92        B' = (B/2-thickness)
93        A' = (A/2-thickness)
94        S(x) = sin(x)/x
95"""
96category = "shape:parallelepiped"
97
98#             ["name", "units", default, [lower, upper], "type","description"],
99parameters = [["sld", "1e-6/Ang^2", 6.3, [-inf, inf], "",
100               "Parallelepiped scattering length density"],
101              ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "",
102               "Solvent scattering length density"],
103              ["a_side", "Ang", 35, [0, inf], "volume",
104               "Shorter side of the parallelepiped"],
105              ["b2a_ratio", "Ang", 1, [0, inf], "volume",
106               "Ratio sides b/a"],
107              ["c2a_ratio", "Ang", 1, [0, inf], "volume",
108               "Ratio sides c/a"],
109              ["thickness", "Ang", 1, [0, inf], "volume",
110               "Thickness of parallelepiped"],
111             ]
112
113source = ["lib/J1.c", "lib/gauss76.c", "hollow_rectangular_prism.c"]
114
115def ER(a_side, b2a_ratio, c2a_ratio, thickness):
116    """
117        Return equivalent radius (ER)
118        thickness parameter not used
119    """
120    b_side = a_side * b2a_ratio
121    c_side = a_side * c2a_ratio
122
123    # surface average radius (rough approximation)
124    surf_rad = sqrt(a_side * b_side / pi)
125
126    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad))
127    return 0.5 * (ddd) ** (1. / 3.)
128
129def VR(a_side, b2a_ratio, c2a_ratio, thickness):
130    """
131        Return shell volume and total volume
132    """
133    b_side = a_side * b2a_ratio
134    c_side = a_side * c2a_ratio
135    a_core = a_side - 2.0*thickness
136    b_core = b_side - 2.0*thickness
137    c_core = c_side - 2.0*thickness
138    vol_core = a_core * b_core * c_core
139    vol_total = a_side * b_side * c_side
140    vol_shell = vol_total - vol_core
141    return vol_total, vol_shell
142
143
144# parameters for demo
145demo = dict(scale=1, background=0,
146            sld=6.3e-6, solvent_sld=1.0e-6,
147            a_side=35, b2a_ratio=1, c2a_ratio=1, thickness=1,
148            a_side_pd=0.1, a_side_pd_n=10,
149            b2a_ratio_pd=0.1, b2a_ratio_pd_n=1,
150            c2a_ratio_pd=0.1, c2a_ratio_pd_n=1)
151
152# For testing against the old sasview models, include the converted parameter
153# names and the target sasview model name.
154oldname = 'RectangularHollowPrismModel'
155oldpars = dict(a_side='short_side', b2a_ratio='b2a_ratio', c_side='c2a_ratio',
156               thickness='thickness', sld='sldPipe', solvent_sld='sldSolv')
157
158tests = [[{}, 0.2, 0.76587283098],
159         [{}, [0.2], [0.76587283098]],
160        ]
161
Note: See TracBrowser for help on using the repository browser.