1 | # core_shell_parallelepiped model |
---|
2 | # Note: model title and parameter table are inserted automatically |
---|
3 | r""" |
---|
4 | Calculates the form factor for a rectangular solid with a core-shell structure. |
---|
5 | **The thickness and the scattering length density of the shell or "rim" |
---|
6 | can be different on all three (pairs) of faces.** |
---|
7 | |
---|
8 | The form factor is normalized by the particle volume *V* such that |
---|
9 | |
---|
10 | *I(q)* = *scale* \* <*f*\ :sup:`2`> / *V* + *background* |
---|
11 | |
---|
12 | where < > is an average over all possible orientations of the rectangular solid. |
---|
13 | |
---|
14 | An instrument resolution smeared version of the model is also provided. |
---|
15 | |
---|
16 | |
---|
17 | Definition |
---|
18 | ---------- |
---|
19 | |
---|
20 | The function calculated is the form factor of the rectangular solid below. |
---|
21 | The core of the solid is defined by the dimensions *A*, *B*, *C* such that |
---|
22 | *A* < *B* < *C*. |
---|
23 | |
---|
24 | .. image:: img/core_shell_parallelepiped_geometry.jpg |
---|
25 | |
---|
26 | There are rectangular "slabs" of thickness $t_A$ that add to the *A* dimension |
---|
27 | (on the *BC* faces). There are similar slabs on the *AC* $(=t_B)$ and *AB* |
---|
28 | $(=t_C)$ faces. The projection in the *AB* plane is then |
---|
29 | |
---|
30 | .. image:: img/core_shell_parallelepiped_projection.jpg |
---|
31 | |
---|
32 | The volume of the solid is |
---|
33 | |
---|
34 | .. math:: |
---|
35 | |
---|
36 | V = ABC + 2t_ABC + 2t_BAC + 2t_CAB |
---|
37 | |
---|
38 | **meaning that there are "gaps" at the corners of the solid.** |
---|
39 | |
---|
40 | The intensity calculated follows the :ref:`parallelepiped` model, with the core-shell |
---|
41 | intensity being calculated as the square of the sum of the amplitudes of the |
---|
42 | core and shell, in the same manner as a core-shell model. |
---|
43 | |
---|
44 | **For the calculation of the form factor to be valid, the sides of the solid |
---|
45 | MUST be chosen such that** *A* < *B* < *C*. |
---|
46 | **If this inequality is not satisfied, the model will not report an error, |
---|
47 | and the calculation will not be correct.** |
---|
48 | |
---|
49 | FITTING NOTES |
---|
50 | If the scale is set equal to the particle volume fraction, |phi|, the returned |
---|
51 | value is the scattered intensity per unit volume; ie, *I(q)* = |phi| *P(q)*. |
---|
52 | However, **no interparticle interference effects are included in this calculation.** |
---|
53 | |
---|
54 | There are many parameters in this model. Hold as many fixed as possible with |
---|
55 | known values, or you will certainly end up at a solution that is unphysical. |
---|
56 | |
---|
57 | Constraints must be applied during fitting to ensure that the inequality |
---|
58 | *A* < *B* < *C* is not violated. The calculation will not report an error, |
---|
59 | but the results will not be correct. |
---|
60 | |
---|
61 | The returned value is in units of |cm^-1|, on absolute scale. |
---|
62 | |
---|
63 | NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated |
---|
64 | based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ |
---|
65 | and length $(C+2t_C)$ values, and used as the effective radius |
---|
66 | for *S(Q)* when *P(Q)* \* *S(Q)* is applied. |
---|
67 | |
---|
68 | .. Comment by Miguel Gonzalez: |
---|
69 | The later seems to contradict the previous statement that interparticle interference |
---|
70 | effects are not included. |
---|
71 | |
---|
72 | To provide easy access to the orientation of the parallelepiped, we define the |
---|
73 | axis of the cylinder using three angles |theta|, |phi| and |bigpsi|. |
---|
74 | (see :ref:`cylinder orientation <cylinder-angle-definition>`). |
---|
75 | The angle |bigpsi| is the rotational angle around the *long_c* axis against the |
---|
76 | *q* plane. For example, |bigpsi| = 0 when the *short_b* axis is parallel to the |
---|
77 | *x*-axis of the detector. |
---|
78 | |
---|
79 | .. figure:: img/parallelepiped_angle_definition.jpg |
---|
80 | |
---|
81 | Definition of the angles for oriented core-shell parallelepipeds. |
---|
82 | |
---|
83 | .. figure:: img/parallelepiped_angle_projection.jpg |
---|
84 | |
---|
85 | Examples of the angles for oriented core-shell parallelepipeds against the |
---|
86 | detector plane. |
---|
87 | |
---|
88 | Validation |
---|
89 | ---------- |
---|
90 | |
---|
91 | The model uses the form factor calculations implemented in a c-library provided |
---|
92 | by the NIST Center for Neutron Research (Kline, 2006). |
---|
93 | |
---|
94 | References |
---|
95 | ---------- |
---|
96 | |
---|
97 | P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 |
---|
98 | Equations (1), (13-14). (in German) |
---|
99 | |
---|
100 | """ |
---|
101 | |
---|
102 | import numpy as np |
---|
103 | from numpy import pi, inf, sqrt |
---|
104 | |
---|
105 | name = "core_shell_parallelepiped" |
---|
106 | title = "Rectangular solid with a core-shell structure." |
---|
107 | description = """ |
---|
108 | P(q)= |
---|
109 | """ |
---|
110 | category = "shape:parallelepiped" |
---|
111 | |
---|
112 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
113 | parameters = [["sld_core", "1e-6/Ang^2", 1, [-inf, inf], "", |
---|
114 | "Parallelepiped core scattering length density"], |
---|
115 | ["sld_a", "1e-6/Ang^2", 2, [-inf, inf], "", |
---|
116 | "Parallelepiped A rim scattering length density"], |
---|
117 | ["sld_b", "1e-6/Ang^2", 4, [-inf, inf], "", |
---|
118 | "Parallelepiped B rim scattering length density"], |
---|
119 | ["sld_c", "1e-6/Ang^2", 2, [-inf, inf], "", |
---|
120 | "Parallelepiped C rim scattering length density"], |
---|
121 | ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "", |
---|
122 | "Solvent scattering length density"], |
---|
123 | ["a_side", "Ang", 35, [0, inf], "volume", |
---|
124 | "Shorter side of the parallelepiped"], |
---|
125 | ["b_side", "Ang", 75, [0, inf], "volume", |
---|
126 | "Second side of the parallelepiped"], |
---|
127 | ["c_side", "Ang", 400, [0, inf], "volume", |
---|
128 | "Larger side of the parallelepiped"], |
---|
129 | ["arim_thickness", "Ang", 10, [0, inf], "volume", |
---|
130 | "Thickness of A rim"], |
---|
131 | ["brim_thickness", "Ang", 10, [0, inf], "volume", |
---|
132 | "Thickness of B rim"], |
---|
133 | ["crim_thickness", "Ang", 10, [0, inf], "volume", |
---|
134 | "Thickness of C rim"], |
---|
135 | ["theta", "degrees", 0, [-inf, inf], "orientation", |
---|
136 | "In plane angle"], |
---|
137 | ["phi", "degrees", 0, [-inf, inf], "orientation", |
---|
138 | "Out of plane angle"], |
---|
139 | ["psi", "degrees", 0, [-inf, inf], "orientation", |
---|
140 | "Rotation angle around its own c axis against q plane"], |
---|
141 | ] |
---|
142 | |
---|
143 | source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] |
---|
144 | |
---|
145 | |
---|
146 | def ER(a_side, b_side, c_side, arim_thickness, brim_thickness, crim_thickness): |
---|
147 | """ |
---|
148 | Return equivalent radius (ER) |
---|
149 | """ |
---|
150 | |
---|
151 | # surface average radius (rough approximation) |
---|
152 | surf_rad = sqrt((a_side + 2.0*arim_thickness) * (b_side + 2.0*brim_thickness) / pi) |
---|
153 | |
---|
154 | height = c_side + 2.0*crim_thickness |
---|
155 | |
---|
156 | ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad)) |
---|
157 | return 0.5 * (ddd) ** (1. / 3.) |
---|
158 | |
---|
159 | # VR defaults to 1.0 |
---|
160 | |
---|
161 | # parameters for demo |
---|
162 | demo = dict(scale=1, background=0.0, |
---|
163 | sld_core=1e-6, sld_a=2e-6, sld_b=4e-6, |
---|
164 | sld_c=2e-6, sld_solvent=6e-6, |
---|
165 | a_side=35, b_side=75, c_side=400, |
---|
166 | arim_thickness=10, brim_thickness=10, crim_thickness=10, |
---|
167 | theta=0, phi=0, psi=0, |
---|
168 | a_side_pd=0.1, a_side_pd_n=1, |
---|
169 | b_side_pd=0.1, b_side_pd_n=1, |
---|
170 | c_side_pd=0.1, c_side_pd_n=1, |
---|
171 | arim_thickness_pd=0.1, arim_thickness_pd_n=1, |
---|
172 | brim_thickness_pd=0.1, brim_thickness_pd_n=1, |
---|
173 | crim_thickness_pd=0.1, crim_thickness_pd_n=1, |
---|
174 | theta_pd=10, theta_pd_n=1, |
---|
175 | phi_pd=10, phi_pd_n=1, |
---|
176 | psi_pd=10, psi_pd_n=10) |
---|
177 | |
---|
178 | qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) |
---|
179 | tests = [[{}, 0.2, 0.533149288477], |
---|
180 | [{}, [0.2], [0.533149288477]], |
---|
181 | [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569], |
---|
182 | [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]], |
---|
183 | ] |
---|
184 | del qx, qy # not necessary to delete, but cleaner |
---|