[2f6f4c3] | 1 | r""" |
---|
| 2 | This model describes a Lorentzian shaped peak on a flat background. |
---|
| 3 | |
---|
| 4 | Definition |
---|
| 5 | ---------- |
---|
| 6 | |
---|
| 7 | The 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 | |
---|
[04b0b30] | 13 | with the peak having height of $I_0$ centered at $q_0$ and having |
---|
| 14 | a HWHM (half-width half-maximum) of B. |
---|
[2f6f4c3] | 15 | |
---|
| 16 | For 2D data the scattering intensity is calculated in the same way as 1D, |
---|
| 17 | where the $q$ vector is defined as |
---|
| 18 | |
---|
| 19 | .. math:: |
---|
| 20 | |
---|
| 21 | q = \sqrt{q_x^2 + q_y^2} |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | References |
---|
| 25 | ---------- |
---|
| 26 | |
---|
| 27 | None. |
---|
| 28 | |
---|
| 29 | """ |
---|
| 30 | |
---|
[2c74c11] | 31 | from numpy import inf |
---|
[2f6f4c3] | 32 | |
---|
| 33 | name = "peak_lorentz" |
---|
| 34 | title = "A Lorentzian peak on a flat background" |
---|
| 35 | description = """\ |
---|
| 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 | |
---|
| 46 | category = "shape-independent" |
---|
| 47 | |
---|
| 48 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
| 49 | parameters = [["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 | |
---|
| 53 | def Iq(q, peak_pos, peak_hwhm): |
---|
[04b0b30] | 54 | """ |
---|
| 55 | Return I(q) |
---|
| 56 | """ |
---|
[2f6f4c3] | 57 | inten = (1/(1+((q-peak_pos)/peak_hwhm)**2)) |
---|
| 58 | return inten |
---|
| 59 | Iq.vectorized = True # Iq accepts an array of q values |
---|
| 60 | |
---|
| 61 | demo = dict(scale=100, background=1.0, |
---|
| 62 | peak_pos=0.05, peak_hwhm=0.005) |
---|
| 63 | |
---|
[14ba6f6] | 64 | tests = [[{'scale':100.0, 'background':1.0}, 0.001, 2.0305]] |
---|