1 | # rectangular_prism model |
---|
2 | # Note: model title and parameter table are inserted automatically |
---|
3 | r""" |
---|
4 | Definition |
---|
5 | ---------- |
---|
6 | |
---|
7 | |
---|
8 | This model provides the form factor, $P(q)$, for a hollow rectangular |
---|
9 | prism with infinitely thin walls. It computes only the 1D scattering, not the 2D. |
---|
10 | The 1D scattering intensity for this model is calculated according to the |
---|
11 | equations given by Nayuk and Huber\ [#Nayuk2012]_. |
---|
12 | |
---|
13 | Assuming a hollow parallelepiped with infinitely thin walls, edge lengths |
---|
14 | $A \le B \le C$ and presenting an orientation with respect to the |
---|
15 | scattering vector given by $\theta$ and $\phi$, where $\theta$ is the angle |
---|
16 | between the $z$ axis and the longest axis of the parallelepiped $C$, and |
---|
17 | $\phi$ is the angle between the scattering vector (lying in the $xy$ plane) |
---|
18 | and the $y$ axis, the form factor is given by |
---|
19 | |
---|
20 | .. math:: |
---|
21 | |
---|
22 | P(q) = \frac{1}{V^2} \frac{2}{\pi} \int_0^{\frac{\pi}{2}} |
---|
23 | \int_0^{\frac{\pi}{2}} [A_L(q)+A_T(q)]^2 \sin\theta\,d\theta\,d\phi |
---|
24 | |
---|
25 | where |
---|
26 | |
---|
27 | .. math:: |
---|
28 | |
---|
29 | V &= 2AB + 2AC + 2BC \\ |
---|
30 | A_L(q) &= 8 \times \frac{ |
---|
31 | \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right) |
---|
32 | \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) |
---|
33 | \cos \left( \tfrac{1}{2} q C \cos\theta \right) |
---|
34 | }{q^2 \, \sin^2\theta \, \sin\phi \cos\phi} \\ |
---|
35 | A_T(q) &= A_F(q) \times |
---|
36 | \frac{2\,\sin \left( \tfrac{1}{2} q C \cos\theta \right)}{q\,\cos\theta} |
---|
37 | |
---|
38 | and |
---|
39 | |
---|
40 | .. math:: |
---|
41 | |
---|
42 | A_F(q) = 4 \frac{ \cos \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right) |
---|
43 | \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) } |
---|
44 | {q \, \cos\phi \, \sin\theta} + |
---|
45 | 4 \frac{ \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right) |
---|
46 | \cos \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) } |
---|
47 | {q \, \sin\phi \, \sin\theta} |
---|
48 | |
---|
49 | The 1D scattering intensity is then calculated as |
---|
50 | |
---|
51 | .. math:: |
---|
52 | |
---|
53 | I(q) = \text{scale} \times V \times (\rho_\text{p} - \rho_\text{solvent})^2 \times P(q) |
---|
54 | |
---|
55 | where $V$ is the surface area of the rectangular prism, $\rho_\text{p}$ |
---|
56 | is the scattering length density of the parallelepiped, $\rho_\text{solvent}$ |
---|
57 | is the scattering length density of the solvent, and (if the data are in |
---|
58 | absolute units) *scale* is related to the total surface area. |
---|
59 | |
---|
60 | **The 2D scattering intensity is not computed by this model.** |
---|
61 | |
---|
62 | |
---|
63 | Validation |
---|
64 | ---------- |
---|
65 | |
---|
66 | Validation of the code was conducted by qualitatively comparing the output |
---|
67 | of the 1D model to the curves shown in (Nayuk, 2012\ [#Nayuk2012]_). |
---|
68 | |
---|
69 | |
---|
70 | References |
---|
71 | ---------- |
---|
72 | |
---|
73 | .. [#Nayuk2012] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 |
---|
74 | L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949). |
---|
75 | |
---|
76 | |
---|
77 | Authorship and Verification |
---|
78 | ---------------------------- |
---|
79 | |
---|
80 | * **Author:** Miguel Gonzales **Date:** February 26, 2016 |
---|
81 | * **Last Modified by:** Paul Kienzle **Date:** October 15, 2016 |
---|
82 | * **Last Reviewed by:** Paul Butler **Date:** September 07, 2018 |
---|
83 | """ |
---|
84 | |
---|
85 | import numpy as np |
---|
86 | from numpy import pi, inf, sqrt |
---|
87 | |
---|
88 | name = "hollow_rectangular_prism_thin_walls" |
---|
89 | title = "Hollow rectangular parallelepiped with thin walls." |
---|
90 | description = """ |
---|
91 | I(q)= scale*V*(sld - sld_solvent)^2*P(q)+background |
---|
92 | with P(q) being the form factor corresponding to a hollow rectangular |
---|
93 | parallelepiped with infinitely thin walls. |
---|
94 | """ |
---|
95 | category = "shape:parallelepiped" |
---|
96 | |
---|
97 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
98 | parameters = [["sld", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", |
---|
99 | "Parallelepiped scattering length density"], |
---|
100 | ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", |
---|
101 | "Solvent scattering length density"], |
---|
102 | ["length_a", "Ang", 35, [0, inf], "volume", |
---|
103 | "Shorter side of the parallelepiped"], |
---|
104 | ["b2a_ratio", "Ang", 1, [0, inf], "volume", |
---|
105 | "Ratio sides b/a"], |
---|
106 | ["c2a_ratio", "Ang", 1, [0, inf], "volume", |
---|
107 | "Ratio sides c/a"], |
---|
108 | ] |
---|
109 | |
---|
110 | source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] |
---|
111 | have_Fq = True |
---|
112 | effective_radius_type = [ |
---|
113 | "equivalent cylinder excluded volume", "equivalent outer volume sphere", |
---|
114 | "half length_a", "half length_b", "half length_c", |
---|
115 | "equivalent outer circular cross-section", |
---|
116 | "half ab diagonal", "half diagonal", |
---|
117 | ] |
---|
118 | |
---|
119 | |
---|
120 | def random(): |
---|
121 | a, b, c = 10**np.random.uniform(1, 4.7, size=3) |
---|
122 | pars = dict( |
---|
123 | length_a=a, |
---|
124 | b2a_ratio=b/a, |
---|
125 | c2a_ratio=c/a, |
---|
126 | ) |
---|
127 | return pars |
---|
128 | |
---|
129 | |
---|
130 | # parameters for demo |
---|
131 | demo = dict(scale=1, background=0, |
---|
132 | sld=6.3, sld_solvent=1.0, |
---|
133 | length_a=35, b2a_ratio=1, c2a_ratio=1, |
---|
134 | length_a_pd=0.1, length_a_pd_n=10, |
---|
135 | b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, |
---|
136 | c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) |
---|
137 | |
---|
138 | tests = [[{}, 0.2, 0.837719188592], |
---|
139 | [{}, [0.2], [0.837719188592]], |
---|
140 | ] |
---|