[636adb6] | 1 | r""" |
---|
[b0c4271] | 2 | Definition |
---|
| 3 | ---------- |
---|
| 4 | |
---|
[636adb6] | 5 | This model calculates an empirical functional form for SAS data characterized |
---|
| 6 | by a broad scattering peak. Many SAS spectra are characterized by a broad peak |
---|
| 7 | even though they are from amorphous soft materials. For example, soft systems |
---|
| 8 | that show a SAS peak include copolymers, polyelectrolytes, multiphase systems, |
---|
| 9 | layered structures, etc. |
---|
| 10 | |
---|
[3c56da87] | 11 | The d-spacing corresponding to the broad peak is a characteristic distance |
---|
| 12 | between the scattering inhomogeneities (such as in lamellar, cylindrical, or |
---|
[636adb6] | 13 | spherical morphologies, or for bicontinuous structures). |
---|
| 14 | |
---|
[eb69cce] | 15 | The scattering intensity $I(q)$ is calculated as |
---|
[636adb6] | 16 | |
---|
[40a87fa] | 17 | .. math:: I(q) = \frac{A}{q^n} + \frac{C}{1 + (|q - q_0|\xi)^m} + B |
---|
[636adb6] | 18 | |
---|
[43fe34b] | 19 | Here the peak position is related to the d-spacing as $q_0 = 2\pi / d_0$. |
---|
[636adb6] | 20 | |
---|
[40a87fa] | 21 | $A$ is the Porod law scale factor, $n$ the Porod exponent, $C$ is the |
---|
| 22 | Lorentzian scale factor, $m$ the exponent of $q$, $\xi$ the screening length, |
---|
| 23 | and $B$ the flat background. |
---|
[aad336c] | 24 | |
---|
[eb69cce] | 25 | For 2D data the scattering intensity is calculated in the same way as 1D, |
---|
| 26 | where the $q$ vector is defined as |
---|
[636adb6] | 27 | |
---|
[40a87fa] | 28 | .. math:: q = \sqrt{q_x^2 + q_y^2} |
---|
[636adb6] | 29 | |
---|
[eb69cce] | 30 | References |
---|
| 31 | ---------- |
---|
[636adb6] | 32 | |
---|
| 33 | None. |
---|
| 34 | |
---|
[b0c4271] | 35 | Authorship and Verification |
---|
| 36 | ---------------------------- |
---|
| 37 | |
---|
| 38 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
| 39 | * **Last Modified by:** Paul kienle **Date:** July 24, 2016 |
---|
| 40 | * **Last Reviewed by:** Richard Heenan **Date:** March 21, 2016 |
---|
[636adb6] | 41 | """ |
---|
| 42 | |
---|
[2d81cfe] | 43 | import numpy as np |
---|
[2c74c11] | 44 | from numpy import inf, errstate |
---|
[636adb6] | 45 | |
---|
| 46 | name = "broad_peak" |
---|
| 47 | title = "Broad Lorentzian type peak on top of a power law decay" |
---|
| 48 | description = """\ |
---|
| 49 | I(q) = scale_p/pow(q,exponent)+scale_l/ |
---|
| 50 | (1.0 + pow((fabs(q-q_peak)*length_l),exponent_l) )+ background |
---|
| 51 | |
---|
| 52 | List of default parameters: |
---|
| 53 | porod_scale = Porod term scaling |
---|
| 54 | porod_exp = Porod exponent |
---|
| 55 | lorentz_scale = Lorentzian term scaling |
---|
| 56 | lorentz_length = Lorentzian screening length [A] |
---|
| 57 | peak_pos = peak location [1/A] |
---|
| 58 | lorentz_exp = Lorentzian exponent |
---|
| 59 | background = Incoherent background""" |
---|
[485aee2] | 60 | category = "shape-independent" |
---|
[636adb6] | 61 | |
---|
[dcdf29d] | 62 | # pylint: disable=bad-whitespace, line-too-long |
---|
[485aee2] | 63 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
[dcdf29d] | 64 | parameters = [["porod_scale", "", 1.0e-05, [-inf, inf], "", "Power law scale factor"], |
---|
| 65 | ["porod_exp", "", 3.0, [-inf, inf], "", "Exponent of power law"], |
---|
| 66 | ["lorentz_scale", "", 10.0, [-inf, inf], "", "Scale factor for broad Lorentzian peak"], |
---|
| 67 | ["lorentz_length", "Ang", 50.0, [-inf, inf], "", "Lorentzian screening length"], |
---|
| 68 | ["peak_pos", "1/Ang", 0.1, [-inf, inf], "", "Peak position in q"], |
---|
| 69 | ["lorentz_exp", "", 2.0, [-inf, inf], "", "Exponent of Lorentz function"], |
---|
[485aee2] | 70 | ] |
---|
[dcdf29d] | 71 | # pylint: enable=bad-whitespace, line-too-long |
---|
| 72 | |
---|
| 73 | def Iq(q, |
---|
| 74 | porod_scale=1.0e-5, |
---|
| 75 | porod_exp=3.0, |
---|
| 76 | lorentz_scale=10.0, |
---|
| 77 | lorentz_length=50.0, |
---|
| 78 | peak_pos=0.1, |
---|
| 79 | lorentz_exp=2.0): |
---|
| 80 | """ |
---|
| 81 | :param q: Input q-value |
---|
| 82 | :param porod_scale: Power law scale factor |
---|
| 83 | :param porod_exp: Exponent of power law |
---|
| 84 | :param lorentz_scale: Scale factor for broad Lorentzian peak |
---|
| 85 | :param lorentz_length: Lorentzian screening length |
---|
| 86 | :param peak_pos: Peak position in q |
---|
| 87 | :param lorentz_exp: Exponent of Lorentz function |
---|
| 88 | :return: Calculated intensity |
---|
| 89 | """ |
---|
[2c74c11] | 90 | z = abs(q - peak_pos) * lorentz_length |
---|
| 91 | with errstate(divide='ignore'): |
---|
| 92 | inten = (porod_scale / q ** porod_exp |
---|
| 93 | + lorentz_scale / (1 + z ** lorentz_exp)) |
---|
[3c56da87] | 94 | return inten |
---|
[eb69cce] | 95 | Iq.vectorized = True # Iq accepts an array of q values |
---|
[636adb6] | 96 | |
---|
[0bdddc2] | 97 | def random(): |
---|
[b297ba9] | 98 | """Return a random parameter set for the model.""" |
---|
[0bdddc2] | 99 | pars = dict( |
---|
| 100 | scale=1, |
---|
| 101 | porod_scale=10**np.random.uniform(-8, -5), |
---|
| 102 | porod_exp=np.random.uniform(1, 6), |
---|
| 103 | lorentz_scale=10**np.random.uniform(0.3, 6), |
---|
| 104 | lorentz_length=10**np.random.uniform(0, 2), |
---|
| 105 | peak_pos=10**np.random.uniform(-3, -1), |
---|
| 106 | lorentz_exp=np.random.uniform(1, 4), |
---|
| 107 | ) |
---|
| 108 | pars['lorentz_length'] /= pars['peak_pos'] |
---|
| 109 | pars['lorentz_scale'] *= pars['porod_scale'] / pars['peak_pos']**pars['porod_exp'] |
---|
| 110 | #pars['porod_scale'] = 0. |
---|
| 111 | return pars |
---|
| 112 | |
---|
[485aee2] | 113 | demo = dict(scale=1, background=0, |
---|
| 114 | porod_scale=1.0e-05, porod_exp=3, |
---|
| 115 | lorentz_scale=10, lorentz_length=50, peak_pos=0.1, lorentz_exp=2) |
---|