[deb7ee0] | 1 | # rectangular_prism model |
---|
| 2 | # Note: model title and parameter table are inserted automatically |
---|
| 3 | r""" |
---|
| 4 | |
---|
[ab2aea8] | 5 | This model provides the form factor, $P(q)$, for a hollow rectangular |
---|
[deb7ee0] | 6 | prism with infinitely thin walls. It computes only the 1D scattering, not the 2D. |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | Definition |
---|
| 10 | ---------- |
---|
| 11 | |
---|
| 12 | The 1D scattering intensity for this model is calculated according to the |
---|
| 13 | equations given by Nayuk and Huber (Nayuk, 2012). |
---|
| 14 | |
---|
| 15 | Assuming a hollow parallelepiped with infinitely thin walls, edge lengths |
---|
[ab2aea8] | 16 | $A \le B \le C$ and presenting an orientation with respect to the |
---|
| 17 | scattering vector given by $\theta$ and $\phi$, where $\theta$ is the angle |
---|
| 18 | between the $z$ axis and the longest axis of the parallelepiped $C$, and |
---|
| 19 | $\phi$ is the angle between the scattering vector (lying in the $xy$ plane) |
---|
| 20 | and the $y$ axis, the form factor is given by |
---|
[deb7ee0] | 21 | |
---|
| 22 | .. math:: |
---|
| 23 | |
---|
[ab2aea8] | 24 | P(q) = \frac{1}{V^2} \frac{2}{\pi} \int_0^{\frac{\pi}{2}} |
---|
| 25 | \int_0^{\frac{\pi}{2}} [A_L(q)+A_T(q)]^2 \sin\theta\,d\theta\,d\phi |
---|
[deb7ee0] | 26 | |
---|
[ab2aea8] | 27 | where |
---|
[deb7ee0] | 28 | |
---|
| 29 | .. math:: |
---|
| 30 | |
---|
[ab2aea8] | 31 | V &= 2AB + 2AC + 2BC \\ |
---|
| 32 | A_L(q) &= 8 \times \frac{ |
---|
| 33 | \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right) |
---|
| 34 | \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) |
---|
| 35 | \cos \left( \tfrac{1}{2} q C \cos\theta \right) |
---|
| 36 | }{q^2 \, \sin^2\theta \, \sin\phi \cos\phi} \\ |
---|
| 37 | A_T(q) &= A_F(q) \times |
---|
| 38 | \frac{2\,\sin \left( \tfrac{1}{2} q C \cos\theta \right)}{q\,\cos\theta} |
---|
[deb7ee0] | 39 | |
---|
| 40 | and |
---|
| 41 | |
---|
| 42 | .. math:: |
---|
[ab2aea8] | 43 | |
---|
| 44 | A_F(q) = 4 \frac{ \cos \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right) |
---|
| 45 | \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) } |
---|
[deb7ee0] | 46 | {q \, \cos\phi \, \sin\theta} + |
---|
[ab2aea8] | 47 | 4 \frac{ \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right) |
---|
| 48 | \cos \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) } |
---|
[deb7ee0] | 49 | {q \, \sin\phi \, \sin\theta} |
---|
| 50 | |
---|
| 51 | The 1D scattering intensity is then calculated as |
---|
| 52 | |
---|
| 53 | .. math:: |
---|
| 54 | |
---|
[ab2aea8] | 55 | I(q) = \text{scale} \times V \times (\rho_\text{p} - \rho_\text{solvent})^2 \times P(q) |
---|
| 56 | |
---|
| 57 | where $V$ is the volume of the rectangular prism, $\rho_\text{p}$ |
---|
| 58 | is the scattering length of the parallelepiped, $\rho_\text{solvent}$ |
---|
[deb7ee0] | 59 | is the scattering length of the solvent, and (if the data are in absolute |
---|
| 60 | units) *scale* represents the volume fraction (which is unitless). |
---|
| 61 | |
---|
| 62 | **The 2D scattering intensity is not computed by this model.** |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | Validation |
---|
| 66 | ---------- |
---|
| 67 | |
---|
| 68 | Validation of the code was conducted by qualitatively comparing the output |
---|
| 69 | of the 1D model to the curves shown in (Nayuk, 2012). |
---|
| 70 | |
---|
[aa2edb2] | 71 | |
---|
| 72 | References |
---|
| 73 | ---------- |
---|
[deb7ee0] | 74 | |
---|
| 75 | R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 |
---|
| 76 | """ |
---|
| 77 | |
---|
[2d81cfe] | 78 | import numpy as np |
---|
[deb7ee0] | 79 | from numpy import pi, inf, sqrt |
---|
| 80 | |
---|
[3d8283b] | 81 | name = "hollow_rectangular_prism_thin_walls" |
---|
| 82 | title = "Hollow rectangular parallelepiped with thin walls." |
---|
[deb7ee0] | 83 | description = """ |
---|
[3d8283b] | 84 | I(q)= scale*V*(sld - sld_solvent)^2*P(q)+background |
---|
[deb7ee0] | 85 | with P(q) being the form factor corresponding to a hollow rectangular |
---|
| 86 | parallelepiped with infinitely thin walls. |
---|
| 87 | """ |
---|
| 88 | category = "shape:parallelepiped" |
---|
| 89 | |
---|
| 90 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
[42356c8] | 91 | parameters = [["sld", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", |
---|
[deb7ee0] | 92 | "Parallelepiped scattering length density"], |
---|
[42356c8] | 93 | ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", |
---|
[deb7ee0] | 94 | "Solvent scattering length density"], |
---|
[a807206] | 95 | ["length_a", "Ang", 35, [0, inf], "volume", |
---|
[deb7ee0] | 96 | "Shorter side of the parallelepiped"], |
---|
| 97 | ["b2a_ratio", "Ang", 1, [0, inf], "volume", |
---|
| 98 | "Ratio sides b/a"], |
---|
| 99 | ["c2a_ratio", "Ang", 1, [0, inf], "volume", |
---|
| 100 | "Ratio sides c/a"], |
---|
| 101 | ] |
---|
| 102 | |
---|
[3d8283b] | 103 | source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] |
---|
[deb7ee0] | 104 | |
---|
[a807206] | 105 | def ER(length_a, b2a_ratio, c2a_ratio): |
---|
[deb7ee0] | 106 | """ |
---|
| 107 | Return equivalent radius (ER) |
---|
| 108 | """ |
---|
[a807206] | 109 | b_side = length_a * b2a_ratio |
---|
| 110 | c_side = length_a * c2a_ratio |
---|
[deb7ee0] | 111 | |
---|
| 112 | # surface average radius (rough approximation) |
---|
[a807206] | 113 | surf_rad = sqrt(length_a * b_side / pi) |
---|
[deb7ee0] | 114 | |
---|
| 115 | ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) |
---|
| 116 | return 0.5 * (ddd) ** (1. / 3.) |
---|
| 117 | |
---|
[a807206] | 118 | def VR(length_a, b2a_ratio, c2a_ratio): |
---|
[deb7ee0] | 119 | """ |
---|
| 120 | Return shell volume and total volume |
---|
| 121 | """ |
---|
[a807206] | 122 | b_side = length_a * b2a_ratio |
---|
| 123 | c_side = length_a * c2a_ratio |
---|
| 124 | vol_total = length_a * b_side * c_side |
---|
| 125 | vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side) |
---|
[deb7ee0] | 126 | return vol_shell, vol_total |
---|
| 127 | |
---|
| 128 | |
---|
[31df0c9] | 129 | def random(): |
---|
| 130 | a, b, c = 10**np.random.uniform(1, 4.7, size=3) |
---|
| 131 | pars = dict( |
---|
| 132 | length_a=a, |
---|
| 133 | b2a_ratio=b/a, |
---|
| 134 | c2a_ratio=c/a, |
---|
| 135 | ) |
---|
| 136 | return pars |
---|
| 137 | |
---|
| 138 | |
---|
[deb7ee0] | 139 | # parameters for demo |
---|
| 140 | demo = dict(scale=1, background=0, |
---|
[ab2aea8] | 141 | sld=6.3, sld_solvent=1.0, |
---|
[a807206] | 142 | length_a=35, b2a_ratio=1, c2a_ratio=1, |
---|
| 143 | length_a_pd=0.1, length_a_pd_n=10, |
---|
[deb7ee0] | 144 | b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, |
---|
| 145 | c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) |
---|
| 146 | |
---|
[6dd90c1] | 147 | tests = [[{}, 0.2, 0.837719188592], |
---|
| 148 | [{}, [0.2], [0.837719188592]], |
---|
[deb7ee0] | 149 | ] |
---|