source: sasmodels/sasmodels/models/peak_lorentz.py @ 58c3367

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

implicit Iqxy; fix divide by 0 for q=0

  • Property mode set to 100644
File size: 1.6 KB
Line 
1r"""
2This model describes a Lorentzian shaped peak on a flat background.
3
4Definition
5----------
6
7The scattering intensity $I(q)$ is calculated as
8
9.. math::
10
11    I(q) = \frac{scale}{\bigl(1+\bigl(\frac{q-q_0}{B}\bigr)^2\bigr)} + background
12
13with the peak having height of $I_0$ centered at $q_0$ and having
14a HWHM (half-width half-maximum) of B.
15
16For 2D data the scattering intensity is calculated in the same way as 1D,
17where the $q$ vector is defined as
18
19.. math::
20
21    q = \sqrt{q_x^2 + q_y^2}
22
23
24References
25----------
26
27None.
28
29"""
30
31from numpy import inf
32
33name = "peak_lorentz"
34title = "A Lorentzian peak on a flat background"
35description = """\
36      Class that evaluates a lorentzian  shaped peak.
37
38        F(q) = scale/(1+[(q-q0)/B]^2 ) + background
39
40        The model has three parameters:
41            scale     =  scale
42            peak_pos        =  peak position
43            peak_hwhm        =  half-width-half-maximum of peak
44            background=  incoherent background"""
45
46category = "shape-independent"
47
48#             ["name", "units", default, [lower, upper], "type", "description"],
49parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak postion in q"],
50              ["peak_hwhm", "1/Ang", 0.005, [-inf, inf], "", "HWHM of peak"],
51             ]
52
53def Iq(q, peak_pos, peak_hwhm):
54    """
55        Return I(q)
56    """
57    inten = (1/(1+((q-peak_pos)/peak_hwhm)**2))
58    return inten
59Iq.vectorized = True  # Iq accepts an array of q values
60
61demo = dict(scale=100, background=1.0,
62            peak_pos=0.05, peak_hwhm=0.005)
63
64tests = [[{'scale':100.0, 'background':1.0}, 0.001, 2.0305]]
Note: See TracBrowser for help on using the repository browser.