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