-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.py
48 lines (40 loc) · 1.52 KB
/
point.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import matplotlib.pyplot as plt
dx = 0.0000000000001
linelength = 2000
def_dir = np.array([-np.cos(np.pi/3), -np.sin(np.pi/5)])
#default_dir = np.array([-1,0])
class Particle():
"""particle type with attributes of postition and direction"""
def __init__(self, coords, direction=def_dir):
self.coords = coords
#self.fermi_cicle = fermi_circle
self.direction = direction
self.intermediate_point = 'empty'
def line_coordinates(self):
"""beginning and end of trajectory in a dir"""
start_coord = self.coords + dx * self.direction/np.linalg.norm(self.direction)
expanded_dir = linelength * self.direction
end_coord = self.coords + expanded_dir
line = [(start_coord[0], start_coord[1]), (end_coord[0], end_coord[1])]
return line
def normal(self, boundary):
"""calculates inward normal of the boundary at the interseciton point"""
normal = - boundary.grad(self.coords[0], self.coords[1])
return normal
def tangent(self,boundary):
"""calculated tangent to the boundary and the intersection point"""
normal = normal(boundary)
tangent = np.array([- normal[1], normal[0]])
return tangent
class Phonon (Particle):
def __init__(self, coords, direction=def_dir):
super().__init__(coords, direction)
self.specie = "phonon"
class Electron(Particle):
def __init__(self, coords, direction, fermi_circle, k_vector_index):
"""inherits from the Lead class"""
super().__init__(coords, direction)
self.specie = "electron"
self.fermi_circle = fermi_circle
self.k_vector_index = k_vector_index