예제 #1
0
 def calc_amplitudes(self, theta, Energy):
     self.calc_parameters(Energy)
     Q=self.Q
     eta=self.eta
     alpha=self.alpha
     R=self.R
     M=self.structure.M
     Miller=self.Miller
     XR = pyasf.makefunc(sp.I*sp.sin(alpha)/Q, "numpy")
     XT = pyasf.makefunc(sp.sqrt(eta**2-1)/Q, "numpy")
     XR0=0
     XT0=1
     thissubs = self.structure.subs.copy()
     dt = np.diff(self.thickness)
     for i in xrange(self.length):
         for sym in self.strain:
             thissubs[sym] = self.structure.subs[sym] * (self.strain[sym][i] + 1)
         theta_layer_sub=self.theta_layer_func.dictcall(dict(theta=theta, **thissubs))
         thickness=dt[i]
         subs=dict(theta=theta_layer_sub,thickness=thickness, **thissubs)
         XR1=XR.dictcall(subs)
         XT1=XT.dictcall(subs)
         XT0*=XT1/(1-XR0*XR1)
         XR0=(XR1-XR0*(XR1**2-XT1**2))/(1-XR0*XR1)
     self.XR=XR0
     self.XT=XT0
예제 #2
0
 def calc_amplitudes(self, theta, Energy):
     theta_layer_sub=self.theta_layer_func.dictcall(dict(theta=theta, **self.structure.subs))
     self.calc_parameters(Energy)
     alpha=self.alpha
     eta=self.eta
     Q=self.Q
     XR = pyasf.makefunc(sp.I*sp.sin(alpha)/Q, "numpy")
     XT=pyasf.makefunc(sp.sqrt(eta**2-1)/Q, "numpy")
     thissubs=dict(theta=theta, thickness=self.thickness, **self.structure.subs)
     self.XR=XR.dictcall(thissubs)
     self.XT=XT.dictcall(thissubs)
예제 #3
0
 def calc_wavevectors(self):
     theta = sp.Symbol("theta", real=True)
     w1=self.w1
     n=self.w3
     H=self.calc_H_cartesian()
     u=H/H.norm()
     wv=w1-(w1.dot(u))*u
     w=wv/wv.norm()
     k_in_unit=(self.R*(-sp.sin(theta)*u+sp.cos(theta)*w)).subs(self.structure.subs).evalf()
     k_sc_unit=(self.R*( sp.sin(theta)*u+sp.cos(theta)*w)).subs(self.structure.subs).evalf()
     self.k_in_unit=pyasf.makefunc(k_in_unit, "sympy")
     self.k_sc_unit=pyasf.makefunc(k_sc_unit, "sympy")
     self.q_unit=u
예제 #4
0
 def calc_amplitudes(self, theta, Energy):
     Miller=self.Miller
     struct=self.structure
     wavelength=12398./Energy
     Volume=struct.V.subs(struct.subs).evalf()
     r_e=2.818e-5
     Gamma=r_e*wavelength**2/(sp.pi*Volume)
     g0=self.g0
     gH=self.gH
     b=g0/gH
     C=1
     
     thetaBragg=self.calc_Bragg_angle(Energy).subs(struct.subs).evalf()
     FH=struct.DAFS(Energy, Miller)
     FHc=struct.DAFS(Energy, tuple([-i for i in Miller]))
     F0=struct.DAFS(Energy, (0,0,0))
     F0 = F0[0]
     
     if isinstance(FH, sp.numbers.Zero) or isinstance(FHc, sp.numbers.Zero):
         etaval = np.zeros(len(theta), dtype=complex)
     else:
         FH = FH[0]
         FHc = FHc[0]
         thetasym = sp.Symbol("theta", real=True)
         eta=(-b*(thetasym-thetaBragg)*sp.sin(2*thetaBragg)-Gamma*F0*(1-b)/2)/(sp.sqrt(sp.Abs(b))*C*Gamma*sp.sqrt(FH*FHc))
         etafunc = pyasf.makefunc(eta)
         self.etafunc = etafunc
         etaval = etafunc(theta)
     
     s=-np.sign(etaval.real)
     X=etaval+s*np.sqrt(etaval**2-1)
     self.etaval=etaval
     self.XR=X
