[f7930be] | 1 | r""" |
---|
| 2 | Definition |
---|
| 3 | ---------- |
---|
| 4 | |
---|
| 5 | This model is a trivial extension of the CoreShell function to a larger number |
---|
[40a87fa] | 6 | of shells. The scattering length density profile for the default sld values |
---|
[f7930be] | 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 | |
---|
[263daec] | 14 | The 2D scattering intensity is the same as $P(q)$ above, regardless of the |
---|
[2d73a53] | 15 | orientation of the $\vec q$ vector which is defined as |
---|
[f7930be] | 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 |
---|
[263daec] | 25 | effective radius for $S(Q)$ when $P(Q)*S(Q)$ is applied. |
---|
[f7930be] | 26 | |
---|
[40a87fa] | 27 | For information about polarised and magnetic scattering, see |
---|
[9a4811a] | 28 | the :ref:`magnetism` documentation. |
---|
[f7930be] | 29 | |
---|
| 30 | Our model uses the form factor calculations implemented in a c-library provided |
---|
[2d73a53] | 31 | by the NIST Center for Neutron Research (Kline, 2006) [#kline]_. |
---|
[f7930be] | 32 | |
---|
| 33 | References |
---|
| 34 | ---------- |
---|
| 35 | |
---|
[b0c4271] | 36 | .. [#] See the :ref:`core-shell-sphere` model documentation. |
---|
[2d73a53] | 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. |
---|
[f7930be] | 40 | |
---|
[b0c4271] | 41 | Authorship and Verification |
---|
| 42 | ---------------------------- |
---|
[f7930be] | 43 | |
---|
[b0c4271] | 44 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
| 45 | * **Last Modified by:** Paul Kienzle **Date:** September 12, 2016 |
---|
[2d73a53] | 46 | * **Last Reviewed by:** Paul Kienzle **Date:** September 12, 2016 |
---|
[f7930be] | 47 | """ |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | from __future__ import division |
---|
| 52 | |
---|
| 53 | import numpy as np |
---|
[40a87fa] | 54 | from numpy import inf |
---|
[f7930be] | 55 | |
---|
| 56 | name = "core_multi_shell" |
---|
| 57 | title = "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 | |
---|
| 61 | description = """\ |
---|
| 62 | Form factor for a core muti-shell (up to 4) sphere normalized by the volume. |
---|
| 63 | Each 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 |
---|
[a151caa] | 72 | |
---|
| 73 | |
---|
[f7930be] | 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 | |
---|
| 85 | category = "shape:sphere" |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
[42356c8] | 89 | parameters = [["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", |
---|
[f7930be] | 90 | "Core scattering length density"], |
---|
[6f0e04f] | 91 | ["radius", "Ang", 200., [0, inf], "volume", |
---|
[f7930be] | 92 | "Radius of the core"], |
---|
[42356c8] | 93 | ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", |
---|
[f7930be] | 94 | "Solvent scattering length density"], |
---|
[c5ac2b2] | 95 | ["n", "", 1, [0, 10], "volume", |
---|
[f7930be] | 96 | "number of shells"], |
---|
[42356c8] | 97 | ["sld[n]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", |
---|
[f7930be] | 98 | "scattering length density of shell k"], |
---|
[6f0e04f] | 99 | ["thickness[n]", "Ang", 40., [0, inf], "volume", |
---|
[f7930be] | 100 | "Thickness of shell k"], |
---|
[40a87fa] | 101 | ] |
---|
[f7930be] | 102 | |
---|
[925ad6e] | 103 | source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] |
---|
[f7930be] | 104 | |
---|
[a151caa] | 105 | def random(): |
---|
| 106 | import numpy as np |
---|
| 107 | num_shells = np.minimum(np.random.poisson(3)+1, 10) |
---|
| 108 | total_radius = 10**np.random.uniform(1.7, 4) |
---|
| 109 | thickness = np.random.exponential(size=num_shells+1) |
---|
| 110 | thickness *= total_radius/np.sum(thickness) |
---|
| 111 | pars = dict( |
---|
| 112 | #background=0, |
---|
| 113 | n=num_shells, |
---|
| 114 | radius=thickness[0], |
---|
| 115 | ) |
---|
| 116 | for k, v in enumerate(thickness[1:]): |
---|
| 117 | pars['thickness%d'%(k+1)] = v |
---|
| 118 | return pars |
---|
| 119 | |
---|
[c5ac2b2] | 120 | def profile(sld_core, radius, sld_solvent, n, sld, thickness): |
---|
[f7930be] | 121 | """ |
---|
[e187b25] | 122 | Returns the SLD profile *r* (Ang), and *rho* (1e-6/Ang^2). |
---|
[f7930be] | 123 | """ |
---|
[21fbab1] | 124 | n = int(n+0.5) |
---|
[40a87fa] | 125 | z = [] |
---|
[e187b25] | 126 | rho = [] |
---|
[f7930be] | 127 | |
---|
| 128 | # add in the core |
---|
[40a87fa] | 129 | z.append(0) |
---|
[e187b25] | 130 | rho.append(sld_core) |
---|
[40a87fa] | 131 | z.append(radius) |
---|
[e187b25] | 132 | rho.append(sld_core) |
---|
[f7930be] | 133 | |
---|
| 134 | # add in the shells |
---|
[8c6fbbc] | 135 | for k in range(int(n)): |
---|
[f7930be] | 136 | # Left side of each shells |
---|
[40a87fa] | 137 | z.append(z[-1]) |
---|
[e187b25] | 138 | rho.append(sld[k]) |
---|
[40a87fa] | 139 | z.append(z[-1] + thickness[k]) |
---|
[e187b25] | 140 | rho.append(sld[k]) |
---|
[c5ac2b2] | 141 | # add in the solvent |
---|
[40a87fa] | 142 | z.append(z[-1]) |
---|
[e187b25] | 143 | rho.append(sld_solvent) |
---|
[40a87fa] | 144 | z.append(z[-1]*1.25) |
---|
[e187b25] | 145 | rho.append(sld_solvent) |
---|
[f7930be] | 146 | |
---|
[40a87fa] | 147 | return np.asarray(z), np.asarray(rho) |
---|
[f7930be] | 148 | |
---|
[6f0e04f] | 149 | def ER(radius, n, thickness): |
---|
[40a87fa] | 150 | """Effective radius""" |
---|
[5a0b3d7] | 151 | n = int(n[0]+0.5) # n is a control parameter and is not polydisperse |
---|
[6f0e04f] | 152 | return np.sum(thickness[:n], axis=0) + radius |
---|
[f7930be] | 153 | |
---|
[40a87fa] | 154 | demo = dict(sld_core=6.4, |
---|
| 155 | radius=60, |
---|
| 156 | sld_solvent=6.4, |
---|
| 157 | n=2, |
---|
| 158 | sld=[2.0, 3.0], |
---|
| 159 | thickness=20, |
---|
| 160 | thickness1_pd=0.3, |
---|
| 161 | thickness2_pd=0.3, |
---|
| 162 | thickness1_pd_n=10, |
---|
| 163 | thickness2_pd_n=10, |
---|
[c5ac2b2] | 164 | ) |
---|