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