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

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since d189429 was 2f0c07d, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

make figure names regular (geometry, angle_definition, angle_projection)

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[636adb6]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
[3c56da87]8The d-spacing corresponding to the broad peak is a characteristic distance
9between the scattering inhomogeneities (such as in lamellar, cylindrical, or
[636adb6]10spherical morphologies, or for bicontinuous structures).
11
12Definition
13----------
14
[eb69cce]15The scattering intensity $I(q)$ is calculated as
[636adb6]16
[eb69cce]17.. math::
[f57d123]18
[eb69cce]19    I(q) = \frac{A}{q^n} + \frac{C}{1 + (q\xi)^m} + B
[636adb6]20
[eb69cce]21Here the peak position is related to the d-spacing as $q_o = 2\pi / d_o$.
[636adb6]22
[eb69cce]23For 2D data the scattering intensity is calculated in the same way as 1D,
24where the $q$ vector is defined as
[636adb6]25
[eb69cce]26.. math::
[f57d123]27
28    q = \sqrt{q_x^2 + q_y^2}
[636adb6]29
30
[eb69cce]31References
32----------
[636adb6]33
34None.
35
36*2013/09/09 - Description reviewed by King, S and Parker, P.*
37
38"""
39
[3c56da87]40from numpy import inf, sqrt
[636adb6]41
42name = "broad_peak"
43title = "Broad Lorentzian type peak on top of a power law decay"
44description = """\
45      I(q) = scale_p/pow(q,exponent)+scale_l/
46      (1.0 + pow((fabs(q-q_peak)*length_l),exponent_l) )+ background
47
48      List of default parameters:
49      porod_scale = Porod term scaling
50      porod_exp = Porod exponent
51      lorentz_scale = Lorentzian term scaling
52      lorentz_length = Lorentzian screening length [A]
53      peak_pos = peak location [1/A]
54      lorentz_exp = Lorentzian exponent
55      background = Incoherent background"""
[485aee2]56category = "shape-independent"
[636adb6]57
[dcdf29d]58# pylint: disable=bad-whitespace, line-too-long
[485aee2]59#             ["name", "units", default, [lower, upper], "type", "description"],
[dcdf29d]60parameters = [["porod_scale",    "",  1.0e-05, [-inf, inf], "", "Power law scale factor"],
61              ["porod_exp",      "",      3.0, [-inf, inf], "", "Exponent of power law"],
62              ["lorentz_scale",  "",     10.0, [-inf, inf], "", "Scale factor for broad Lorentzian peak"],
63              ["lorentz_length", "Ang",  50.0, [-inf, inf], "", "Lorentzian screening length"],
64              ["peak_pos",       "1/Ang", 0.1, [-inf, inf], "", "Peak position in q"],
65              ["lorentz_exp",    "",      2.0, [-inf, inf], "", "Exponent of Lorentz function"],
[485aee2]66             ]
[dcdf29d]67# pylint: enable=bad-whitespace, line-too-long
68
69def Iq(q,
70       porod_scale=1.0e-5,
71       porod_exp=3.0,
72       lorentz_scale=10.0,
73       lorentz_length=50.0,
74       peak_pos=0.1,
75       lorentz_exp=2.0):
76    """
77    :param q:              Input q-value
78    :param porod_scale:    Power law scale factor
79    :param porod_exp:      Exponent of power law
80    :param lorentz_scale:  Scale factor for broad Lorentzian peak
81    :param lorentz_length: Lorentzian screening length
82    :param peak_pos:       Peak position in q
83    :param lorentz_exp:    Exponent of Lorentz function
84    :return:               Calculated intensity
85    """
[636adb6]86
[485aee2]87    inten = (porod_scale / q ** porod_exp + lorentz_scale
88             / (1.0 + (abs(q - peak_pos) * lorentz_length) ** lorentz_exp))
[3c56da87]89    return inten
[eb69cce]90Iq.vectorized = True  # Iq accepts an array of q values
[636adb6]91
[f734e7d]92def Iqxy(qx, qy, *args):
[dcdf29d]93    """
94    :param qx:   Input q_x-value
95    :param qy:   Input q_y-value
96    :param args: Remaining arguments
97    :return:     2D-Intensity
98    """
[485aee2]99    return Iq(sqrt(qx ** 2 + qy ** 2), *args)
[636adb6]100
[dcdf29d]101Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values
[636adb6]102
[485aee2]103demo = dict(scale=1, background=0,
104            porod_scale=1.0e-05, porod_exp=3,
105            lorentz_scale=10, lorentz_length=50, peak_pos=0.1, lorentz_exp=2)
[3c56da87]106
[636adb6]107oldname = "BroadPeakModel"
[3c56da87]108oldpars = dict(porod_scale='scale_p', porod_exp='exponent_p',
[485aee2]109               lorentz_scale='scale_l', lorentz_length='length_l', peak_pos='q_peak',
110               lorentz_exp='exponent_l', scale=None)
Note: See TracBrowser for help on using the repository browser.