-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.py
95 lines (64 loc) · 3.18 KB
/
temp.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import numpy as np
import matplotlib.pyplot as plt
k = 60.5
h = 100
x = 0.3
y = 0.3
dx = 0.06
dy = 0.06
Tinf = 750
alpha = 17.7e-06
iteracoes = 33
dt = 0.3
criterioEstabilidade = (((-2*((alpha*dt)/(dy**2))) + ((alpha*dt)/(dx**2)) + 1))
print(criterioEstabilidade >= 0)
comportamentoCentral = np.array([300])
x = np.array([[750, 750, 750, 750, 750, 750, 750],
[750, 300, 300, 300, 300, 300, 750],
[750, 300, 300, 300, 300, 300, 750],
[750, 300, 300, 300, 300, 300, 750],
[750, 300, 300, 300, 300, 750, 750],
[750, 300, 300, 300, 750, 750, 750],
[750, 750, 750, 750, 750, 750, 750]])
x = x.astype(float)
y = x.astype(float)
tiposCelulas = np.array([[0, 0, 0, 0, 0, 0, 0],
[0, 8, 3, 3, 3, 7, 0],
[0, 2, 5, 5, 5, 1, 0],
[0, 2, 5, 5, 6, 10, 0],
[0, 2, 5, 6, 10, 0, 0],
[0, 9, 4, 10, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]])
linhas, colunas = x.shape
print("Perfil de temperatura inicial da barra (os valores 750 se referem ao ar quente)")
print(x)
while(x[3,3] < 600):
for m in range(linhas):
for n in range(colunas):
if tiposCelulas[m,n] == 0: # ar quente
y[m,n] = Tinf
if tiposCelulas[m,n] == 1: # lateral direita
y[m,n] = ((2*x[m-1,n] + x[m,n+1] + x[m,n-1]) + Tinf*(2*h*dx)/k) / (2*((h*dx/k)+2))
if tiposCelulas[m,n] == 2: # lateral esquerda
y[m,n] = ((2*x[m+1,n] + x[m,n+1] + x[m,n-1]) + Tinf*(2*h*dx)/k) / (2*((h*dx/k)+2))
if tiposCelulas[m,n] == 3: # lateral cima
y[m,n] = ((2*x[m,n-1] + x[m+1,n] + x[m-1,n]) + Tinf*(2*h*dx)/k) / (2*((h*dx/k)+2))
if tiposCelulas[m,n] == 4: # lateral baixo
y[m,n] = ((2*x[m,n+1] + x[m+1,n] + x[m-1,n]) + Tinf*(2*h*dx)/k) / (2*((h*dx/k)+2))
if tiposCelulas[m,n] == 5: # interna
y[m,n] = (x[m,n+1] + x[m,n-1] + x[m+1,n] + x[m-1,m]) / 4
if tiposCelulas[m,n] == 6: # vulco inferior direito
y[m,n] = ((2*(x[m-1,n] + x[m,n+1]) + (x[m+1,n] + x[m,n-1]) + (2*Tinf*h*dx)/k)) / (2*((h*dx/k)+3))
if tiposCelulas[m,n] == 7: # canto superior direito
y[m,n] = (x[m,n-1] + x[m-1,n] + (Tinf*(2*(h*dx)))/k) / (2*((h*dx/k)+1))
if tiposCelulas[m,n] == 8: # canto superior esquerdo
y[m,n] = (x[m,n-1] + x[m+1,n] + (Tinf*(2*(h*dx)))/k) / (2*((h*dx/k)+1))
if tiposCelulas[m,n] == 9: # canto inferior esquerdo
y[m,n] = (x[m,n+1] + x[m+1,n] + (Tinf*(2*(h*dx)))/k) / (2*((h*dx/k)+1))
if tiposCelulas[m,n] == 10: # canto inferior direito
y[m,n] = (x[m,n+1] + x[m-1,n] + (Tinf*(2*(h*dx)))/k) / (2*((h*dx/k)+1))
x += dt * (y - x)
print(x[3,3])
print(np.round(x, 3))
i, j = np.meshgrid(np.arange(x.shape[0]), np.arange(x.shape[1]))
plt.imshow(x, cmap='plasma', interpolation='nearest')