source: sasmodels/sasmodels/models/power_law.py @ 7f47777

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

delint

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