-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.py
More file actions
41 lines (28 loc) · 1.35 KB
/
source.py
File metadata and controls
41 lines (28 loc) · 1.35 KB
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
import numpy as np
class Source:
def __init__(self, strength, x0, y0):
self.strength = strength
self.x0 = x0
self.y0 = y0
def evaluate(self, x_map, y_map):
i = (self.strength / (2 * np.pi)) * (x_map - self.x0) / ((x_map - self.x0) ** 2 + (y_map - self.y0) ** 2)
j = (self.strength / (2 * np.pi)) * (y_map - self.y0) / ((x_map - self.x0) ** 2 + (y_map - self.y0) ** 2)
return i, j
class Vortex:
def __init__(self, strength, x0, y0):
self.strength = strength
self.x0 = x0
self.y0 = y0
def evaluate(self, x_map, y_map): # not working?
u = -(self.strength / (2 * np.pi)) * (y_map - self.y0) / ((x_map - self.x0) ** 2 + (y_map - self.y0) ** 2)
v = (self.strength / (2 * np.pi)) * (x_map - self.x0) / ((x_map - self.x0) ** 2 + (y_map - self.y0) ** 2)
return u, v
class Doublet:
def __init__(self, strength, x0, y0):
self.strength = strength
self.x0 = x0
self.y0 = y0
def evaluate(self, x_map, y_map): # not working?
w = -(self.strength / (2 * np.pi)) * ((x_map - self.x0) ** 2 - (y_map - self.y0) ** 2) / ((x_map - self.x0) ** 2 + (y_map - self.y0) ** 2)**2
z = -(self.strength / (2 * np.pi)) * 2 * (x_map - self.x0) * (y_map - self.y0) / ((x_map - self.x0) ** 2 + (y_map - self.y0) ** 2) ** 2
return w, z