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

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

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

revision 2673 by jpye, Wed Dec 12 06:04:23 2012 UTC revision 2674 by jpye, Thu Jan 24 02:27:41 2013 UTC
# Line 14  except: Line 14  except:
14    
15  #--- for (T,s) plots ---  #--- for (T,s) plots ---
16    
17  def sat_curve(d):  def sat_curve(D):
18      Tt = d.T_t      Tt = D.T_t
19      Tc = d.T_c      Tc = D.T_c
20      TT = []      TT = []
21      pp = []      pp = []
22      ssf = []      ssf = []
23      ssg = []      ssg = []
24      for T in linspace(Tt,Tc,100):      for T in linspace(Tt,Tc,100):
25          res,p,rf,rg = fprops.fprops_sat_T(T,d)          # TODO this is inefficient because of repeated saturation solutions.
26          if not res:          SF = D.set_Tx(T,0)
27              TT.append(T - 273.15)          SG = D.set_Tx(T,1)
28              pp.append(p)          TT.append(SF.T - 273.15)
29              ssf.append(fprops.helmholtz_s_raw(T,rf,d)/1.e3)          pp.append(SF.p)
30              ssg.append(fprops.helmholtz_s_raw(T,rg,d)/1.e3)          ssf.append(SF.s/1.e3)
31            ssg.append(SG.s/1.e3)
32      plot(ssf,TT,"b--")      plot(ssf,TT,"b--")
33      plot(ssg,TT,"r--")      plot(ssg,TT,"r--")
34    
# Line 41  def write(msg): Line 42  def write(msg):
42    
43  def pconst(S1,S2,n):  def pconst(S1,S2,n):
44      """Return a set of (T,s) points between two states, with pressure held constant."""      """Return a set of (T,s) points between two states, with pressure held constant."""
45      D = fprops.fprops_fluid(str(S1.cd.component.getSymbolValue()))        D = fprops.fluid(str(S1.cd.component.getSymbolValue()),str(S1.cd.type.getSymbolValue()))    
46      out = []      out = []
47      hh = linspace(float(S1.h), float(S2.h), n)      hh = linspace(float(S1.h), float(S2.h), n)
48      for h in hh:      for h in hh:
49          res, T, rho = fprops.fprops_solve_ph(float(S1.p), h, 0, D)          S = D.set_ph(float(S1.p), h)
50          if not res:          out += [TSPoint(S.T,S.s)]
             out += [TSPoint(T,fprops.helmholtz_s(T,rho,D))]  
51      return out      return out
52    
53    
# Line 69  class THPoint: Line 69  class THPoint:
69    
70  def pconsth(S1,S2,n):  def pconsth(S1,S2,n):
71      """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"""
72      D = fprops.fprops_fluid(str(S1.cd.component.getSymbolValue()))        D = fprops.fluid(str(S1.cd.component.getSymbolValue()),str(S1.cd.type.getSymbolValue()))    
73      out = []      out = []
74      hh = linspace(float(S1.h), float(S2.h), n)      hh = linspace(float(S1.h), float(S2.h), n)
75      mdot = float(S1.mdot)      mdot = float(S1.mdot)
76      for h in hh:      for h in hh:
77          res, T, rho = fprops.fprops_solve_ph(float(S1.p), h, 0, D)          # TODO add try/except
78          if not res:          S = D.set_ph(float(S1.p),h)
79              out += [THPoint(T,h * mdot)]          out += [THPoint(S.T,h * mdot)]
80      return out      return out
81    
82  def plot_TH(SS,style='b-',Href = 0):  def plot_TH(SS,style='b-',Href = 0):
# Line 95  def cycle_plot_brayton(self): Line 95  def cycle_plot_brayton(self):
95      loading.load_matplotlib(throw=True)      loading.load_matplotlib(throw=True)
96      ioff()      ioff()
97      figure()      figure()
98      hold(1)      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
     D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))  
