File: lorentz.py

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (65 lines) | stat: -rw-r--r-- 1,542 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
r"""
Lorentz (Ornstein-Zernicke Model)

Definition
----------

The Ornstein-Zernicke model is defined by

.. math:: I(q)=\frac{\text{scale}}{1+(qL)^2}+\text{background}

The parameter $L$ is the screening length *cor_length*.

For 2D data the scattering intensity is calculated in the same way as 1D,
where the $q$ vector is defined as

.. math:: q=\sqrt{q_x^2 + q_y^2}


References
----------

#. 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.

Authorship and Verification
----------------------------

* **Author:**
* **Last Modified by:**
* **Last Reviewed by:**
"""

import numpy as np
from numpy import inf

name = "lorentz"
title = "Ornstein-Zernicke correlation length model"
description = """
Model that evaluates a Lorentz (Ornstein-Zernicke) model.

I(q) = scale/( 1 + (q*L)^2 ) + bkd

The model has three parameters:
    length = screening Length
    scale = scale factor
    background = incoherent background
"""
category = "shape-independent"

#             ["name", "units", default, [lower, upper], "type","description"],
parameters = [["cor_length", "Ang", 50.0, [0, inf], "", "Screening length"],]

source = ["lorentz.c"] 

def random():
    """Return a random parameter set for the model."""
    pars = dict(
        #background=0,
        scale=10**np.random.uniform(1, 4),
        cor_length=10**np.random.uniform(0, 3),
    )
    return pars

# parameters for unit tests
tests = [[{'cor_length': 250}, 0.01, 0.138931]]