source: sasmodels/sasmodels/models/core_multi_shell.py @ 34edbb8

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 34edbb8 was 34edbb8, checked in by smk78, 8 years ago

Fixed undefined label warning during doc build

  • Property mode set to 100644
File size: 6.7 KB
Line 
1r"""
2Definition
3----------
4
5This model is a trivial extension of the CoreShell function to a larger number
6of 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
14The 2D scattering intensity is the same as *P(q)* above, regardless of the
15orientation of the *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
27For information about polarised and magnetic scattering, see
28the :ref:`mag_help` documentation.
29
30Our model uses the form factor calculations implemented in a c-library provided
31by the NIST Center for Neutron Research (Kline, 2006).
32
33References
34----------
35See the :ref:`core_shell_sphere <core_shell_sphere>` model documentation.
36
37L A Feigin and D I Svergun,
38*Structure Analysis by Small-Angle X-Ray and Neutron Scattering*,
39Plenum Press, New York, 1987.
40
41**Author:** NIST IGOR/DANSE **on:** pre 2010
42
43**Last Modified by:** in progress **on:** March 20, 2016
44
45**Last Reviewed by:** in progress **on:** March 20, 2016
46"""
47
48
49
50from __future__ import division
51
52import numpy as np
53from numpy import inf, nan
54from math import fabs, exp, expm1
55
56name = "core_multi_shell"
57title = "This model provides the scattering from a spherical core with 1 to 4 \
58 concentric shell structures. The SLDs of the core and each shell are \
59 individually specified."
60
61description = """\
62Form factor for a core muti-shell (up to 4) sphere normalized by the volume.
63Each shell can have a unique thickness and sld.
64
65        background:background,
66        rad_core0: radius of sphere(core)
67        thick_shell#:the thickness of the shell#
68        sld_core0: the SLD of the sphere
69        sld_solv: the SLD of the solvent
70        sld_shell: the SLD of the shell#
71        A_shell#: the coefficient in the exponential function
72       
73       
74    scale: 1.0 if data is on absolute scale
75    volfraction: volume fraction of spheres
76    radius: the radius of the core
77    sld: the SLD of the core
78    thick_shelli: the thickness of the i'th shell from the core
79    sld_shelli: the SLD of the i'th shell from the core
80    sld_solvent: the SLD of the solvent
81    background: incoherent background
82
83"""
84
85category = "shape:sphere"
86
87
88#             ["name", "units", default, [lower, upper], "type","description"],
89parameters = [["volfraction", "", 0.05, [0,1],"",
90               "volume fraction of spheres"],
91              ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "",
92               "Core scattering length density"],
93              ["radius", "Ang", 200., [0, inf], "",
94               "Radius of the core"],
95              ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "",
96               "Solvent scattering length density"],
97              ["n", "", 1, [0, 10], "volume",
98               "number of shells"],
99              ["sld_shell[n]", "1e-6/Ang^2", 1.7, [-inf, inf], "",
100               "scattering length density of shell k"],
101              ["thick_shell[n]", "Ang", 40., [0, inf], "volume",
102               "Thickness of shell k"],
103              ]
104
105#source = ["lib/sph_j1c.c", "onion.c"]
106
107def Iq(q, *args, **kw):
108    return q
109
110def Iqxy(qx, *args, **kw):
111    return qx
112
113
114def shape(core_sld, core_radius, solvent_sld, n, in_sld, out_sld, thickness, A):
115    """
116    SLD profile
117   
118    :return: (r, beta) where r is a list of radius of the transition points\
119      and beta is a list of the corresponding SLD values.
120
121    """
122#        r = []
123#        beta = []
124#        # for core at r=0
125#        r.append(0)
126#        beta.append(self.params['sld_core0'])
127#        # for core at r=rad_core
128#        r.append(self.params['rad_core0'])
129#        beta.append(self.params['sld_core0'])
130#
131#        # for shells
132#        for n in range(1, self.n_shells+1):
133#            # Left side of each shells
134#            r0 = r[len(r)-1]
135#            r.append(r0)
136#            exec "beta.append(self.params['sld_shell%s'% str(n)])"
137#
138#            # Right side of each shells
139#            exec "r0 += self.params['thick_shell%s'% str(n)]"
140#            r.append(r0)
141#            exec "beta.append(self.params['sld_shell%s'% str(n)])"
142#
143#        # for solvent
144#        r0 = r[len(r)-1]           
145#        r.append(r0)
146#        beta.append(self.params['sld_solv'])
147#        r_solv = 5*r0/4
148#        r.append(r_solv)
149#        beta.append(self.params['sld_solv'])
150#
151#        return r, beta
152# above is directly from old code -- below is alotered from Woitek's first
153# cut an the onion.  Seems like we should be consistant?
154
155    total_radius = 1.25*(sum(thickness[:n]) + core_radius + 1)
156    dr = total_radius/400  # 400 points for a smooth plot
157
158    r = []
159    beta = []
160
161    # add in the core
162    r.append(0)
163    beta.append(sld)
164    r.append(radius)
165    beta.append(sld)
166
167    # add in the shells
168    for k in range(n):
169        # Left side of each shells
170        r0 = r[-1]
171        r.append(r0)
172        beta.append(sld_shell[k])
173        r.append(r0 + thickness[k])
174        beta.append(sld_shell[k])
175   # add in the solvent
176    r.append(r[-1])
177    beta.append(solvent_sld)
178    r.append(total_radius)
179    beta.append(solvent_sld)
180
181    return np.asarray(r), np.asarray(beta)
182
183def ER(radius, n, thick_shell):
184    return np.sum(thick_shell[:n], axis=0) + core_radius
185
186def VR(radius, n, thick_shell):
187    return 1.0
188
189parameters = [["volfraction", "", 0.05, [0,1],"",
190               "volume fraction of spheres"],
191              ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "",
192               "Core scattering length density"],
193              ["radius", "Ang", 200., [0, inf], "",
194               "Radius of the core"],
195              ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "",
196               "Solvent scattering length density"],
197              ["n", "", 1, [0, 10], "volume",
198               "number of shells"],
199              ["sld_shell[n]", "1e-6/Ang^2", 1.7, [-inf, inf], "",
200               "scattering length density of shell k"],
201              ["thick_shell[n]", "Ang", 40., [0, inf], "volume",
202               "Thickness of shell k"],
203               ]
204
205demo = dict(volfraction = 1.0,
206            sld = 6.4,
207            radius = 60,
208            sld_solvent = 6.4,
209            n = 1,
210            sld_shell = [2.0],
211            thick_shell = [10])
212
213oldname = "CoreMultiShellModel"
214oldpars = dict(
215    sld="sld_core0",
216    radius="rad_core0",
217    sld_solvent="sld_solv",
218    n="n_shells",
219    sld_shell="sld_in_shell",
220    thick_shell="thick_shell",
221    # func_shell is always 2 in the user interface, so isn't included
222    )
Note: See TracBrowser for help on using the repository browser.