source: sasmodels/sasmodels/models/power_law.py @ ec45c4f

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

remove oldname/oldpars from new models

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#power_law model
2#conversion of PowerLawAbsModel.py
3#converted by Steve King, Dec 2015
4
5r"""
6This model calculates a simple power law with a flat background.
7
8Definition
9----------
10
11.. math::
12
13    I(q) = \text{scale} \cdot q^{-\text{power}} + \text{background}
14
15Note the minus sign in front of the exponent. The exponent *power*
16should therefore be entered as a **positive** number for fitting.
17
18Also note that unlike many other models, *scale* in this model
19is NOT explicitly related to a volume fraction. Be careful if
20combining this model with other models.
21
22
23References
24----------
25
26None.
27"""
28
29from numpy import inf, sqrt
30
31name = "power_law"
32title = "Simple power law with a flat background"
33
34description = """
35    Evaluates the function
36    I(q) = scale * q^(-power) + background
37    NB: enter power as a positive number!
38    """
39category = "shape-independent"
40
41#             ["name", "units", default, [lower, upper], "type", "description"],
42parameters = [["power", "", 4.0, [-inf, inf], "", "Power law exponent"]]
43
44# NB: Scale and Background are implicit parameters on every model
45def Iq(q, power):
46    # pylint: disable=missing-docstring
47    inten = (q**-power)
48    return inten
49Iq.vectorized = True  # Iq accepts an array of q values
50
51def Iqxy(qx, qy, *args):
52    # pylint: disable=missing-docstring
53    return Iq(sqrt(qx ** 2 + qy ** 2), *args)
54Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values
55
56demo = dict(scale=1.0,
57            power=4.0,
58            background=0.0)
59
60tests = [
61    [{'scale': 1.0, 'power': 4.0, 'background' : 0.0},
62     [0.0106939, 0.469418], [7.64644e+07, 20.5949]],
63    ]
Note: See TracBrowser for help on using the repository browser.