1 | r""" |
---|
2 | Definition |
---|
3 | ---------- |
---|
4 | |
---|
5 | This model is a trivial extension of the CoreShell function to a larger number |
---|
6 | of shells. The scattering length density profile for the default sld values |
---|
7 | (w/ 4 shells). |
---|
8 | |
---|
9 | .. figure:: img/core_multi_shell_sld_default_profile.jpg |
---|
10 | |
---|
11 | SLD profile of the core_multi_shell object from the center of sphere out |
---|
12 | for the default SLDs.* |
---|
13 | |
---|
14 | The 2D scattering intensity is the same as $P(q)$ above, regardless of the |
---|
15 | orientation of the $\vec q$ vector which is defined as |
---|
16 | |
---|
17 | .. math:: |
---|
18 | |
---|
19 | q = \sqrt{q_x^2 + q_y^2} |
---|
20 | |
---|
21 | .. note:: **Be careful!** The SLDs and scale can be highly correlated. Hold as |
---|
22 | many of these parameters fixed as possible. |
---|
23 | |
---|
24 | .. note:: The outer most radius (= *radius* + *thickness*) is used as the |
---|
25 | effective radius for $S(Q)$ when $P(Q)*S(Q)$ is applied. |
---|
26 | |
---|
27 | For information about polarised and magnetic scattering, see |
---|
28 | the :ref:`magnetism` documentation. |
---|
29 | |
---|
30 | Our model uses the form factor calculations implemented in a c-library provided |
---|
31 | by the NIST Center for Neutron Research (Kline, 2006) [#kline]_. |
---|
32 | |
---|
33 | References |
---|
34 | ---------- |
---|
35 | |
---|
36 | .. [#] See the :ref:`core-shell-sphere` model documentation. |
---|
37 | .. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 |
---|
38 | .. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and |
---|
39 | Neutron Scattering*, Plenum Press, New York, 1987. |
---|
40 | |
---|
41 | Source |
---|
42 | ------ |
---|
43 | |
---|
44 | `core_multi_shell.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/core_multi_shell.py>`_ |
---|
45 | |
---|
46 | `core_multi_shell.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/core_multi_shell.c>`_ |
---|
47 | |
---|
48 | Authorship and Verification |
---|
49 | ---------------------------- |
---|
50 | |
---|
51 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
52 | * **Last Modified by:** Paul Kienzle **Date:** September 12, 2016 |
---|
53 | * **Last Reviewed by:** Paul Kienzle **Date:** September 12, 2016 |
---|
54 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
55 | """ |
---|
56 | from __future__ import division |
---|
57 | |
---|
58 | import numpy as np |
---|
59 | from numpy import inf |
---|
60 | |
---|
61 | name = "core_multi_shell" |
---|
62 | title = "This model provides the scattering from a spherical core with 1 to 4 \ |
---|
63 | concentric shell structures. The SLDs of the core and each shell are \ |
---|
64 | individually specified." |
---|
65 | |
---|
66 | description = """\ |
---|
67 | Form factor for a core muti-shell (up to 4) sphere normalized by the volume. |
---|
68 | Each shell can have a unique thickness and sld. |
---|
69 | |
---|
70 | background:background, |
---|
71 | rad_core0: radius of sphere(core) |
---|
72 | thick_shell#:the thickness of the shell# |
---|
73 | sld_core0: the SLD of the sphere |
---|
74 | sld_solv: the SLD of the solvent |
---|
75 | sld_shell: the SLD of the shell# |
---|
76 | A_shell#: the coefficient in the exponential function |
---|
77 | |
---|
78 | |
---|
79 | scale: 1.0 if data is on absolute scale |
---|
80 | volfraction: volume fraction of spheres |
---|
81 | radius: the radius of the core |
---|
82 | sld: the SLD of the core |
---|
83 | thick_shelli: the thickness of the i'th shell from the core |
---|
84 | sld_shelli: the SLD of the i'th shell from the core |
---|
85 | sld_solvent: the SLD of the solvent |
---|
86 | background: incoherent background |
---|
87 | |
---|
88 | """ |
---|
89 | |
---|
90 | category = "shape:sphere" |
---|
91 | |
---|
92 | |
---|
93 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
94 | parameters = [["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", |
---|
95 | "Core scattering length density"], |
---|
96 | ["radius", "Ang", 200., [0, inf], "volume", |
---|
97 | "Radius of the core"], |
---|
98 | ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", |
---|
99 | "Solvent scattering length density"], |
---|
100 | ["n", "", 1, [0, 10], "volume", |
---|
101 | "number of shells"], |
---|
102 | ["sld[n]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", |
---|
103 | "scattering length density of shell k"], |
---|
104 | ["thickness[n]", "Ang", 40., [0, inf], "volume", |
---|
105 | "Thickness of shell k"], |
---|
106 | ] |
---|
107 | |
---|
108 | source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] |
---|
109 | have_Fq = True |
---|
110 | effective_radius_type = ["outer radius", "core radius"] |
---|
111 | |
---|
112 | def random(): |
---|
113 | """Return a random parameter set for the model.""" |
---|
114 | num_shells = np.minimum(np.random.poisson(3)+1, 10) |
---|
115 | total_radius = 10**np.random.uniform(1.7, 4) |
---|
116 | thickness = np.random.exponential(size=num_shells+1) |
---|
117 | thickness *= total_radius/np.sum(thickness) |
---|
118 | pars = dict( |
---|
119 | #background=0, |
---|
120 | n=num_shells, |
---|
121 | radius=thickness[0], |
---|
122 | ) |
---|
123 | for k, v in enumerate(thickness[1:]): |
---|
124 | pars['thickness%d'%(k+1)] = v |
---|
125 | return pars |
---|
126 | |
---|
127 | def profile(sld_core, radius, sld_solvent, n, sld, thickness): |
---|
128 | """ |
---|
129 | Returns the SLD profile *r* (Ang), and *rho* (1e-6/Ang^2). |
---|
130 | """ |
---|
131 | n = int(n+0.5) |
---|
132 | z = [] |
---|
133 | rho = [] |
---|
134 | |
---|
135 | # add in the core |
---|
136 | z.append(0) |
---|
137 | rho.append(sld_core) |
---|
138 | z.append(radius) |
---|
139 | rho.append(sld_core) |
---|
140 | |
---|
141 | # add in the shells |
---|
142 | for k in range(int(n)): |
---|
143 | # Left side of each shells |
---|
144 | z.append(z[-1]) |
---|
145 | rho.append(sld[k]) |
---|
146 | z.append(z[-1] + thickness[k]) |
---|
147 | rho.append(sld[k]) |
---|
148 | # add in the solvent |
---|
149 | z.append(z[-1]) |
---|
150 | rho.append(sld_solvent) |
---|
151 | z.append(z[-1]*1.25) |
---|
152 | rho.append(sld_solvent) |
---|
153 | |
---|
154 | return np.asarray(z), np.asarray(rho) |
---|
155 | |
---|
156 | demo = dict(sld_core=6.4, |
---|
157 | radius=60, |
---|
158 | sld_solvent=6.4, |
---|
159 | n=2, |
---|
160 | sld=[2.0, 3.0], |
---|
161 | thickness=20, |
---|
162 | thickness1_pd=0.3, |
---|
163 | thickness2_pd=0.3, |
---|
164 | thickness1_pd_n=10, |
---|
165 | thickness2_pd_n=10, |
---|
166 | ) |
---|