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

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since f57d123 was f57d123, checked in by pkienzle, 9 years ago

convert broad peak equations to latex

  • Property mode set to 100644
File size: 3.8 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
12The returned value is scaled to units of |cm^-1|, absolute scale.
13
14Definition
15----------
16
17The scattering intensity *I(q)* is calculated as
18
19.. math:
20
21    I(q) = \frac{A}{Q^n} + \frac{C}{1 + (Q\xi}^m} + B
22
23Here the peak position is related to the d-spacing as *Q0* = 2|pi| / *d0*.
24
25For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
26where the *q* vector is defined as
27
28.. math:
29
30    q = \sqrt{q_x^2 + q_y^2}
31
32=====================  =========  =============
33Parameter name          Units     Default value
34=====================  =========  =============
35lorentz_scale(=C)       None      10
36porod_scale  (=A)       None      1e-05
37lorentz_length (= |xi| )  |Ang|     50
38peak_pos  (=Q0)         |Ang^-1|  0.1
39porod_exp  (=n)         None      2
40lorentz_exp (=m)        None      3
41Background (=B)        |cm^-1|   0.1
42==================  ========  =============
43
44.. image:: img/image175.jpg
45
46*Figure. 1D plot using the default values (w/200 data point).*
47
48REFERENCE
49
50None.
51
52*2013/09/09 - Description reviewed by King, S and Parker, P.*
53
54"""
55
56import numpy as np
57from numpy import pi, inf, sin, cos, sqrt, exp, log, fabs
58
59name = "broad_peak"
60title = "Broad Lorentzian type peak on top of a power law decay"
61description = """\
62      I(q) = scale_p/pow(q,exponent)+scale_l/
63      (1.0 + pow((fabs(q-q_peak)*length_l),exponent_l) )+ background
64
65      List of default parameters:
66      porod_scale = Porod term scaling
67      porod_exp = Porod exponent
68      lorentz_scale = Lorentzian term scaling
69      lorentz_length = Lorentzian screening length [A]
70      peak_pos = peak location [1/A]
71      lorentz_exp = Lorentzian exponent
72      background = Incoherent background"""
73
74parameters = [
75#   [ "name", "units", default, [lower, upper], "type",
76#     "description" ],
77
78    [ "porod_scale", "", 1.0e-05, [-inf,inf], "",
79      "Power law scale factor" ],
80    [ "porod_exp", "", 3.0, [-inf,inf], "",
81      "Exponent of power law" ],
82    [ "lorentz_scale", "", 10.0, [-inf,inf], "",
83      "Scale factor for broad Lorentzian peak" ],
84    [ "lorentz_length", "Ang",  50.0, [-inf, inf], "",
85      "Lorentzian screening length" ],
86    [ "peak_pos", "1/Ang",  0.1, [-inf, inf], "",
87      "Peak postion in q" ],
88    [ "lorentz_exp", "",  2.0, [-inf, inf], "",
89      "exponent of Lorentz function" ],
90    ]
91
92
93def form_volume():
94    return 1
95
96def Iq(q, porod_scale, porod_exp, lorentz_scale, lorentz_length, peak_pos, lorentz_exp):
97    inten = porod_scale/pow(q,porod_exp) + lorentz_scale/(1.0 \
98        + pow((fabs(q-peak_pos)*lorentz_length),lorentz_exp))
99    return inten 
100
101# FOR VECTORIZED VERSION, UNCOMMENT THE NEXT LINE
102Iq.vectorized = True
103
104def Iqxy(qx, qy, porod_scale, porod_exp, lorentz_scale, lorentz_length, peak_pos, lorentz_exp):
105    return Iq(sqrt(qx**2 + qy**2), porod_scale, porod_exp, lorentz_scale, lorentz_length, peak_pos, lorentz_exp)
106
107# FOR VECTORIZED VERSION, UNCOMMENT THE NEXT LINE
108Iqxy.vectorized = True
109
110
111demo = dict(
112    scale=1, background=0,
113    porod_scale=1.0e-05, porod_exp=3,
114    lorentz_scale=10,lorentz_length=50, peak_pos=0.1, lorentz_exp=2,
115    )
116oldname = "BroadPeakModel"
117oldpars = dict(porod_scale='scale_p', porod_exp='exponent_p', 
118        lorentz_scale='scale_l', lorentz_length='length_l', peak_pos='q_peak', 
119        lorentz_exp='exponent_l', scale=None)
Note: See TracBrowser for help on using the repository browser.