-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeatFlow.py
69 lines (54 loc) · 1.49 KB
/
HeatFlow.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import numpy as np
from PipeGrid import PipeGrid
from getNeighbours import getNeighbours
import matplotlib.pyplot as plt
from simulate import run
# Global parameters
v = 21.8
L = 0.1
t_Tot = L / v
T_g = 573.15
k_s = 16.3
rho_s = 8030
reco_step = 1
def body():
dh = 0.0001
dt = 0.0001
time = 100
t_finish = int(time/dt)
grid = PipeGrid(dh)
X = int(grid.shape[0]/2)
Y = grid.shape[1] - 2
T_Tot = []
file = open('stats.csv', 'w')
file.write('Time (s), Temperature (K)\n')
T_Tot.append(grid)
file.write('{0}, {1:.2f}\n'.format(0, grid[X, Y]))
for t in np.arange(1, t_finish):
print("----{}----".format(t*dt))
z = v * dt * t
if z < L:
heated = int(z/dh)
grid[:heated, 1] = T_g
if t % reco_step == 0:
T_Tot.append(grid)
file.write('{0:.2f}, {1:.2f}\n'.format(t*dt, grid[X, Y]))
else:
grid[:, 1] = T_g
break
run(grid, T_g, k_s, rho_s, T_Tot, dh, dt)
t_start = t
for t in np.arange(t_start, t_finish):
print("----{}----".format(t*dt))
if t % reco_step == 0:
T_Tot.append(grid)
file.write('{0:.2f}, {1:.2f}\n'.format(t*dt, grid[X, Y]))
run(grid, T_g, k_s, rho_s, T_Tot, dh, dt)
t_list = np.arange(len(T_Tot)) * dt
T_plot = []
for T in T_Tot:
T_plot.append(T[X, Y])
file.close()
return t_list, T_plot
if __name__ == '__main__':
body()