예제 #1
0
    def diffracted_eranges(self, Emin=1., Emax=1000., sphi=0., stheta=pi, deltasource=0): 
        
        l = math.sqrt(self.photon.r[0]**2 + self.photon.r[1]**2)

        sphi = self.divergence_sphi(self.photon.r)
        
        """Energy ranges that are diffracted by the crystals."""
        ##################################################################
        #local_xtal_g = self.change_the_g(self.xtal.g)
        #local_xtal_gphi = Physics.atan2(local_xtal_g[1], local_xtal_g[0])
        #local_xtal_gtheta = math.acos(local_xtal_g[2])
        ##################################################################
        order, reached_max_order = 0,False
        factor = 2.5 
        if self.xtal.structure == "mosaic":
            Deltatheta = 1.0 * (self.xtal.fwhm/60/180*pi) 
        else:
            Darwin_Width = Physics.darwinwidth(self.xtal.Z, self.xtal.hkl, self.photon.e)
            Deltatheta =  Darwin_Width + (self.xtal.dim[2] * self.xtal.curvature) / factor
            
        Delta_curvature = self.xtal.curvature * self.xtal.dim[0]
                 
        thetamin, thetamax = self.xtal.gtheta-Deltatheta/2-Delta_curvature/2, self.xtal.gtheta+Deltatheta/2+Delta_curvature/2
        
        constant=-Booklet.hc/(2.*self.xtal.d_hkl)
        eranges=[]
        while not reached_max_order:
            order+=1
            cosdeltaphi=math.cos(sphi-self.xtal.gphi)
            sinstheta=math.sin(stheta)
            cosstheta=math.cos(stheta)
            sinthetamin=math.sin(thetamin)
            costhetamin=math.cos(thetamin)
            sinthetamax=math.sin(thetamax)
            costhetamax=math.cos(thetamax)

           
            Emin_= constant*order/(cosdeltaphi*sinstheta*sinthetamin+cosstheta*costhetamin)
            Emax_= constant*order/(cosdeltaphi*sinstheta*sinthetamax+cosstheta*costhetamax)
            #print "DELTAE",  order, Emin_, Emax_, Emax_- Emin_
            if Emax_ >= Emax:
                if Emin_>=Emax: return eranges
                else:
                    reached_max_order=True
                    Emax_=Emax
            if Emin_ <= Emin:
                if Emax_ <= Emin: pass
                else:
                    Emin_=Emin
                    eranges.append((Emin_, Emax_))
                    
            else: eranges.append((Emin_, Emax_))  
        return eranges
예제 #2
0
    def local_eranges(self, Emin=1., Emax=1000., sphi=0., stheta=pi, deltasource=0):
        
        l = math.sqrt(self.photon.r[0]**2 + self.photon.r[1]**2)

        #stheta = stheta - self.divergence_stheta(l, deltasource)
        sphi = self.divergence_sphi(self.photon.r)

        local_xtal_g = self.change_the_g(self.xtal.g) 
        lgn=Physics.normalize(local_xtal_g)
        local_xtal_gphi = Physics.atan2(local_xtal_g[1], local_xtal_g[0])
        local_xtal_gtheta = math.acos(lgn[2])
        order, reached_max_order = 0,False
        factor = 2.5 
        Darwin_Width = Physics.darwinwidth(self.xtal.Z, self.xtal.hkl, self.photon.e)
        if self.xtal.structure == "mosaic":
            Deltatheta = 1.0 * (self.xtal.fwhm/60/180*pi) 
        else:
            Deltatheta = Darwin_Width + (self.xtal.dim[2] * self.xtal.curvature) / factor
        Delta_curvature = self.xtal.curvature * self.xtal.dim[0]
        
        thetamin, thetamax = local_xtal_gtheta-Deltatheta/2, local_xtal_gtheta+Deltatheta/2

        constant=-Booklet.hc/(2.*self.xtal.d_hkl)
        eranges=[]
        while not reached_max_order:
            order+=1
            cosdeltaphi=math.cos(sphi-local_xtal_gphi)
            sinstheta=math.sin(stheta)
            cosstheta=math.cos(stheta)
            sinthetamin=math.sin(thetamin)
            costhetamin=math.cos(thetamin)
            sinthetamax=math.sin(thetamax)
            costhetamax=math.cos(thetamax)
            Eminim_= constant*order/(cosdeltaphi*sinstheta*sinthetamin+cosstheta*costhetamin)
            Emaxim_= constant*order/(cosdeltaphi*sinstheta*sinthetamax+cosstheta*costhetamax)
            if Emaxim_ >= Emax:
                if Eminim_>=Emax: return eranges
                else:
                    reached_max_order=True
                    Emaxim_=Emax
            if Eminim_ <= Emin:
                if Emaxim_ <= Emin: pass
                else:
                    Eminim_=Emin
                    eranges.append((Eminim_, Emaxim_))                   
            else: eranges.append((Eminim_, Emaxim_))

        return eranges