source: sasmodels/sasmodels/models/hollow_rectangular_prism_thin_walls.py @ d277229

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since d277229 was d277229, checked in by grethevj, 6 years ago

Models updated to include choices for effective interaction radii

  • Property mode set to 100644
File size: 5.1 KB
Line 
1# rectangular_prism model
2# Note: model title and parameter table are inserted automatically
3r"""
4
5This model provides the form factor, $P(q)$, for a hollow rectangular
6prism with infinitely thin walls. It computes only the 1D scattering, not the 2D.
7
8
9Definition
10----------
11
12The 1D scattering intensity for this model is calculated according to the
13equations given by Nayuk and Huber (Nayuk, 2012).
14
15Assuming a hollow parallelepiped with infinitely thin walls, edge lengths
16$A \le B \le C$ and presenting an orientation with respect to the
17scattering vector given by $\theta$ and $\phi$, where $\theta$ is the angle
18between the $z$ axis and the longest axis of the parallelepiped $C$, and
19$\phi$ is the angle between the scattering vector (lying in the $xy$ plane)
20and the $y$ axis, the form factor is given by
21
22.. math::
23
24    P(q) = \frac{1}{V^2} \frac{2}{\pi} \int_0^{\frac{\pi}{2}}
25           \int_0^{\frac{\pi}{2}} [A_L(q)+A_T(q)]^2 \sin\theta\,d\theta\,d\phi
26
27where
28
29.. math::
30
31    V &= 2AB + 2AC + 2BC \\
32    A_L(q) &=  8 \times \frac{
33            \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right)
34            \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right)
35            \cos \left( \tfrac{1}{2} q C \cos\theta \right)
36        }{q^2 \, \sin^2\theta \, \sin\phi \cos\phi} \\
37    A_T(q) &=  A_F(q) \times
38      \frac{2\,\sin \left( \tfrac{1}{2} q C \cos\theta \right)}{q\,\cos\theta}
39
40and
41
42.. math::
43
44  A_F(q) =  4 \frac{ \cos \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right)
45                       \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) }
46                     {q \, \cos\phi \, \sin\theta} +
47              4 \frac{ \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right)
48                       \cos \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) }
49                     {q \, \sin\phi \, \sin\theta}
50
51The 1D scattering intensity is then calculated as
52
53.. math::
54
55  I(q) = \text{scale} \times V \times (\rho_\text{p} - \rho_\text{solvent})^2 \times P(q)
56
57where $V$ is the volume of the rectangular prism, $\rho_\text{p}$
58is the scattering length of the parallelepiped, $\rho_\text{solvent}$
59is the scattering length of the solvent, and (if the data are in absolute
60units) *scale* represents the volume fraction (which is unitless).
61
62**The 2D scattering intensity is not computed by this model.**
63
64
65Validation
66----------
67
68Validation of the code was conducted  by qualitatively comparing the output
69of the 1D model to the curves shown in (Nayuk, 2012).
70
71
72References
73----------
74
75R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854
76"""
77
78import numpy as np
79from numpy import pi, inf, sqrt
80
81name = "hollow_rectangular_prism_thin_walls"
82title = "Hollow rectangular parallelepiped with thin walls."
83description = """
84    I(q)= scale*V*(sld - sld_solvent)^2*P(q)+background
85        with P(q) being the form factor corresponding to a hollow rectangular
86        parallelepiped with infinitely thin walls.
87"""
88category = "shape:parallelepiped"
89
90#             ["name", "units", default, [lower, upper], "type","description"],
91parameters = [["sld", "1e-6/Ang^2", 6.3, [-inf, inf], "sld",
92               "Parallelepiped scattering length density"],
93              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld",
94               "Solvent scattering length density"],
95              ["length_a", "Ang", 35, [0, inf], "volume",
96               "Shorter side of the parallelepiped"],
97              ["b2a_ratio", "Ang", 1, [0, inf], "volume",
98               "Ratio sides b/a"],
99              ["c2a_ratio", "Ang", 1, [0, inf], "volume",
100               "Ratio sides c/a"],
101             ]
102
103source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"]
104have_Fq = True
105effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c",
106                         "equivalent outer circular cross-section","half ab diagonal","half diagonal"]
107
108#def ER(length_a, b2a_ratio, c2a_ratio):
109#    """
110#        Return equivalent radius (ER)
111#    """
112#    b_side = length_a * b2a_ratio
113#    c_side = length_a * c2a_ratio
114#
115#    # surface average radius (rough approximation)
116#    surf_rad = sqrt(length_a * b_side / pi)
117#
118#    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad))
119#    return 0.5 * (ddd) ** (1. / 3.)
120
121def VR(length_a, b2a_ratio, c2a_ratio):
122    """
123        Return shell volume and total volume
124    """
125    b_side = length_a * b2a_ratio
126    c_side = length_a * c2a_ratio
127    vol_total = length_a * b_side * c_side
128    vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side)
129    return vol_shell, vol_total
130
131
132def random():
133    a, b, c = 10**np.random.uniform(1, 4.7, size=3)
134    pars = dict(
135        length_a=a,
136        b2a_ratio=b/a,
137        c2a_ratio=c/a,
138    )
139    return pars
140
141
142# parameters for demo
143demo = dict(scale=1, background=0,
144            sld=6.3, sld_solvent=1.0,
145            length_a=35, b2a_ratio=1, c2a_ratio=1,
146            length_a_pd=0.1, length_a_pd_n=10,
147            b2a_ratio_pd=0.1, b2a_ratio_pd_n=1,
148            c2a_ratio_pd=0.1, c2a_ratio_pd_n=1)
149
150tests = [[{}, 0.2, 0.837719188592],
151         [{}, [0.2], [0.837719188592]],
152        ]
Note: See TracBrowser for help on using the repository browser.