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


Python Physics.rot方法代码示例

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


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

示例1: divergence_sphi

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import rot [as 别名]
    def  divergence_sphi(self,r):
        theta, phi = pi/2-self.xtal.gtheta, self.xtal.gphi
        rot_in_xtal = lambda x: Physics.rot(x, (('y', -theta), ('z', phi)))
        drag_in_xtal = lambda x: array(self.xtal.r) - array(x)        

        r=rot_in_xtal(self.photon.r)
        r=drag_in_xtal(self.photon.r)
        if self.xtal.source_lens_distance == "inf":
            return 0.0
        else:
            
            return math.atan ( r[1] / r[0] )
开发者ID:enricovirgilli,项目名称:lll,代码行数:14,代码来源:Source.py

示例2: generate_position

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import rot [as 别名]
 def generate_position(self):
    
     theta, phi = pi/2-self.xtal.gtheta, self.xtal.gphi
     self.photon.r = self.random_position_on_surface()
     # lambda functions to:
     # 1. Convert from the crystal reference frame to the lens reference frame;
     # 2. Rotate the photon WRT the lens axis till it corresponds to its defined xtal;
     drag_out_xtal = lambda x: array(x) + array(self.xtal.r)
     rot_out_xtal = lambda x: Physics.rot(x, (('y', -theta), ('z', -phi)))
     
     # Set the photon position in the observer reference frame (rotation + translation)
     self.photon.r=rot_out_xtal(self.photon.r)
     self.photon.r=drag_out_xtal(self.photon.r)
开发者ID:enricovirgilli,项目名称:lll,代码行数:15,代码来源:Source.py

示例3: interaction

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import rot [as 别名]
    def interaction(self):
        """Interaction between photon and xtal."""

        # Lambda function for coordinate transformation
        theta, phi = pi/2-self.xtal.gtheta, self.xtal.gphi
        drag_in_xtal = lambda x: x-self.xtal.r
        drag_out_xtal = lambda x: x+self.xtal.r
        rot_in_xtal  = lambda x: Physics.rot(x, (('z', phi), ('y', theta)))
        rot_out_xtal = lambda x: Physics.rot(x, (('y', -theta), ('z', -phi)))
        in_xtal = lambda x: rot_in_xtal(drag_in_xtal(x))
        out_xtal= lambda x: drag_out_xtal(rot_out_xtal(x))

        # Changing reference frame for photon and xtal
        self.photon.k=rot_in_xtal(self.photon.k)
        self.photon.r = in_xtal(self.photon.r)
        self.xtal.g=rot_in_xtal(self.xtal.g)

        self.int_history=[] # History init

        # Photon adventure begins...
        while self.isinside():
            interaction_type=self.which_interaction()
            self.interact(interaction_type)
            if interaction_type==0: break # Photoabsorption: the photon dies in to xtal

        # Photon adventure is over...
        if interaction_type==0: pass # Dead photon (photo-absorption)
        elif self.photon.knormalized[2]<=0.: # photon points towards focal plane... (no backscattering)
            # Back to the original reference frame
            self.photon.k=rot_out_xtal(self.photon.k)
            self.photon.r=out_xtal(self.photon.r)
            # transport the photon to the focal plane
            self.photon.travelz(0.)
        else: pass # Photon is backscattered and thus lost

        # anyway the xtal goes backs to the previous reference frame
        self.xtal.g=rot_out_xtal(self.xtal.g)
开发者ID:enricovirgilli,项目名称:lll,代码行数:39,代码来源:Source.py

示例4: divergence_stheta

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import rot [as 别名]
 def divergence_stheta(self, r):
     source_extension = 0.035
     if self.xtal.source_lens_distance == "inf":
         return 0.0
     else: 
         theta, phi = pi/2-self.xtal.gtheta, self.xtal.gphi
         rot_in_xtal = lambda x: Physics.rot(x, (('y', -theta), ('z', phi)))
         drag_in_xtal = lambda x: array(self.xtal.r) - array(x)
         
         r=rot_in_xtal(self.photon.r)
         r=drag_in_xtal(self.photon.r)
     
         if r[0] <= 0: s = math.sqrt(r[0]**2 + r[1]**2)
         else: s = -math.sqrt(r[0]**2 + r[1]**2)
         deltas = uniform (-source_extension/2 , source_extension/2 )
         return math.atan(( s + deltas) / self.xtal.source_lens_distance)
开发者ID:enricovirgilli,项目名称:lll,代码行数:18,代码来源:Source_originale15febb2016.py

示例5: generator

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import rot [as 别名]
    def generator(self, Emin=1., Emax=1000., Exp=False,  sphi=0., stheta=pi):
        '''Generates randomly a photon that will go on to xtal.
        Exp is the powerlaw spectral index (-2.1 for the Crab Nebula).
        '''
        theta, phi = pi/2-self.xtal.gtheta, self.xtal.gphi
        # lambda functions #
        drag_out_xtal = lambda x: array(x) + array(self.xtal.r)
        rot_out_xtal = lambda x: Physics.rot(x, (('y', -theta), ('z', -phi)))

        # Puts a photon an EPSILON under the xtal surface in a random 2D point
        random_pos_on_surface=[uniform(-x/2., x/2.) for x in self.xtal.dim[:2]]
        random_pos_on_surface.append(-EPSILON)
        self.photon.r=random_pos_on_surface

        # The photon position in observer reference frame (rotation + translation)
        self.photon.r=rot_out_xtal(self.photon.r)
        self.photon.r=drag_out_xtal(self.photon.r)
        if self.photon.i !=1: self.photon.i=1.
        # wavevector definition from source angular parameters
        self.photon.k=Physics.makenormalvec(sphi, stheta)
        # Energy calculation (powerlaw if Exp is False)
        self.erandom((Emin, Emax), Exp=Exp)
开发者ID:enricovirgilli,项目名称:lll,代码行数:24,代码来源:Source.py


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