[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 | |
---|
| 10 | .. math: |
---|
| 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 | |
---|
| 18 | The empirical fit function is (eq 9'): |
---|
| 19 | |
---|
| 20 | .. math: |
---|
| 21 | |
---|
| 22 | I(q) = \text{background} |
---|
| 23 | + \Sum_{i=1}^N \left[ |
---|
| 24 | G_i \exp\left(-\frac{q^2R_{gi}^2}{3}\right) |
---|
| 25 | + B_i \exp\left(-\frac{q^2R_{g(i+1)}^2}{3}\right) |
---|
| 26 | \left(\frac{1}{q_i^*}\right)^{P_i} |
---|
| 27 | |
---|
| 28 | where |
---|
| 29 | |
---|
| 30 | .. math: |
---|
| 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 | |
---|
| 39 | For example, to approximate the scattering from random coils (Debye_ equation), |
---|
| 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 | |
---|
| 47 | .. math: |
---|
| 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 |
---|
| 64 | from numpy import inf, exp, sqrt |
---|
| 65 | from scipy.special import erf |
---|
| 66 | |
---|
| 67 | parameters = [ |
---|
| 68 | ["level", "", 1, [0, 6], "", "Level number"], |
---|
[42356c8] | 69 | ["rg[level]", "Ang", 15.8, [0, inf], "", "Radius of gyration"], |
---|
[263daec] | 70 | ["power[level]", "", 4, [-inf, inf], "", "Power"], |
---|
| 71 | ["B[level]", "1/cm", 4.5e-6, [-inf, inf], "", ""], |
---|
| 72 | ["G[level]", "1/cm", 400, [0, inf], "", ""], |
---|
| 73 | ] |
---|
| 74 | |
---|
[42356c8] | 75 | def Iq(q, level, rg, power, B, G): |
---|
[263daec] | 76 | ilevel = int(level) |
---|
| 77 | if ilevel == 0: |
---|
| 78 | return 1./q |
---|
| 79 | |
---|
| 80 | result = np.zeros_like(q) |
---|
| 81 | for i in range(ilevel): |
---|
[42356c8] | 82 | exp_now = exp(-(q*rg[i])**2/3.) |
---|
| 83 | pow_now = (erf(q*rg[i]/sqrt(6.))**3/q)**power[i] |
---|
| 84 | exp_next = exp(-(q*rg[i+1])**2/3.) if i < ilevel-1 else 1. |
---|
[263daec] | 85 | result += G[i]*exp_now + B[i]*exp_next*pow_now |
---|
| 86 | result[q==0] = np.sum(G[:ilevel]) |
---|
| 87 | return result |
---|
| 88 | Iq.vectorized = True |
---|
| 89 | |
---|
| 90 | demo = dict( |
---|
| 91 | level=2, |
---|
[42356c8] | 92 | rg=[15.8, 21], |
---|
[263daec] | 93 | power=[4, 2], |
---|
| 94 | B=[4.5e-6, 0.0006], |
---|
| 95 | G=[400, 3], |
---|
| 96 | scale=1., |
---|
| 97 | background=0., |
---|
| 98 | ) |
---|