source: sasmodels/sasmodels/models/core_shell_parallelepiped.py @ 14838a3

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 14838a3 was 14838a3, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

update parallelepiped and core_shell_parallelepiped to use ORIENT macros

  • Property mode set to 100644
File size: 7.0 KB
Line 
1# core_shell_parallelepiped model
2# Note: model title and parameter table are inserted automatically
3r"""
4Calculates the form factor for a rectangular solid with a core-shell structure.
5**The thickness and the scattering length density of the shell or "rim"
6can be different on all three (pairs) of faces.**
7
8The form factor is normalized by the particle volume $V$ such that
9
10.. math::
11
12    I(q) = \text{scale}\frac{\langle f^2 \rangle}{V} + \text{background}
13
14where $\langle \ldots \rangle$ is an average over all possible orientations
15of the rectangular solid.
16
17An instrument resolution smeared version of the model is also provided.
18
19
20Definition
21----------
22
23The function calculated is the form factor of the rectangular solid below.
24The core of the solid is defined by the dimensions $A$, $B$, $C$ such that
25$A < B < C$.
26
27.. image:: img/core_shell_parallelepiped_geometry.jpg
28
29There are rectangular "slabs" of thickness $t_A$ that add to the $A$ dimension
30(on the $BC$ faces). There are similar slabs on the $AC$ $(=t_B)$ and $AB$
31$(=t_C)$ faces. The projection in the $AB$ plane is then
32
33.. image:: img/core_shell_parallelepiped_projection.jpg
34
35The volume of the solid is
36
37.. math::
38
39    V = ABC + 2t_ABC + 2t_BAC + 2t_CAB
40
41**meaning that there are "gaps" at the corners of the solid.**
42
43The intensity calculated follows the :ref:`parallelepiped` model, with the core-shell
44intensity being calculated as the square of the sum of the amplitudes of the
45core and shell, in the same manner as a core-shell model.
46
47**For the calculation of the form factor to be valid, the sides of the solid
48MUST be chosen such that** $A < B < C$.
49**If this inequality is not satisfied, the model will not report an error,
50and the calculation will not be correct.**
51
52FITTING NOTES
53If the scale is set equal to the particle volume fraction, |phi|, the returned
54value is the scattered intensity per unit volume, $I(q) = \phi P(q)$.
55However, **no interparticle interference effects are included in this calculation.**
56
57There are many parameters in this model. Hold as many fixed as possible with
58known values, or you will certainly end up at a solution that is unphysical.
59
60Constraints must be applied during fitting to ensure that the inequality
61$A < B < C$ is not violated. The calculation will not report an error,
62but the results will not be correct.
63
64The returned value is in units of |cm^-1|, on absolute scale.
65
66NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated
67based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$
68and length $(C+2t_C)$ values, and used as the effective radius
69for $S(Q)$ when $P(Q) * S(Q)$ is applied.
70
71.. Comment by Miguel Gonzalez:
72   The later seems to contradict the previous statement that interparticle interference
73   effects are not included.
74
75To provide easy access to the orientation of the parallelepiped, we define the
76axis of the cylinder using three angles $\theta$, $\phi$ and $\Psi$.
77(see :ref:`cylinder orientation <cylinder-angle-definition>`).
78The angle $\Psi$ is the rotational angle around the *long_c* axis against the
79$q$ plane. For example, $\Psi = 0$ when the *short_b* axis is parallel to the
80*x*-axis of the detector.
81
82.. figure:: img/parallelepiped_angle_definition.jpg
83
84    Definition of the angles for oriented core-shell parallelepipeds.
85
86.. figure:: img/parallelepiped_angle_projection.jpg
87
88    Examples of the angles for oriented core-shell parallelepipeds against the
89    detector plane.
90
91Validation
92----------
93
94The model uses the form factor calculations implemented in a c-library provided
95by the NIST Center for Neutron Research (Kline, 2006).
96
97References
98----------
99
100P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211
101Equations (1), (13-14). (in German)
102
103"""
104
105import numpy as np
106from numpy import pi, inf, sqrt
107
108name = "core_shell_parallelepiped"
109title = "Rectangular solid with a core-shell structure."
110description = """
111     P(q)=
112"""
113category = "shape:parallelepiped"
114
115#             ["name", "units", default, [lower, upper], "type","description"],
116parameters = [["sld_core", "1e-6/Ang^2", 1, [-inf, inf], "sld",
117               "Parallelepiped core scattering length density"],
118              ["sld_a", "1e-6/Ang^2", 2, [-inf, inf], "sld",
119               "Parallelepiped A rim scattering length density"],
120              ["sld_b", "1e-6/Ang^2", 4, [-inf, inf], "sld",
121               "Parallelepiped B rim scattering length density"],
122              ["sld_c", "1e-6/Ang^2", 2, [-inf, inf], "sld",
123               "Parallelepiped C rim scattering length density"],
124              ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld",
125               "Solvent scattering length density"],
126              ["length_a", "Ang", 35, [0, inf], "volume",
127               "Shorter side of the parallelepiped"],
128              ["length_b", "Ang", 75, [0, inf], "volume",
129               "Second side of the parallelepiped"],
130              ["length_c", "Ang", 400, [0, inf], "volume",
131               "Larger side of the parallelepiped"],
132              ["thick_rim_a", "Ang", 10, [0, inf], "volume",
133               "Thickness of A rim"],
134              ["thick_rim_b", "Ang", 10, [0, inf], "volume",
135               "Thickness of B rim"],
136              ["thick_rim_c", "Ang", 10, [0, inf], "volume",
137               "Thickness of C rim"],
138              ["theta", "degrees", 0, [-inf, inf], "orientation",
139               "In plane angle"],
140              ["phi", "degrees", 0, [-inf, inf], "orientation",
141               "Out of plane angle"],
142              ["psi", "degrees", 0, [-inf, inf], "orientation",
143               "Rotation angle around its own c axis against q plane"],
144             ]
145
146source = ["lib/gauss76.c", "core_shell_parallelepiped.c"]
147
148
149def ER(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c):
150    """
151        Return equivalent radius (ER)
152    """
153
154    # surface average radius (rough approximation)
155    surf_rad = sqrt((length_a + 2.0*thick_rim_a) * (length_b + 2.0*thick_rim_b) / pi)
156
157    height = length_c + 2.0*thick_rim_c
158
159    ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad))
160    return 0.5 * (ddd) ** (1. / 3.)
161
162# VR defaults to 1.0
163
164# parameters for demo
165demo = dict(scale=1, background=0.0,
166            sld_core=1, sld_a=2, sld_b=4, sld_c=2, sld_solvent=6,
167            length_a=35, length_b=75, length_c=400,
168            thick_rim_a=10, thick_rim_b=10, thick_rim_c=10,
169            theta=0, phi=0, psi=0,
170            length_a_pd=0.1, length_a_pd_n=1,
171            length_b_pd=0.1, length_b_pd_n=1,
172            length_c_pd=0.1, length_c_pd_n=1,
173            thick_rim_a_pd=0.1, thick_rim_a_pd_n=1,
174            thick_rim_b_pd=0.1, thick_rim_b_pd_n=1,
175            thick_rim_c_pd=0.1, thick_rim_c_pd_n=1,
176            theta_pd=10, theta_pd_n=1,
177            phi_pd=10, phi_pd_n=1,
178            psi_pd=10, psi_pd_n=1)
179
180qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5)
181tests = [[{}, 0.2, 0.533149288477],
182         [{}, [0.2], [0.533149288477]],
183         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569],
184         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]],
185        ]
186del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.