[c97724e] | 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 | |
---|
[09ebe8c] | 16 | def make_q(q_max, Rmax): |
---|
[384d114] | 17 | r""" |
---|
[09ebe8c] | 18 | Return a $q$ vector suitable for SESANS covering from $2\pi/ (10 R_{\max})$ |
---|
| 19 | to $q_max$. |
---|
| 20 | """ |
---|
[c97724e] | 21 | q_min = dq = 0.1 * 2*pi / Rmax |
---|
[09ebe8c] | 22 | return np.arange(q_min, q_max, dq) |
---|
[c97724e] | 23 | |
---|
| 24 | def hankel(SElength, wavelength, thickness, q, Iq): |
---|
[384d114] | 25 | r""" |
---|
[c97724e] | 26 | Compute the expected SESANS polarization for a given SANS pattern. |
---|
| 27 | |
---|
[384d114] | 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}$). |
---|
[c97724e] | 32 | |
---|
[384d114] | 33 | *SElength* [A] is the set of $z$ points at which to compute the |
---|
| 34 | Hankel transform |
---|
[c97724e] | 35 | |
---|
| 36 | *wavelength* [m] is the wavelength of each individual point *zz* |
---|
| 37 | |
---|
| 38 | *thickness* [cm] is the sample thickness. |
---|
| 39 | |
---|
[384d114] | 40 | *q* [A$^{-1}$] is the set of $q$ points at which the model has been |
---|
| 41 | computed. These should be equally spaced. |
---|
[c97724e] | 42 | |
---|
[384d114] | 43 | *I* [cm$^{-1}$] is the value of the SANS model at *q* |
---|
[c97724e] | 44 | """ |
---|
[190fc2b] | 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) |
---|
[384d114] | 49 | |
---|
| 50 | # [m^-1] step size in q, needed for integration |
---|
[190fc2b] | 51 | dq = (q[1]-q[0])*1e10 |
---|
[384d114] | 52 | |
---|
| 53 | # integration step, convert q into [m**-1] and 2 pi circle integration |
---|
| 54 | G *= dq*1e10*2*pi |
---|
| 55 | |
---|
[c97724e] | 56 | P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) |
---|
| 57 | |
---|
| 58 | return P |
---|