当前位置: 首页>>代码示例>>Python>>正文


Python Physics.spherical2cartesian方法代码示例

本文整理汇总了Python中Physics.spherical2cartesian方法的典型用法代码示例。如果您正苦于以下问题:Python Physics.spherical2cartesian方法的具体用法?Python Physics.spherical2cartesian怎么用?Python Physics.spherical2cartesian使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Physics的用法示例。


在下文中一共展示了Physics.spherical2cartesian方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: change_the_g

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import spherical2cartesian [as 别名]
    def change_the_g(self, g): 
        # funzione che in base alla posizione del cristallo su cui cade il
        # fotone gli cambia il g relativamente alla curvatura del cristallo
        raggio = math.sqrt (self.photon.r[0]**2 + self.photon.r[1]**2)
        
        delta_angle =  (self.xtal.rho-raggio ) * self.xtal.curvature

        gtheta = self.xtal.gtheta + delta_angle
        
        return Physics.spherical2cartesian(norm(g),self.xtal.gphi, gtheta)
开发者ID:enricovirgilli,项目名称:lll,代码行数:12,代码来源:Source.py

示例2: g_needed

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import spherical2cartesian [as 别名]
    def g_needed(self, order=1):
        
        ###############################################
        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])
        ###############################################
        
        """Calculates the reciprocal lattice vector that a photon needs to be
        scattered by a known crystal with planes oriented in a particular
        direction that is already known"""
        #When the energy is too low the returned value is None.
        if self.photon.knorm < self.xtal.gnorm*order: return None
        # For the calculation see the notes of 09/07/2004 modified the 12/07/04

        A = (self.photon.k[0]*math.cos(local_xtal_gphi)+self.photon.k[1]*math.sin(local_xtal_gphi))
        B = self.photon.k[2]
        C = self.xtal.gnorm/2.

        #A = (self.photon.k[0]*math.cos(self.xtal.gphi)+self.photon.k[1]*math.sin(self.xtal.gphi))
        #B = self.photon.k[2]
        #C = self.xtal.gnorm/2.

        if abs(A)<=EPSILON:
            # B can't be 0 together with A unless gnorm=0, so this function should be almost safe
            # The result can be otained with the calculation in the else block
            # but this is faster and common (is the case of paraxial photons).
            if abs(C/B)>1.: return None
            else: 
                theta=math.acos(-C/B)
        else:
            A2B2=A**2+B**2
            BC=B*C
            # Two solutions, but only one satisfies the Laue equation
            Mean=-BC/A2B2
            try:
                Delta=A*math.sqrt(A2B2-C**2)/A2B2
            except ValueError:
                return None
            cosp, cosm = Mean+Delta, Mean-Delta
            thp, thm = math.acos(cosp), math.acos(cosm)
            sinp, sinm = math.sin(thp), math.sin(thm)
            checkp = abs(A*sinp + B*cosp + C)
            checkm = abs(A*sinm + B*cosm + C)
            # Da ricontrollare
            if  checkp<checkm:
                theta=thp
            else:
                theta=thm
        return Physics.spherical2cartesian(self.xtal.gnorm, local_xtal_gphi, theta)
开发者ID:enricovirgilli,项目名称:lll,代码行数:53,代码来源:Source.py


注:本文中的Physics.spherical2cartesian方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。