1 | """ |
---|
2 | Conversion of scattering cross section from SANS in absolute |
---|
3 | units into SESANS using a Hankel transformation |
---|
4 | |
---|
5 | Everything is in units of metres except specified otherwise |
---|
6 | |
---|
7 | Wim Bouwman (w.g.bouwman@tudelft.nl), June 2013 |
---|
8 | """ |
---|
9 | |
---|
10 | from __future__ import division |
---|
11 | |
---|
12 | import numpy as np |
---|
13 | from numpy import pi, exp |
---|
14 | from scipy.special import jv as besselj |
---|
15 | |
---|
16 | def make_q(q_max, Rmax): |
---|
17 | r""" |
---|
18 | Return a $q$ vector suitable for SESANS covering from $2\pi/ (10 R_{\max})$ |
---|
19 | to $q_max$. |
---|
20 | """ |
---|
21 | q_min = dq = 0.1 * 2*pi / Rmax |
---|
22 | return np.arange(q_min, q_max, dq) |
---|
23 | |
---|
24 | def hankel(SElength, wavelength, thickness, q, Iq): |
---|
25 | r""" |
---|
26 | Compute the expected SESANS polarization for a given SANS pattern. |
---|
27 | |
---|
28 | Uses the hankel transform followed by the exponential. The values for *zz* |
---|
29 | (or spin echo length, or delta), wavelength and sample thickness should |
---|
30 | come from the dataset. $q$ should be chosen such that the oscillations |
---|
31 | in $I(q)$ are well sampled (e.g., $5 \cdot 2 \pi/d_{\max}$). |
---|
32 | |
---|
33 | *SElength* [A] is the set of $z$ points at which to compute the |
---|
34 | Hankel transform |
---|
35 | |
---|
36 | *wavelength* [m] is the wavelength of each individual point *zz* |
---|
37 | |
---|
38 | *thickness* [cm] is the sample thickness. |
---|
39 | |
---|
40 | *q* [A$^{-1}$] is the set of $q$ points at which the model has been |
---|
41 | computed. These should be equally spaced. |
---|
42 | |
---|
43 | *I* [cm$^{-1}$] is the value of the SANS model at *q* |
---|
44 | """ |
---|
45 | G = np.zeros_like(SElength, 'd') |
---|
46 | for i, SElength_i in enumerate(SElength): |
---|
47 | integral = besselj(0, q*SElength_i)*Iq*q |
---|
48 | G[i] = np.sum(integral) |
---|
49 | |
---|
50 | # [m^-1] step size in q, needed for integration |
---|
51 | dq = (q[1]-q[0])*1e10 |
---|
52 | |
---|
53 | # integration step, convert q into [m**-1] and 2 pi circle integration |
---|
54 | G *= dq*1e10*2*pi |
---|
55 | |
---|
56 | P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) |
---|
57 | |
---|
58 | return P |
---|