source: sasmodels/sasmodels/models/sc_paracrystal.py @ d86f0fc

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since d86f0fc was 2d81cfe, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

lint

  • Property mode set to 100644
File size: 6.0 KB
Line 
1r"""
2Calculates the scattering from a **simple cubic lattice** with
3paracrystalline distortion. Thermal vibrations are considered to be
4negligible, and the size of the paracrystal is infinitely large.
5Paracrystalline distortion is assumed to be isotropic and characterized
6by a Gaussian distribution.
7
8Definition
9----------
10
11The scattering intensity $I(q)$ is calculated as
12
13.. math::
14
15    I(q) = \text{scale}\frac{V_\text{lattice}P(q)Z(q)}{V_p} + \text{background}
16
17where scale is the volume fraction of spheres, $V_p$ is the volume of
18the primary particle, $V_\text{lattice}$ is a volume correction for the crystal
19structure, $P(q)$ is the form factor of the sphere (normalized), and
20$Z(q)$ is the paracrystalline structure factor for a simple cubic structure.
21
22Equation (16) of the 1987 reference is used to calculate $Z(q)$, using
23equations (13)-(15) from the 1987 paper for Z1, Z2, and Z3.
24
25The lattice correction (the occupied volume of the lattice) for a simple cubic
26structure of particles of radius *R* and nearest neighbor separation *D* is
27
28.. math::
29
30    V_\text{lattice}=\frac{4\pi}{3}\frac{R^3}{D^3}
31
32The distortion factor (one standard deviation) of the paracrystal is included
33in the calculation of $Z(q)$
34
35.. math::
36
37    \Delta a = gD
38
39where *g* is a fractional distortion based on the nearest neighbor distance.
40
41The simple cubic lattice is
42
43.. figure:: img/sc_crystal_geometry.jpg
44
45For a crystal, diffraction peaks appear at reduced q-values given by
46
47.. math::
48
49    \frac{qD}{2\pi} = \sqrt{h^2+k^2+l^2}
50
51where for a simple cubic lattice any h, k, l are allowed and none are
52forbidden. Thus the peak positions correspond to (just the first 5)
53
54.. math::
55    :nowrap:
56
57    \begin{align*}
58    q/q_0 \quad & \quad 1
59                & \sqrt{2} \quad
60                & \quad  \sqrt{3} \quad
61                & \sqrt{4} \quad
62                & \quad \sqrt{5}\quad \\
63    Indices \quad & (100)
64                  & \quad (110) \quad
65                  & \quad (111)
66                  & (200) \quad
67                  & \quad (210)
68    \end{align*}
69
70.. note::
71
72    The calculation of *Z(q)* is a double numerical integral that must be
73    carried out with a high density of points to properly capture the sharp
74    peaks of the paracrystalline scattering.
75    So be warned that the calculation is slow. Fitting of any experimental data
76    must be resolution smeared for any meaningful fit. This makes a triple
77    integral which may be very slow.
78
79The 2D (Anisotropic model) is based on the reference below where *I(q)* is
80approximated for 1d scattering. Thus the scattering pattern for 2D may not
81be accurate particularly at low $q$. For general details of the calculation
82and angular dispersions for oriented particles see :ref:`orientation` .
83Note that we are not responsible for any incorrectness of the
842D model computation.
85
86.. figure:: img/parallelepiped_angle_definition.png
87
88    Orientation of the crystal with respect to the scattering plane, when
89    $\theta = \phi = 0$ the $c$ axis is along the beam direction (the $z$ axis).
90
91Reference
92---------
93Hideki Matsuoka et. al. *Physical Review B,* 36 (1987) 1754-1765
94(Original Paper)
95
96Hideki Matsuoka et. al. *Physical Review B,* 41 (1990) 3854 -3856
97(Corrections to FCC and BCC lattice structure calculation)
98"""
99
100import numpy as np
101from numpy import inf
102
103name = "sc_paracrystal"
104title = "Simple cubic lattice with paracrystalline distortion"
105description = """
106        P(q)=(scale/Vp)*V_lattice*P(q)*Z(q)+bkg where scale is the volume
107        fraction of sphere,
108        Vp = volume of the primary particle,
109        V_lattice = volume correction for
110        for the crystal structure,
111        P(q)= form factor of the sphere (normalized),
112        Z(q)= paracrystalline structure factor
113        for a simple cubic structure.
114        [Simple Cubic ParaCrystal Model]
115        Parameters;
116        scale: volume fraction of spheres
117        bkg:background, R: radius of sphere
118        dnn: Nearest neighbor distance
119        d_factor: Paracrystal distortion factor
120        radius: radius of the spheres
121        sldSph: SLD of the sphere
122        sldSolv: SLD of the solvent
123        """
124category = "shape:paracrystal"
125single = False
126# pylint: disable=bad-whitespace, line-too-long
127#             ["name", "units", default, [lower, upper], "type","description"],
128parameters = [["dnn",         "Ang",       220.0, [0.0, inf],  "",            "Nearest neighbor distance"],
129              ["d_factor",    "",           0.06, [-inf, inf], "",            "Paracrystal distortion factor"],
130              ["radius",      "Ang",        40.0, [0.0, inf],  "volume",      "Radius of sphere"],
131              ["sld",  "1e-6/Ang^2",         3.0, [0.0, inf],  "sld",         "Sphere scattering length density"],
132              ["sld_solvent", "1e-6/Ang^2",  6.3, [0.0, inf],  "sld",         "Solvent scattering length density"],
133              ["theta",       "degrees",    0,    [-360, 360], "orientation", "c axis to beam angle"],
134              ["phi",         "degrees",    0,    [-360, 360], "orientation", "rotation about beam"],
135              ["psi",         "degrees",    0,    [-360, 360], "orientation", "rotation about c axis"]
136             ]
137# pylint: enable=bad-whitespace, line-too-long
138
139source = ["lib/sas_3j1x_x.c", "lib/sphere_form.c", "lib/gauss150.c", "sc_paracrystal.c"]
140
141def random():
142    # copied from bcc_paracrystal
143    radius = 10**np.random.uniform(1.3, 4)
144    d_factor = 10**np.random.uniform(-2, -0.7)  # sigma_d in 0.01-0.7
145    dnn_fraction = np.random.beta(a=10, b=1)
146    dnn = radius*4/np.sqrt(4)/dnn_fraction
147    pars = dict(
148        #sld=1, sld_solvent=0, scale=1, background=1e-32,
149        dnn=dnn,
150        d_factor=d_factor,
151        radius=radius,
152    )
153    return pars
154
155tests = [
156    # Accuracy tests based on content in test/utest_extra_models.py, 2d tests added April 10, 2017
157    [{}, 0.001, 10.3048],
158    [{}, 0.215268, 0.00814889],
159    [{}, 0.414467, 0.001313289],
160    [{'theta': 10.0, 'phi': 20, 'psi': 30.0}, (0.045, -0.035), 18.0397138402],
161    [{'theta': 10.0, 'phi': 20, 'psi': 30.0}, (0.023, 0.045), 0.0177333171285],
162    ]
Note: See TracBrowser for help on using the repository browser.