class ReheatedRankine(object): """ This is a very specific use of the base state and component functions that I need for a project in my Thermo class. Once I am done with the project I plan on introducing a much more generica way of developing a cycle """ def __init__(self, p_1, t_1, p_2, p_cond, eta_t, eta_p,t_3, t0, p0, TL, TH): self._one = State('Water', P=p_1, T=t_1) self._one.define() self._two = State('Water', P=p_2) self.turb_one = Turbine(self._one, self._two) self.turb_one.isentropic(eta_t) self.turb_one.exergyBalance(t0, p0) self._three = State('Water', P=p_2, T=t_3) self._three.define() self.reheater = Reheater(self._two, self._three) self._four = State('Water', P=p_cond) self.turb_two = Turbine(self._three, self._four) self.turb_two.isentropic(eta_t) self.turb_two.exergyBalance(t0, p0) self._five = State('Water') self.condensor = Condensor(p_cond, self._four, self._five) self._six = State('Water', P=p_1) self.pump = Pump(self._five, self._six) self.pump.isentropic(eta_p) self.pump.exergyBalance(t0, p0) self.superHeater = Reheater(self._six, self._one) self.eta = (sum([self.turb_two.w, self.turb_one.w, self.pump.w])/ sum([self.reheater.q, self.superHeater.q])) self.E = self.eta*(1/(1-float(TL)/float(TH)))
def testPressureEnthalpy(self): P = 200000 #Pa h = 3126608.7815658785 #J/kg fluid = 'Water' testState = State(fluid) testState.define(P=P, H=h) val = testState.properties['s'] - 7994 self.assertAlmostEquals(True, val < 10)
def testTempEntropy(self): T = 600 #K s = 7994 #J/kg fluid = 'Water' testState = State(fluid) testState.define(T=T, S=s) val = testState.properties['h'] - 3126608 self.assertAlmostEquals(True, val < 100)
def testIsentropic(self): inlet = State("Water", Q=1, P=10 * 10 ** 6) outlet = State("Water", P=10 * 10 ** 3) inlet.define() turb = Turbine(inlet, outlet) turb.isentropic(0.9) self.assertEquals(True, outlet.defined) self.assertEquals(abs(outlet.properties["h"] * 10 ** (-3) - 1870) < 10, True)
def testExergyBalance(self): inlet = State("Water", Q=1, P=10 * 10 ** 6) outlet = State("Water", P=10 * 10 ** 3) inlet.define() turb = Turbine(inlet, outlet) turb.isentropic(0.9) turb.exergyBalance(300, 100 * 10 ** 3) import IPython IPython.embed()
def testTempPressure(self): P = 200000 #Pa T = 600 #K fluid = 'Water' testState = State(fluid) testState.define(T=T, P=P) # I am testing against the value returned the first time # just to make sure it is still working, I do not know # how else to test this. val = testState.properties['h'] - 3126608 self.assertAlmostEquals(True, val < 10)
class CFWH(object): """ This is a very specific use of the base state and component functions that I need for a project in my Thermo class. Once I am done with the project I plan on introducing a much more generica way of developing a cycle """ def __init__(self, t0, p0, p_1, t_1, p_2, eta_t, eta_p, p_cond, TL, TH): self.one = State('Water', P=p_1, T=t_1) self.one.define() self.two = State('Water', P=p_2) self.turb_one = Turbine(self.one, self.two) self.turb_one.isentropic(eta_t) self.turb_one.exergyBalance(t0, p0) self.three = State('Water', P=p_cond) self.turb_two = Turbine(self.two, self.three) self.turb_two.isentropic(eta_t) self.four = State('Water', P=p_cond, Q=0) self.four.define() self.five = State('Water', P=p_1) self.pump_one = Pump(self.four, self.five) self.pump_one.isentropic(eta_p) self.six = State('Water', P=p_1, T=350) self.six.define() self.seven = State('Water', P=p_2, Q=0) self.seven.define() self.eight = State('Water', P=p_cond, h=self.seven.properties['h']) self.eight.define() y = ((self.six.properties['h']-self.five.properties['h']) /(self.two.properties['h']-self.seven.properties['h'])) self.y = y self.turb_two.exergyBalanceY(t0, p0, y) self.pump_one.exergyBalance(t0, p0) self.superHeater = Reheater(self.six, self.one) self.eta = (sum([self.turb_one.w, self.turb_two.w, self.pump_one.w])/ sum([self.superHeater.q])) self.E = self.eta*(1/(1-float(TL)/float(TH))) self.cfwh = CFeedWater([self.two, self.five], [y, 1], [self.seven, self.six], [y, (1-y)], t0, p0)
class OFWH(object): def __init__(self, t0, p0, p_1, t_1, p_2, eta_t, eta_p, p_cond, TL, TH): self.one = State('Water', P=p_1, T=t_1) self.one.define() self.two = State('Water', P=p_2) self.turb_one = Turbine(self.one, self.two) self.turb_one.isentropic(eta_t) self.turb_one.exergyBalance(p0, t0) self.three = State('Water', P=p_cond) self.turb_two = Turbine(self.two, self.three) self.turb_two.isentropic(eta_t) self.four = State('Water', P=p_cond) self.condensor = Condensor(p_cond, self.three, self.four) self.five = State('Water', P=p_2) self.pump_one = Pump(self.four, self.five) self.pump_one.isentropic(eta_p) self.six = State('Water', P=p_2, Q=0) if self.six.define(): y = ((self.six.properties['h']-self.five.properties['h']) /(self.two.properties['h']-self.five.properties['h'])) else: print 'Failed to define state 6' self.y = y self.seven = State('Water', P=p_1) self.pump_two = Pump(self.six, self.seven) self.pump_two.isentropic(eta_p) self.pump_two.exergyBalance(t0, p0) self.turb_two.exergyBalanceY(t0, p0, y) self.pump_one.exergyBalanceY(t0, p0, y) self.superHeater = Reheater(self.seven, self.one) self.eta = (sum([self.turb_one.w, self.turb_two.w, self.pump_one.w, self.pump_two.w])/ sum([self.superHeater.q])) self.E = self.eta*(1/(1-float(TL)/float(TH))) self.ofwh = OFeedWater([self.two, self.five], [y, (1-y)], self.six, [1], t0, p0)
def testMixingChamber(self): stream_in = State("Water", flowRate=2) stream_in.define(P=970000, T=800) rQ = 0 P2 = 15000 # Pa stream_out = State("Water")