[263daec] | 1 | r""" |
---|
| 2 | Definition |
---|
| 3 | ---------- |
---|
| 4 | |
---|
[6431056] | 5 | This model employs the empirical multiple level unified Exponential/Power-law |
---|
| 6 | fit method developed by Beaucage. Four functions are included so that 1, 2, 3, |
---|
| 7 | or 4 levels can be used. In addition a 0 level has been added which simply |
---|
| 8 | calculates |
---|
[263daec] | 9 | |
---|
[948db69] | 10 | .. math:: |
---|
[263daec] | 11 | |
---|
| 12 | I(q) = \text{scale} / q + \text{background} |
---|
| 13 | |
---|
| 14 | The Beaucage method is able to reasonably approximate the scattering from |
---|
| 15 | many different types of particles, including fractal clusters, random coils |
---|
| 16 | (Debye equation), ellipsoidal particles, etc. |
---|
| 17 | |
---|
[cdcebf1] | 18 | The model works best for mass fractal systems characterized by Porod exponents |
---|
| 19 | between 5/3 and 3. It should not be used for surface fractal systems. Hammouda |
---|
[6431056] | 20 | (2010) has pointed out a deficiency in the way this model handles the |
---|
| 21 | transitioning between the Guinier and Porod regimes and which can create |
---|
| 22 | artefacts that appear as kinks in the fitted model function. |
---|
| 23 | |
---|
| 24 | Also see the Guinier_Porod model. |
---|
| 25 | |
---|
[948db69] | 26 | The empirical fit function is: |
---|
[263daec] | 27 | |
---|
[948db69] | 28 | .. math:: |
---|
[263daec] | 29 | |
---|
| 30 | I(q) = \text{background} |
---|
[eb574d7] | 31 | + \sum_{i=1}^N \Bigl[ |
---|
| 32 | G_i \exp\Bigl(-\frac{q^2R_{gi}^2}{3}\Bigr) |
---|
| 33 | + B_i \exp\Bigl(-\frac{q^2R_{g(i+1)}^2}{3}\Bigr) |
---|
| 34 | \Bigl(\frac{1}{q_i^*}\Bigr)^{P_i} \Bigr] |
---|
[263daec] | 35 | |
---|
| 36 | where |
---|
| 37 | |
---|
[948db69] | 38 | .. math:: |
---|
[263daec] | 39 | |
---|
| 40 | q_i^* = \frac{q}{\operatorname{erf}^3(q R_{gi}/\sqrt{6}} |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | For each level, the four parameters $G_i$, $R_{gi}$, $B_i$ and $P_i$ must |
---|
| 44 | be chosen. Beaucage has an additional factor $k$ in the definition of |
---|
| 45 | $q_i^*$ which is ignored here. |
---|
| 46 | |
---|
[40a87fa] | 47 | For example, to approximate the scattering from random coils (Debye equation), |
---|
[263daec] | 48 | set $R_{gi}$ as the Guinier radius, $P_i = 2$, and $B_i = 2 G_i / R_{gi}$ |
---|
| 49 | |
---|
| 50 | See the references for further information on choosing the parameters. |
---|
| 51 | |
---|
| 52 | For 2D data: The 2D scattering intensity is calculated in the same way as 1D, |
---|
| 53 | where the $q$ vector is defined as |
---|
| 54 | |
---|
[948db69] | 55 | .. math:: |
---|
[263daec] | 56 | |
---|
| 57 | q = \sqrt{q_x^2 + q_y^2} |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | References |
---|
| 61 | ---------- |
---|
| 62 | |
---|
| 63 | G Beaucage, *J. Appl. Cryst.*, 28 (1995) 717-728 |
---|
| 64 | |
---|
| 65 | G Beaucage, *J. Appl. Cryst.*, 29 (1996) 134-146 |
---|
| 66 | |
---|
[cdcebf1] | 67 | B Hammouda, *Analysis of the Beaucage model, J. Appl. Cryst.*, (2010), 43, 1474-1478 |
---|
[6431056] | 68 | |
---|
[263daec] | 69 | """ |
---|
| 70 | |
---|
| 71 | from __future__ import division |
---|
| 72 | |
---|
| 73 | import numpy as np |
---|
[2c74c11] | 74 | from numpy import inf, exp, sqrt, errstate |
---|
[263daec] | 75 | from scipy.special import erf |
---|
| 76 | |
---|
[40a87fa] | 77 | category = "shape-independent" |
---|
[948db69] | 78 | name = "unified_power_Rg" |
---|
| 79 | title = "Unified Power Rg" |
---|
| 80 | description = """ |
---|
| 81 | The Beaucage model employs the empirical multiple level unified |
---|
| 82 | Exponential/Power-law fit method developed by G. Beaucage. Four functions |
---|
| 83 | are included so that 1, 2, 3, or 4 levels can be used. |
---|
| 84 | """ |
---|
[40a87fa] | 85 | |
---|
| 86 | # pylint: disable=bad-whitespace, line-too-long |
---|
[263daec] | 87 | parameters = [ |
---|
| 88 | ["level", "", 1, [0, 6], "", "Level number"], |
---|
[42356c8] | 89 | ["rg[level]", "Ang", 15.8, [0, inf], "", "Radius of gyration"], |
---|
[263daec] | 90 | ["power[level]", "", 4, [-inf, inf], "", "Power"], |
---|
| 91 | ["B[level]", "1/cm", 4.5e-6, [-inf, inf], "", ""], |
---|
| 92 | ["G[level]", "1/cm", 400, [0, inf], "", ""], |
---|
| 93 | ] |
---|
[40a87fa] | 94 | # pylint: enable=bad-whitespace, line-too-long |
---|
[263daec] | 95 | |
---|
[42356c8] | 96 | def Iq(q, level, rg, power, B, G): |
---|
[263daec] | 97 | ilevel = int(level) |
---|
| 98 | if ilevel == 0: |
---|
[2c74c11] | 99 | with errstate(divide='ignore'): |
---|
| 100 | return 1./q |
---|
| 101 | |
---|
| 102 | with errstate(divide='ignore', invalid='ignore'): |
---|
[ec77322] | 103 | result = np.zeros(q.shape, 'd') |
---|
[2c74c11] | 104 | for i in range(ilevel): |
---|
| 105 | exp_now = exp(-(q*rg[i])**2/3.) |
---|
| 106 | pow_now = (erf(q*rg[i]/sqrt(6.))**3/q)**power[i] |
---|
[b3f2a24] | 107 | if i < ilevel-1: |
---|
| 108 | exp_next = exp(-(q*rg[i+1])**2/3.) |
---|
| 109 | else: |
---|
| 110 | exp_next = 1 |
---|
[2c74c11] | 111 | result += G[i]*exp_now + B[i]*exp_next*pow_now |
---|
[b3f2a24] | 112 | |
---|
[40a87fa] | 113 | result[q == 0] = np.sum(G[:ilevel]) |
---|
[263daec] | 114 | return result |
---|
[2c74c11] | 115 | |
---|
[263daec] | 116 | Iq.vectorized = True |
---|
| 117 | |
---|
| 118 | demo = dict( |
---|
| 119 | level=2, |
---|
[42356c8] | 120 | rg=[15.8, 21], |
---|
[263daec] | 121 | power=[4, 2], |
---|
| 122 | B=[4.5e-6, 0.0006], |
---|
| 123 | G=[400, 3], |
---|
| 124 | scale=1., |
---|
| 125 | background=0., |
---|
[40a87fa] | 126 | ) |
---|