source: sasmodels/sasmodels/models/broad_peak.py @ d507c3a

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since d507c3a was dcdf29d, checked in by piotr, 8 years ago

pylint cleanup

  • Property mode set to 100644
File size: 3.9 KB
Line 
1r"""
2This model calculates an empirical functional form for SAS data characterized
3by a broad scattering peak. Many SAS spectra are characterized by a broad peak
4even though they are from amorphous soft materials. For example, soft systems
5that show a SAS peak include copolymers, polyelectrolytes, multiphase systems,
6layered structures, etc.
7
8The d-spacing corresponding to the broad peak is a characteristic distance
9between the scattering inhomogeneities (such as in lamellar, cylindrical, or
10spherical morphologies, or for bicontinuous structures).
11
12Definition
13----------
14
15The scattering intensity $I(q)$ is calculated as
16
17.. math::
18
19    I(q) = \frac{A}{q^n} + \frac{C}{1 + (q\xi)^m} + B
20
21Here the peak position is related to the d-spacing as $q_o = 2\pi / d_o$.
22
23For 2D data the scattering intensity is calculated in the same way as 1D,
24where the $q$ vector is defined as
25
26.. math::
27
28    q = \sqrt{q_x^2 + q_y^2}
29
30
31.. figure:: img/broad_peak_1d.jpg
32
33    1D plot using the default values (w/200 data point).
34
35References
36----------
37
38None.
39
40*2013/09/09 - Description reviewed by King, S and Parker, P.*
41
42"""
43
44from numpy import inf, sqrt
45
46name = "broad_peak"
47title = "Broad Lorentzian type peak on top of a power law decay"
48description = """\
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"""
60category = "shape-independent"
61
62# pylint: disable=bad-whitespace, line-too-long
63#             ["name", "units", default, [lower, upper], "type", "description"],
64parameters = [["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"],
70             ]
71# pylint: enable=bad-whitespace, line-too-long
72
73def 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    """
90
91    inten = (porod_scale / q ** porod_exp + lorentz_scale
92             / (1.0 + (abs(q - peak_pos) * lorentz_length) ** lorentz_exp))
93    return inten
94Iq.vectorized = True  # Iq accepts an array of q values
95
96def Iqxy(qx, qy, *args):
97    """
98    :param qx:   Input q_x-value
99    :param qy:   Input q_y-value
100    :param args: Remaining arguments
101    :return:     2D-Intensity
102    """
103    return Iq(sqrt(qx ** 2 + qy ** 2), *args)
104
105Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values
106
107demo = dict(scale=1, background=0,
108            porod_scale=1.0e-05, porod_exp=3,
109            lorentz_scale=10, lorentz_length=50, peak_pos=0.1, lorentz_exp=2)
110
111oldname = "BroadPeakModel"
112oldpars = dict(porod_scale='scale_p', porod_exp='exponent_p',
113               lorentz_scale='scale_l', lorentz_length='length_l', peak_pos='q_peak',
114               lorentz_exp='exponent_l', scale=None)
Note: See TracBrowser for help on using the repository browser.