-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.py
48 lines (37 loc) · 1.22 KB
/
geometry.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
''' This is a library of differnet geometries that can be used for the modelling '''
import csv
import copy
import numpy as np
import math
from scipy.interpolate import interp1d
def single_hump(length, number_nodes):
L = length
dx = L/(number_nodes-1)
x = np.zeros(number_nodes)
zb = np.ones(number_nodes)
''' Gaussian curve parameters '''
A0 = 1.0
A1 = 1.0 # mean
lam = length
for i in range(len(x)):
x[i] = -lam/2. + i*dx
zb[i] = A0 + A1*math.cos(2.0*math.pi*x[i]/lam)
return x,zb
def flume_experiment(num_cells):
x=[]
zb=[]
with open(r'C:\Users\Patrick\Dropbox\PhD\Morphodynamic_Model\data\BedProfile_eq_v03.csv','rb') as csvfile:
reader = csv.reader(csvfile,delimiter=',')
for row in reader:
x.append(float(row[0])/100.)
zb.append(float(row[1])/100.)
xnew = np.linspace(min(x),max(x), num=num_cells)
f1 = interp1d(x,zb)
zbnew = f1(xnew)
''' Copy the variables '''
x = copy.deepcopy(xnew)
zb = copy.deepcopy(zbnew)
return x,zb
if __name__ == "__main__":
x,zb = single_hump(20., 201)
print zb