Package reflectometry :: Package model3d :: Module GSAXS_orthaganal

Source Code for Module reflectometry.model3d.GSAXS_orthaganal

 1  # Copyright (C) 2008 University of Maryland
 
 2  # All rights reserved.
 
 3  # See LICENSE.txt for details.
 
 4  
 
 5  # Author: Christopher Metting
 
 6  # Starting Date: 4/14/2008
 
 7  
 
 8  
 
 9  from numpy import exp,cumsum,concatenate,empty,sinc,sum,sqrt,cos,sin,pi 
10  from scipy import special 
11  from sys import exit 
12  
 
13  
 
14 -def form_loop(type,feature_form,substrate_form,qx,qy,qz):
15 Tz_sub,Tz = layer_loop(substrate_form.thickness,feature_form.depth,feature_form.SLD,substrate_form.SLD_sub,qz) 16 total_form_sub = empty([len(qz),len(qx),len(qy)],'D') 17 total_form_feature = empty([len(qz),len(qx),len(qy)],'D') 18 19 for i,qxi in enumerate(qx): 20 for j,qyj in enumerate(qy): 21 Txy = orth_shape(qxi,qyj,feature_form.depth,feature_form.Rx,feature_form.Ry,type) 22 Txy_sub = orth_shape(qxi,qyj,substrate_form.thickness,substrate_form.Dx,substrate_form.Dy,'sub') 23 total_form_sub[:,i,j] = (Tz_sub*Txy_sub) 24 total_form_feature[:,i,j] = Tz*Txy 25 26 return total_form_feature,total_form_sub
27 28
29 -def layer_loop(thickness,depth,SLD,SLD_sub,qz):
30 #%:-) calculations for the substrate 31 # z_sub contains the positions of the interfaces for the base 32 z_sub = cumsum(concatenate(([0],thickness))) 33 print z_sub 34 Fz_sub = 0 # Fz = total integral for rho e^{iQ_z z} over all sections 35 36 for m in range(len(thickness)): 37 Fz_sub += z_form(SLD_sub[m], qz, z_sub[m], z_sub[m+1]) 38 Tz_sub = Fz_sub/(1j*qz) 39 40 #calculations for the feature 41 # z contains the positions of the interfaces for the features 42 z = cumsum(concatenate(([sum(thickness)],depth))) 43 print z 44 Fz = 0 45 46 for n in range(len(depth)): 47 Fz += z_form(SLD[n], qz, z[n], z[n+1]) 48 Tz = Fz/(1j*qz) 49 return Tz_sub,Tz
50 51 52 53
54 -def z_form(rho, Qz,zlo,zhi):
55 """ 56 Calculations of \int_zlo^zhi{ rho e^{iQ_z z} dz } 57 """ 58 return rho * (exp(1j * Qz * zhi) - exp(1j*Qz *zlo))
59
60 -def orth_shape(qx,qy,depth,Rx,Ry,check):
61 62 if check == 'sub': 63 return Rx * Ry * sinc(qx*(Rx/2))* sinc(qy*(Ry/2)) 64 65 66 elif check == 'parallelepiped': 67 return Rx * Ry * sinc(qx*(Rx/2))* sinc(qy*(Ry/2)) 68 69 70 elif check =='prism_3': 71 fraction = (2*sqrt(3)*exp(-1j*qy*(Rx/2)*sqrt(3))) /(qx*(qx**2-3*qy**2)) 72 function = qx * exp(1j*qy*(Rx/2)*sqrt(3)) - qx * cos(qx*(Rx/2))-1j * sqrt(3)*qy*sin(qx*(Rx/2)) 73 return fraction * function 74 75 elif check == 'cylinder': 76 x = sqrt((qx**2)+(qy**2))*(Rx) 77 return pi * 2 * ((Rx)**2)*((special.j1(x))/x) 78 else: 79 exit("Error: No match for requested feature type")
80