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

revision 2300 by jpye, Fri Aug 20 05:47:43 2010 UTC revision 2301 by jpye, Sat Aug 21 13:28:35 2010 UTC
# Line 38  def write(msg): Line 38  def write(msg):
38
39  def pconst(S1,S2,n):  def pconst(S1,S2,n):
40      """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."""
41      D = fprops_fluid(S1.cd.component.getSymbolValue())        D = fprops.fprops_fluid(str(S1.cd.component.getSymbolValue()))
42      out = []      out = []
43      hh = linspace(float(S1.h), float(S2.h), n)      hh = linspace(float(S1.h), float(S2.h), n)
44      for h in hh:      for h in hh:
# Line 47  def pconst(S1,S2,n): Line 47  def pconst(S1,S2,n):
47              out += [TSPoint(T,fprops.helmholtz_s(T,rho,D))]              out += [TSPoint(T,fprops.helmholtz_s(T,rho,D))]
48      return out      return out
49
50  def plot_Ts(SS):  def plot_Ts(SS,style='b-'):
51      xx = []      xx = []
52      yy = []      yy = []
53      for S in SS:      for S in SS:
54          yy.append(float(S.T) - 273.15)          yy.append(float(S.T) - 273.15)
55          xx.append(float(S.s)/1.e3)          xx.append(float(S.s)/1.e3)
56      plot(xx,yy)      plot(xx,yy,style)
57
58  def cycle_plot(self):  def cycle_plot(self):
59      """Plot T-s diagram for combined-cycle gas turbine"""      """Plot T-s diagram for combined-cycle gas turbine"""
# Line 62  def cycle_plot(self): Line 62  def cycle_plot(self):
62      ioff()      ioff()
63      figure()      figure()
64
65      D = fprops_fluid(self.cd_rankine.component.getSymbolValue())      D = fprops.fprops_fluid(str(self.cd_rankine.component.getSymbolValue()))
66
67      # plot gas turbine cycle      # plot gas turbine cycle
68      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]
# Line 91  def cycle_plot_rankine(self): Line 91  def cycle_plot_rankine(self):
91      ioff()      ioff()
92      figure()      figure()
93      hold(1)      hold(1)
94      D = fprops_fluid(self.cd.component.getSymbolValue())      D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))
95      sat_curve(D)      sat_curve(D)
96
97      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)      boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)
98      condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)      condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)
99      SS = [self.PU.outlet, self.BO.inlet] + boiler_curve + [self.TU.inlet, self.TU.outlet] + condenser_curve + [self.CO.outlet, self.PU.outlet]      SS = [self.PU.outlet, self.BO.inlet] + boiler_curve + [self.TU.inlet, self.TU.outlet] + condenser_curve + [self.CO.outlet, self.PU.outlet]
100      plot_Ts(SS)      plot_Ts(SS)
101
102      title(unicode(r"Rankine cycle with %s" % D.name))      title(unicode(r"Rankine cycle with %s" % D.name))
103      ylabel(unicode(r"T / [°C]"))      ylabel(unicode(r"T / [°C]"))
104      xlabel("s / [kJ/kg/K]")      xlabel("s / [kJ/kg/K]")
# Line 106  def cycle_plot_rankine(self): Line 107  def cycle_plot_rankine(self):
107      ion()      ion()
108      show()      show()
109
110    def cycle_plot_rankine_regen2(self):
111        """Plot T-s diagram for a regenerative Rankine cycle (bleed steam regen)"""
114        ioff()
115        figure()
116        hold(1)
117        D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))
118        sat_curve(D)
119
120        boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)
121        condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)
122
123        SS = [self.PU1.inlet, self.PU1.outlet] + \
124                pconst(self.HE.inlet, self.HE.outlet, 100) + \
125                [self.PU2.inlet, self.PU2.outlet] + \
126                boiler_curve + \
127                [self.TU1.inlet, self.TU1.outlet, self.TU2.outlet] + \
128                condenser_curve + [self.PU1.inlet]
129
130        plot_Ts(SS)
131        plot_Ts(
132            [self.PU1.inlet, self.PU1.outlet, self.HE.inlet, self.HE.outlet,
133                self.PU2.inlet, self.PU2.outlet, self.TU1.inlet, self.TU1.outlet,
134                self.TU2.outlet, self.PU1.inlet]
135            ,'bo'
136        )
137
138        # line for the heat exchanger
139        plot_Ts(pconst(self.HE.inlet_heat, self.HE.outlet,100),'b-')
140
141        title(unicode(r"Regenerative Rankine cycle with %s" % D.name))
142        ylabel(unicode(r"T / [°C]"))
143        xlabel("s / [kJ/kg/K]")
144
145        extpy.getbrowser().reporter.reportNote("Plotting completed")
146        ion()
147        show()
148        import os.path
149        savefig(os.path.expanduser("~/Desktop/regen2.eps"))
150
151
152
153    def cycle_plot_rankine_regen1(self):
154        """Plot T-s diagram for a regenerative Rankine cycle"""
157        ioff()
158        figure()
159        hold(1)
160        D = fprops.fprops_fluid(str(self.cd.component.getSymbolValue()))
161        sat_curve(D)
162
163        boiler_curve = pconst(self.BO.inlet, self.BO.outlet,100)
164        condenser_curve = pconst(self.CO.inlet,self.CO.outlet,100)
165        he_hot = pconst(self.HE.inlet_heat, self.HE.outlet_heat,100)
166        he_cold = pconst(self.HE.inlet, self.HE.outlet,100)
167
168        SS = [self.PU.outlet] + he_cold + [self.BO.inlet] + boiler_curve + [self.TU.inlet, self.TU.outlet] + he_hot + condenser_curve + [self.PU.inlet, self.PU.outlet]
169
170        plot_Ts(SS)
171        plot_Ts(
172            [self.PU.outlet,self.BO.inlet,self.TU.inlet, self.TU.outlet
173                ,self.HE.outlet_heat, self.PU.inlet, self.PU.outlet]
174            ,'bo'
175        )
176
177        # dotted lines for the heat exchanger
178        plot_Ts([self.HE.inlet_heat, self.HE.outlet],'b:')
179        plot_Ts([self.HE.outlet_heat, self.HE.inlet],'b:')
180
181        title(unicode(r"Regenerative Rankine cycle with %s" % D.name))
182        ylabel(unicode(r"T / [°C]"))
183        xlabel("s / [kJ/kg/K]")
184
185        extpy.getbrowser().reporter.reportNote("Plotting completed")
186        ion()
187        show()
188
189
190  extpy.registermethod(cycle_plot_rankine)  extpy.registermethod(cycle_plot_rankine)
191    extpy.registermethod(cycle_plot_rankine_regen1)
192    extpy.registermethod(cycle_plot_rankine_regen2)
193
194  extpy.registermethod(cycle_plot)  extpy.registermethod(cycle_plot)
195  #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.2300 changed lines Added in v.2301