# source:sasmodels/sasmodels/models/core_shell_sphere.py@dc76240

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since dc76240 was dc76240, checked in by smk78, 20 months ago

Corrected 2nd equation in doc string from F2(q) to F(q)

• Property mode set to 100644
File size: 4.3 KB
Line
1r"""
2.. _core_shell_sphere:
3
4This model provides the form factor, $P(q)$, for a spherical particle with
5a core-shell structure. The form factor is normalized by the particle volume.
6
7For information about polarised and magnetic scattering, see
8the :ref:magnetism documentation.
9
10Definition
11----------
12
13The 1D scattering intensity is calculated in the following way (Guinier, 1955)
14
15.. math::
16
17    P(q) = \frac{\text{scale}}{V} F^2(q) + \text{background}
18
19where
20
21.. math::
22
23    F(q) = \frac{3}{V_s}\left[
24       V_c(\rho_c-\rho_s)\frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3} +
25       V_s(\rho_s-\rho_\text{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}
26       \right]
27
28where $V_s$ is the volume of the whole particle, $V_c$ is the volume of the
29core, $r_s$ = $radius$ + $thickness$ is the radius of the particle, $r_c$
30is the radius of the core, $\rho_c$ is the scattering length density of the
31core, $\rho_s$ is the scattering length density of the shell,
32$\rho_\text{solv}$, is the scattering length density of the solvent.
33
34The 2D scattering intensity is the same as $P(q)$ above, regardless of the
35orientation of the $q$ vector.
36
37NB: The outer most radius (ie, = radius + thickness) is used as the
38effective radius for $S(Q)$ when $P(Q) \cdot S(Q)$ is applied.
39
40References
41----------
42
43A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*,
44John Wiley and Sons, New York, (1955)
45
46Validation
47----------
48
49Validation of our code was done by comparing the output of the 1D model to
50the output of the software provided by NIST (Kline, 2006). Figure 1 shows a
51comparison of the output of our model and the output of the NIST software.
52"""
53
54import numpy as np
55from numpy import pi, inf
56
57name = "core_shell_sphere"
58title = "Form factor for a monodisperse spherical particle with particle with a core-shell structure."
59description = """
61                   + V_s (sld_shell-sld_solvent) (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3]
62
63            V_s: Volume of the sphere shell
64            V_c: Volume of the sphere core
66"""
67category = "shape:sphere"
68
70#             ["name", "units", default, [lower, upper], "type","description"],
72              ["thickness",   "Ang",        10.0, [0, inf],    "volume", "Sphere shell thickness"],
73              ["sld_core",    "1e-6/Ang^2", 1.0,  [-inf, inf], "sld",    "core scattering length density"],
74              ["sld_shell",   "1e-6/Ang^2", 2.0,  [-inf, inf], "sld",    "shell scattering length density"],
75              ["sld_solvent", "1e-6/Ang^2", 3.0,  [-inf, inf], "sld",    "Solvent scattering length density"]]
77
78source = ["lib/sas_3j1x_x.c", "lib/core_shell.c", "core_shell_sphere.c"]
79
80demo = dict(scale=1, background=0, radius=60, thickness=10,
81            sld_core=1.0, sld_shell=2.0, sld_solvent=0.0)
82
84    """
87        @param thickness: shell thickness
88    """
90
92    """
93        Volume ratio
95        @param thickness: shell thickness
96    """
97    return (1, 1)
98    whole = 4.0/3.0 * pi * (radius + thickness)**3
99    core = 4.0/3.0 * pi * radius**3
100    return whole, whole - core
101
102def random():
104    # Use a distribution with a preference for thin shell or thin core
105    # Avoid core,shell radii < 1
108    pars = dict(
110        thickness=thickness,
111    )
112    return pars
113
114tests = [
115    [{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0],
116    # TODO: VR test suppressed until we sort out new product model
117    # and determine what to do with volume ratio.
118    #[{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704],
119
120    # The SasView test result was 0.00169, with a background of 0.001
121    [{'radius': 60.0, 'thickness': 10.0, 'sld_core': 1.0, 'sld_shell': 2.0,
122      'sld_solvent': 3.0, 'background': 0.0}, 0.4, 0.000698838],
123]
Note: See TracBrowser for help on using the repository browser.