1 | r""" |
---|
2 | This model provides the form factor, $P(q)$, for a core shell ellipsoid (below) |
---|
3 | where the form factor is normalized by the volume of the outer [CHECK]. |
---|
4 | |
---|
5 | .. math:: |
---|
6 | |
---|
7 | P(q) = scale * \left<f^2\right>/V + background |
---|
8 | |
---|
9 | where the volume $V = (4/3)\pi(R_{major\_outer}R_{minor\_outer}^2)$ and the averaging $< >$ is |
---|
10 | applied over all orientations for 1D. |
---|
11 | |
---|
12 | .. figure:: img/core_shell_ellipsoid_geometry.png |
---|
13 | |
---|
14 | The returned value is in units of $cm^{-1}$, on absolute scale. |
---|
15 | |
---|
16 | Definition |
---|
17 | ---------- |
---|
18 | |
---|
19 | The form factor calculated is |
---|
20 | |
---|
21 | .. math:: |
---|
22 | |
---|
23 | P(q) = \frac{scale}{V}\int_0^1 |
---|
24 | \left|F(q,r_{minor\_core},r_{major\_core},\alpha) + F(q,r_{major\_outer},r_{major\_outer},\alpha)\right|^2d\alpha + background |
---|
25 | |
---|
26 | \left|F(q,r_{minor},r_{major},\alpha)\right|=(4\pi/3)r_{major}r_{minor}^2 \Delta \rho \cdot (3j_1(u)/u) |
---|
27 | |
---|
28 | u = q\left[ r_{major}^2\alpha ^2 + r_{minor}^2(1-\alpha ^2)\right]^{1/2} |
---|
29 | |
---|
30 | where |
---|
31 | |
---|
32 | .. math:: |
---|
33 | |
---|
34 | j_1(u)=(\sin x - x \cos x)/x^2 |
---|
35 | |
---|
36 | To provide easy access to the orientation of the core-shell ellipsoid, |
---|
37 | we define the axis of the solid ellipsoid using two angles $\theta$ and $\phi$. |
---|
38 | These angles are defined as for |
---|
39 | :ref:`cylinder orientation <cylinder-angle-definition>`. |
---|
40 | The contrast is defined as SLD(core) - SLD(shell) and SLD(shell) - SLD(solvent). |
---|
41 | |
---|
42 | In the parameters, *equat_core* = equatorial core radius, *polar_core* = |
---|
43 | polar core radius, *equat_shell* = $r_{min}$ (or equatorial outer radius), |
---|
44 | and *polar_shell* = $r_{maj}$ (or polar outer radius). |
---|
45 | |
---|
46 | Note:It is the users' responsibility to ensure that shell radii are larger than |
---|
47 | the core radii, especially if both are polydisperse, in which case the |
---|
48 | core_shell_ellipsoid_xt model may be much better. |
---|
49 | |
---|
50 | |
---|
51 | .. note:: |
---|
52 | The 2nd virial coefficient of the solid ellipsoid is calculated based on |
---|
53 | the *radius_a* (= *polar_shell)* and *radius_b (= equat_shell)* values, |
---|
54 | and used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied. |
---|
55 | |
---|
56 | .. figure:: img/core_shell_ellipsoid_angle_projection.jpg |
---|
57 | |
---|
58 | The angles for oriented core_shell_ellipsoid. |
---|
59 | |
---|
60 | Our model uses the form factor calculations implemented in a c-library provided |
---|
61 | by the NIST Center for Neutron Research (Kline, 2006). |
---|
62 | |
---|
63 | References |
---|
64 | ---------- |
---|
65 | |
---|
66 | M Kotlarchyk, S H Chen, *J. Chem. Phys.*, 79 (1983) 2461 |
---|
67 | |
---|
68 | S J Berr, *Phys. Chem.*, 91 (1987) 4760 |
---|
69 | |
---|
70 | """ |
---|
71 | |
---|
72 | from numpy import inf, sin, cos, pi |
---|
73 | |
---|
74 | name = "core_shell_ellipsoid" |
---|
75 | title = "Form factor for an spheroid ellipsoid particle with a core shell structure." |
---|
76 | description = """ |
---|
77 | [SpheroidCoreShellModel] Calculates the form factor for an spheroid |
---|
78 | ellipsoid particle with a core_shell structure. |
---|
79 | The form factor is averaged over all possible |
---|
80 | orientations of the ellipsoid such that P(q) |
---|
81 | = scale*<f^2>/Vol + bkg, where f is the |
---|
82 | single particle scattering amplitude. |
---|
83 | [Parameters]: |
---|
84 | equat_core = equatorial radius of core, Rminor_core, |
---|
85 | polar_core = polar radius of core, Rmajor_core, |
---|
86 | equat_shell = equatorial radius of shell, Rminor_outer, |
---|
87 | polar_shell = polar radius of shell, Rmajor_outer, |
---|
88 | sld_core = scattering length density of core, |
---|
89 | sld_shell = scattering length density of shell, |
---|
90 | sld_solvent = scattering length density of solvent, |
---|
91 | background = Incoherent bkg |
---|
92 | scale =scale |
---|
93 | Note:It is the users' responsibility to ensure |
---|
94 | that shell radii are larger than core radii, |
---|
95 | especially if both are polydisperse. |
---|
96 | oblate: polar radius < equatorial radius |
---|
97 | prolate : polar radius > equatorial radius |
---|
98 | """ |
---|
99 | category = "shape:ellipsoid" |
---|
100 | |
---|
101 | single = False # TODO: maybe using sph_j1c inside gfn would help? |
---|
102 | # pylint: disable=bad-whitespace, line-too-long |
---|
103 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
104 | parameters = [ |
---|
105 | ["equat_core", "Ang", 200, [0, inf], "volume", "Equatorial radius of core, Rminor_core "], |
---|
106 | ["polar_core", "Ang", 10, [0, inf], "volume", "Polar radius of core, Rmajor_core"], |
---|
107 | ["equat_shell", "Ang", 250, [0, inf], "volume", "Equatorial radius of shell, Rminor_outer "], |
---|
108 | ["polar_shell", "Ang", 30, [0, inf], "volume", "Polar radius of shell, Rmajor_outer"], |
---|
109 | ["sld_core", "1e-6/Ang^2", 2, [-inf, inf], "sld", "Core scattering length density"], |
---|
110 | ["sld_shell", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Shell scattering length density"], |
---|
111 | ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent scattering length density"], |
---|
112 | ["theta", "degrees", 0, [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"], |
---|
113 | ["phi", "degrees", 0, [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"], |
---|
114 | ] |
---|
115 | # pylint: enable=bad-whitespace, line-too-long |
---|
116 | |
---|
117 | source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] |
---|
118 | |
---|
119 | def ER(equat_shell, polar_shell): |
---|
120 | """ |
---|
121 | Returns the effective radius used in the S*P calculation |
---|
122 | """ |
---|
123 | import numpy as np |
---|
124 | from .ellipsoid import ER as ellipsoid_ER |
---|
125 | return ellipsoid_ER(rpolar, equat_shell) |
---|
126 | |
---|
127 | |
---|
128 | demo = dict(scale=1, background=0.001, |
---|
129 | equat_core=200.0, |
---|
130 | polar_core=10.0, |
---|
131 | equat_shell=250.0, |
---|
132 | polar_shell=30.0, |
---|
133 | sld_core=2.0, |
---|
134 | sld_shell=1.0, |
---|
135 | sld_solvent=6.3, |
---|
136 | theta=0, |
---|
137 | phi=0) |
---|
138 | |
---|
139 | oldname = 'CoreShellEllipsoidModel' |
---|
140 | |
---|
141 | oldpars = dict(equat_core='equat_core',polar_core='polar_core',equat_shell='equat_shell',polar_shell='polar_shell', |
---|
142 | sld_core='sld_core', |
---|
143 | sld_shell='sld_shell', |
---|
144 | sld_solvent='sld_solvent', |
---|
145 | theta='axis_theta', |
---|
146 | phi='axis_phi') |
---|
147 | |
---|
148 | q = 0.1 |
---|
149 | phi = pi/6 |
---|
150 | qx = q*cos(phi) |
---|
151 | qy = q*sin(phi) |
---|
152 | |
---|
153 | tests = [ |
---|
154 | # Accuracy tests based on content in test/utest_other_models.py |
---|
155 | [{'equat_core': 200.0, |
---|
156 | 'polar_core': 20.0, |
---|
157 | 'equat_shell': 250.0, |
---|
158 | 'polar_shell': 30.0, |
---|
159 | 'sld_core': 2.0, |
---|
160 | 'sld_shell': 1.0, |
---|
161 | 'sld_solvent': 6.3, |
---|
162 | 'background': 0.001, |
---|
163 | 'scale': 1.0, |
---|
164 | }, 1.0, 0.00189402], |
---|
165 | |
---|
166 | # Additional tests with larger range of parameters |
---|
167 | [{'background': 0.01}, 0.1, 8.86741], |
---|
168 | |
---|
169 | [{'equat_core': 20.0, |
---|
170 | 'polar_core': 200.0, |
---|
171 | 'equat_shell': 54.0, |
---|
172 | 'polar_shell': 3.0, |
---|
173 | 'sld_core': 20.0, |
---|
174 | 'sld_shell': 10.0, |
---|
175 | 'sld_solvent': 6.0, |
---|
176 | 'background': 0.0, |
---|
177 | 'scale': 1.0, |
---|
178 | }, 0.01, 26150.4], |
---|
179 | |
---|
180 | [{'background': 0.001}, (0.4, 0.5), 0.00170471], |
---|
181 | |
---|
182 | [{'equat_core': 20.0, |
---|
183 | 'polar_core': 200.0, |
---|
184 | 'equat_shell': 54.0, |
---|
185 | 'polar_shell': 3.0, |
---|
186 | 'sld_core': 20.0, |
---|
187 | 'sld_shell': 10.0, |
---|
188 | 'sld_solvent': 6.0, |
---|
189 | 'background': 0.01, |
---|
190 | 'scale': 0.01, |
---|
191 | }, (qx, qy), 0.105764], |
---|
192 | ] |
---|