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