source: sasmodels/sasmodels/models/peak_lorentz.py @ 14ba6f6

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

Fixing unit test

  • Property mode set to 100644
File size: 1.8 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 a HWHM (half-width half-maximum) of B.
14
15For 2D data the scattering intensity is calculated in the same way as 1D,
16where the $q$ vector is defined as
17
18.. math::
19
20    q = \sqrt{q_x^2 + q_y^2}
21
22
23.. figure:: img/peak_lorentz_1d.jpg
24
25    1D plot using the default values (w/200 data point).
26
27References
28----------
29
30None.
31
32"""
33
34from numpy import inf, sqrt
35
36name = "peak_lorentz"
37title = "A Lorentzian peak on a flat background"
38description = """\
39      Class that evaluates a lorentzian  shaped peak.
40
41        F(q) = scale/(1+[(q-q0)/B]^2 ) + background
42
43        The model has three parameters:
44            scale     =  scale
45            peak_pos        =  peak position
46            peak_hwhm        =  half-width-half-maximum of peak
47            background=  incoherent background"""
48
49category = "shape-independent"
50
51#             ["name", "units", default, [lower, upper], "type", "description"],
52parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak postion in q"],
53              ["peak_hwhm", "1/Ang", 0.005, [-inf, inf], "", "HWHM of peak"],
54             ]
55
56def Iq(q, peak_pos, peak_hwhm):
57    inten = (1/(1+((q-peak_pos)/peak_hwhm)**2))
58    return inten
59Iq.vectorized = True  # Iq accepts an array of q values
60
61def Iqxy(qx, qy, *args):
62    return Iq(sqrt(qx ** 2 + qy ** 2), *args)
63Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values
64
65
66demo = dict(scale=100, background=1.0,
67            peak_pos=0.05, peak_hwhm=0.005)
68
69oldname = "PeakLorentzModel"
70oldpars = dict(peak_pos='q0', peak_hwhm='B')
71
72tests = [[{'scale':100.0, 'background':1.0}, 0.001, 2.0305]]
Note: See TracBrowser for help on using the repository browser.