예제 #5
0
    def calc_reflection_amplitude(self, theta, Energy):
        Miller = self.Miller
        struct = self.structure
        wavelenght = 12398. / Energy
        Volume = struct.V.subs(struct.subs).evalf()
        r_e = 2.818e-5
        Gamma = r_e * wavelenght**2 / (sp.pi * Volume)
        g0 = self.g0
        gH = self.gH
        b = g0 / gH
        C = 1

        thetaBragg = self.calc_Bragg_angle(Energy).subs(struct.subs).evalf()
        FH = struct.DAFS(Energy, Miller)
        FHc = struct.DAFS(Energy, tuple([-i for i in Miller]))
        F0 = struct.DAFS(Energy, (0, 0, 0))

        thetasym = sp.Symbol("theta", real=True)
        eta = (-b * (thetasym - thetaBragg) * sp.sin(2 * thetaBragg) -
               Gamma * F0[0] * (1 - b) / 2) / (sp.sqrt(sp.Abs(b)) * C * Gamma *
                                               sp.sqrt(FH[0] * FHc[0]))
        etafunc = pyasf.makefunc(eta)
        self.etafunc = etafunc
        etaval = etafunc(theta)
        s = -np.sign(etaval.real)
        X = etaval + s * np.sqrt(etaval**2 - 1)
        self.etaval = etaval
        return X
예제 #6
0
 def calc_reflection_amplitude(self, theta, Energy):
     Miller=self.Miller
     struct=self.structure
     wavelenght=12398./Energy
     Volume=struct.V.subs(struct.subs).evalf()
     r_e=2.818e-5
     Gamma=r_e*wavelenght**2/(sp.pi*Volume)
     g0=self.g0
     gH=self.gH
     b=g0/gH
     C=1
     
     thetaBragg=self.calc_Bragg_angle(Energy).subs(struct.subs).evalf()
     FH=struct.DAFS(Energy, Miller)
     FHc=struct.DAFS(Energy, tuple([-i for i in Miller]))
     F0=struct.DAFS(Energy, (0,0,0))
     
     thetasym = sp.Symbol("theta", real=True)
     eta=(-b*(thetasym-thetaBragg)*sp.sin(2*thetaBragg)-Gamma*F0[0]*(1-b)/2)/(sp.sqrt(sp.Abs(b))*C*Gamma*sp.sqrt(FH[0]*FHc[0]))
     etafunc = pyasf.makefunc(eta)
     self.etafunc = etafunc
     etaval = etafunc(theta)
     s=-np.sign(etaval.real)
     X=etaval+s*np.sqrt(etaval**2-1)
     self.etaval=etaval
     return X
예제 #7
0
 def calc_transmission_amplitude(self, theta, Energy):
     self.calc_parameters(theta, Energy)
     alpha=self.alpha
     Q=self.Q
     eta=self.eta
     XT=pyasf.makefunc(sp.sqrt(eta**2-1)/Q, "numpy")
     return XT.dictcall(dict(theta=theta, **self.structure.subs))
예제 #8
0
    def calc_parameters(self, theta, Energy):
        Miller=self.Miller
        struct=self.structure
        wavelenght=12398./Energy
        Volume=struct.V.subs(struct.subs).evalf()
        r_e=2.818e-5
        Gamma=r_e*wavelenght**2/(sp.pi*Volume)
        g0=self.g0
        gH=self.gH
        b=g0/gH
        C=1
        
        thetaBragg=self.calc_Bragg_angle(Energy).subs(struct.subs).evalf()
        FH=struct.DAFS(Energy, Miller)
        FHc=struct.DAFS(Energy, tuple([-i for i in Miller]))
        F0=struct.DAFS(Energy, (0,0,0))

        
        thetasym = sp.Symbol("theta", real=True)
        eta=(-b*(thetasym-thetaBragg)*sp.sin(2*thetaBragg)-Gamma*F0[0]*(1-b)/2)/(sp.sqrt(sp.Abs(b))*C*Gamma*sp.sqrt(FH[0]*FHc[0]))
        etafunc = pyasf.makefunc(eta)
        self.etafunc = etafunc
        etaval = etafunc(theta)
        self.etaval=etaval
        
        
        T=sp.pi*C*Gamma*sp.sqrt(FH[0]*FHc[0])*self.thickness/(wavelenght*sp.sqrt(abs(g0*gH)))

        self.T=T = complex(T.evalf(subs=struct.subs))
        
        alpha=T*np.sqrt(etaval**2-1)
        Q=np.sqrt(etaval**2-1)*np.cos(alpha)+1j*etaval*np.sin(alpha)
        self.alpha=alpha
        self.Q=Q
