-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrabalho_varia_N.py
79 lines (64 loc) · 1.82 KB
/
trabalho_varia_N.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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Aluno: Thales Carl Lavoratti
Matricula: 15100656
Data: 27/11/2019
Trabalho computacional da disciplina EMC5419 – MECÂNICA DOS FLUIDOS II
"""
#import numpy as
import math
import matplotlib.pyplot as plt
from CoolProp.CoolProp import PropsSI
from auxiliar import getGasFraction, getRho, getMu, SolutionContext
#input data
fluid= 'R600a'
T_in = 318.15 #K
T_out = 248.15 #K
D = 5.5e-4 #m
massFlow = 2.0 #kg/h
massFlow = massFlow/3600.0 #kg/s
A = math.pi * D * D * 0.25
G = massFlow / A
P_in = PropsSI('P','T',T_in ,'Q',0,fluid)
P_out = PropsSI('P','T',T_out,'Q',0,fluid)
Ns = range(5,75,5)
save = SolutionContext()
for N in Ns:
deltaP = (P_out - P_in)/float(N)
P_1 = P_in
deltaL = 1.0
L = 0
x_1 = 0
maxIterations = 10000
stopCounter = 0
while(deltaL > 0):
P_2 = P_1 + deltaP
x_2 = getGasFraction(fluid,G,P_1,P_2,x_1)
rho_1 = getRho(x_1,fluid,P_1)
rho_2 = getRho(x_2,fluid,P_2)
mu_1 = getMu(x_1,fluid,P_1)
mu_2 = getMu(x_2,fluid,P_2)
V_1 = G/rho_1
V_2 = G/rho_2
Re_1 = (rho_1*V_1*D)/mu_1
Re_2 = (rho_2*V_2*D)/mu_2
f_1 = 0.3316/((Re_1)**0.25)
f_2 = 0.3316/((Re_2)**0.25)
f_m = 0.5 * (f_1 + f_2)
V_m = 0.5 * (V_1 + V_2)
deltaL = (P_1 - P_2 + G*(V_1-V_2))*D/(0.5*f_m*G*V_m)
L += deltaL
x_1 = x_2
P_1 = P_2
stopCounter += 1
if(stopCounter > maxIterations):
print('Código não convergiu')
deltaL = float('nan')
save.N.append(N)
save.L.append(L)
plt.grid(color='k', linestyle=':', linewidth=0.5)
plt.plot(save.N,save.L,'sk')
plt.xlabel(r'N [-]')
plt.ylabel('L [cm]')
plt.savefig('length_N_edson.png')