99      sat_curve(D)      sat_curve(D)
100        hold(1)
101    
102      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)
103      condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)      condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)
# Line 121  def cycle_plot_rankine_regen2(self): Line 121  def cycle_plot_rankine_regen2(self):
121      ioff()      ioff()
122      figure()      figure()
123      hold(1)      hold(1)
124      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
125      sat_curve(D)      sat_curve(D)
126    
127      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)
# Line 164  def cycle_plot_rankine_regen1(self): Line 164  def cycle_plot_rankine_regen1(self):
164      ioff()      ioff()
165      figure()      figure()
166      hold(1)      hold(1)
167      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
168      sat_curve(D)      sat_curve(D)
169    
170      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)
# Line 205  def heater_closed_plot(self): Line 205  def heater_closed_plot(self):
205      ioff()      ioff()
206      figure()      figure()
207      hold(1)      hold(1)
208      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
209      HE = self.HE      HE = self.HE
210    
211      extpy.getbrowser().reporter.reportNote("Fluid is %s" % D.name)        extpy.getbrowser().reporter.reportNote("Fluid is %s" % D.name)  
# Line 237  def cycle_plot_brayton_regen(self): Line 237  def cycle_plot_brayton_regen(self):
237      ioff()      ioff()
238      figure()      figure()
239      hold(1)      hold(1)
240      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
241      sat_curve(D)          sat_curve(D)    
242    
243      # plot gas turbine cycle      # plot gas turbine cycle
# Line 263  def cycle_plot_brayton_split(self): Line 263  def cycle_plot_brayton_split(self):
263      ioff()      ioff()
264      figure()              figure()        
265      hold(1)      hold(1)
266      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
267      sat_curve(D)      sat_curve(D)
268            
269      # add some dots for the points in the cycle      # add some dots for the points in the cycle
# Line 318  def cycle_plot_brayton_reheat(self): Line 318  def cycle_plot_brayton_reheat(self):
318      ioff()      ioff()
319      figure()              figure()        
320      hold(1)      hold(1)
321      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
322      sat_curve(D)      sat_curve(D)
323            
324      # plot gas turbine cycle      # plot gas turbine cycle
# Line 345  def cycle_plot_brayton_reheat_regen(self Line 345  def cycle_plot_brayton_reheat_regen(self
345      ioff()      ioff()
346      figure()              figure()        
347      """hold(1)      """hold(1)
348      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()))
349      sat_curve(D)"""      sat_curve(D)"""
350            
351      # plot gas turbine cycle      # plot gas turbine cycle
# Line 374  def cycle_plot_brayton_reheat_regen_inte Line 374  def cycle_plot_brayton_reheat_regen_inte
374      ioff()      ioff()
375      figure()              figure()        
376      hold(1)      hold(1)
377      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))      D = fprops.fluid(str(self.cd.component.getSymbolValue()),str(self.cd.type.getSymbolValue()))
378      sat_curve(D)      sat_curve(D)
379            
380      # add some dots for the points in the cycle      # add some dots for the points in the cycle
# Line 424  def air_stream_heat_exchanger_plot(self) Line 424  def air_stream_heat_exchanger_plot(self)
424      ioff()      ioff()
425      figure()      figure()
426      hold(1)      hold(1)
427      D = fprops.fprops_fluid(str(self.cd_cold.component.getSymbolValue()))      D = fprops.fluid(str(self.cd_cold.component.getSymbolValue()),str(self.cd_cold.type.getSymbolValue()))
428    
429      n = self.n.getIntValue()      n = self.n.getIntValue()
430      extpy.getbrowser().reporter.reportNote("Fluid is %s" % D.name)        extpy.getbrowser().reporter.reportNote("Fluid is %s" % D.name)  
# Line 447  def air_stream_heat_exchanger_plot(self) Line 447  def air_stream_heat_exchanger_plot(self)
447      show()      show()
448      #savefig(os.path.expanduser("~/Desktop/air_stream_heatex.eps"))      #savefig(os.path.expanduser("~/Desktop/air_stream_heatex.eps"))
449    
 def regenerator_plot_fprops(self):  
     """Plot T-H diagram of regenerator"""  
     import loading; loading.load_matplotlib(throw=True)  
     ioff(); figure(); hold(1)  
     D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))  
     extpy.getbrowser().reporter.reportNote("Fluid is %s" % D.name)    
   
     plot_TH(pconsth(self.inlet_hot, self.outlet_hot, 50),'r-',  
         Href = (float(self.outlet_hot.h)*float(self.outlet_hot.mdot))\  
     )  
   
     plot_TH(pconsth(self.inlet, self.outlet, 50),'b-',  
         Href = (float(self.inlet.h)*float(self.inlet.mdot))\  
     )  
   
     title(unicode(r"%s heat exchanger" % D.name))  
     ylabel(unicode(r"T / [°C]"))  
     xlabel("H / [MW]")  
   
     extpy.getbrowser().reporter.reportNote("Plotting completed")  
     ion()  
     show()  
   
   
450  extpy.registermethod(cycle_plot_brayton)  extpy.registermethod(cycle_plot_brayton)
451  extpy.registermethod(cycle_plot_rankine_regen1)  extpy.registermethod(cycle_plot_rankine_regen1)
452  extpy.registermethod(cycle_plot_rankine_regen2)  extpy.registermethod(cycle_plot_rankine_regen2)
# Line 479  extpy.registermethod(cycle_plot_ccgt) Line 455  extpy.registermethod(cycle_plot_ccgt)
455  extpy.registermethod(cycle_plot_brayton_split)  extpy.registermethod(cycle_plot_brayton_split)
456  extpy.registermethod(heater_closed_plot)  extpy.registermethod(heater_closed_plot)
457  extpy.registermethod(air_stream_heat_exchanger_plot)  extpy.registermethod(air_stream_heat_exchanger_plot)
 extpy.registermethod(regenerator_plot_fprops)  
458  extpy.registermethod(cycle_plot_brayton_reheat_regen)  extpy.registermethod(cycle_plot_brayton_reheat_regen)
459  extpy.registermethod(cycle_plot_brayton_reheat)  extpy.registermethod(cycle_plot_brayton_reheat)
460  extpy.registermethod(cycle_plot_brayton_reheat_regen_intercool)  extpy.registermethod(cycle_plot_brayton_reheat_regen_intercool)

Legend:
Removed from v.2673  
changed lines
  Added in v.2674

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