[cc3fac6] | 1 | r""" |
---|
| 2 | Calculates the scattering for a generalized Guinier/power law object. |
---|
| 3 | This is an empirical model that can be used to determine the size |
---|
| 4 | and dimensionality of scattering objects, including asymmetric objects |
---|
| 5 | such as rods or platelets, and shapes intermediate between spheres |
---|
| 6 | and rods or between rods and platelets. |
---|
| 7 | |
---|
| 8 | Definition |
---|
| 9 | ---------- |
---|
| 10 | |
---|
| 11 | The following functional form is used |
---|
| 12 | |
---|
| 13 | .. math:: |
---|
[40a87fa] | 14 | |
---|
| 15 | I(q) = \begin{cases} |
---|
| 16 | \frac{G}{Q^s}\ \exp{\left[\frac{-Q^2R_g^2}{3-s} \right]} & Q \leq Q_1 \\ |
---|
| 17 | D / Q^m & Q \geq Q_1 |
---|
| 18 | \end{cases} |
---|
[cc3fac6] | 19 | |
---|
| 20 | This is based on the generalized Guinier law for such elongated objects |
---|
[40a87fa] | 21 | (see the Glatter reference below). For 3D globular objects (such as spheres), |
---|
| 22 | $s = 0$ and one recovers the standard Guinier formula. For 2D symmetry |
---|
| 23 | (such as for rods) $s = 1$, and for 1D symmetry (such as for lamellae or |
---|
| 24 | platelets) $s = 2$. A dimensionality parameter ($3-s$) is thus defined, |
---|
| 25 | and is 3 for spherical objects, 2 for rods, and 1 for plates. |
---|
[cc3fac6] | 26 | |
---|
[40a87fa] | 27 | Enforcing the continuity of the Guinier and Porod functions and their |
---|
| 28 | derivatives yields |
---|
[cc3fac6] | 29 | |
---|
| 30 | .. math:: |
---|
[40a87fa] | 31 | |
---|
[cc3fac6] | 32 | Q_1 = \frac{1}{R_g} \sqrt{(m-s)(3-s)/2} |
---|
| 33 | |
---|
| 34 | and |
---|
| 35 | |
---|
| 36 | .. math:: |
---|
| 37 | |
---|
[40a87fa] | 38 | D &= G \ \exp{ \left[ \frac{-Q_1^2 R_g^2}{3-s} \right]} \ Q_1^{m-s} |
---|
[cc3fac6] | 39 | |
---|
[40a87fa] | 40 | &= \frac{G}{R_g^{m-s}} \ \exp \left[ -\frac{m-s}{2} \right] |
---|
| 41 | \left( \frac{(m-s)(3-s)}{2} \right)^{\frac{m-s}{2}} |
---|
[cc3fac6] | 42 | |
---|
[45330ed] | 43 | |
---|
[40a87fa] | 44 | Note that the radius of gyration for a sphere of radius $R$ is given |
---|
| 45 | by $R_g = R \sqrt{3/5}$. For a cylinder of radius $R$ and length $L$, |
---|
| 46 | $R_g^2 = \frac{L^2}{12} + \frac{R^2}{2}$ from which the cross-sectional |
---|
| 47 | radius of gyration for a randomly oriented thin cylinder is $R_g = R/\sqrt{2}$ |
---|
| 48 | and the cross-sectional radius of gyration of a randomly oriented lamella |
---|
| 49 | of thickness $T$ is given by $R_g = T / \sqrt{12}$. |
---|
[cc3fac6] | 50 | |
---|
| 51 | For 2D data: The 2D scattering intensity is calculated in the same way as 1D, |
---|
| 52 | where the q vector is defined as |
---|
| 53 | |
---|
| 54 | .. math:: |
---|
| 55 | q = \sqrt{q_x^2+q_y^2} |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | Reference |
---|
| 59 | --------- |
---|
| 60 | |
---|
[40a87fa] | 61 | A Guinier, G Fournet, *Small-Angle Scattering of X-Rays*, |
---|
| 62 | John Wiley and Sons, New York, (1955) |
---|
[cc3fac6] | 63 | |
---|
[40a87fa] | 64 | O Glatter, O Kratky, *Small-Angle X-Ray Scattering*, Academic Press (1982) |
---|
[cc3fac6] | 65 | Check out Chapter 4 on Data Treatment, pages 155-156. |
---|
| 66 | """ |
---|
| 67 | |
---|
[2c74c11] | 68 | from numpy import inf, sqrt, exp, errstate |
---|
[cc3fac6] | 69 | |
---|
| 70 | name = "guinier_porod" |
---|
| 71 | title = "Guinier-Porod function" |
---|
| 72 | description = """\ |
---|
| 73 | I(q) = scale/q^s* exp ( - R_g^2 q^2 / (3-s) ) for q<= ql |
---|
| 74 | = scale/q^m*exp((-ql^2*Rg^2)/(3-s))*ql^(m-s) for q>=ql |
---|
| 75 | where ql = sqrt((m-s)(3-s)/2)/Rg. |
---|
| 76 | List of parameters: |
---|
| 77 | scale = Guinier Scale |
---|
| 78 | s = Dimension Variable |
---|
| 79 | Rg = Radius of Gyration [A] |
---|
| 80 | m = Porod Exponent |
---|
| 81 | background = Background [1/cm]""" |
---|
| 82 | |
---|
| 83 | category = "shape-independent" |
---|
| 84 | |
---|
| 85 | # pylint: disable=bad-whitespace, line-too-long |
---|
| 86 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
| 87 | parameters = [["rg", "Ang", 60.0, [0, inf], "", "Radius of gyration"], |
---|
| 88 | ["s", "", 1.0, [0, inf], "", "Dimension variable"], |
---|
| 89 | ["m", "", 3.0, [0, inf], "", "Porod exponent"]] |
---|
| 90 | # pylint: enable=bad-whitespace, line-too-long |
---|
| 91 | |
---|
[1ce6e82] | 92 | # pylint: disable=C0103 |
---|
[cc3fac6] | 93 | def Iq(q, rg, s, m): |
---|
| 94 | """ |
---|
| 95 | @param q: Input q-value |
---|
| 96 | """ |
---|
| 97 | n = 3.0 - s |
---|
[2c74c11] | 98 | ms = 0.5*(m-s) # =(n-3+m)/2 |
---|
| 99 | |
---|
| 100 | # preallocate return value |
---|
| 101 | iq = 0.0*q |
---|
[cc3fac6] | 102 | |
---|
| 103 | # Take care of the singular points |
---|
[2c74c11] | 104 | if rg <= 0.0 or ms <= 0.0: |
---|
| 105 | return iq |
---|
[cc3fac6] | 106 | |
---|
| 107 | # Do the calculation and return the function value |
---|
[2c74c11] | 108 | idx = q < sqrt(n*ms)/rg |
---|
| 109 | with errstate(divide='ignore'): |
---|
| 110 | iq[idx] = q[idx]**-s * exp(-(q[idx]*rg)**2/n) |
---|
| 111 | iq[~idx] = q[~idx]**-m * (exp(-ms) * (n*ms/rg**2)**ms) |
---|
[1ce6e82] | 112 | return iq |
---|
[cc3fac6] | 113 | |
---|
[2c74c11] | 114 | Iq.vectorized = True # Iq accepts an array of q values |
---|
[cc3fac6] | 115 | |
---|
| 116 | demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, m=3.0) |
---|
| 117 | |
---|
| 118 | tests = [[{'scale': 1.5, 'background':0.5}, 0.04, 5.290096890253155]] |
---|