source: sasmodels/sasmodels/models/mono_gauss_coil.py @ 404ebbd

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 404ebbd was 404ebbd, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

tuned random model generation for more models

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#mono_gauss_coil model
2#conversion of DebyeModel.py
3#converted by Steve King, Mar 2016
4r"""
5This Debye Gaussian coil model strictly describes the scattering from
6*monodisperse* polymer chains in theta solvents or polymer melts, conditions
7under which the distances between segments follow a Gaussian distribution.
8Provided the number of segments is large (ie, high molecular weight polymers)
9the single-chain form factor P(Q) is that described by Debye (1947).
10
11To describe the scattering from *polydisperse* polymer chains see the
12:ref:`poly-gauss-coil` model.
13
14Definition
15----------
16
17.. math::
18
19     I(q) = \text{scale} \cdot I_0 \cdot P(q) + \text{background}
20
21where
22
23.. math::
24
25     I_0 &= \phi_\text{poly} \cdot V
26            \cdot (\rho_\text{poly} - \rho_\text{solv})^2
27
28     P(q) &= 2 [\exp(-Z) + Z - 1] / Z^2
29
30     Z &= (q R_g)^2
31
32     V &= M / (N_A \delta)
33
34Here, $\phi_\text{poly}$ is the volume fraction of polymer, $V$ is the
35volume of a polymer coil, *M* is the molecular weight of the polymer,
36$N_A$ is Avogadro's Number, $\delta$ is the bulk density of the polymer,
37$\rho_\text{poly}$ is the sld of the polymer, $\rho\text{solv}$ is the
38sld of the solvent, and $R_g$ is the radius of gyration of the polymer coil.
39
40The 2D scattering intensity is calculated in the same way as the 1D,
41but where the *q* vector is redefined as
42
43.. math::
44
45    q = \sqrt{q_x^2 + q_y^2}
46
47References
48----------
49
50P Debye, *J. Phys. Colloid. Chem.*, 51 (1947) 18.
51
52R J Roe, *Methods of X-Ray and Neutron Scattering in Polymer Science*,
53Oxford University Press, New York (2000).
54
55http://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_28.pdf
56"""
57
58from numpy import inf, exp, errstate
59
60name = "mono_gauss_coil"
61title = "Scattering from monodisperse polymer coils"
62
63description = """
64    Evaluates the scattering from
65    monodisperse polymer chains.
66    """
67category = "shape-independent"
68
69# pylint: disable=bad-whitespace, line-too-long
70#   ["name", "units", default, [lower, upper], "type", "description"],
71parameters = [
72    ["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"],
73    ["rg", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"],
74    ]
75# pylint: enable=bad-whitespace, line-too-long
76
77# NB: Scale and Background are implicit parameters on every model
78def Iq(q, i_zero, rg):
79    # pylint: disable = missing-docstring
80    z = (q * rg)**2
81
82    with errstate(invalid='ignore'):
83        inten = (i_zero * 2.0) * (exp(-z) + z - 1.0)/z**2
84        inten[q == 0] = i_zero
85    return inten
86Iq.vectorized = True # Iq accepts an array of q values
87
88def random():
89    import numpy as np
90    rg = 10**np.random.uniform(0, 4)
91    #rg = 1e3
92    pars = dict(
93        #scale=1, background=0,
94        i_zero=1e7, # i_zero is a simple scale
95        rg=rg,
96    )
97    return pars
98
99demo = dict(scale=1.0, i_zero=70.0, rg=75.0, background=0.0)
100
101# these unit test values taken from SasView 3.1.2
102tests = [
103    [{'scale': 1.0, 'i_zero': 70.0, 'rg': 75.0, 'background': 0.0},
104     [0.0106939, 0.469418], [57.1241, 0.112859]],
105    ]
Note: See TracBrowser for help on using the repository browser.