コード例 #1
0
ファイル: LightSources.py プロジェクト: GuzSku/mcclanahoochie
 def photon(self):
     photon = Photon()
     
     photon.source = self.source_id
     photon.id = self.throw
     self.throw = self.throw + 1
     
     intphi = np.random.randint(1, self.spacing+1)        
     inttheta = np.random.randint(1, self.spacing+1)
     
     phi = intphi*(self.phimax-self.phimin)/self.spacing
     if self.thetamin == self.thetamax:
         theta = self.thetamin
     else:
         theta = inttheta*(self.thetamax-self.thetamin)/self.spacing
     
     x = np.cos(phi)*np.sin(theta)      
     y = np.sin(phi)*np.sin(theta) 
     z = np.cos(theta)
     direction = (x,y,z)
     
     transform = tf.translation_matrix((0,0,0))
     point = transform_point(self.center, transform)
     
     photon.direction = direction
     photon.position = point
     
     if self.spectrum != None:
         photon.wavelength = self.spectrum.wavelength_at_probability(np.random.uniform())
     else:
         photon.wavelength = self.wavelength
         
     photon.active = True
     
     return photon
コード例 #2
0
ファイル: LightSources.py プロジェクト: taymingyang/pvtrace
    def photon(self):
        photon = Photon()
        photon.source = self.source_id
        photon.id = self.throw
        self.throw = self.throw + 1

        phi = np.random.uniform(self.phimin, self.phimax)
        theta = np.random.uniform(self.thetamin, self.thetamax)

        x = np.cos(phi) * np.sin(theta)
        y = np.sin(phi) * np.sin(theta)
        z = np.cos(theta)
        direction = (x, y, z)

        transform = tf.translation_matrix((0, 0, 0))
        point = transform_point(self.center, transform)

        photon.direction = direction
        photon.position = point

        if self.spectrum != None:
            photon.wavelength = self.spectrum.wavelength_at_probability(
                np.random.uniform())
        else:
            photon.wavelength = self.wavelength

        photon.active = True

        return photon
コード例 #3
0
 def photon(self):
     photon = Photon()
     photon.source = self.source_id
     photon.id = self.throw
     self.throw = self.throw + 1 
     # Create a point which is on the surface of the finite plane in it's local frame
     x = np.random.uniform(0., self.length)
     y = np.random.uniform(0., self.width)
     local_point = (x, y, 0.)
     
     # Transform the direciton
     photon.position = transform_point(local_point, self.plane.transform)
     photon.direction = self.direction
     photon.active = True
     if self.spectrum != None:
         photon.wavelength = self.spectrum.wavelength_at_probability(np.random.uniform())
     else:
         photon.wavelength = self.wavelength
     return photon
コード例 #4
0
ファイル: LightSources.py プロジェクト: taymingyang/pvtrace
    def photon(self):
        photon = Photon()
        photon.source = self.source_id
        photon.id = self.throw
        self.throw = self.throw + 1

        # Position of emission
        phi = np.random.uniform(0., 2 * np.pi)
        r = np.random.uniform(0., self.radius)

        x = r * np.cos(phi)
        y = r * np.sin(phi)
        z = np.random.uniform(0., self.length)
        local_center = (x, y, z)

        photon.position = transform_point(local_center, self.shape.transform)

        # Direction of emission (no need to transform if meant to be isotropic)
        phi = np.random.uniform(0., 2 * np.pi)
        theta = np.random.uniform(0., np.pi)

        x = np.cos(phi) * np.sin(theta)
        y = np.sin(phi) * np.sin(theta)
        z = np.cos(theta)
        local_direction = (x, y, z)

        photon.direction = local_direction

        # Set wavelength of photon
        if self.spectrum != None:
            photon.wavelength = self.spectrum.wavelength_at_probability(
                np.random.uniform())
        else:
            photon.wavelength = self.wavelength

        # Further initialisation
        photon.active = True

        return photon
コード例 #5
0
ファイル: LightSources.py プロジェクト: GuzSku/mcclanahoochie
 def photon(self):
     photon = Photon()
     photon.source = self.source_id
     photon.id = self.throw
     self.throw = self.throw + 1 
     
     # Position of emission
     phi = np.random.uniform(0., 2*np.pi)
     r = np.random.uniform(0.,self.radius)        
     
     x = r*np.cos(phi)
     y = r*np.sin(phi) 
     z = np.random.uniform(0.,self.length)
     local_center = (x,y,z)
     
     photon.position = transform_point(local_center, self.shape.transform)
     
     
     # Direction of emission (no need to transform if meant to be isotropic)
     phi = np.random.uniform(0.,2*np.pi)
     theta = np.random.uniform(0.,np.pi)
     
     x = np.cos(phi)*np.sin(theta)
     y = np.sin(phi)*np.sin(theta)
     z = np.cos(theta)
     local_direction = (x,y,z)
     
     photon.direction = local_direction
     
     # Set wavelength of photon
     if self.spectrum != None:
         photon.wavelength = self.spectrum.wavelength_at_probability(np.random.uniform())        
     else:
         photon.wavelength = self.wavelength
         
     # Further initialisation
     photon.active = True
     
     return photon
コード例 #6
0
ファイル: LightSources.py プロジェクト: sheershoff/pvtrace
    def photon(self):
        photon = Photon()
        photon.source = self.source_id
        photon.id = self.throw
        self.throw = self.throw + 1

        #This does not work, since the area element scales with Sin(theta) d theta d phi
        #See  http://mathworld.wolfram.com/SpherePointPicking.html
        #Reimplementing the Randomizer

        phi = np.random.uniform(self.phimin, self.phimax)
        #theta = np.random.uniform(self.thetamin, self.thetamax)

        theta = -1
        while theta > self.thetamax or theta < self.thetamin:
            theta = np.arccos(2 * np.random.uniform(0, 1) - 1)

        x = np.cos(phi) * np.sin(theta)
        y = np.sin(phi) * np.sin(theta)
        z = np.cos(theta)
        direction = (x, y, z)

        transform = tf.translation_matrix((0, 0, 0))
        point = transform_point(self.center, transform)

        photon.direction = direction
        photon.position = point

        if self.spectrum != None:
            photon.wavelength = self.spectrum.wavelength_at_probability(
                np.random.uniform())
        else:
            photon.wavelength = self.wavelength

        photon.active = True

        return photon
コード例 #7
0
ファイル: LightSources.py プロジェクト: christophra/pvtrace
    def photon(self):
        photon = Photon()
        photon.source = self.source_id
        photon.id = self.throw
        self.throw = self.throw + 1
        
		
		#This does not work, since the area element scales with Sin(theta) d theta d phi
		#See  http://mathworld.wolfram.com/SpherePointPicking.html
		#Reimplementing the Randomizer
		
        phi = np.random.uniform(self.phimin, self.phimax)
        #theta = np.random.uniform(self.thetamin, self.thetamax)
		
        theta = -1
        while theta > self.thetamax or theta < self.thetamin :
            theta = np.arccos(2* np.random.uniform(0,1)-1)	
        
        x = np.cos(phi)*np.sin(theta)
        y = np.sin(phi)*np.sin(theta)
        z = np.cos(theta)
        direction = (x,y,z)
        
        transform = tf.translation_matrix((0,0,0))
        point = transform_point(self.center, transform)
        
        photon.direction = direction
        photon.position = point
        
        if self.spectrum != None:
            photon.wavelength = self.spectrum.wavelength_at_probability(np.random.uniform())
        else:
            photon.wavelength = self.wavelength
            
        photon.active = True
        
        return photon