1 | r""" |
---|
2 | Definition |
---|
3 | ---------- |
---|
4 | |
---|
5 | The output of the 2D scattering intensity function for oriented core-shell |
---|
6 | cylinders is given by (Kline, 2006 [#kline]_). The form factor is normalized |
---|
7 | by the particle volume. |
---|
8 | |
---|
9 | .. math:: |
---|
10 | |
---|
11 | I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background} |
---|
12 | |
---|
13 | where |
---|
14 | |
---|
15 | .. math:: |
---|
16 | |
---|
17 | F(q,\alpha) = &\ (\rho_c - \rho_s) V_c |
---|
18 | \frac{\sin \left( q \tfrac12 L\cos\alpha \right)} |
---|
19 | {q \tfrac12 L\cos\alpha} |
---|
20 | \frac{2 J_1 \left( qR\sin\alpha \right)} |
---|
21 | {qR\sin\alpha} \\ |
---|
22 | &\ + (\rho_s - \rho_\text{solv}) V_s |
---|
23 | \frac{\sin \left( q \left(\tfrac12 L+T\right) \cos\alpha \right)} |
---|
24 | {q \left(\tfrac12 L +T \right) \cos\alpha} |
---|
25 | \frac{ 2 J_1 \left( q(R+T)\sin\alpha \right)} |
---|
26 | {q(R+T)\sin\alpha} |
---|
27 | |
---|
28 | and |
---|
29 | |
---|
30 | .. math:: |
---|
31 | |
---|
32 | V_s = \pi (R + T)^2 (L + 2T) |
---|
33 | |
---|
34 | and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, |
---|
35 | $V_s$ is the volume of the outer shell (i.e. the total volume, including |
---|
36 | the shell), $V_c$ is the volume of the core, $L$ is the length of the core, |
---|
37 | $R$ is the radius of the core, $T$ is the thickness of the shell, $\rho_c$ |
---|
38 | is the scattering length density of the core, $\rho_s$ is the scattering |
---|
39 | length density of the shell, $\rho_\text{solv}$ is the scattering length |
---|
40 | density of the solvent, and *background* is the background level. The outer |
---|
41 | radius of the shell is given by $R+T$ and the total length of the outer |
---|
42 | shell is given by $L+2T$. $J1$ is the first order Bessel function. |
---|
43 | |
---|
44 | .. _core-shell-cylinder-geometry: |
---|
45 | |
---|
46 | .. figure:: img/core_shell_cylinder_geometry.jpg |
---|
47 | |
---|
48 | Core shell cylinder schematic. |
---|
49 | |
---|
50 | To provide easy access to the orientation of the core-shell cylinder, we |
---|
51 | define the axis of the cylinder using two angles $\theta$ and $\phi$. |
---|
52 | (see :ref:`cylinder model <cylinder-angle-definition>`) |
---|
53 | |
---|
54 | NB: The 2nd virial coefficient of the cylinder is calculated based on |
---|
55 | the radius and 2 length values, and used as the effective radius for |
---|
56 | $S(q)$ when $P(q) \cdot S(q)$ is applied. |
---|
57 | |
---|
58 | The $\theta$ and $\phi$ parameters are not used for the 1D output. |
---|
59 | |
---|
60 | Reference |
---|
61 | --------- |
---|
62 | |
---|
63 | .. [#] see, for example, Ian Livsey J. Chem. Soc., Faraday Trans. 2, 1987,83, |
---|
64 | 1445-1452 |
---|
65 | .. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 |
---|
66 | |
---|
67 | Authorship and Verification |
---|
68 | ---------------------------- |
---|
69 | |
---|
70 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
71 | * **Last Modified by:** Paul Kienzle **Date:** Aug 8, 2016 |
---|
72 | * **Last Reviewed by:** Richard Heenan **Date:** March 18, 2016 |
---|
73 | """ |
---|
74 | |
---|
75 | import numpy as np |
---|
76 | from numpy import pi, inf, sin, cos |
---|
77 | |
---|
78 | name = "core_shell_cylinder" |
---|
79 | title = "Right circular cylinder with a core-shell scattering length density profile." |
---|
80 | description = """ |
---|
81 | P(q,alpha)= scale/Vs*f(q)^(2) + background, |
---|
82 | where: f(q)= 2(sld_core - solvant_sld) |
---|
83 | * Vc*sin[qLcos(alpha/2)] |
---|
84 | /[qLcos(alpha/2)]*J1(qRsin(alpha)) |
---|
85 | /[qRsin(alpha)]+2(sld_shell-sld_solvent) |
---|
86 | *Vs*sin[q(L+T)cos(alpha/2)][[q(L+T) |
---|
87 | *cos(alpha/2)]*J1(q(R+T)sin(alpha)) |
---|
88 | /q(R+T)sin(alpha)] |
---|
89 | |
---|
90 | alpha:is the angle between the axis of |
---|
91 | the cylinder and the q-vector |
---|
92 | Vs: the volume of the outer shell |
---|
93 | Vc: the volume of the core |
---|
94 | L: the length of the core |
---|
95 | sld_shell: the scattering length density of the shell |
---|
96 | sld_solvent: the scattering length density of the solvent |
---|
97 | background: the background |
---|
98 | T: the thickness |
---|
99 | R+T: is the outer radius |
---|
100 | L+2T: The total length of the outershell |
---|
101 | J1: the first order Bessel function |
---|
102 | theta: axis_theta of the cylinder |
---|
103 | phi: the axis_phi of the cylinder |
---|
104 | """ |
---|
105 | category = "shape:cylinder" |
---|
106 | |
---|
107 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
108 | parameters = [["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld", |
---|
109 | "Cylinder core scattering length density"], |
---|
110 | ["sld_shell", "1e-6/Ang^2", 4, [-inf, inf], "sld", |
---|
111 | "Cylinder shell scattering length density"], |
---|
112 | ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", |
---|
113 | "Solvent scattering length density"], |
---|
114 | ["radius", "Ang", 20, [0, inf], "volume", |
---|
115 | "Cylinder core radius"], |
---|
116 | ["thickness", "Ang", 20, [0, inf], "volume", |
---|
117 | "Cylinder shell thickness"], |
---|
118 | ["length", "Ang", 400, [0, inf], "volume", |
---|
119 | "Cylinder length"], |
---|
120 | ["theta", "degrees", 60, [-360, 360], "orientation", |
---|
121 | "cylinder axis to beam angle"], |
---|
122 | ["phi", "degrees", 60, [-360, 360], "orientation", |
---|
123 | "rotation about beam"], |
---|
124 | ] |
---|
125 | |
---|
126 | source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] |
---|
127 | |
---|
128 | def ER(radius, thickness, length): |
---|
129 | """ |
---|
130 | Returns the effective radius used in the S*P calculation |
---|
131 | """ |
---|
132 | radius = radius + thickness |
---|
133 | length = length + 2 * thickness |
---|
134 | ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) |
---|
135 | return 0.5 * (ddd) ** (1. / 3.) |
---|
136 | |
---|
137 | def VR(radius, thickness, length): |
---|
138 | """ |
---|
139 | Returns volume ratio |
---|
140 | """ |
---|
141 | whole = pi * (radius + thickness) ** 2 * (length + 2 * thickness) |
---|
142 | core = pi * radius ** 2 * length |
---|
143 | return whole, whole - core |
---|
144 | |
---|
145 | def random(): |
---|
146 | outer_radius = 10**np.random.uniform(1, 4.7) |
---|
147 | # Use a distribution with a preference for thin shell or thin core |
---|
148 | # Avoid core,shell radii < 1 |
---|
149 | radius = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 |
---|
150 | thickness = outer_radius - radius |
---|
151 | length = np.random.uniform(1, 4.7) |
---|
152 | pars = dict( |
---|
153 | radius=radius, |
---|
154 | thickness=thickness, |
---|
155 | length=length, |
---|
156 | ) |
---|
157 | return pars |
---|
158 | |
---|
159 | demo = dict(scale=1, background=0, |
---|
160 | sld_core=6, sld_shell=8, sld_solvent=1, |
---|
161 | radius=45, thickness=25, length=340, |
---|
162 | theta=30, phi=15, |
---|
163 | radius_pd=.2, radius_pd_n=1, |
---|
164 | length_pd=.2, length_pd_n=10, |
---|
165 | thickness_pd=.2, thickness_pd_n=10, |
---|
166 | theta_pd=15, theta_pd_n=45, |
---|
167 | phi_pd=15, phi_pd_n=1) |
---|
168 | q = 0.1 |
---|
169 | # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! |
---|
170 | qx = q*cos(pi/6.0) |
---|
171 | qy = q*sin(pi/6.0) |
---|
172 | tests = [ |
---|
173 | [{}, 0.075, 10.8552692237], |
---|
174 | [{}, (qx, qy), 0.444618752741], |
---|
175 | ] |
---|
176 | del qx, qy # not necessary to delete, but cleaner |
---|