source: sasmodels/sasmodels/models/lorentz.py @ c1e44e5

Last change on this file since c1e44e5 was c1e44e5, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

Add local link to source files. Refs #1263.

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[77ad412]1r"""
2Lorentz (Ornstein-Zernicke Model)
3
4Definition
5----------
6
7The Ornstein-Zernicke model is defined by
8
[eb69cce]9.. math:: I(q)=\frac{\text{scale}}{1+(qL)^2}+\text{background}
[77ad412]10
[eb69cce]11The parameter $L$ is the screening length *cor_length*.
[77ad412]12
[eb69cce]13For 2D data the scattering intensity is calculated in the same way as 1D,
[d138d43]14where the $q$ vector is defined as
[77ad412]15
16.. math:: q=\sqrt{q_x^2 + q_y^2}
17
[d138d43]18
[eb69cce]19References
20----------
[77ad412]21
[0507e09]22.. [#] L.S. Qrnstein and F. Zernike, *Proc. Acad. Sci. Amsterdam* 17, 793 (1914), and *Z. Phys.* 19, 134 (1918), and 27, 761 {1926); referred to as QZ.
23
24Authorship and Verification
25----------------------------
26
[c1e44e5]27* **Author:**
28* **Last Modified by:**
29* **Last Reviewed by:**
30"""
[77ad412]31
[2d81cfe]32import numpy as np
[77ad412]33from numpy import inf
34
35name = "lorentz"
36title = "Ornstein-Zernicke correlation length model"
37description = """
38Model that evaluates a Lorentz (Ornstein-Zernicke) model.
[404ebbd]39
[77ad412]40I(q) = scale/( 1 + (q*L)^2 ) + bkd
[404ebbd]41
42The model has three parameters:
43    length = screening Length
44    scale = scale factor
45    background = incoherent background
[77ad412]46"""
47category = "shape-independent"
48
49#             ["name", "units", default, [lower, upper], "type","description"],
50parameters = [["cor_length", "Ang", 50.0, [0, inf], "", "Screening length"],]
51
52Iq = """
53    double denominator = 1 + (q*cor_length)*(q*cor_length);
54    return 1/denominator;
55"""
56
[404ebbd]57def random():
[b297ba9]58    """Return a random parameter set for the model."""
[404ebbd]59    pars = dict(
60        #background=0,
61        scale=10**np.random.uniform(1, 4),
62        cor_length=10**np.random.uniform(0, 3),
63    )
64    return pars
65
[77ad412]66# parameters for demo
[705bcb1]67demo = dict(scale=1.0, background=0.0, cor_length=50.0)
[77ad412]68
[66ebdd6]69# parameters for unit tests
[6dd90c1]70tests = [[{'cor_length': 250}, 0.01, 0.138931]]
Note: See TracBrowser for help on using the repository browser.