forked from cedricrocha/Python-Finite-Elements-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluxodecalor1d_Vilem.py
276 lines (200 loc) · 13.4 KB
/
fluxodecalor1d_Vilem.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# -*- coding: utf-8 -*-
"""fluxodecalor1D_Vilem.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1XaSvs1bwIukJkbtWq5McXDwEb02_yH7f
Código para resolver um problema simples de transmissão de calor, unidimensional, pelo método dos elementos fintos (problema do livro do Fish & Belytschko). Importamos as bibliotecas de algebra matricial e de gráficos
![image.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZgAAABiCAYAAABtRcWeAAATvklEQVR4Ae2de1AUV77HtzZbdff6z2Zra+8fibvGRBGCigm3tjSauF5jXIzGGBM1JlFBjRjFa7xxI7oRH6iIiqJoxCcqooKCiiAxSnyhPFzXFyqFyGOBEYIMGUCYMJPvrTM6Ms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IAiRAAqokQINRZbcxaBIgARJQPgEajPL7iBGSAAmQgCoJ0GBU2W0MmgRIgASUT4AGo/w+YoQkQAIkoEoCNBhVdhuDJgESIAHlE6DBKL+PGCEJkAAJqJIADUaV3cagSYAESED5BP4fLRTnSaP+YmQAAAAASUVORK5CYII=)
"""
import numpy as np
import matplotlib.pyplot as plt
"""
Parâmetros do cálculo: comprimento total da barra,
área da seção transversal, constante elástica, comprimento dos elementos, módulo de Young. A dimensão do problema é igual ao número de nós. Exemplo 2 elementos lineares, 3 nós. 4 elementos lineares, 5 nós"""
#Quantidade de nós. deve ser modificado pelo usuário
nos = 3
#Vamos plotar dois cálculos para comparação
nos2 = 10
#Comprimento total da barra
comp = 4
#Seção transversal
A = 0.1
#Condutividade térmica
k = 2
#Temperatura fixa no primeiro nó (extremo esquerdo engastado)
T0 = 0
#Fluxo de calor no último nó (extremo direito)
q = 5
#Fonte interna de calor
s = 5
#A partir daqui, nada deve ser modidificado.Estrutura 1D - elementos = nos -1
elem = nos - 1
elem2 = nos2 - 1
#Tamanho dos elementos
l = comp / elem
l2 = comp / elem2
#Condutividade térmica dos elementos
k1 = A * k / l
k2 = A * k / l2
print(nos, elem, l, k1)
print(nos2, elem2, l2, k2)
"""Se quiséssemos escrever a matriz manualmente, no caso de dim=3, seria assim"""
#K=np.array([[0.1,-0.1,0], [-0.1,0.2,-0.1], [0.0,-0.1,0.1]])
#print(K)
"""Automatizando Matriz Rigidez. Método direto"""
#K1=np.identity(nos,float)
K1 = np.zeros((nos, nos))
for i in range(nos):
for j in range (nos):
if (i == j and (i == 0 or i == (nos - 1))):
K1[i, j] = k1
elif abs(i - j) == 1:
K1[i, j] = -k1
elif (i == j and (i != 0 or i != (nos - 1))):
K1[i, j] = 2 * k1
print(K1)
"""Agora para a segunda análise com número maior de nós nos2
"""
#K2=np.identity(nos2,float)
K2 = np.zeros((nos2, nos2))
for i in range(nos2):
for j in range (nos2):
if (i == j and (i == 0 or i == (nos2 - 1))):
K2[i, j] = k2
elif abs(i - j) == 1:
K2[i, j] = -k2
elif (i == j and (i != 0 or i != (nos - 1))):
K2[i, j] = 2 * k2
print(K2)
"""O determinante nulo indica que as condições de contorno do problema não foram definidas"""
#det=np.linalg.det(K1)
#print(det)
#u,v=np.linalg.eig(K1)
#print("Autovalores",u),
#print("Autovetores",v)
"""Se invertermmos a matriz singular, teremos uma mensagem de erro"""
#M=np.linalg.inv(K1)
#print(M)
"""Impondo BC. No caso, apenas o nó 1 está engastado. Cortamos a linha 1 e a coluna 1 da matriz K1, pois o primeiro nó está fixo (engastado). Note que agora o determinante da submatriz livre não é mais nulo e ela é invesível
"""
S = K1[1:, 1:]
#S = np.identity(nos - 1, float)
#for i in range(nos - 1):
#for j in range(nos - 1):
#S[i, j] = K1[i + 1, j + 1]
print(S)
#det2=np.linalg.det(S)
#print(det2)
"""Para o segundo conjunto de nós"""
S2 = K2[1:, 1:]
#S2 = np.identity(nos2 - 1, float)
#for i in range(nos2 - 1):
#for j in range(nos2 - 1):
#S2[i, j] = K2[i + 1, j + 1]
print(S2)
INV = np.linalg.inv(S)
print(INV)
#print(np.linalg.det(INV))
INV2 = np.linalg.inv(S2)
print(INV2)
"""Apenas para verificação. O produto de uma matriz pela sua inversa deve dar a matriz identidade (números em potências 1o^(-16 são numericamente zero)"""
#I=INV@S
#print(I)
"""Source é a matriz coluna dos termos de fonte interna de calor, no exemplo s=5 W/m mas pode ser mudado acima. A matriz de força de corpo para cada elemento será dada pelo produto do interpolador de lagrange por esta matriz
"""
#Source=np.array([s,s])
#Fce=l/6*np.array([[2,1],[1,2]])@Source.T
#print(Fce)
"""Escrevemos as Matrizes de força de corpo, de superfície e total usando matrizes expandidas ao invés de matrizes de junção"""
Fc = np.zeros(nos)
for i in range(nos):
if i == 0 or i == nos - 1 :
Fc[i] = l * s / 2
#print("Ciclo", i)
else:
Fc[i] = l * s
Fs = np.zeros(nos)
if i == nos - 1:
Fs[i] = -0.5
else:
Fs[i] = 0
F = Fc + Fs
print(Fc, Fs, F)
"""Para o problema com nos2"""
Fc2 = np.zeros(nos2)
for i in range(nos2):
if i == 0 or i == nos2 - 1:
Fc2[i] = l2 * s / 2
#print("Ciclo", i)
else:
Fc2[i] = l2 * s
Fs2 = np.zeros(nos2)
if i == nos2 - 1 :
Fs2[i] = -0.5
else:
Fs2[i] = 0
F2 = Fc2 + Fs2
print(Fc2, Fs2, F2)
"""Cortamos os termos associados aos nós engastados (no caso, apenas o primeiro)"""
FL = F[1:]
#FL=np.ones(nos - 1)
#array1d=np.ones(3)
#print(array1d)
#for i in range(nos - 1) :
#FL[i] = F[i + 1]
print(FL)
FL2 = F2[1:]
#FL2 = np.ones(nos2 - 1)
#for i in range(nos2 - 1):
#FL2[i] = F2[i + 1]
print(FL2)
"""Multiplicando a inversa da submatriz de rigidez livre, com a matriz de força livre, obtemos os valores da temperatura nos 4 nós livres. A temperatura no nó engastado é dada: zero grau Celsius."""
T = INV @ FL
#print("Temperaturas com",nos,"nós:", T)
T2 = INV2 @ FL2
#print("Temperaturas com",nos2,"nós:", T2)
"""Para fazer o gráfico, determinamos os pontos das coordenadas dos nós. No caso de dim=5 são 0, 1, 2, 3, e 4 """
x1 = np.linspace(0, comp, nos)
print(x1)
x2 = np.linspace(0, comp, nos2)
print(x2)
"""Agora escrevemos a matriz de valores de temperatura, juntando os resultados calculados com o valor prescrito do nó engastado, x=0, T1=0"""
#Tc = np.ones(nos)
Tc = np.zeros(nos)
for i in range(nos):
if i == 0:
Tc[i] = 0.0
else:
Tc[i] = T[i - 1]
print("Temperaturas com", nos, "nós:", Tc)
#Tc2 = np.ones(nos2)
Tc2 = np.zeros(nos2)
for i in range(nos2):
if i==0:
Tc2[i] = 0.0
else:
Tc2[i] = T2[i - 1]
print("Temperaturas com", nos2, "nós:", Tc2)
"""Fazemos o gráfico, sobrepondo a solução exata do problema (quadrática) com os resultados que obtivemos"""
x = np.linspace(0, comp, 20)
Tex = -12.5 * x ** 2 + 97.5 * x
print("Nós 1 =", nos, "Nós 2 =", nos2)
# Criar uma figura e dois subplots lado a lado
fig, (ax1, ax2) = plt.subplots(1, 2)
# Aumenta o tamanho dos subplots proporcionalmente
#fig, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw={'width_ratios': [3, 2]})
# Aumenta o tamanho dos subplots de forma idependente
fig.set_size_inches(9, 9)
ax1.plot(x, Tex, lw=4, label="exata"),
ax1.plot(x1, Tc, "o--", color="red", label='Elementos Finitos com nos={}' .format(nos))
ax1.set_xlabel("distância")
ax1.set_ylabel("Temperatura C")
ax1.set_title("Temperatura barra 3 nós")
ax1.legend(loc='lower right', fontsize=10, ncol=1)
#Segundo gráfico do subplot
ax2.plot(x, Tex, lw=4, label="exata"),
ax2.plot(x2, Tc2, "*--", color="red", ms=10, label="Elementos Finitos com nos={}".format(nos2))
ax2.set_title("Temperatura barra 10 nós")
ax2.legend(loc='lower right', fontsize=10, ncol=1)
# Exibir os gráficos
plt.show()