source: sasmodels/sasmodels/models/fractal_core_shell.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, 5 years ago

Added link to source code to each model. Closes #883

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[7d4b2ae]1r"""
2Definition
3----------
[07300ea]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.
[7d4b2ae]10
11.. math::
12
[07300ea]13    I(q) = P(q)S(q) + \text{background}
[7d4b2ae]14
[07300ea]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:
[7d4b2ae]18
19.. math::
20
[07300ea]21    P(q) &= \frac{\phi}{V_s}\left[3V_c(\rho_c-\rho_s)
[7d4b2ae]22    \frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+
23    3V_s(\rho_s-\rho_{solv})
[ca04add]24    \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 \\
[efb7615]25    S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q\xi)^2]^{(D_f-1)/2}}
[07300ea]26    \frac{\sin[(D_f-1)\tan^{-1}(q\xi)]}{(qr_s)^{D_f}}
[7d4b2ae]27
[07300ea]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
[efb7615]32of the whole particle respectively, $D_f$ is the fractal dimension, and $\xi$ the
[07300ea]33correlation length.
[efb7615]34
[07300ea]35Polydispersity of radius and thickness are also provided for.
[7d4b2ae]36
[07300ea]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
[7d4b2ae]39
40.. math::
41
42    q = \sqrt{q_x^2 + q_y^2}
43
[07300ea]44Our model is derived from the form factor calculations implemented in IGOR
45macros by the NIST Center for Neutron Research\ [#Kline]_
46
[aad336c]47References
48----------
[7d4b2ae]49
[07300ea]50.. [#teixeira] J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785
51.. [#Kline]  S R Kline, *J Appl. Cryst.*, 39 (2006) 895
52
[0507e09]53Source
54------
55
56`fractal_core_shell.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/fractal_core_shell.py>`_
57
58`fractal_core_shell.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/fractal_core_shell.c>`_
59
[07300ea]60Authorship and Verification
61----------------------------
62
63* **Author:** NIST IGOR/DANSE **Date:** pre 2010
[ef07e95]64* **Last Modified by:** Paul Butler and Paul Kienzle **Date:** November 27, 2016
65* **Last Reviewed by:** Paul Butler and Paul Kienzle **Date:** November 27, 2016
[0507e09]66* **Source added by :** Steve King **Date:** March 25, 2019
[7d4b2ae]67"""
68
[2d81cfe]69import numpy as np
[b297ba9]70from numpy import inf
[7d4b2ae]71
72name = "fractal_core_shell"
[07300ea]73title = "Scattering from a fractal structure formed from core shell spheres"
74description = """\
75    Model for fractal aggregates of core-shell primary particles. It is based on
76    the Teixeira model for the S(q) of a fractal * P(q) for a core-shell sphere
77
78    radius =  the radius of the core
79    thickness = thickness of the shell
80    thick_layer = thickness of a layer
81    sld_core = the SLD of the core
82    sld_shell = the SLD of the shell
83    sld_solvent = the SLD of the solvent
84    volfraction = volume fraction of core-shell particles
85    fractal_dim = fractal dimension
86    cor_length = correlation length of the fractal like aggretates
87    """
[7d4b2ae]88category = "shape-independent"
89
90# pylint: disable=bad-whitespace, line-too-long
91#   ["name", "units", default, [lower, upper], "type","description"],
92parameters = [
[6d96b66]93    ["radius",      "Ang",        60.0, [0.0, inf],  "volume", "Sphere core radius"],
94    ["thickness",   "Ang",        10.0, [0.0, inf],  "volume", "Sphere shell thickness"],
[42356c8]95    ["sld_core",    "1e-6/Ang^2", 1.0,  [-inf, inf], "sld",    "Sphere core scattering length density"],
96    ["sld_shell",   "1e-6/Ang^2", 2.0,  [-inf, inf], "sld",    "Sphere shell scattering length density"],
97    ["sld_solvent", "1e-6/Ang^2", 3.0,  [-inf, inf], "sld",    "Solvent scattering length density"],
[eb3eb38]98    ["volfraction", "",           0.05,  [0.0, inf],  "",       "Volume fraction of building block spheres"],
[217590b]99    ["fractal_dim",    "",        2.0,  [0.0, 6.0],  "",       "Fractal dimension"],
[6d96b66]100    ["cor_length",  "Ang",      100.0,  [0.0, inf],  "",       "Correlation length of fractal-like aggregates"],
101]
[7d4b2ae]102# pylint: enable=bad-whitespace, line-too-long
103
[925ad6e]104source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "lib/core_shell.c",
[217590b]105          "lib/fractal_sq.c", "fractal_core_shell.c"]
[7d4b2ae]106
[404ebbd]107def random():
[b297ba9]108    """Return a random parameter set for the model."""
[8f04da4]109    outer_radius = 10**np.random.uniform(0.7, 4)
110    # Use a distribution with a preference for thin shell or thin core
111    # Avoid core,shell radii < 1
112    thickness = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1
113    radius = outer_radius - thickness
114    cor_length = 10**np.random.uniform(0.7, 2)*outer_radius
[404ebbd]115    volfraction = 10**np.random.uniform(-3, -1)
116    fractal_dim = 2*np.random.beta(3, 4) + 1
117    pars = dict(
118        #background=0, sld_block=1, sld_solvent=0,
119        volfraction=volfraction,
120        radius=radius,
121        cor_length=cor_length,
122        fractal_dim=fractal_dim,
123    )
124    return pars
125
[7d4b2ae]126demo = dict(scale=0.05,
127            background=0,
128            radius=20,
129            thickness=5,
[aad336c]130            sld_core=3.5,
131            sld_shell=1.0,
132            sld_solvent=6.35,
[7d4b2ae]133            volfraction=0.05,
[a807206]134            fractal_dim=2.0,
[7d4b2ae]135            cor_length=100.0)
136
[b297ba9]137# TODO: why is there an ER function here?
[7d4b2ae]138def ER(radius, thickness):
139    """
140        Equivalent radius
141        @param radius: core radius
142        @param thickness: shell thickness
143    """
144    return radius + thickness
145
[2cc8aa2]146#tests = [[{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0],
147tests = [
[b297ba9]148    # At some point the SasView 3.x test result was deemed incorrect.  The
149    # following tests were verified against NIST IGOR macros ver 7.850.
150    # NOTE: NIST macros do only provide for a polydispers core (no option
151    # for a poly shell or for a monodisperse core.  The results seemed
152    # extremely sensitive to the core PD, varying non monotonically all
153    # the way to a PD of 1e-6. From 1e-6 to 1e-9 no changes in the
154    # results were observed and the values below were taken using PD=1e-9.
155    # Non-monotonically = I(0.001)=188 to 140 to 177 back to 160 etc.
156    [{'radius': 20.0,
157      'thickness': 5.0,
158      'sld_core': 3.5,
159      'sld_shell': 1.0,
160      'sld_solvent': 6.35,
161      'volfraction': 0.05,
162      'background': 0.0},
163     [0.001, 0.00291, 0.0107944, 0.029923, 0.100726, 0.476304],
164     [177.146, 165.151, 84.1596, 20.1466, 1.40906, 0.00622666]
165    ]
166]
Note: See TracBrowser for help on using the repository browser.