/[ascend]/branches/fprops-incomp/models/johnpye/fprops/pipe_sequence_plot.py
ViewVC logotype

Contents of /branches/fprops-incomp/models/johnpye/fprops/pipe_sequence_plot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3469 - (show annotations) (download) (as text)
Thu Feb 13 01:45:55 2020 UTC (7 months ago) by jpye
File MIME type: text/x-python
File size: 3000 byte(s)
correct error in insulation cost.
add report on temperature drops.

1 # -*- coding: utf8 -*-
2 import extpy, sys
3 from solverreporter import *
4 from __builtin__ import *
5 import sys, os, os.path
6 if 'ASCENDLIBRARY' in os.environ:
7 p1 = os.path.join(os.environ['ASCENDLIBRARY'],'johnpye/fprops/python')
8 print "ADDING PATH",p1
9 sys.path.append(p1)
10 import fprops
11
12 try:
13 import matplotlib.pyplot as pl
14 import numpy as np
15 except:
16 pass
17
18 #--- heat exchange (T,H) plot ---
19
20 def pipe_sequence_plot(self):
21 """Plot T-H diagram of heat transfer in a heater_closed model"""
22 import loading
23 loading.load_matplotlib(throw=True)
24 import matplotlib.pyplot as pl
25 import numpy as np
26
27 pl.ioff()
28 pl.subplot(311)
29 pl.hold(1)
30
31 extpy.getbrowser().reporter.reportNote("Gathering values...")
32
33 D = fprops.fluid(str(self.cd.component.getSymbolValue()))
34
35 n = self.n.getIntValue()
36 p = np.zeros((n+1))
37 T = np.zeros((n+1))
38 L = np.zeros((n))
39 Q = np.zeros((n))
40 T_ext = np.zeros((n))
41 for i in range(n):
42 p[i] = float(self.P[i+1].inlet.p) / 1e5
43 T[i] = float(self.P[i+1].inlet.T)
44 L[i] = float(self.P[i+1].L)
45 Q[i] = float(self.P[i+1].Q)
46 T_ext[i] = float(self.P[i+1].T_ext)
47 p[n] = float(self.P[n].outlet.p) / 1e5;
48 T[n] = float(self.P[i+1].outlet.T)
49
50 extpy.getbrowser().reporter.reportNote("Plotting...")
51
52 x = np.zeros((n+1))
53 x[0] = 0;
54 for i in range(n):
55 x[i+1] = x[i] + L[i]
56
57 pl.plot(x,p,'bo-');
58 pl.ylabel(unicode(r"p / [bar]"))
59 pl.subplot(312)
60 pl.plot(x,T,'ro-');
61 pl.plot(x[1:],T_ext,'go-')
62 pl.ylabel(unicode(r"T / [K]"))
63
64 pl.subplot(313)
65 pl.plot(x[1:],Q,'ro-')
66 pl.ylabel(unicode(r"Q / [W]"))
67
68 pl.title(unicode(r"Pipe heat loss and pressure drop (fluid %s)" % D.name))
69 pl.xlabel("x / [m]")
70
71 extpy.getbrowser().reporter.reportNote("Plotting completed")
72 pl.ion()
73 pl.show()
74
75 def table_to_text(t):
76 #import tabulate
77 return "\n".join(["\t".join([str(c) for c in r]) for r in t]) + "\n"
78 def float_C(n):
79 return float(n)-273.15
80
81 def disharray_temperature_list(self):
82 n_DI = self.n_DI.getIntValue()
83 n_PH = self.n_PH.getIntValue()
84 t = []
85 t.append(["Location","T / [��C]","p / [bar]"])
86 import ascpy
87 for i in range(n_DI):
88 t.append(["DI[%d].inlet"%i, float_C(self.DI[i].inlet.T), float(self.DI[i].inlet.p)/1e5])
89 t.append(["DI[%d].outlet"%i, float_C(self.DI[i].outlet.T), float(self.DI[i].outlet.p)/1e5])
90 t.append(["TH[%d].outlet"%i, float_C(self.TH[i].outlet.T), float(self.DI[i].outlet.p)/1e5])
91 t.append(["inlet", float_C(self.inlet.T), float(self.inlet.p)/1e5])
92 t.append(["outlet", float_C(self.outlet.T), float(self.outlet.p)/1e5])
93 s = table_to_text(t) + "\n"
94
95 t = []
96 t.append(["Pipe","T_in / [��C]","T_out / [��C]","L / [m]", "D_i / [m]","t_pipe / [m]","Vel_out / [m/s]"])
97 for i in range(n_PH):
98 d = {'PC[%d]'%i : self.PC[i], 'PH[%d]'%i : self.PH[i]}
99 for k,n in d.iteritems():
100 t.append([k] + [float(j) for j in [n.T_in_C, n.T_out_C, n.L, n.D, n.t_pipe, n.Vel_out]])
101 s += table_to_text(t) + "\n"
102 extpy.getbrowser().show_info(s,"csparray temperatures")
103
104 extpy.registermethod(pipe_sequence_plot)
105 extpy.registermethod(disharray_temperature_list)
106
107

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22