source: sasmodels/sasmodels/models/fractal_core_shell.py @ ca04add

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since ca04add was ca04add, checked in by lewis, 7 years ago

Modify model docs to render correctly on marketplace

  • Property mode set to 100644
File size: 5.9 KB
Line 
1r"""
2Definition
3----------
4Calculates the scattering from a fractal structure with a primary building
5block of core-shell spheres, as opposed to just homogeneous spheres in
6the fractal model. It is an extension of the well known Teixeira\ [#teixeira]_
7fractal model replacing the $P(q)$ of a solid sphere with that of a core-shell
8sphere. This model could find use for aggregates of coated particles, or
9aggregates of vesicles for example.
10
11.. math::
12
13    I(q) = P(q)S(q) + \text{background}
14
15Where $P(q)$ is the core-shell form factor and $S(q)$ is the
16Teixeira\ [#teixeira]_ fractal structure factor both of which are given again
17below:
18
19.. math::
20
21    P(q) &= \frac{\phi}{V_s}\left[3V_c(\rho_c-\rho_s)
22    \frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+
23    3V_s(\rho_s-\rho_{solv})
24    \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 \\
25    S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q\xi)^2]^{(D_f-1)/2}}
26    \frac{\sin[(D_f-1)\tan^{-1}(q\xi)]}{(qr_s)^{D_f}}
27
28where $\phi$ is the volume fraction of particles, $V_s$ is the volume of the
29whole particle, $V_c$ is the volume of the core, $\rho_c$, $\rho_s$, and
30$\rho_{solv}$ are the scattering length densities of the core, shell, and
31solvent respectively, $r_c$ and $r_s$ are the radius of the core and the radius
32of the whole particle respectively, $D_f$ is the fractal dimension, and $\xi$ the
33correlation length.
34
35Polydispersity of radius and thickness are also provided for.
36
37This model does not allow for anisotropy and thus the 2D scattering intensity
38is calculated in the same way as 1D, where the $q$ vector is defined as
39
40.. math::
41
42    q = \sqrt{q_x^2 + q_y^2}
43
44Our model is derived from the form factor calculations implemented in IGOR
45macros by the NIST Center for Neutron Research\ [#Kline]_
46
47References
48----------
49
50.. [#teixeira] J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785
51.. [#Kline]  S R Kline, *J Appl. Cryst.*, 39 (2006) 895
52
53Authorship and Verification
54----------------------------
55
56* **Author:** NIST IGOR/DANSE **Date:** pre 2010
57* **Last Modified by:** Paul Butler and Paul Kienzle **on:** November 27, 2016
58* **Last Reviewed by:** Paul Butler and Paul Kienzle **on:** November 27, 2016
59
60"""
61
62from numpy import pi, inf
63
64name = "fractal_core_shell"
65title = "Scattering from a fractal structure formed from core shell spheres"
66description = """\
67    Model for fractal aggregates of core-shell primary particles. It is based on
68    the Teixeira model for the S(q) of a fractal * P(q) for a core-shell sphere
69
70    radius =  the radius of the core
71    thickness = thickness of the shell
72    thick_layer = thickness of a layer
73    sld_core = the SLD of the core
74    sld_shell = the SLD of the shell
75    sld_solvent = the SLD of the solvent
76    volfraction = volume fraction of core-shell particles
77    fractal_dim = fractal dimension
78    cor_length = correlation length of the fractal like aggretates
79    """
80category = "shape-independent"
81
82# pylint: disable=bad-whitespace, line-too-long
83#   ["name", "units", default, [lower, upper], "type","description"],
84parameters = [
85    ["radius",      "Ang",        60.0, [0.0, inf],  "volume", "Sphere core radius"],
86    ["thickness",   "Ang",        10.0, [0.0, inf],  "volume", "Sphere shell thickness"],
87    ["sld_core",    "1e-6/Ang^2", 1.0,  [-inf, inf], "sld",    "Sphere core scattering length density"],
88    ["sld_shell",   "1e-6/Ang^2", 2.0,  [-inf, inf], "sld",    "Sphere shell scattering length density"],
89    ["sld_solvent", "1e-6/Ang^2", 3.0,  [-inf, inf], "sld",    "Solvent scattering length density"],
90    ["volfraction", "",           1.0,  [0.0, inf],  "",       "Volume fraction of building block spheres"],
91    ["fractal_dim",    "",        2.0,  [0.0, 6.0],  "",       "Fractal dimension"],
92    ["cor_length",  "Ang",      100.0,  [0.0, inf],  "",       "Correlation length of fractal-like aggregates"],
93]
94# pylint: enable=bad-whitespace, line-too-long
95
96source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "lib/core_shell.c",
97          "lib/fractal_sq.c", "fractal_core_shell.c"]
98
99def random():
100    import numpy as np
101    outer_radius = 10**np.random.uniform(0.7, 4)
102    # Use a distribution with a preference for thin shell or thin core
103    # Avoid core,shell radii < 1
104    thickness = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1
105    radius = outer_radius - thickness
106    cor_length = 10**np.random.uniform(0.7, 2)*outer_radius
107    volfraction = 10**np.random.uniform(-3, -1)
108    fractal_dim = 2*np.random.beta(3, 4) + 1
109    pars = dict(
110        #background=0, sld_block=1, sld_solvent=0,
111        volfraction=volfraction,
112        radius=radius,
113        cor_length=cor_length,
114        fractal_dim=fractal_dim,
115    )
116    return pars
117
118demo = dict(scale=0.05,
119            background=0,
120            radius=20,
121            thickness=5,
122            sld_core=3.5,
123            sld_shell=1.0,
124            sld_solvent=6.35,
125            volfraction=0.05,
126            fractal_dim=2.0,
127            cor_length=100.0)
128
129def ER(radius, thickness):
130    """
131        Equivalent radius
132        @param radius: core radius
133        @param thickness: shell thickness
134    """
135    return radius + thickness
136
137def VR(radius, thickness):
138    """
139        Volume ratio
140        @param radius: core radius
141        @param thickness: shell thickness
142    """
143    whole = 4.0/3.0 * pi * (radius + thickness)**3
144    core = 4.0/3.0 * pi * radius**3
145    return whole, whole-core
146
147tests = [[{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0],
148         [{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704]]
149
150#         # The SasView test result was 0.00169, with a background of 0.001
151#         # They are however wrong as we now know.  IGOR might be a more
152#         # appropriate source. Otherwise will just have to assume this is now
153#         # correct and self generate a correct answer for the future. Until we
154#         # figure it out leave the tests commented out
155#         [{'radius': 60.0,
156#           'thickness': 10.0,
157#           'sld_core': 1.0,
158#           'sld_shell': 2.0,
159#           'sld_solvent': 3.0,
160#           'background': 0.0
161#          }, 0.015211, 692.84]]
Note: See TracBrowser for help on using the repository browser.