-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExergy_mixed_water.py
More file actions
83 lines (62 loc) · 2.1 KB
/
Exergy_mixed_water.py
File metadata and controls
83 lines (62 loc) · 2.1 KB
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
import numpy as np
from tespy import cmp, con, nwk, hlp
# inputs
class Parameters:
def __init__(self, tw, tc, td, ta, q, cp):
self.Tw = tw
self.Tc = tc
self.Td = td
self.Ta = ta
self.Q = q
self.Cp = cp
def select_parameters():
tw = 45+273
tc = 8+273
td = 40+273
ta = 15+273
q = 100
cp = 4.19
p = Parameters(tw, tc, td, ta, q, cp)
return p
parameters_data = select_parameters()
nw = nwk.network(fluids=['H2O'], T_unit='K', p_unit='bar', h_unit='kJ / kg',
m_unit='kg / s')
def mass_flow():
mf = parameters_data.Q/(4.19*(parameters_data.Td - parameters_data.Tc))
e_w = (hlp.h_pT(100000, 318, 'H2O'))
e_c = (hlp.h_pT(100000, 281, 'H2O'))
mfc = (100-(e_w*mf))/(e_c-e_w)
mfw = mf-mfc
return mfc, mfw
mass_flow_data = mass_flow()
hw_in = cmp.source('hot water')
ww_out = cmp.sink('warm water out')
cc_in = cmp.source('cold water in')
m = cmp.merge('merge', num_in=2)
# connections
lin1 = con.connection(hw_in, 'out1', m, 'in1')
lin2 = con.connection(cc_in, 'out1', m, 'in2')
lin3 = con.connection(m, 'out1', ww_out, 'in1')
nw.add_conns(lin1, lin2, lin3)
# connection parametrization
lin1.set_attr(fluid={'H2O': 1}, T=parameters_data.Tw, m=mass_flow_data[0])
lin2.set_attr(fluid={'H2O': 1}, T=parameters_data.Tc, m=mass_flow_data[1])
lin3.set_attr(T=parameters_data.Td)
# solve
nw.solve('design')
mass_flow = round(lin3.m.val_SI, 2)
print('Demand mass_flow = ', mass_flow)
# demand exergy calculations
Tf = parameters_data.Td - parameters_data.Tc\
- parameters_data.Ta * np.log(parameters_data.Td/parameters_data.Tc)
Supply_exergy = mass_flow*Tf*parameters_data.Cp
print('Supply_exergy =', Supply_exergy)
# input exergy calculations
CarnotExergy_inputm1 = parameters_data.Q*(
1-(parameters_data.Ta/parameters_data.Tw))
CarnotExergy_inputm2 = parameters_data.Q*(
1-(parameters_data.Ta/parameters_data.Tc))
Input_exergy = CarnotExergy_inputm1+CarnotExergy_inputm2
print('Input_exergy =', Input_exergy)
Consumed_exergy = Input_exergy-Supply_exergy
print('Exergy_consumed =', Consumed_exergy)