source: sasmodels/sasmodels/models/fcc_paracrystal.py @ b297ba9

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since b297ba9 was b297ba9, checked in by Paul Kienzle <pkienzle@…>, 8 months ago

lint

  • Property mode set to 100644
File size: 6.1 KB
RevLine 
[e7b3d7b]1#fcc paracrystal model
[3271e20]2#note model title and parameter table are automatically inserted
3#note - calculation requires double precision
[e7b3d7b]4r"""
[b297ba9]5.. warning:: This model and this model description are under review following
6             concerns raised by SasView users. If you need to use this model,
7             please email help@sasview.org for the latest situation. *The
[da7b26b]8             SasView Developers. September 2018.*
9
10Definition
11----------
12
[3c56da87]13Calculates the scattering from a **face-centered cubic lattice** with
14paracrystalline distortion. Thermal vibrations are considered to be
15negligible, and the size of the paracrystal is infinitely large.
16Paracrystalline distortion is assumed to be isotropic and characterized by
17a Gaussian distribution.
[3271e20]18
[d138d43]19The scattering intensity $I(q)$ is calculated as
20
21.. math::
[3271e20]22
[eb69cce]23    I(q) = \frac{\text{scale}}{V_p} V_\text{lattice} P(q) Z(q)
[3271e20]24
[d138d43]25where *scale* is the volume fraction of spheres, $V_p$ is the volume of
[eb69cce]26the primary particle, $V_\text{lattice}$ is a volume correction for the crystal
[d138d43]27structure, $P(q)$ is the form factor of the sphere (normalized), and $Z(q)$
[3c56da87]28is the paracrystalline structure factor for a face-centered cubic structure.
[3271e20]29
[da7b26b]30Equation (1) of the 1990 reference\ [#CIT1990]_ is used to calculate $Z(q)$,
31using equations (23)-(25) from the 1987 paper\ [#CIT1987]_ for $Z1$, $Z2$, and
32$Z3$.
[3271e20]33
[3c56da87]34The lattice correction (the occupied volume of the lattice) for a
[eb69cce]35face-centered cubic structure of particles of radius $R$ and nearest
[d138d43]36neighbor separation $D$ is
[3271e20]37
[d138d43]38.. math::
39
40   V_\text{lattice} = \frac{16\pi}{3}\frac{R^3}{\left(D\sqrt{2}\right)^3}
[3271e20]41
[3c56da87]42The distortion factor (one standard deviation) of the paracrystal is
[d138d43]43included in the calculation of $Z(q)$
44
45.. math::
[3271e20]46
[d138d43]47    \Delta a = gD
[3271e20]48
[d138d43]49where $g$ is a fractional distortion based on the nearest neighbor distance.
[3271e20]50
[2f0c07d]51.. figure:: img/fcc_geometry.jpg
[3271e20]52
[d138d43]53    Face-centered cubic lattice.
[3271e20]54
55For a crystal, diffraction peaks appear at reduced q-values given by
56
[d138d43]57.. math::
[3271e20]58
[d138d43]59    \frac{qD}{2\pi} = \sqrt{h^2 + k^2 + l^2}
60
61where for a face-centered cubic lattice $h, k , l$ all odd or all
62even are allowed and reflections where $h, k, l$ are mixed odd/even
[3c56da87]63are forbidden. Thus the peak positions correspond to (just the first 5)
[3271e20]64
[d138d43]65.. math::
66
67    \begin{array}{cccccc}
68    q/q_0 & 1 & \sqrt{4/3} & \sqrt{8/3} & \sqrt{11/3} & \sqrt{4} \\
69    \text{Indices} & (111)  & (200) & (220) & (311) & (222)
70    \end{array}
[3271e20]71
[eda8b30]72.. note::
73
74  The calculation of $Z(q)$ is a double numerical integral that
75  must be carried out with a high density of points to properly capture
[1f159bd]76  the sharp peaks of the paracrystalline scattering.
77  So be warned that the calculation is slow. Fitting of any experimental data
[eda8b30]78  must be resolution smeared for any meaningful fit. This makes a triple integral
79  which may be very slow.
[3271e20]80
[eb69cce]81The 2D (Anisotropic model) is based on the reference below where $I(q)$ is
[3c56da87]82approximated for 1d scattering. Thus the scattering pattern for 2D may not
[1f159bd]83be accurate particularly at low $q$. For general details of the calculation
[eda8b30]84and angular dispersions for oriented particles see :ref:`orientation` .
85Note that we are not responsible for any incorrectness of the
[3c56da87]862D model computation.
[3271e20]87
[1f65db5]88.. figure:: img/parallelepiped_angle_definition.png
[d138d43]89
[404ebbd]90    Orientation of the crystal with respect to the scattering plane, when
[1f65db5]91    $\theta = \phi = 0$ the $c$ axis is along the beam direction (the $z$ axis).
[3271e20]92
[eb69cce]93References
94----------
[3271e20]95
[da7b26b]96.. [#CIT1987] Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765
97   (Original Paper)
98.. [#CIT1990] Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856
99   (Corrections to FCC and BCC lattice structure calculation)
100
101Authorship and Verification
102---------------------------
[3271e20]103
[da7b26b]104* **Author:** NIST IGOR/DANSE **Date:** pre 2010
105* **Last Modified by:** Paul Butler **Date:** September 29, 2016
106* **Last Reviewed by:** Richard Heenan **Date:** March 21, 2016
[3271e20]107"""
108
[2d81cfe]109import numpy as np
[e2d6e3b]110from numpy import inf, pi
[3271e20]111
[e7b3d7b]112name = "fcc_paracrystal"
113title = "Face-centred cubic lattic with paracrystalline distortion"
[3271e20]114description = """
[e7b3d7b]115    Calculates the scattering from a **face-centered cubic lattice** with paracrystalline distortion. Thermal vibrations
[3271e20]116    are considered to be negligible, and the size of the paracrystal is infinitely large. Paracrystalline distortion is
117    assumed to be isotropic and characterized by a Gaussian distribution.
118    """
[a5d0d00]119category = "shape:paracrystal"
[3271e20]120
[13ed84c]121single = False
122
[c0ccea8]123# pylint: disable=bad-whitespace, line-too-long
[3e428ec]124#             ["name", "units", default, [lower, upper], "type","description"],
125parameters = [["dnn", "Ang", 220, [-inf, inf], "", "Nearest neighbour distance"],
126              ["d_factor", "", 0.06, [-inf, inf], "", "Paracrystal distortion factor"],
127              ["radius", "Ang", 40, [0, inf], "volume", "Particle radius"],
[42356c8]128              ["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Particle scattering length density"],
129              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Solvent scattering length density"],
[9b79f29]130              ["theta",       "degrees",    60,    [-360, 360], "orientation", "c axis to beam angle"],
131              ["phi",         "degrees",    60,    [-360, 360], "orientation", "rotation about beam"],
132              ["psi",         "degrees",    60,    [-360, 360], "orientation", "rotation about c axis"]
[3e428ec]133             ]
[c0ccea8]134# pylint: enable=bad-whitespace, line-too-long
[3e428ec]135
[925ad6e]136source = ["lib/sas_3j1x_x.c", "lib/gauss150.c", "lib/sphere_form.c", "fcc_paracrystal.c"]
[3271e20]137
[404ebbd]138def random():
[b297ba9]139    """Return a random parameter set for the model."""
[1511c37c]140    # copied from bcc_paracrystal
141    radius = 10**np.random.uniform(1.3, 4)
142    d_factor = 10**np.random.uniform(-2, -0.7)  # sigma_d in 0.01-0.7
[404ebbd]143    dnn_fraction = np.random.beta(a=10, b=1)
[8f04da4]144    dnn = radius*4/np.sqrt(2)/dnn_fraction
[404ebbd]145    pars = dict(
146        #sld=1, sld_solvent=0, scale=1, background=1e-32,
[1511c37c]147        dnn=dnn,
148        d_factor=d_factor,
149        radius=radius,
[404ebbd]150    )
151    return pars
152
[69e1afc]153# april 10 2017, rkh add unit tests, NOT compared with any other calc method, assume correct!
[1f159bd]154# TODO: fix the 2d tests
[8f04da4]155q = 4.*pi/220.
[e2d6e3b]156tests = [
[8f04da4]157    [{}, [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]],
[1f159bd]158    #[{}, (-0.047, -0.007), 238.103096286],
159    #[{}, (0.053, 0.063), 0.863609587796],
[e2d6e3b]160]
Note: See TracBrowser for help on using the repository browser.