/[ascend]/trunk/models/johnpye/fprops/cycle_plot.py
ViewVC logotype

Diff of /trunk/models/johnpye/fprops/cycle_plot.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2304 by jpye, Sun Aug 22 01:33:16 2010 UTC revision 2305 by jpye, Sun Aug 22 11:22:34 2010 UTC
# Line 61  def plot_Ts(SS,style='b-'): Line 61  def plot_Ts(SS,style='b-'):
61  #--- for (T,H) plots ---  #--- for (T,H) plots ---
62    
63  class THPoint:  class THPoint:
64      def __init__(self,T,H):      def __init__(self,T,h,mdot = 1.):
65          self.T = T          self.T = T
66          self.H = H          self.h = h
67            self.mdot = mdot
68    
69  def pconsth(S1,S2,n):  def pconsth(S1,S2,n):
70      """Return a set of (T,H) points between two states, with pressure constant"""      """Return a set of (T,H) points between two states, with pressure constant"""
71      D = fprops.fprops_fluid(str(S1.cd.component.getSymbolValue()))        D = fprops.fprops_fluid(str(S1.cd.component.getSymbolValue()))  
72      out = []      out = []
73      hh = linspace(float(S1.h), float(S2.h), n)      hh = linspace(float(S1.h), float(S2.h), n)
74        mdot = float(S1.mdot)
75      for h in hh:      for h in hh:
76          res, T, rho = fprops.fprops_solve_ph(float(S1.p), h, 0, D)          res, T, rho = fprops.fprops_solve_ph(float(S1.p), h, 0, D)
77          if not res:          if not res:
78              out += [THPoint(T,h * float(S1.mdot))]              out += [THPoint(T,h * mdot)]
79      return out      return out
80    
81  def plot_TH(SS,style='b-',Href = 0):  def plot_TH(SS,style='b-',Href = 0):
# Line 81  def plot_TH(SS,style='b-',Href = 0): Line 83  def plot_TH(SS,style='b-',Href = 0):
83      yy = []      yy = []
84      for S in SS:      for S in SS:
85          yy.append(float(S.T) - 273.15)          yy.append(float(S.T) - 273.15)
86          xx.append((float(S.H) - Href)/1.e6)          xx.append(((float(S.h)*float(S.mdot)) - Href)/1.e6)
87      plot(xx,yy,style)      plot(xx,yy,style)
88    
89  #--- various Rankine cycle configurations ---  #--- various Rankine cycle configurations ---
# Line 223  def heater_closed_plot(self): Line 225  def heater_closed_plot(self):
225    
226  #--- the big one: a combined-cycle GT ---  #--- the big one: a combined-cycle GT ---
227    
228  def cycle_plot(self):  def cycle_plot_ccgt(self):
229      """Plot T-s diagram for combined-cycle gas turbine"""      """Plot T-s diagram for combined-cycle gas turbine"""
230      import loading      import loading
231      loading.load_matplotlib(throw=True)      loading.load_matplotlib(throw=True)
# Line 234  def cycle_plot(self): Line 236  def cycle_plot(self):
236    
237      # plot gas turbine cycle      # plot gas turbine cycle
238      SS = [self.GC.inlet, self.GC.outlet, self.GT.inlet, self.GT.outlet, self.HE.inlet, self.HE.outlet, self.GC.inlet]      SS = [self.GC.inlet, self.GC.outlet, self.GT.inlet, self.GT.outlet, self.HE.inlet, self.HE.outlet, self.GC.inlet]
239      plot_Ts(SS)      plot_Ts(SS,'g-')
240        plot_Ts(SS,'go')
241      hold(1)      hold(1)
242            
243      sat_curve(d)      sat_curve(D)
244    
245      boiler_curve = pconst(self.HE.inlet_cold,self.HE.outlet_cold,100)      boiler_curve = pconst(self.HE.inlet_cold,self.HE.outlet_cold,100)
246      condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)      condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)
247      SS2 = [self.PU.outlet, self.HE.inlet_cold] + boiler_curve + [self.HE.outlet_cold, self.TU.inlet, self.TU.outlet, self.CO.inlet] + condenser_curve + [self.CO.outlet, self.PU.inlet, self.PU.outlet]      SS2 = [self.PU.outlet, self.HE.inlet_cold] + boiler_curve + [self.HE.outlet_cold, self.TU.inlet, self.TU.outlet, self.CO.inlet] + condenser_curve + [self.CO.outlet, self.PU.inlet, self.PU.outlet]
248      plot_Ts(SS2)      plot_Ts(SS2)
249        plot_Ts([self.PU.outlet, self.HE.inlet_cold,self.HE.outlet_cold, self.TU.inlet, self.TU.outlet, self.CO.inlet,self.CO.outlet, self.PU.inlet, self.PU.outlet],'bo')
250    
251        title(unicode(r"Combined cycle with air and %s" % D.name))
252        ylabel(unicode(r"T / [°C]"))
253        xlabel("s / [kJ/kg/K]")
254    
255        extpy.getbrowser().reporter.reportNote("Plotting completed")
256        ion()
257        show()
258        savefig(os.path.expanduser("~/Desktop/ccgt.eps"))
259        savefig(os.path.expanduser("~/Desktop/ccgt.png"))
260    
261    
262      title(unicode(r"With %s bottoming cycle" % d.name))  #--- simple gas turbine models ---
263    
264    def cycle_plot_brayton_regen(self):
265        """Plot T-s diagran for regenerative gas turbine"""
266        import loading
267        loading.load_matplotlib(throw=True)
268        ioff()
269        figure()        
270    
271        # plot gas turbine cycle
272        SS = [self.CO.inlet, self.CO.outlet, self.RE.inlet, self.RE.outlet, self.BU.inlet,self.BU.outlet, self.TU.inlet, self.TU.outlet,self.RE.inlet_hot, self.RE.outlet_hot, self.DI.inlet, self.DI.outlet,self.CO.inlet]
273        plot_Ts(SS,'g-')
274        plot_Ts(SS,'go')
275        hold(1)
276    
277        title(unicode(r"Regenerative Brayton cycle"))
278      ylabel(unicode(r"T / [°C]"))      ylabel(unicode(r"T / [°C]"))
279      xlabel("s / [kJ/kg/K]")      xlabel("s / [kJ/kg/K]")
280    
281      extpy.getbrowser().reporter.reportNote("Plotting completed")      extpy.getbrowser().reporter.reportNote("Plotting completed")
282      ion()      ion()
283      show()      show()
284        savefig(os.path.expanduser("~/Desktop/brayton_regen.eps"))
285    
286    #--- air-to-stream heat exchanger plot ---
287    
288    def air_stream_heat_exchanger_plot(self):
289        """Plot T-H diagram of heat transfer in a heater_closed model"""
290        import loading
291        loading.load_matplotlib(throw=True)
292        ioff()
293        figure()
294        hold(1)
295        D = fprops.fprops_fluid(str(self.cd_cold.component.getSymbolValue()))
296    
297        n = self.n.getIntValue()
298        extpy.getbrowser().reporter.reportNote("Fluid is %s" % D.name)  
299    
300        # hot side is the air, calculated in the model
301        plot_TH( [self.H[i] for i in range(1+int(n))],'r-',\
302            Href = (float(self.outlet.h)*float(self.outlet.mdot))\
303        )
304    
305        plot_TH(pconsth(self.inlet_cold, self.outlet_cold, 50),'b-',
306            Href = (float(self.inlet_cold.h)*float(self.inlet_cold.mdot))\
307        )
308    
309        title(unicode(r"Combined-cycle air-%s heat exchanger" % D.name))
310        ylabel(unicode(r"T / [°C]"))
311        xlabel("H / [MW]")
312    
313        extpy.getbrowser().reporter.reportNote("Plotting completed")
314        ion()
315        show()
316        savefig(os.path.expanduser("~/Desktop/air_strea_heatex.eps"))
317    
318    
319  extpy.registermethod(cycle_plot_rankine)  extpy.registermethod(cycle_plot_rankine)
320  extpy.registermethod(cycle_plot_rankine_regen1)  extpy.registermethod(cycle_plot_rankine_regen1)
321  extpy.registermethod(cycle_plot_rankine_regen2)  extpy.registermethod(cycle_plot_rankine_regen2)
322    extpy.registermethod(cycle_plot_brayton_regen)
323    extpy.registermethod(cycle_plot_ccgt)
324    
325  extpy.registermethod(heater_closed_plot)  extpy.registermethod(heater_closed_plot)
326    extpy.registermethod(air_stream_heat_exchanger_plot)
327    
 extpy.registermethod(cycle_plot)  
328  #the above method can be called using "EXTERNAL fourbarplot(SELF)" in ASCEND.  #the above method can be called using "EXTERNAL fourbarplot(SELF)" in ASCEND.

Legend:
Removed from v.2304  
changed lines
  Added in v.2305

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