source: sasmodels/sasmodels/models/linear_pearls.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: 3.3 KB
Line 
1r"""
2This model provides the form factor for $N$ spherical pearls of radius $R$
3linearly joined by short strings (or segment length or edge separation)
4$l$ $(= A - 2R)$. $A$ is the center-to-center pearl separation distance.
5The thickness of each string is assumed to be negligible.
6
7.. figure:: img/linear_pearls_geometry.jpg
8
9
10Definition
11----------
12
13The output of the scattering intensity function for the linear_pearls model
14is given by (Dobrynin, 1996)
15
16.. math::
17
18    P(Q) = \frac{\text{scale}}{V}\left[ m_{p}^2
19    \left(N+2\sum_{n-1}^{N-1}(N-n)\frac{\sin(qnl)}{qnl}\right)
20    \left( 3\frac{\sin(qR)-qR\cos(qR)}{(qr)^3}\right)^2\right]
21
22where the mass $m_p$ is $(SLD_{pearl}-SLD_{solvent})*(volume\ of\ N\ pearls)$.
23V is the total volume.
24
25The 2D scattering intensity is the same as P(q) above,
26regardless of the orientation of the q vector.
27
28References
29----------
30
31.. [#] A V Dobrynin, M Rubinstein and S P Obukhov, *Macromol.*, 29 (1996) 2974-2979
32
33Authorship and Verification
34----------------------------
35
36* **Author:**
37* **Last Modified by:**
38* **Last Reviewed by:**
39"""
40
41import numpy as np
42from numpy import inf
43
44name = "linear_pearls"
45title = "Linear pearls model of scattering from spherical pearls."
46description = """
47    Calculate form factor for Pearl Necklace Model
48    [Macromol. 1996, 29, 2974-2979]
49    Parameters:
50
51    sld_pearl: the SLD of the pearl spheres
52    sld_solv: the SLD of the solvent
53    num_pearls: number of the pearls
54    radius: the radius of a pearl
55    edge_separation: the length of string segment; surface to surface
56    """
57category = "shape:sphere"
58
59# pylint: disable=bad-whitespace, line-too-long
60#            ["name", "units", default, [lower, upper], "type", "description"],
61parameters = [
62    ["radius",      "Ang",       80.0, [0, inf],     "", "Radius of the pearls"],
63    ["edge_sep",    "Ang",      350.0, [0, inf],     "", "Length of the string segment - surface to surface"],
64    ["num_pearls",  "",           3.0, [1, inf],     "", "Number of the pearls"],
65    ["sld",   "1e-6/Ang^2", 1.0, [-inf, inf],  "sld", "SLD of the pearl spheres"],
66    ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf],  "sld", "SLD of the solvent"],
67    ]
68# pylint: enable=bad-whitespace, line-too-long
69single = False
70
71source = ["lib/sas_3j1x_x.c", "linear_pearls.c"]
72
73def random():
74    """Return a random parameter set for the model."""
75    radius = 10**np.random.uniform(1, 3) # 1 - 1000
76    edge_sep = 10**np.random.uniform(0, 3)  # 1 - 1000
77    num_pearls = np.round(10**np.random.uniform(0.3, 3)) # 2 - 1000
78    pars = dict(
79        radius=radius,
80        edge_sep=edge_sep,
81        num_pearls=num_pearls,
82    )
83    return pars
84
85_ = """
86Tests temporarily disabled, until single-double precision accuracy issue solved.
87
88tests = [
89    # Accuracy tests based on content in test/utest_model_pearlnecklace.py
90    [{'radius':      20.0,
91      'num_pearls':   2.0,
92      'sld':    1.0,
93      'sld_solvent':  6.3,
94      'edge_sep':   400.0,
95     }, 0.001, 185.135],
96
97    # Additional tests with larger range of parameters
98    [{'radius':     120.0,
99      'num_pearls':   5.0,
100      'sld':    2.0,
101      'sld_solvent':  2.3,
102      'edge_sep':   100.0,
103     }, 0.01, 45.4984],
104
105    [{'radius':       7.0,
106      'num_pearls':   2.0,
107      'sld':   10.0,
108      'sld_solvent': 99.3,
109      'edge_sep':    20.0,
110     }, 1.0, 0.632811],
111    ]
112"""
Note: See TracBrowser for help on using the repository browser.