def __set_g(self, g): self.__g = array(g) self.gnorm = Physics.norm(g) self.gnormalized = Physics.normalize(g) # angular coordinates (azimuth and colatitude) of the g versor self.gtheta = math.acos(self.gnormalized[2]) self.gphi = Physics.atan2(g[1], g[0])
def __set_k(self, k): self.__k = array(k) self.knorm=Physics.norm(k) self.knormalized = Physics.normalize(k) # Calculates wavelength and energy of the photon if self.knorm==0.: self.__e, self.__lam=0., '+inf' else: self.__lam=2.*pi/self.knorm self.__e=Booklet.hc/self.__lam
def __set_g(self, g): self.__g = array(g) self.gnorm = Physics.norm(g) self.gnormalized = Physics.normalize(g) # angular coordinates of the reciprocal lattice vector g # gtheta is the polar angle (the angle between z axis and g vector) # gphi is the azimuthal angle (in the plane xy, from the x axis) self.gtheta = math.acos(self.gnormalized[2]) self.gphi = Physics.atan2(g[1], g[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
def best_thickness(keV): """Wrapper for the Physics module function""" return Physics.best_thickness(keV, Z, hkl, eta) g=20 theta_0=0 D=2000 dim1=1.5 dim2=1.5 dim3=0.3 g=0 gnormalized = Physics.normalize(g) gtheta = 0.0 EB = 100.0 def extinction_factor(keVB, theta_0): return Physics.extinction_factor(keVB, Z, hkl, microthick, theta_0) def getDelta(self, tB, OFFSET=0.): return pi/2-gtheta-tB mat_facs = Booklet.mat_fac(Z, hkl)