# source:sasmodels/sasmodels/models/linear_pearls.py@0507e09

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0507e09 was 0507e09, checked in by smk78, 17 months ago

• Property mode set to 100644
File size: 3.6 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
33Source
34------
35
36linear_pearls.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/linear_pearls.py>_
37
38linear_pearls.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/linear_pearls.c>_
39
40Authorship and Verification
41----------------------------
42
43* **Author:**
45* **Last Reviewed by:**
46* **Source added by :** Steve King **Date:** March 25, 2019"""
47
48import numpy as np
49from numpy import inf
50
51name = "linear_pearls"
52title = "Linear pearls model of scattering from spherical pearls."
53description = """
54    Calculate form factor for Pearl Necklace Model
55    [Macromol. 1996, 29, 2974-2979]
56    Parameters:
57
58    sld_pearl: the SLD of the pearl spheres
59    sld_solv: the SLD of the solvent
60    num_pearls: number of the pearls
62    edge_separation: the length of string segment; surface to surface
63    """
64category = "shape:sphere"
65
67#            ["name", "units", default, [lower, upper], "type", "description"],
68parameters = [
70    ["edge_sep",    "Ang",      350.0, [0, inf],     "", "Length of the string segment - surface to surface"],
71    ["num_pearls",  "",           3.0, [1, inf],     "", "Number of the pearls"],
72    ["sld",   "1e-6/Ang^2", 1.0, [-inf, inf],  "sld", "SLD of the pearl spheres"],
73    ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf],  "sld", "SLD of the solvent"],
74    ]
76single = False
77
78source = ["lib/sas_3j1x_x.c", "linear_pearls.c"]
79
80def random():
81    """Return a random parameter set for the model."""
82    radius = 10**np.random.uniform(1, 3) # 1 - 1000
83    edge_sep = 10**np.random.uniform(0, 3)  # 1 - 1000
84    num_pearls = np.round(10**np.random.uniform(0.3, 3)) # 2 - 1000
85    pars = dict(
87        edge_sep=edge_sep,
88        num_pearls=num_pearls,
89    )
90    return pars
91
92_ = """
93Tests temporarily disabled, until single-double precision accuracy issue solved.
94
95tests = [
96    # Accuracy tests based on content in test/utest_model_pearlnecklace.py
98      'num_pearls':   2.0,
99      'sld':    1.0,
100      'sld_solvent':  6.3,
101      'edge_sep':   400.0,
102     }, 0.001, 185.135],
103
104    # Additional tests with larger range of parameters
106      'num_pearls':   5.0,
107      'sld':    2.0,
108      'sld_solvent':  2.3,
109      'edge_sep':   100.0,
110     }, 0.01, 45.4984],
111