File: hollow_rectangular_prism_thin_walls.py

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (132 lines) | stat: -rw-r--r-- 4,655 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# rectangular_prism model
# Note: model title and parameter table are inserted automatically
r"""
Definition
----------
This model provides the form factor, $P(q)$, for a hollow rectangular prism
with infinitely thin walls. It computes only the 1D scattering, not the 2D.
The 1D scattering intensity for this model is calculated according to the
equations given by Nayuk and Huber\ [#Nayuk2012]_.

Assuming a hollow parallelepiped with infinitely thin walls, edge lengths
$A \le B \le C$ and presenting an orientation with respect to the
scattering vector given by $\theta$ and $\phi$, where $\theta$ is the angle
between the $z$ axis and the longest axis of the parallelepiped $C$, and
$\phi$ is the angle between the scattering vector (lying in the $xy$ plane)
and the $y$ axis, the form factor is given by

.. math::

    P(q) = \frac{1}{V^2} \frac{2}{\pi} \int_0^{\frac{\pi}{2}}
           \int_0^{\frac{\pi}{2}} [A_L(q)+A_T(q)]^2 \sin\theta\,d\theta\,d\phi

where

.. math::

    V &= 2AB + 2AC + 2BC \\
    A_L(q) &=  8 \times \frac{
            \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right)
            \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right)
            \cos \left( \tfrac{1}{2} q C \cos\theta \right)
        }{q^2 \, \sin^2\theta \, \sin\phi \cos\phi} \\
    A_T(q) &=  A_F(q) \times
      \frac{2\,\sin \left( \tfrac{1}{2} q C \cos\theta \right)}{q\,\cos\theta}

and

.. math::

  A_F(q) =  4 \frac{ \cos \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right)
                       \sin \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) }
                     {q \, \cos\phi \, \sin\theta} +
              4 \frac{ \sin \left( \tfrac{1}{2} q A \sin\phi \sin\theta \right)
                       \cos \left( \tfrac{1}{2} q B \cos\phi \sin\theta \right) }
                     {q \, \sin\phi \, \sin\theta}

The 1D scattering intensity is then calculated as

.. math::

  I(q) = \text{scale} \times V \times (\rho_\text{p} - \rho_\text{solvent})^2 \times P(q)

where $V$ is the surface area of the rectangular prism, $\rho_\text{p}$
is the scattering length density of the parallelepiped, $\rho_\text{solvent}$
is the scattering length density of the solvent, and (if the data are in
absolute units) *scale* is related to the total surface area.

**The 2D scattering intensity is not computed by this model.**


Validation
----------

Validation of the code was conducted  by qualitatively comparing the output
of the 1D model to the curves shown in (Nayuk, 2012\ [#Nayuk2012]_).


References
----------

See also Onsager [#Onsager1949]_.

.. [#Nayuk2012] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854

.. [#Onsager1949] L. Onsager, *Ann. New York Acad. Sci.*, 51 (1949) 627-659

Authorship and Verification
----------------------------

* **Author:** Miguel Gonzales **Date:** February 26, 2016
* **Last Modified by:** Paul Kienzle **Date:** October 15, 2016
* **Last Reviewed by:** Paul Butler **Date:** September 07, 2018
"""

import numpy as np
from numpy import inf

name = "hollow_rectangular_prism_thin_walls"
title = "Hollow rectangular parallelepiped with thin walls."
description = """
    I(q)= scale*V*(sld - sld_solvent)^2*P(q)+background
        with P(q) being the form factor corresponding to a hollow rectangular
        parallelepiped with infinitely thin walls.
"""
category = "shape:parallelepiped"

#             ["name", "units", default, [lower, upper], "type","description"],
parameters = [["sld", "1e-6/Ang^2", 6.3, [-inf, inf], "sld",
               "Parallelepiped scattering length density"],
              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld",
               "Solvent scattering length density"],
              ["length_a", "Ang", 35, [0, inf], "volume",
               "Shorter side of the parallelepiped"],
              ["b2a_ratio", "Ang", 1, [0, inf], "volume",
               "Ratio sides b/a"],
              ["c2a_ratio", "Ang", 1, [0, inf], "volume",
               "Ratio sides c/a"],
             ]

source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"]
have_Fq = True
radius_effective_modes = [
    "equivalent cylinder excluded volume", "equivalent outer volume sphere",
    "half length_a", "half length_b", "half length_c",
    "equivalent outer circular cross-section",
    "half ab diagonal", "half diagonal",
    ]


def random():
    """Return a random parameter set for the model."""
    a, b, c = 10**np.random.uniform(1, 4.7, size=3)
    pars = dict(
        length_a=a,
        b2a_ratio=b/a,
        c2a_ratio=c/a,
    )
    return pars

tests = [[{}, 0.2, 0.837719188592],
         [{}, [0.2], [0.837719188592]],
        ]