[10576d1] | 1 | # Example of conversion of scattering cross section from SANS in absolute |
---|
| 2 | # units into SESANS using a Hankel transformation |
---|
| 3 | # everything is in units of metres except specified otherwise |
---|
| 4 | # Wim Bouwman (w.g.bouwman@tudelft.nl), June 2013 |
---|
| 5 | |
---|
| 6 | from __future__ import division |
---|
| 7 | |
---|
| 8 | from pylab import * |
---|
| 9 | from scipy.special import jv as besselj |
---|
| 10 | |
---|
| 11 | # q-range parameters |
---|
| 12 | q = arange(0.0003, 1.0, 0.0003); # [nm^-1] range wide enough for Hankel transform |
---|
| 13 | dq=(q[1]-q[0])*1e9; # [m^-1] step size in q, needed for integration |
---|
| 14 | nq=len(q); |
---|
| 15 | Lambda=2e-10; # [m] wavelength |
---|
| 16 | # sample parameters |
---|
| 17 | phi=0.1; # volume fraction |
---|
| 18 | R=100; # [nm] radius particles |
---|
| 19 | DeltaRho=6e14; # [m^-2] |
---|
| 20 | V=4/3*pi*R**3 * 1e-27; # [m^3] |
---|
| 21 | th=0.002; # [m] thickness sample |
---|
| 22 | |
---|
| 23 | #2 PHASE SYSTEM |
---|
| 24 | st= 1.5*Lambda**2*DeltaRho**2*th*phi*(1-phi)*R*1e-9 # scattering power in sesans formalism |
---|
| 25 | |
---|
| 26 | # Form factor solid sphere |
---|
| 27 | qr=q*R; |
---|
| 28 | P=(3.*(sin(qr)-qr*cos(qr)) / qr**3)**2; |
---|
| 29 | # Structure factor dilute |
---|
| 30 | S=1.; |
---|
| 31 | #2 PHASE SYSTEM |
---|
| 32 | # scattered intensity [m^-1] in absolute units according to SANS |
---|
| 33 | I=phi*(1-phi)*V*(DeltaRho**2)*P*S; |
---|
| 34 | |
---|
| 35 | clf() |
---|
| 36 | subplot(1,2,1) # plot the SANS calculation |
---|
| 37 | plot(q,I,'k') |
---|
| 38 | loglog(q,I) |
---|
| 39 | xlim([0.01, 1]) |
---|
| 40 | ylim([1, 1e9]) |
---|
| 41 | xlabel(r'$Q [nm^{-1}]$') |
---|
| 42 | ylabel(r'$d\Sigma/d\Omega [m^{-1}]$') |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | # Hankel transform to nice range for plot |
---|
| 46 | nz=61; |
---|
| 47 | zz=linspace(0,240,nz); # [nm], should be less than reciprocal from q |
---|
| 48 | G=zeros(nz); |
---|
| 49 | for i in range(len(zz)): |
---|
| 50 | integr=besselj(0,q*zz[i])*I*q; |
---|
| 51 | G[i]=sum(integr); |
---|
| 52 | G=G*dq*1e9*2*pi; # integr step, conver q into [m**-1] and 2 pi circle integr |
---|
| 53 | # plot(zz,G); |
---|
| 54 | stt= th*Lambda**2/4/pi/pi*G[0] # scattering power according to SANS formalism |
---|
| 55 | PP=exp(th*Lambda**2/4/pi/pi*(G-G[0])); |
---|
| 56 | |
---|
| 57 | subplot(1,2,2) |
---|
| 58 | plot(zz,PP,'k',label="Hankel transform") # Hankel transform 1D |
---|
| 59 | xlabel('spin-echo length [nm]') |
---|
| 60 | ylabel('polarisation normalised') |
---|
| 61 | hold(True) |
---|
| 62 | |
---|
| 63 | # Cosine transformation of 2D scattering patern |
---|
| 64 | if True: |
---|
| 65 | qy,qz = meshgrid(q,q) |
---|
| 66 | qr=R*sqrt(qy**2 + qz**2); # reuse variable names Hankel transform, but now 2D |
---|
| 67 | P=(3.*(sin(qr)-qr*cos(qr)) / qr**3)**2; |
---|
| 68 | # Structure factor dilute |
---|
| 69 | S=1.; |
---|
| 70 | # scattered intensity [m^-1] in absolute units according to SANS |
---|
| 71 | I=phi*V*(DeltaRho**2)*P*S; |
---|
| 72 | GG=zeros(nz); |
---|
| 73 | for i in range(len(zz)): |
---|
| 74 | integr=cos(qz*zz[i])*I; |
---|
| 75 | GG[i]=sum(sum(integr)); |
---|
| 76 | GG=4*GG* dq**2; # take integration step into account take 4 quadrants |
---|
| 77 | # plot(zz,GG); |
---|
| 78 | sstt= th*Lambda**2/4/pi/pi*GG[0] # scattering power according to SANS formalism |
---|
| 79 | PPP=exp(th*Lambda**2/4/pi/pi*(GG-GG[0])); |
---|
| 80 | |
---|
| 81 | plot(zz,PPP,label="cosine transform") # cosine transform 2D |
---|
| 82 | |
---|
| 83 | # For comparison calculation in SESANS formalism, which overlaps perfectly |
---|
| 84 | def gsphere(z,r): |
---|
| 85 | """ |
---|
| 86 | Calculate SESANS-correlation function for a solid sphere. |
---|
| 87 | |
---|
| 88 | Wim Bouwman after formulae Timofei Kruglov J.Appl.Cryst. 2003 article |
---|
| 89 | """ |
---|
| 90 | d = z/r |
---|
| 91 | g = zeros_like(z) |
---|
| 92 | g[d==0] = 1. |
---|
| 93 | low = ((d > 0) & (d < 2)) |
---|
| 94 | dlow = d[low] |
---|
| 95 | dlow2 = dlow**2 |
---|
| 96 | print dlow.shape, dlow2.shape |
---|
| 97 | g[low] = sqrt(1-dlow2/4.)*(1+dlow2/8.) + dlow2/2.*(1-dlow2/16.)*log(dlow/(2.+sqrt(4.-dlow2))) |
---|
| 98 | return g |
---|
| 99 | |
---|
| 100 | if True: |
---|
| 101 | plot(zz,exp(st*(gsphere(zz,R)-1)),'r', label="analytical") |
---|
| 102 | legend() |
---|
| 103 | show() |
---|