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 | """ |
---|

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 | """ |
---|

26 | Compute the expected SESANS polarization for a given SANS pattern. |
---|

27 | |
---|

28 | Uses the hankel transform followed by the exponential. The values |
---|

29 | for zz (or spin echo length, or delta), wavelength and sample thickness |
---|

30 | information should come from the dataset. *q* should be chosen such |
---|

31 | that the oscillations in *I(q)* are well sampled (e.g., 5*2*pi/d_max). |
---|

32 | |
---|

33 | *SElength* [A] is the set of z points at which to compute the hankel transform |
---|

34 | |
---|

35 | *wavelength* [m] is the wavelength of each individual point *zz* |
---|

36 | |
---|

37 | *thickness* [cm] is the sample thickness. |
---|

38 | |
---|

39 | *q* [A^{-1}] is the set of q points at which the model has been computed. |
---|

40 | These should be equally spaced. |
---|

41 | |
---|

42 | *I* [cm^{-1}] is the value of the SANS model at *q* |
---|

43 | """ |
---|

44 | G = np.zeros(len(SElength), 'd') |
---|

45 | for i in range(len(SElength)): |
---|

46 | integr = besselj(0, q*SElength[i])*Iq*q |
---|

47 | G[i] = np.sum(integr) |
---|

48 | dq=(q[1]-q[0])*1e10 # [m^-1] step size in q, needed for integration |
---|

49 | G *= dq*1e10*2*pi # integr step, conver q into [m**-1] and 2 pi circle integr |
---|

50 | P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) |
---|

51 | |
---|

52 | return P |
---|