[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 rectangular prism. |
---|
| 6 | |
---|
| 7 | Note that this model is almost totally equivalent to the existing |
---|
| 8 | :ref:`parallelepiped` model. |
---|
| 9 | The only difference is that the way the relevant |
---|
| 10 | parameters are defined here (*a*, *b/a*, *c/a* instead of *a*, *b*, *c*) |
---|
[76e5041] | 11 | which allows use of polydispersity with this model while keeping the shape of |
---|
[deb7ee0] | 12 | the prism (e.g. setting *b/a* = 1 and *c/a* = 1 and applying polydispersity |
---|
| 13 | to *a* will generate a distribution of cubes of different sizes). |
---|
| 14 | Note also that, contrary to :ref:`parallelepiped`, it does not compute |
---|
| 15 | the 2D scattering. |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | Definition |
---|
| 19 | ---------- |
---|
| 20 | |
---|
| 21 | The 1D scattering intensity for this model was calculated by Mittelbach and |
---|
| 22 | Porod (Mittelbach, 1961), but the implementation here is closer to the |
---|
| 23 | equations given by Nayuk and Huber (Nayuk, 2012). |
---|
| 24 | Note also that the angle definitions used in the code and the present |
---|
| 25 | documentation correspond to those used in (Nayuk, 2012) (see Fig. 1 of |
---|
| 26 | that reference), with |theta| corresponding to |alpha| in that paper, |
---|
| 27 | and not to the usual convention used for example in the |
---|
| 28 | :ref:`parallelepiped` model. As the present model does not compute |
---|
| 29 | the 2D scattering, this has no further consequences. |
---|
| 30 | |
---|
| 31 | In this model the scattering from a massive parallelepiped with an |
---|
| 32 | orientation with respect to the scattering vector given by |theta| |
---|
| 33 | and |phi| |
---|
| 34 | |
---|
| 35 | .. math:: |
---|
| 36 | A_P\,(q) = \frac{\sin \bigl( q \frac{C}{2} \cos\theta \bigr)}{\left( q \frac{C}{2} |
---|
| 37 | \cos\theta \right)} \, \times \, \frac{\sin \bigl( q \frac{A}{2} \sin\theta \sin\phi |
---|
| 38 | \bigr)}{\left( q \frac{A}{2} \sin\theta \sin\phi \right)} \, \times \, \frac{\sin \bigl( |
---|
| 39 | q \frac{B}{2} \sin\theta \cos\phi \bigr)}{\left( q \frac{B}{2} \sin\theta \cos\phi \right)} |
---|
| 40 | |
---|
| 41 | where *A*, *B* and *C* are the sides of the parallelepiped and must fulfill |
---|
| 42 | :math:`A \le B \le C`, |theta| is the angle between the *z* axis and the |
---|
| 43 | longest axis of the parallelepiped *C*, and |phi| is the angle between the |
---|
| 44 | scattering vector (lying in the *xy* plane) and the *y* axis. |
---|
| 45 | |
---|
| 46 | The normalized form factor in 1D is obtained averaging over all possible |
---|
| 47 | orientations |
---|
| 48 | |
---|
| 49 | .. math:: |
---|
| 50 | P(q) = \frac{2}{\pi} \times \, \int_0^{\frac{\pi}{2}} \, |
---|
| 51 | \int_0^{\frac{\pi}{2}} A_P^2(q) \, \sin\theta \, d\theta \, d\phi |
---|
| 52 | |
---|
| 53 | And the 1D scattering intensity is calculated as |
---|
| 54 | |
---|
| 55 | .. math:: |
---|
| 56 | I(q) = \mbox{scale} \times V \times (\rho_{\mbox{p}} - |
---|
| 57 | \rho_{\mbox{solvent}})^2 \times P(q) |
---|
| 58 | |
---|
| 59 | where *V* is the volume of the rectangular prism, :math:`\rho_{\mbox{p}}` |
---|
| 60 | is the scattering length of the parallelepiped, :math:`\rho_{\mbox{solvent}}` |
---|
| 61 | is the scattering length of the solvent, and (if the data are in absolute |
---|
| 62 | units) *scale* represents the volume fraction (which is unitless). |
---|
| 63 | |
---|
| 64 | **The 2D scattering intensity is not computed by this model.** |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | Validation |
---|
| 68 | ---------- |
---|
| 69 | |
---|
| 70 | Validation of the code was conducted by comparing the output of the 1D model |
---|
| 71 | to the output of the existing :ref:`parallelepiped` model. |
---|
| 72 | |
---|
[aa2edb2] | 73 | |
---|
| 74 | References |
---|
| 75 | ---------- |
---|
[deb7ee0] | 76 | |
---|
| 77 | P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 |
---|
| 78 | |
---|
| 79 | R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 |
---|
| 80 | |
---|
| 81 | """ |
---|
| 82 | |
---|
| 83 | from numpy import pi, inf, sqrt |
---|
| 84 | |
---|
| 85 | name = "rectangular_prism" |
---|
| 86 | title = "Rectangular parallelepiped with uniform scattering length density." |
---|
| 87 | description = """ |
---|
[76e5041] | 88 | I(q)= scale*V*(sld - sld_solvent)^2*P(q,theta,phi)+background |
---|
[deb7ee0] | 89 | P(q,theta,phi) = (2/pi) * double integral from 0 to pi/2 of ... |
---|
| 90 | AP^2(q)*sin(theta)*dtheta*dphi |
---|
| 91 | AP = S(q*C*cos(theta)/2) * S(q*A*sin(theta)*sin(phi)/2) * S(q*B*sin(theta)*cos(phi)/2) |
---|
| 92 | S(x) = sin(x)/x |
---|
| 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"], |
---|
| 101 | ["a_side", "Ang", 35, [0, inf], "volume", |
---|
| 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 | |
---|
[43b7eea] | 109 | source = ["lib/gauss76.c", "rectangular_prism.c"] |
---|
[deb7ee0] | 110 | |
---|
| 111 | def ER(a_side, b2a_ratio, c2a_ratio): |
---|
| 112 | """ |
---|
| 113 | Return equivalent radius (ER) |
---|
| 114 | """ |
---|
| 115 | b_side = a_side * b2a_ratio |
---|
| 116 | c_side = a_side * c2a_ratio |
---|
| 117 | |
---|
| 118 | # surface average radius (rough approximation) |
---|
| 119 | surf_rad = sqrt(a_side * b_side / pi) |
---|
| 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 | |
---|
| 124 | |
---|
| 125 | # parameters for demo |
---|
| 126 | demo = dict(scale=1, background=0, |
---|
[76e5041] | 127 | sld=6.3e-6, sld_solvent=1.0e-6, |
---|
[deb7ee0] | 128 | a_side=35, b2a_ratio=1, c2a_ratio=1, |
---|
| 129 | a_side_pd=0.1, a_side_pd_n=10, |
---|
| 130 | b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, |
---|
| 131 | c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) |
---|
| 132 | |
---|
[6dd90c1] | 133 | tests = [[{}, 0.2, 0.375248406825], |
---|
| 134 | [{}, [0.2], [0.375248406825]], |
---|
[deb7ee0] | 135 | ] |
---|