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