def matter_plate(freq, epsil, width, rep=0, meth=0, polar='s', ang=0, n0=1): '''alternative approach without angular dependance yet ''' from numpy import sqrt, cos, sin, exp, conj, zeros, ones #from spectra import ev2um global delt, pl matt = None #matrix([[1.,0],[0.,1.]],'c16') cang = 1 if polar == 'p': pl0 = n0 / cang else: pl0 = n0 * cang o1 = ones(len(freq)) z1 = zeros(len(freq)) from algebra import tensor for i in range(len(width)): n = sqrt(epsil[i]) pl = n * cang delt = 2 * pi * (freq * ev2um * 1e-3) * pl * width[i] if polar == 'p': pl = n / cang if meth == 1: mult = tensor([[cos(delt), -1j / pl * sin(delt)], [-1j * pl * sin(delt), cos(delt)]]) else: r12 = (pl0 - pl) / (pl0 + pl) t12 = 2 * pl0 / (pl0 + pl) mult = tensor([[o1, r12], [r12, o1]]) * (1. / t12) if width[i] > 0: delt = 2 * pi * (freq * ev2um * 1e-3) * pl * width[i] mult *= tensor([[exp(1j * delt), z1], [z1, exp(-1j * delt)]]) if matt == None: matt = mult else: matt *= mult #cang=sqrt(pl0**2-pl**2*(1-cang**2)) pl0 = pl #now pl0 and pl are that of the incident medium and substrate, resp. if rep == -1: return matt if len(epsil) > len(width): pl = sqrt(epsil[len(width)]) * cang a = (matt[0, 0] + matt[0, 1] * pl) * sqrt(epsil[0]) * cang b = (matt[1, 0] + matt[1, 1] * pl) r = (a - b) / (a + b) return (r * conj(r))
def matter_plate(freq,epsil,width,rep=0,meth=0,polar='s',ang=0,n0=1): '''alternative approach without angular dependance yet ''' from numpy import sqrt,cos,sin,exp,conj,zeros,ones from spectra import ev2um global delt,pl matt=None;#matrix([[1.,0],[0.,1.]],'c16') cang=1 if polar=='p': pl0=n0/cang else: pl0=n0*cang o1=ones(len(freq)) z1=zeros(len(freq)) from algebra import tensor for i in range(len(width)): n=sqrt(epsil[i]) pl=n*cang delt=2*pi*(freq*ev2um*1e-3)*pl*width[i] if polar=='p': pl=n/cang if meth==1: mult=tensor([[cos(delt),-1j/pl*sin(delt)],[-1j*pl*sin(delt),cos(delt)]]) else: r12=(pl0-pl)/(pl0+pl) t12=2*pl0/(pl0+pl) mult=tensor([[o1,r12],[r12,o1]])*(1./t12) if width[i]>0: delt=2*pi*(freq*ev2um*1e-3)*pl*width[i] mult*=tensor([[exp(1j*delt),z1],[z1,exp(-1j*delt)]]) if matt==None: matt=mult else: matt*=mult #cang=sqrt(pl0**2-pl**2*(1-cang**2)) pl0=pl #now pl0 and pl are that of the incident medium and substrate, resp. if rep==-1: return matt if len(epsil)>len(width): pl=sqrt(epsil[len(width)])*cang a=(matt[0,0]+matt[0,1]*pl)*sqrt(epsil[0])*cang b=(matt[1,0]+matt[1,1]*pl) r=(a-b)/(a+b) return (r*conj(r))
def tensor_plate(freq, epsil, width, rep=0, meth=1, n0=1., ang=0): '''using tensor algebra ''' from numpy import array, ones, zeros, sqrt, conj from math import cos, sin from algebra import tensor sp = epsil[0].shape matt = tensor(array( [[ones(sp), zeros(sp)], [zeros(sp), ones(sp)]], 'c32'), dim=2) i = 0 r = [] sh = [] cang, canh = None, None for e in epsil: # calculate fresnel coef., widths and angles at each interface n = sqrt(e) if i < len(width): sh.append(mfrq * 2 * pi * n * width[i]) if ang != 0: if cang == None: cang = cos(ang * pi / 180) else: cang = canh # output angle from previous layer psi.append(cang) canh = sqrt(1 - (n0.real)**2 * (1 - cang**2) / (n.real)**2) #cos of angle below the interface pl = n * cang delt = sh[-1] * cang selt, celt = sin(delt), cos(delt) matt *= tensor([[celt, -1j / pl * selt], [-1j * pl * selt, celt]]) else: selt, celt = sin(sh[-1]), cos(sh[-1]) pl = 1 matt *= tensor([[celt, -1j * selt], [-1j * selt, celt]]) n0 = n i += 1 if meth == 3: return matt a = (matt[0, 0] + matt[0, 1] * pl) * n0 * cos(ang * pi / 180) b = (matt[1, 0] + matt[1, 1] * pl) r = (a - b) / (a + b) return (r * conj(r)).real
def tensor_plate(freq,epsil,width,rep=0,meth=1,n0=1.,ang=0): '''using tensor algebra ''' from numpy import array,ones,zeros,sqrt,conj from math import cos,sin from algebra import tensor sp=epsil[0].shape matt=tensor(array([[ones(sp),zeros(sp)],[zeros(sp),ones(sp)]],'c32'),dim=2) i=0 r=[] sh=[] cang,canh=None,None for e in epsil: # calculate fresnel coef., widths and angles at each interface n=sqrt(e) if i<len(width): sh.append(mfrq*2*pi*n*width[i]) if ang!=0: if cang==None: cang=cos(ang*pi/180) else: cang=canh # output angle from previous layer psi.append(cang) canh=sqrt(1-(n0.real)**2*(1-cang**2)/(n.real)**2) #cos of angle below the interface pl=n*cang delt=sh[-1]*cang selt,celt=sin(delt),cos(delt) matt*=tensor([[celt,-1j/pl*selt],[-1j*pl*selt,celt]]) else: selt,celt=sin(sh[-1]),cos(sh[-1]) pl=1 matt*=tensor([[celt,-1j*selt],[-1j*selt,celt]]) n0=n i+=1 if meth==3: return matt a=(matt[0,0]+matt[0,1]*pl)*n0*cos(ang*pi/180) b=(matt[1,0]+matt[1,1]*pl) r=(a-b)/(a+b) return (r*conj(r)).real