예제 #9
0
 def calc_layer_Miller(self):
     for layer in self.Layers:
         M=layer.structure.M.subs(layer.structure.subs).evalf()
         R=layer.R.subs(layer.structure.subs).evalf()
         RS=self.substrate.R.subs(self.substrate.structure.subs).evalf()
         H=RS*self.substrate.H.subs(self.substrate.structure.subs).evalf()
         Recq=M.T*R.T*H
         layer.Miller=sp.Matrix([int(round(element)) for element in Recq])
         u=H.normalized()
         k_in_unit = self.substrate.k_in_unit(sp.Symbol("theta"))
         thetalayer= pyasf.makefunc(-sp.asin(k_in_unit.dot(u)))
         layer.thetalayer=thetalayer
예제 #10
0
 def calc_theta_layer(self):
     theta=sp.Symbol("theta")
     self.substrate.theta_layer_expr=theta
     for layer in self.Layers:
         M=layer.structure.M
         R=layer.R
         RM = (R*M)
         u=(R*M.T.inv()*layer.Miller).normalized()
         layer.u=u
         k_in_unit = self.substrate.k_in_unit(theta)
         theta_layer_expr=-sp.asin(k_in_unit.dot(u))
         layer.theta_layer_expr=theta_layer_expr
         layer.theta_layer_func=pyasf.makefunc(theta_layer_expr, "numpy")
예제 #11
0
 def calc_layer_Miller(self):
     for layer in self.Layers:
         M = layer.structure.M.subs(layer.structure.subs).evalf()
         R = layer.R.subs(layer.structure.subs).evalf()
         RS = self.substrate.R.subs(self.substrate.structure.subs).evalf()
         H = RS * self.substrate.H.subs(
             self.substrate.structure.subs).evalf()
         Recq = M.T * R.T * H
         layer.Miller = sp.Matrix([int(round(element)) for element in Recq])
         u = H.normalized()
         k_in_unit = self.substrate.k_in_unit(sp.Symbol("theta"))
         thetalayer = pyasf.makefunc(-sp.asin(k_in_unit.dot(u)))
         layer.thetalayer = thetalayer
예제 #12
0
 def calc_layer_Miller(self):
     for layer in self.Layers:
         M=layer.structure.M
         R=layer.R
         RM = (R*M).subs(layer.structure.subs).evalf()
         
         RS=self.substrate.R
         H=RS*self.substrate.H
         Recq=RM.T * H.subs(self.substrate.structure.subs).evalf()
         layer.Miller=sp.Matrix([int(round(element)) for element in Recq])
         u=(RM.T.inv()*layer.Miller).normalized()
         layer.u=u
         k_in_unit = self.substrate.k_in_unit(sp.Symbol("theta"))
         thetalayer= pyasf.makefunc(-sp.asin(k_in_unit.dot(u)))
         layer.thetalayer=thetalayer
예제 #13
0
    def calc_parameters(self, theta, Energy):
        Miller = self.Miller
        struct = self.structure
        wavelenght = 12398. / Energy
        Volume = struct.V.subs(struct.subs).evalf()
        r_e = 2.818e-5
        Gamma = r_e * wavelenght**2 / (sp.pi * Volume)
        g0 = self.g0
        gH = self.gH
        b = g0 / gH
        C = 1

        thetaBragg = self.calc_Bragg_angle(Energy).subs(struct.subs).evalf()
        FH = struct.DAFS(Energy, Miller)
        FHc = struct.DAFS(Energy, tuple([-i for i in Miller]))
        F0 = struct.DAFS(Energy, (0, 0, 0))

        thetasym = sp.Symbol("theta", real=True)
        eta = (-b * (thetasym - thetaBragg) * sp.sin(2 * thetaBragg) -
               Gamma * F0[0] * (1 - b) / 2) / (sp.sqrt(sp.Abs(b)) * C * Gamma *
                                               sp.sqrt(FH[0] * FHc[0]))
        etafunc = pyasf.makefunc(eta)
        self.etafunc = etafunc
        etaval = etafunc(theta)
        self.etaval = etaval

        T = sp.pi * C * Gamma * sp.sqrt(FH[0] * FHc[0]) * self.thickness / (
            wavelenght * sp.sqrt(abs(g0 * gH)))

        self.T = T = complex(T.evalf(subs=struct.subs))

        alpha = T * np.sqrt(etaval**2 - 1)
        Q = np.sqrt(etaval**2 -
                    1) * np.cos(alpha) + 1j * etaval * np.sin(alpha)
        self.alpha = alpha
        self.Q = Q
예제 #14
0
 def calc_reflection_amplitude(self, theta, Energy):
     self.calc_parameters(theta, Energy)
     alpha=self.alpha
     Q=self.Q
     XR = pyasf.makefunc(sp.I*sp.sin(alpha)/Q, "numpy")
     return XR.dictcall(dict(theta=theta, **self.structure.subs))