def x_iterate(t, xguess=X0, Tguess=400, eps=0.02): """Iterate to find x(t) and T(t) Inputs: t: time in s xguess: where to start x at Tguess: where to start T at (K) eps: fractionally, how close to get [Default: 0.02] Outputs: x: quality T: Temperature (K) """ # Q_DOT is given as constant; the integral is trivial Q_decay = Q_DOT * t u_target = u0 + Q_decay / M0 Tmin = int(liquid0.T) Tmax = Tmin + 200 for Tguess in range(Tmin, Tmax, 5): #print("\n\n\nTguess:", Tguess) xguess = 0.5 last_x = 10 * xguess last_u = 0.0 c = 0 converged = True overflooded = False while abs(xguess - last_x) / xguess > eps or abs( u_target - last_u) / u_target > eps: last_x = xguess liquid1 = steam(T=Tguess, x=0) vapor1 = steam(T=Tguess, x=1) u_fg = vapor1.u - liquid1.u v_fg = vapor1.v - liquid1.v v1 = liquid1.v + v_fg * xguess # Revise the x guess based on specific volume xguess = (v0 - liquid1.v) / v_fg #print("xguess = {:.4e}".format(xguess)) last_u = liquid1.u + u_fg * xguess c += 1 if c > 10: converged = False break if converged or v1 > v0 or v1 == 0: if converged: print("Converged") if v1 > v0: overflooded = True print("Overflooded at t = {:.3} hours!".format(t / 3600)) break return v1, overflooded
def FW_main(A2, B, B2, Mi, Me): if (A2): Me.h = Mi.h + (B.m * (B.h - B2.h) + A2.m * (A2.h - B2.h)) / Mi.m else: Me.h = Mi.h + B.m * (B.h - B2.h) / Mi.m Me.P = Mi.P Me.T = steam(P=Me.P, h=Me.h).T Me.s = steam(P=Me.P, h=Me.h).s
def Reheat(Mi, Me, temp): Me.T = temp Me.P = Mi.P Me.m = Mi.m Me.h = steam(T=Me.T, P=Me.P).h Me.s = steam(T=Me.T, P=Me.P).s Q = Me.m * (Me.h - Mi.h) return Q
def Pump(Mi, Me, efficiency): Me.m = Mi.m ses = Mi.s hes = steam(s=ses, P=Me.P).h Me.h = (hes - Mi.h) / efficiency + Mi.h Me.T = steam(P=Me.P, h=Me.h).T Me.s = steam(P=Me.P, h=Me.h).s Power = Me.m * (Me.h - Mi.h) return Power
def Deaerator(A2, B, Mi, Me, deaerationCondensate): if (A2): Me.m = A2.m + B.m + Mi.m Me.h = (Mi.h * Mi.m + A2.h * A2.m + B.h * B.m) / Me.m else: Me.m = B.m + Mi.m Me.h = (Mi.h * Mi.m + B.h * B.m) / Me.m Me.P = deaerationCondensate.condPressure Me.T = deaerationCondensate.T = steam(P=Me.P, h=Me.h).T Me.s = deaerationCondensate.s = steam(P=Me.P, h=Me.h).s deaerationCondensate.h = steam(P=Me.P, h=Me.h).h
def Condenser(F2, Mi, Me): if (F2): mMF = Me.m = Mi.m + F2.m hMF = (Mi.m * Mi.h + F2.m * F2.h) / mMF else: mMF = Me.m = Mi.m hMF = Mi.h Me.P = Mi.P Me.h = steam(P=Me.P, x=0).h Me.s = steam(P=Me.P, x=0).s Me.T = steam(P=Me.P, x=0).T Q = mMF * (hMF - Me.h) return Q
def iterate(p_air2=0, tguess=1000.0, xguess=0.1, T2=liquid_in.T): # Initialize some guesses before iterating last_t = 1200 #v2 = V_WATER0/mguess V_gas2 = V_VAPOR0 while abs(tguess - last_t) / last_t > EPS: last_t = tguess mflow = MDOT * last_t mguess = M0 + mflow if p_air2: # Partial pressure of air at T2 p_air2 = T2 * M_AIR * R_AIR / V_gas2 * 1E-6 # MPa psat = P_BURST - p_air2 # MPa de_air = M_AIR * CV_AIR * (T2 - T_AIR0) * 1E-3 # kJ else: psat = P_BURST de_air = 0 liquid2 = steam(P=psat, x=0) vapor2 = steam(P=psat, x=1) T2 = liquid2.T # K vmix2 = lambda x: liquid2.v * (1 - x) + vapor2.v * x umix2 = lambda x: liquid2.u * (1 - x) + vapor2.u * x u_fg = vapor2.u - liquid2.u # kJ/kg # Control volume xguess = (V_TOTAL / mguess - liquid2.v) / (vapor2.v - liquid2.v) # Conservation of energy u2 = umix2(xguess) mflow = (U0 - de_air - M0 * u2) / (u2 - liquid_in.u) # This calculation is unstable. Underrelax it! # (I'd like to thank Sterling for telling me to try this) tguess = Y * mflow / MDOT + (1 - Y) * tguess return mguess, xguess, tguess
def CycleHP(load,massFlow): #-------------------------------------------------------------------------- # Initial Design Conditions #-------------------------------------------------------------------------- #load = 1.0 # load as percentage of designed mass flow #massFlow = 450 # mass flow rate at 100% load (kg/s) mainTemp = 585 + 273 # temperature at inlet of HP turbine (K) reheatTemp = 585 + 273 # temperature at inlet of IP turbine (K) highPressure = 19 # pressure at inlet of HP turbine (MPa) intPressure = 2 # pressure at inlet of IP turbine (MPa) lowPressure = 0.8 # pressure at inlet of LP turbine (MPa) condPressure = 0.01 # pressure at inlet of condensor (MPa) pE_A = 10/100 # percent of mass flow extracted at A pE_B = 10/100 # percent of mass flow extracted at B pE_C = 5/100 # percent of mass flow extracted at C #pE_D = 000 # percent of mass flow extracted at D #pE_E = 000 # percent of mass flow extracted at E #pE_F = 000 # percent of mass flow extracted at F TTD = 5/1.8 # terminal temperature difference (K) DCA = 10/1.8 # drain cooler approach (K) deaeratorInletPressure = 0.2 #-------------------------------------------------------------------------- # Power Cycle #-------------------------------------------------------------------------- # set inital state at the high pressure turbine inlet M1 = state() M1.T = mainTemp M1.P = highPressure M1.m = massFlow * load M1.h = steam(T=M1.T, P=M1.P).h M1.s = steam(T=M1.T, P=M1.P).s # set deaeration conditions for determining extraction flows deaerationConditions = components.preheatConditions() deaerationConditions.condPressure = condPressure deaerationConditions.P = deaeratorInletPressure deaerationConditions.T = steam(P=deaerationConditions.P,x=0).T deaerationConditions.h = steam(P=deaerationConditions.P,x=0).h deaerationConditions.s = steam(P=deaerationConditions.P,x=0).s deaerationConditions.TTD = TTD deaerationConditions.DCA = DCA deaeratorCondensate = components.preheatConditions() deaeratorCondensate.condPressure = 0.02 deaeratorCondensate.P = M1.P deaeratorCondensate.TTD = -5/1.8 deaeratorCondensate.DCA = 10/1.8 # high pressure turbine states and function M2 = state() A = state() PR_HP = intPressure / M1.P # pressure ratio of the high pressure turbine PowerHP = components.Turbine(M1,M2,A,None,None,pE_A,None,None,None,PR_HP,load) deaeratorCondensate.T = steam(P=A.P,x=0).T # reheat after high pressure turbine M3 = state() Qin_reheat = components.Reheat(M2, M3, reheatTemp) # intermediate pressure turbine states and function M4 = state() B = state() C = state() PR_IP = lowPressure / M3.P # pressure ratio of the intermediate pressure turbine PowerIP = components.Turbine(M3,M4,B,C,None,pE_B,pE_C,None,None,PR_IP,load) # low pressure turbine states and function M5 = state() D = state() E = state() F = state() PR_LP = condPressure / M4.P # pressure ratio of the low pressure turbine PowerLP = components.Turbine(M4,M5,D,E,F,None,None,None,deaerationConditions,PR_LP,load) # extracted steam through closed feedwater heaters A2 = state() B2 = state() D2 = state() E2 = state() F2 = state() components.FW_extracted(A,A2,B,B2,None,None,deaeratorCondensate) components.FW_extracted(D,D2,E,E2,F,F2,deaerationConditions) # [main + extracted steam from LP] though condenser M6 = state() Qout = components.Condenser(F2, M5, M6) M7 = state() M7.P = deaerationConditions.P PowerPump1 = components.Pump(M6, M7, 0.85) # feedwater heaters for LP section M8 = state() M9 = state() M10 = state() M10.m = M9.m = M8.m = M7.m components.FW_main(E2,F,F2,M7,M8) components.FW_main(D2,E,E2,M8,M9) components.FW_main(None,D,D2,M9,M10) # deaerator combining extracted steam at C, # combined feedwater from HP & IP, and main steam M11 = state() components.Deaerator(B2,C,M10,M11,deaeratorCondensate) # pump 2 to reach high pressure for the HP turbine M12 = state() M12.P = M1.P PowerPump2 = components.Pump(M11, M12, 0.85) # feedwater heating from HP and IP turbines M14 = state() M13 = state() M13.m=M14.m = M12.m components.FW_main(A2,B,B2,M12,M13) components.FW_main(None,A,A2,M13,M14) # heat in from the steam generator Qin_main = components.SteamGenerator(M14, M1, 0.95) # efficiency calculations Power = PowerHP+PowerIP+PowerLP-PowerPump1-PowerPump2 Qin = Qin_reheat + Qin_main nth = Power/Qin nc = 1 - M6.T / M1.T return PowerHP/1000
def Turbine(Mi, Me, A, B, C, pE_A, pE_B, pE_C, preheatConditions, PR, load): efficiency = (0.86 - 0.72) / (1.0 - 0.6) * load + 0.51 # find exit properties ses = Mi.s # isentropic exit entropy (kJ/kg/K) Me.P = Mi.P * PR # set rest of state with steam tables hes = steam(P=Me.P, s=ses).h Me.h = Mi.h - efficiency * (Mi.h - hes) Me.T = steam(h=Me.h, P=Me.P).T Me.s = steam(h=Me.h, P=Me.P).s numExtract = 0 if (A): numExtract += 1 if (B): numExtract += 1 if (C): numExtract += 1 if (preheatConditions): if (numExtract == 3): P0 = preheatConditions.condPressure h0 = steam(P=P0, x=0).h s0 = steam(P=P0, x=0).s m2 = m3 = Mi.m P1 = P2 = P3 = preheatConditions.P s1s = s0 h1s = steam(s=s1s, P=P1).h h1 = (h1s - h0) / preheatConditions.pumpEfficiency + h0 T1 = steam(P=P1, h=h1).T T4 = preheatConditions.T h4 = preheatConditions.h T2 = 1 * (T4 - T1) / 3 + T1 T3 = 2 * (T4 - T1) / 3 + T1 h2 = steam(T=T2, P=P2).h h3 = steam(T=T3, P=P3).h A.P = PA2 = steam(T=(T4 + preheatConditions.TTD), x=0).P TA2 = T3 + preheatConditions.DCA hA2 = steam(T=TA2, P=PA2).h hAs = steam(P=A.P, s=ses).h A.h = Mi.h - efficiency * (Mi.h - hAs) A.T = steam(P=A.P, h=A.h).T A.s = steam(P=A.P, h=A.h).s A.m = mA2 = m3 * (h4 - h3) / (A.h - hA2) B.P = PB2 = steam(T=(T3 + preheatConditions.TTD), x=0).P TB2 = T2 + preheatConditions.DCA hB2 = steam(T=TB2, P=PB2).h hBs = steam(P=B.P, s=ses).h B.h = Mi.h - efficiency * (Mi.h - hBs) B.T = steam(P=B.P, h=B.h).T B.s = steam(P=B.P, h=B.h).s B.m = (m2 * (h3 - h2) - mA2 * (hA2 - hB2)) / (B.h - hB2) mB2 = B.m + mA2 C.P = PC2 = steam(T=(T2 + preheatConditions.TTD), x=0).P TC2 = T1 + preheatConditions.DCA hC2 = steam(T=TC2, P=PC2).h hCs = steam(P=C.P, s=ses).h C.h = Mi.h - efficiency * (Mi.h - hCs) C.T = steam(P=C.P, h=C.h).T C.s = steam(P=C.P, h=C.h).s C.m = (m2 * (h2 - h1) - mB2 * (hB2 - hC2)) / (C.h - hC2) Me.m = Mi.m - A.m - B.m - C.m Power = Mi.m * (Mi.h - A.h) + (Mi.m - A.m) * (A.h - B.h) + ( Mi.m - A.m - B.m) * (B.h - Me.h) else: print("ERROR: Turbine()") else: if (numExtract == 1): A.P = Me.P A.h = Me.h A.T = Me.T A.s = Me.s A.m = Mi.m * pE_A Me.m = Mi.m - A.m Power = Mi.m * (Mi.h - Me.h) elif (numExtract == 2): TH = steam(P=Mi.P, x=1).T TL = steam(P=Me.P, x=1).T TA = (TH - TL) / (numExtract) + TL A.P = steam(T=TA, x=1).P hAs = steam(P=A.P, s=ses).h A.h = Mi.h - efficiency * (Mi.h - hAs) A.T = steam(P=A.P, h=A.h).T A.s = steam(P=A.P, h=A.h).s A.m = Mi.m * pE_A B.P = Me.P B.h = Me.h B.T = Me.T B.s = Me.s B.m = Mi.m * pE_B Me.m = Mi.m - A.m - B.m Power = Mi.m * (Mi.h - A.h) + (Mi.m - A.m) * (A.h - Me.h) elif (numExtract == 3): TH = steam(P=Mi.P, x=1).T TL = steam(P=Me.P, x=1).T TA = 2 * (TH - TL) / (numExtract) + TL A.P = steam(T=TA, x=1).P hAs = steam(P=A.P, s=ses).h A.h = Mi.h - efficiency * (Mi.h - hAs) A.T = steam(P=A.P, h=A.h).T A.s = steam(P=A.P, h=A.h).s A.m = Mi.m * pE_A TB = (TH - TL) / (numExtract) + TL B.P = steam(T=TB, x=1).P hBs = steam(P=B.P, s=ses).h B.h = Mi.h - efficiency * (Mi.h - hBs) B.T = steam(P=B.P, h=B.h).T B.s = steam(P=B.P, h=B.h).s B.m = Mi.m * pE_B C.P = Me.P C.h = Me.h C.T = Me.T C.s = Me.s C.m = Mi.m * pE_C Me.m = Mi.m - A.m - B.m - C.m Power = Mi.m * (Mi.h - A.h) + (Mi.m - A.m) * (A.h - B.h) + ( Mi.m - A.m - B.m) * (B.h - Me.h) else: Me.m = Mi.m Power = Mi.m * (Mi.h - Me.h) return Power
def x(temp): vf = steam(T=temp, x=0).v vg = steam(T=temp, x=1).v return (VOL - vf) / (vg - vf)
V_TOT = 2500 # m^3 M_TOT = 2.12E6 # kg VOL = V_TOT / M_TOT # specific volume T0 = 373 # K def x(temp): vf = steam(T=temp, x=0).v vg = steam(T=temp, x=1).v return (VOL - vf) / (vg - vf) temperatures = linspace(T0, T0 + 110) qualities = array([x(ti) for ti in temperatures]) for i, q in enumerate(qualities): if q == max(qualities): break txmax = temperatures[i] plot(temperatures, qualities, label="X") plot([temperatures.min(), temperatures.max()], [q, q], 'gray') plot([txmax, txmax], [qualities.min(), qualities.max()], 'gray') text(txmax, 1.05 * q, "$X_{max} = $" + "{:.3e}".format(q) + " @ {:.4} K".format(txmax), ha="center") vmin = steam(T=txmax, x=0).v * M_TOT * (1 - q) print("Minimum water volume: {:.5} m^3".format(vmin)) grid() legend() show()
R_VESSEL = 6.5 # m AXS_VESSEL = math.pi * R_VESSEL**2 # m^2; cross-sectional area of vessel ZCORE = 2.0 # m ZCYL = 14.5 # m ZSTEAM0 = 2.17 # m Z_ABOVE = ZCYL - ZSTEAM0 - ZCORE # m V_STEAM0 = AXS_VESSEL * ZSTEAM0 # m^3; volume of the initial steam V_BELOW = math.pi * 2 / 3 * R_VESSEL**3 # m^3; volume below core V_ZCORE = AXS_VESSEL * ZCORE # m^3; volume around core V_ABOVE = AXS_VESSEL * Z_ABOVE # m^3; volume above core V_LIQUID0 = V_BELOW + V_ZCORE + V_ABOVE # m^3; volume if the initial liquid water V_VESSEL = V_LIQUID0 + V_STEAM0 # m^3; entire pressure vessel volume # Thermal hydraulic parameters P0 = 0.10135 # MPa liquid0 = steam(P=P0, x=0) vapor0 = steam(P=P0, x=1) M_LIQUID0 = V_LIQUID0 / liquid0.v M_VAPOR0 = V_STEAM0 / vapor0.v M0 = M_LIQUID0 + M_VAPOR0 X0 = M_VAPOR0 / M0 U0 = M_LIQUID0 + liquid0.u + M_VAPOR0 * vapor0.u u0 = liquid0.u * (1 - X0) + vapor0.u * X0 v0 = V_VESSEL / M0 """ Unknowns: 1. T2 or P2 at one week 2. X2 at one week 3. U, V at one week Equations:
#pE_F = 000 # percent of mass flow extracted at F TTD = 5 / 1.8 # terminal temperature difference (K) DCA = 10 / 1.8 # drain cooler approach (K) deaeratorInletPressure = 0.2 # ----------------------------------------------------------------------------- # Power Cycle # ----------------------------------------------------------------------------- # set inital state at the high pressure turbine inlet M1 = state() M1.T = mainTemp M1.P = highPressure M1.m = massFlow * load M1.h = steam(T=M1.T, P=M1.P).h M1.s = steam(T=M1.T, P=M1.P).s # set deaeration conditions for determining extraction flows deaerationConditions = components.preheatConditions() deaerationConditions.condPressure = condPressure deaerationConditions.P = deaeratorInletPressure deaerationConditions.T = steam(P=deaerationConditions.P, x=0).T deaerationConditions.h = steam(P=deaerationConditions.P, x=0).h deaerationConditions.s = steam(P=deaerationConditions.P, x=0).s deaerationConditions.TTD = TTD deaerationConditions.DCA = DCA deaeratorCondensate = components.preheatConditions() deaeratorCondensate.condPressure = 0.02 deaeratorCondensate.P = M1.P
# Constants V_C = 50970 # m^3 R_AIR = 286 # J/kg-K M_AIR = 5.9E4 # kg CV_AIR = 719 # J/kg-K EPS = 0.02 # Starting conditions from Example 7.1 P0 = 0.523 # MPa Pa0 = 0.137 # MPa T0 = 415.6 # Kelvins X0 = 0.505 m_pw = 2.1E5 # kg m_pg = 2.11E5 # kg mp = m_pw + m_pg sat_liquid0 = steam(T=T0, x=0) sat_vapor0 = steam(T=T0, x=1) st0 = steam(T=T0, x=X0) V_vapor0 = m_pg * sat_vapor0.v e_p0 = m_pw * sat_liquid0.u + m_pg * sat_vapor0.u #print("Partial pressure of st0 =", st0.P) # Saturated liquid released from the secondary system PS = 6.89 # MPa VS = 89 # m^3 sts = steam(P=PS, x=0) print("Temperature of the secondary coolant at break: {:.4} K".format(sts.T)) ms = VS / sts.v e_s0 = ms * sts.u #print("Mass of secondary coolant released at {:.4} K: {:.4} kg".format(sts.T, ms)) m_w = ms + mp # Total mass of coolant (primary + secondary)
from iapws import IAPWS97 as steam # Constants EPS = 0.02 # How close to converge Y = 0.2 # Underrelaxation factor # Given parameters: # Tank itself P_TANK0 = 3 # MPa P_BURST = 10 # MPa P_SAT0 = 15.4 # MPa V_TOTAL = 12 # m^3 V_WATER0 = 2 # m^3 V_VAPOR0 = V_TOTAL - V_WATER0 # m^3 # Water in tank water0 = steam(P=P_TANK0, x=0) vapor0 = steam(P=P_TANK0, x=1) M_l0 = V_WATER0 / water0.v # kg M_v0 = V_VAPOR0 / vapor0.v # kg M0 = M_v0 + M_l0 # kg X0 = M_v0 / (M_l0 + M_v0) U0 = M_l0 * water0.u + M_v0 * vapor0.u # kJ # Flow in MDOT = 3 # kg/s liquid_in = steam(P=P_SAT0, x=0) # Air in tank (for part C only) M_AIR = 11.93 # kg R_AIR = 268 # J/kg-K CV_AIR = 719 # J/kg-K V_AIR0 = V_VAPOR0 T_AIR0 = vapor0.T
def FW_extracted(A, A2, B, B2, C, C2, preheatConditions): numExtract = 0 if (A): numExtract += 1 if (B): numExtract += 1 if (C): numExtract += 1 if (preheatConditions): P0 = preheatConditions.condPressure h0 = steam(P=P0, x=0).h s0 = steam(P=P0, x=0).s P1 = preheatConditions.P s1s = s0 h1s = steam(s=s1s, P=P1).h h1 = (h1s - h0) / preheatConditions.pumpEfficiency + h0 T1 = steam(P=P1, h=h1).T if (numExtract == 1): T2 = preheatConditions.T A2.P = steam(T=(T2 + preheatConditions.TTD), x=0).P A2.T = T1 + preheatConditions.DCA A2.h = steam(T=A2.T, P=A2.P).h A2.s = steam(T=A2.T, P=A2.P).s A2.m = A.m elif (numExtract == 2): T3 = preheatConditions.T T2 = (T3 - T1) / 2 + T1 A2.P = steam(T=(T3 + preheatConditions.TTD), x=0).P A2.T = T2 + preheatConditions.DCA A2.h = steam(T=A2.T, P=A2.P).h A2.s = steam(T=A2.T, P=A2.P).s A2.m = A.m B2.P = steam(T=(T2 + preheatConditions.TTD), x=0).P B2.T = T1 + preheatConditions.DCA B2.h = steam(T=B2.T, P=B2.P).h B2.s = steam(T=B2.T, P=B2.P).s B2.m = B.m + A2.m elif (numExtract == 3): T4 = preheatConditions.T T2 = 1 * (T4 - T1) / 3 + T1 T3 = 2 * (T4 - T1) / 3 + T1 A2.P = steam(T=(T4 + preheatConditions.TTD), x=0).P A2.T = T3 + preheatConditions.DCA A2.h = steam(T=A2.T, P=A2.P).h A2.s = steam(T=A2.T, P=A2.P).s A2.m = A.m B2.P = steam(T=(T3 + preheatConditions.TTD), x=0).P B2.T = T2 + preheatConditions.DCA B2.h = steam(T=B2.T, P=B2.P).h B2.s = steam(T=B2.T, P=B2.P).s B2.m = B.m + A2.m C2.P = steam(T=(T2 + preheatConditions.TTD), x=0).P C2.T = T1 + preheatConditions.DCA C2.h = steam(T=C2.T, P=C2.P).h C2.s = steam(T=C2.T, P=C2.P).s C2.m = C.m + B2.m else: print("ERROR: no preheat conditions")
from iapws import IAPWS97 as steam from scipy.optimize import fsolve # Fixed parameters P_MAX = 0.4 # MPa V_C = 5.05E4 # m^3 (containment volume) C0 = 273.15 # 0 degrees Celcius EPS = 0.005 # Get within 0.5% of the answer MAX_ITER = 100 # Prevent infinite loops # Initial conditions P0 = 0.1013 # MPa (containment pressure) T_c0 = 300 # K (containment temperature) P_p0 = 15.5 # MPa (primary coolant pressure) V_p0 = 500 # m^3 (primary coolant volume) st0 = steam(P=P_p0, x=0) # primary coolant, sat liquid mp = V_p0 / st0.v # Ice T_ice0 = 263 # K lf_ice = 333 # kJ/kg c_ice = 4.230 # kJ/kg-K c_water = 4.18 # kJ/kg-K liquid_ice = steam(T=T_c0, x=0) # Air R_AIR = 268 # J/kg-K CV_AIR = 719 # J/kg-K # PV = mRT --> m = PV/RT M_AIR = (P0 * 1E6 * V_C) / (R_AIR * T_c0) # kg MRV_AIR = M_AIR * R_AIR / (V_C - V_p0) * 1E-6 # MPa