Peano
Loading...
Searching...
No Matches
Bindding.py
Go to the documentation of this file.
1import numpy as np
2from scipy import io
3import os
4import time
5
6def tracer_seeds_generate(Type=1, a=-0.5, b=0.5 ,N_x=10, N_y=10, N_z=10):
7 x_s = np.linspace(a,b,N_x)
8 if Type==2: #slide
9 y_s = np.linspace(a,b,N_y)
10 if Type==3: #volume
11 y_s = np.linspace(a,b,N_y)
12 z_s = np.linspace(a,b,N_z)
13
14 if Type==1:
15 print("creating tracer seeds on the line of x-axis")
16 f=open('line.dat','w')
17 for i in range(N_x):
18 x=str(x_s[i]); y=str(0); z=str(0)
19 line=" "+x+" "+y+" "+z+"\n"
20 f.write(line)
21 f.close()
22
23 if Type==2:
24 print("creating tracer seeds on x-y plane")
25 f=open('slide.dat','w')
26 for i in range(N_x):
27 for j in range(N_y):
28 x=str(x_s[i]); y=str(y_s[j]); z=str(0)
29 line=" "+x+" "+y+" "+z+"\n"
30 f.write(line)
31 f.close()
32
33 if Type==3:
34 print("creating tracer seeds over domain")
35 f=open('volume.dat','w')
36 for i in range(N_x):
37 for j in range(N_y):
38 for k in range(N_z):
39 x=str(x_s[i]); y=str(y_s[j]); z=str(z_s[k])
40 line=" "+x+" "+y+" "+z+"\n"
41 f.write(line)
42 f.close()
43
44def read_scale_factor_table(table_name="test_table.dat"):
45 f=open(table_name,'r')
46 table=f.readlines()
47 output=[[],[]]
48 for line in table:
49 tem=list(map(float,line.split(' ')))
50 output[0].append(tem[0])
51 output[1].append(tem[1])
52
53 return output
54
55
56
57
58
59
60
61
62
63
64
65
66