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