[44bd2be] | 1 | r""" |
---|
[5810f00] | 2 | Definition |
---|
| 3 | ---------- |
---|
| 4 | |
---|
[44bd2be] | 5 | Calculates the form factor for a rectangular solid with a core-shell structure. |
---|
[8f04da4] | 6 | The thickness and the scattering length density of the shell or |
---|
[393facf] | 7 | "rim" can be different on each (pair) of faces. |
---|
[cb0dc22] | 8 | |
---|
[44bd2be] | 9 | |
---|
[500128b] | 10 | The form factor is normalized by the particle volume $V$ such that |
---|
[44bd2be] | 11 | |
---|
[500128b] | 12 | .. math:: |
---|
| 13 | |
---|
| 14 | I(q) = \text{scale}\frac{\langle f^2 \rangle}{V} + \text{background} |
---|
[44bd2be] | 15 | |
---|
[500128b] | 16 | where $\langle \ldots \rangle$ is an average over all possible orientations |
---|
| 17 | of the rectangular solid. |
---|
[44bd2be] | 18 | |
---|
| 19 | |
---|
| 20 | The function calculated is the form factor of the rectangular solid below. |
---|
[500128b] | 21 | The core of the solid is defined by the dimensions $A$, $B$, $C$ such that |
---|
| 22 | $A < B < C$. |
---|
[44bd2be] | 23 | |
---|
[2f0c07d] | 24 | .. image:: img/core_shell_parallelepiped_geometry.jpg |
---|
[44bd2be] | 25 | |
---|
[500128b] | 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 |
---|
[44bd2be] | 29 | |
---|
[1916c52] | 30 | .. image:: img/core_shell_parallelepiped_projection.jpg |
---|
[44bd2be] | 31 | |
---|
| 32 | The volume of the solid is |
---|
| 33 | |
---|
| 34 | .. math:: |
---|
| 35 | |
---|
| 36 | V = ABC + 2t_ABC + 2t_BAC + 2t_CAB |
---|
| 37 | |
---|
[393facf] | 38 | **meaning that there are "gaps" at the corners of the solid.** |
---|
[44bd2be] | 39 | |
---|
[5810f00] | 40 | The intensity calculated follows the :ref:`parallelepiped` model, with the |
---|
| 41 | core-shell intensity being calculated as the square of the sum of the |
---|
[393facf] | 42 | amplitudes of the core and the slabs on the edges. |
---|
| 43 | |
---|
| 44 | the scattering amplitude is computed for a particular orientation of the core-shell |
---|
| 45 | parallelepiped with respect to the scattering vector and then averaged over all |
---|
| 46 | possible orientations, where $\alpha$ is the angle between the $z$ axis and the longest axis $C$ |
---|
| 47 | of the parallelepiped, $\beta$ is the angle between projection of the particle in the $xy$ detector plane and the $y$ axis. |
---|
[44bd2be] | 48 | |
---|
[5810f00] | 49 | .. math:: |
---|
[393facf] | 50 | \begin{align*} |
---|
| 51 | F(Q)&=A B C (\rho_\text{core}-\rho_\text{solvent}) S(A \sin\alpha \sin\beta)S(B \sin\alpha \cos\beta)S(C \cos\alpha) \\ |
---|
| 52 | &+ 2t_A B C (\rho_\text{A}-\rho_\text{solvent}) \left[S((A+t_A) \sin\alpha \sin\beta)-S(A \sin\alpha \sin\beta)\right] S(B \sin\alpha \cos\beta) S(C \cos\alpha)\\ |
---|
| 53 | &+ 2 A t_B C (\rho_\text{B}-\rho_\text{solvent}) S(A \sin\alpha \sin\beta) \left[S((B+t_B) \sin\alpha \cos\beta)-S(B \sin\alpha \cos\beta)\right] S(C \cos\alpha)\\ |
---|
| 54 | &+ 2 A B t_C (\rho_\text{C}-\rho_\text{solvent}) S(A \sin\alpha \sin\beta) S(B \sin\alpha \cos\beta) \left[S((C+t_C) \cos\alpha)-S(C \cos\alpha)\right] |
---|
| 55 | \end{align*} |
---|
| 56 | |
---|
| 57 | with |
---|
[5810f00] | 58 | |
---|
[393facf] | 59 | .. math:: |
---|
[5810f00] | 60 | |
---|
[393facf] | 61 | S(x) = \frac{\sin \tfrac{1}{2}Q x}{\tfrac{1}{2}Q x} |
---|
[5810f00] | 62 | |
---|
[393facf] | 63 | where $\rho_\text{core}$, $\rho_\text{A}$, $\rho_\text{B}$ and $\rho_\text{C}$ are |
---|
| 64 | the scattering length of the parallelepiped core, and the rectangular slabs of |
---|
| 65 | thickness $t_A$, $t_B$ and $t_C$, respectively. |
---|
| 66 | $\rho_\text{solvent}$ is the scattering length of the solvent. |
---|
[44bd2be] | 67 | |
---|
| 68 | FITTING NOTES |
---|
[92dfe0c] | 69 | If the scale is set equal to the particle volume fraction, $\phi$, the returned |
---|
[500128b] | 70 | value is the scattered intensity per unit volume, $I(q) = \phi P(q)$. |
---|
[5810f00] | 71 | However, **no interparticle interference effects are included in this |
---|
| 72 | calculation.** |
---|
[44bd2be] | 73 | |
---|
| 74 | There are many parameters in this model. Hold as many fixed as possible with |
---|
| 75 | known values, or you will certainly end up at a solution that is unphysical. |
---|
| 76 | |
---|
| 77 | The returned value is in units of |cm^-1|, on absolute scale. |
---|
| 78 | |
---|
| 79 | NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated |
---|
| 80 | based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ |
---|
[15a90c1] | 81 | and length $(C+2t_C)$ values, after appropriately |
---|
[8f04da4] | 82 | sorting the three dimensions to give an oblate or prolate particle, to give an |
---|
[15a90c1] | 83 | effective radius, for $S(Q)$ when $P(Q) * S(Q)$ is applied. |
---|
[44bd2be] | 84 | |
---|
[904cd9c] | 85 | For 2d data the orientation of the particle is required, described using |
---|
| 86 | angles $\theta$, $\phi$ and $\Psi$ as in the diagrams below, for further details |
---|
[eda8b30] | 87 | of the calculation and angular dispersions see :ref:`orientation` . |
---|
[904cd9c] | 88 | The angle $\Psi$ is the rotational angle around the *long_c* axis. For example, |
---|
[eda8b30] | 89 | $\Psi = 0$ when the *short_b* axis is parallel to the *x*-axis of the detector. |
---|
[44bd2be] | 90 | |
---|
[393facf] | 91 | For 2d, constraints must be applied during fitting to ensure that the inequality |
---|
| 92 | $A < B < C$ is not violated, and hence the correct definition of angles is preserved. The calculation will not report an error, |
---|
| 93 | but the results may be not correct. |
---|
| 94 | |
---|
[15a90c1] | 95 | .. figure:: img/parallelepiped_angle_definition.png |
---|
[44bd2be] | 96 | |
---|
| 97 | Definition of the angles for oriented core-shell parallelepipeds. |
---|
[eda8b30] | 98 | Note that rotation $\theta$, initially in the $xz$ plane, is carried out first, then |
---|
[393facf] | 99 | rotation $\phi$ about the $z$ axis, finally rotation $\Psi$ is now around the axis of the parallelepiped. |
---|
[eda8b30] | 100 | The neutron or X-ray beam is along the $z$ axis. |
---|
[44bd2be] | 101 | |
---|
[1916c52] | 102 | .. figure:: img/parallelepiped_angle_projection.png |
---|
[44bd2be] | 103 | |
---|
| 104 | Examples of the angles for oriented core-shell parallelepipeds against the |
---|
| 105 | detector plane. |
---|
| 106 | |
---|
[aa2edb2] | 107 | References |
---|
| 108 | ---------- |
---|
[44bd2be] | 109 | |
---|
[5810f00] | 110 | .. [#] P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 |
---|
| 111 | Equations (1), (13-14). (in German) |
---|
| 112 | .. [#] D Singh (2009). *Small angle scattering studies of self assembly in |
---|
[fc0b7aa] | 113 | lipid mixtures*, Johns Hopkins University Thesis (2009) 223-225. `Available |
---|
[5810f00] | 114 | from Proquest <http://search.proquest.com/docview/304915826?accountid |
---|
| 115 | =26379>`_ |
---|
| 116 | |
---|
| 117 | Authorship and Verification |
---|
| 118 | ---------------------------- |
---|
[44bd2be] | 119 | |
---|
[5810f00] | 120 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
[cb0dc22] | 121 | * **Converted to sasmodels by:** Miguel Gonzales **Date:** February 26, 2016 |
---|
| 122 | * **Last Modified by:** Wojciech Potrzebowski **Date:** January 11, 2017 |
---|
| 123 | * **Currently Under review by:** Paul Butler |
---|
[44bd2be] | 124 | """ |
---|
| 125 | |
---|
| 126 | import numpy as np |
---|
[14207bb] | 127 | from numpy import pi, inf, sqrt, cos, sin |
---|
[44bd2be] | 128 | |
---|
| 129 | name = "core_shell_parallelepiped" |
---|
| 130 | title = "Rectangular solid with a core-shell structure." |
---|
| 131 | description = """ |
---|
[8f04da4] | 132 | P(q)= |
---|
[44bd2be] | 133 | """ |
---|
| 134 | category = "shape:parallelepiped" |
---|
| 135 | |
---|
| 136 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
[42356c8] | 137 | parameters = [["sld_core", "1e-6/Ang^2", 1, [-inf, inf], "sld", |
---|
[44bd2be] | 138 | "Parallelepiped core scattering length density"], |
---|
[42356c8] | 139 | ["sld_a", "1e-6/Ang^2", 2, [-inf, inf], "sld", |
---|
[44bd2be] | 140 | "Parallelepiped A rim scattering length density"], |
---|
[42356c8] | 141 | ["sld_b", "1e-6/Ang^2", 4, [-inf, inf], "sld", |
---|
[44bd2be] | 142 | "Parallelepiped B rim scattering length density"], |
---|
[42356c8] | 143 | ["sld_c", "1e-6/Ang^2", 2, [-inf, inf], "sld", |
---|
[44bd2be] | 144 | "Parallelepiped C rim scattering length density"], |
---|
[42356c8] | 145 | ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld", |
---|
[44bd2be] | 146 | "Solvent scattering length density"], |
---|
[2222134] | 147 | ["length_a", "Ang", 35, [0, inf], "volume", |
---|
[44bd2be] | 148 | "Shorter side of the parallelepiped"], |
---|
[2222134] | 149 | ["length_b", "Ang", 75, [0, inf], "volume", |
---|
[44bd2be] | 150 | "Second side of the parallelepiped"], |
---|
[2222134] | 151 | ["length_c", "Ang", 400, [0, inf], "volume", |
---|
[44bd2be] | 152 | "Larger side of the parallelepiped"], |
---|
[2222134] | 153 | ["thick_rim_a", "Ang", 10, [0, inf], "volume", |
---|
[44bd2be] | 154 | "Thickness of A rim"], |
---|
[2222134] | 155 | ["thick_rim_b", "Ang", 10, [0, inf], "volume", |
---|
[44bd2be] | 156 | "Thickness of B rim"], |
---|
[2222134] | 157 | ["thick_rim_c", "Ang", 10, [0, inf], "volume", |
---|
[44bd2be] | 158 | "Thickness of C rim"], |
---|
[9b79f29] | 159 | ["theta", "degrees", 0, [-360, 360], "orientation", |
---|
| 160 | "c axis to beam angle"], |
---|
| 161 | ["phi", "degrees", 0, [-360, 360], "orientation", |
---|
| 162 | "rotation about beam"], |
---|
| 163 | ["psi", "degrees", 0, [-360, 360], "orientation", |
---|
| 164 | "rotation about c axis"], |
---|
[44bd2be] | 165 | ] |
---|
| 166 | |
---|
[43b7eea] | 167 | source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] |
---|
[44bd2be] | 168 | |
---|
| 169 | |
---|
[2222134] | 170 | def ER(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c): |
---|
[44bd2be] | 171 | """ |
---|
| 172 | Return equivalent radius (ER) |
---|
| 173 | """ |
---|
| 174 | |
---|
| 175 | # surface average radius (rough approximation) |
---|
[2222134] | 176 | surf_rad = sqrt((length_a + 2.0*thick_rim_a) * (length_b + 2.0*thick_rim_b) / pi) |
---|
[44bd2be] | 177 | |
---|
[2222134] | 178 | height = length_c + 2.0*thick_rim_c |
---|
[44bd2be] | 179 | |
---|
| 180 | ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad)) |
---|
| 181 | return 0.5 * (ddd) ** (1. / 3.) |
---|
| 182 | |
---|
| 183 | # VR defaults to 1.0 |
---|
| 184 | |
---|
[8f04da4] | 185 | def random(): |
---|
| 186 | import numpy as np |
---|
| 187 | outer = 10**np.random.uniform(1, 4.7, size=3) |
---|
| 188 | thick = np.random.beta(0.5, 0.5, size=3)*(outer-2) + 1 |
---|
| 189 | length = outer - thick |
---|
| 190 | pars = dict( |
---|
| 191 | length_a=length[0], |
---|
| 192 | length_b=length[1], |
---|
| 193 | length_c=length[2], |
---|
| 194 | thick_rim_a=thick[0], |
---|
| 195 | thick_rim_b=thick[1], |
---|
| 196 | thick_rim_c=thick[2], |
---|
| 197 | ) |
---|
| 198 | return pars |
---|
| 199 | |
---|
[44bd2be] | 200 | # parameters for demo |
---|
| 201 | demo = dict(scale=1, background=0.0, |
---|
[14838a3] | 202 | sld_core=1, sld_a=2, sld_b=4, sld_c=2, sld_solvent=6, |
---|
[2222134] | 203 | length_a=35, length_b=75, length_c=400, |
---|
| 204 | thick_rim_a=10, thick_rim_b=10, thick_rim_c=10, |
---|
[44bd2be] | 205 | theta=0, phi=0, psi=0, |
---|
[2222134] | 206 | length_a_pd=0.1, length_a_pd_n=1, |
---|
| 207 | length_b_pd=0.1, length_b_pd_n=1, |
---|
| 208 | length_c_pd=0.1, length_c_pd_n=1, |
---|
| 209 | thick_rim_a_pd=0.1, thick_rim_a_pd_n=1, |
---|
| 210 | thick_rim_b_pd=0.1, thick_rim_b_pd_n=1, |
---|
| 211 | thick_rim_c_pd=0.1, thick_rim_c_pd_n=1, |
---|
[44bd2be] | 212 | theta_pd=10, theta_pd_n=1, |
---|
| 213 | phi_pd=10, phi_pd_n=1, |
---|
[14838a3] | 214 | psi_pd=10, psi_pd_n=1) |
---|
[44bd2be] | 215 | |
---|
[14207bb] | 216 | # rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models |
---|
| 217 | qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) |
---|
[6dd90c1] | 218 | tests = [[{}, 0.2, 0.533149288477], |
---|
| 219 | [{}, [0.2], [0.533149288477]], |
---|
[14207bb] | 220 | [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0853299803222], |
---|
| 221 | [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0853299803222]], |
---|
[44bd2be] | 222 | ] |
---|
| 223 | del qx, qy # not necessary to delete, but cleaner |
---|