def _Pwsat(self, T): """Calculate the partial pressure of water in saturated moint air""" if T < 273.15: Pws = _Sublimation_Pressure(T) else: Pws = _PSat_T(T) return Pws
print("Calculating isochor lines...") for v in isov: print(" v=%s" % v) pts = [iapws.IAPWS95(T=t, v=v) for t in Tl] x = [] y = [] for p in pts: if p.status: x.append(p.__getattribute__(xAxis)) y.append(p.__getattribute__(yAxis)) plt.plot(x, y, **isov_kw) # Plot region limits if regionBoundary: # Boundary 1-3 Po = _PSat_T(623.15) P = np.linspace(Po, 100, points) pts = [fluid(P=p, T=623.15) for p in P] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] plt.plot(x, y, **isosat_kw) # Boundary 2-3 T = np.linspace(623.15, 863.15) P = [_P23_T(t) for t in T] P[-1] = 100 # Avoid round problem with value out of range > 100 MPa pts = [fluid(P=p, T=t) for p, t in zip(P, T)] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] plt.plot(x, y, **isosat_kw)
def __init__(self, hp, ip, lp, m1, m2, m3, ma, steam_high_temp, water_low_temp): # Input Parameters self.HP = hp # Bar self.IP = ip # Bar self.LP = lp # Bar mass_flow_1 = m1 mass_flow_2 = m2 mass_flow_3 = m3 mass_flow_amine = ma self.massflows = { 'mass flow 1': mass_flow_1, 'mass flow 2': mass_flow_2, 'mass flow 3': mass_flow_3, 'mass flow to amine': mass_flow_amine } # total mass flow total_mass_flow = mass_flow_1 + mass_flow_2 + mass_flow_3 # Turbine Mass Flows HPT_mass_flow = mass_flow_3 IPT_mass_flow = HPT_mass_flow + mass_flow_2 LPT_mass_flow = IPT_mass_flow + mass_flow_1 - mass_flow_amine # Pump Mass Flows HPP_mass_flow = mass_flow_3 IPP_mass_flow = mass_flow_2 LPP_mass_flow = IPP_mass_flow + HPP_mass_flow + mass_flow_1 # HRSG Mass Flows self.economiser_1_mass_flow = total_mass_flow self.economiser_2_mass_flow = mass_flow_2 self.economiser_3_mass_flow = mass_flow_3 self.evaporator_1_mass_flow = mass_flow_1 self.evaporator_2_mass_flow = mass_flow_2 self.evaporator_3_mass_flow = mass_flow_3 self.superheater_1_mass_flow = mass_flow_1 - mass_flow_amine self.superheater_2_mass_flow = mass_flow_2 + mass_flow_3 self.superheater_3_mass_flow = mass_flow_3 self.SteamHighTemp = steam_high_temp # Celcius WaterLowTemp = water_low_temp # Celcius quality = 0.9 # at turbine outlet self.T = [0]*16 self.T[1] = ToKelvin(WaterLowTemp) # Pressures self.P = [0]*16 self.P[1] = steam._PSat_T(self.T[1]) # low pressure self.P[2] = BarToMP(self.LP) # bar self.P[3] = self.P[2] self.P[4] = self.P[2] self.P[5] = self.P[2] # intermediate pressure self.P[7] = BarToMP(self.IP) # bar self.P[8] = self.P[7] self.P[9] = self.P[8] self.P[10] = self.P[9] self.P[15] = self.P[9] # High Pressure self.P[11] = BarToMP(self.HP) # bar self.P[12] = self.P[11] self.P[13] = self.P[12] self.P[14] = self.P[13] # Temperatures in kelvin self.T[3] = steam._TSat_P(self.P[3]) self.T[4] = self.T[3] self.T[6] = self.T[1] self.T[8] = steam._TSat_P(self.P[8]) self.T[9] = self.T[8] self.T[12] = steam._TSat_P(self.P[12]) self.T[13] = self.T[12] self.T[14] = ToKelvin(self.SteamHighTemp) # Begin going around cycle working out available values self.SpecificValues = [0] * 16 self.SpecificValues[1] = steam._Region1(self.T[1], self.P[1]) self.T[2] = steam._Backward1_T_Ps(self.P[2], self.SpecificValues[1]['s']) self.SpecificValues[2] = steam._Region1(self.T[2], self.P[2]) self.SpecificValues[3] = steam._Region4(self.P[3], 0) self.SpecificValues[4] = steam._Region4(self.P[3], 1) self.SpecificValues[6] = steam._Region4(self.P[1], quality) self.T[5] = steam._Backward2_T_Ps(self.P[5], self.SpecificValues[6]['s']) self.SpecificValues[5] = steam._Region2(self.T[5], self.P[5]) self.T[7] = steam._Backward1_T_Ps(self.P[7], self.SpecificValues[3]['s']) self.SpecificValues[7] = steam._Region1(self.T[7], self.P[7]) self.SpecificValues[8] = steam._Region4(self.P[8], 0) self.SpecificValues[9] = steam._Region4(self.P[8], 1) self.T[10] = steam._Backward2_T_Ps(self.P[10], self.SpecificValues[5]['s']) self.SpecificValues[10] = steam._Region2(self.T[10], self.P[10]) self.T[11] = steam._Backward1_T_Ps(self.P[11], self.SpecificValues[3]['s']) self.SpecificValues[11] = steam._Region1(self.T[11], self.P[11]) self.SpecificValues[12] = steam._Region4(self.P[12], 0) self.SpecificValues[13] = steam._Region4(self.P[13], 1) self.SpecificValues[14] = steam._Region2(self.T[14], self.P[14]) self.T[15] = steam._Backward2_T_Ps(self.P[15], self.SpecificValues[14]['s']) self.SpecificValues[15] = steam._Region2(self.T[15], self.P[15]) self.s = [0] * 16 self.h = [0] * 16 for i in range(0, len(self.SpecificValues)): if i == 0: continue self.s[i] = self.SpecificValues[i]['s'] self.h[i] = self.SpecificValues[i]['h'] #Printing T-P conditions at each point print("-------------------------------------------------------") print("\nCycle Conditions:") for i in range(1, 16): print("\n\tT"+str(+i)+" = "+str(ToCelcius(self.T[i]))+" C") print("\tP"+str(+i)+" = "+str(MPToBar(self.P[i]))+" bar") #Finding specific work of turbines and pump self.total_works = { 'Work Type': 'Work [kW]', 'LP Pump work': LPP_mass_flow * (self.h[2] - self.h[1]), 'IP Pump work': IPP_mass_flow * (self.h[7] - self.h[3]), 'HP Pump work': HPP_mass_flow * (self.h[11] - self.h[3]), 'HP Turbine work': HPT_mass_flow * (self.h[14] - self.h[15]), 'IP Turbine work': IPT_mass_flow * (self.h[10] - self.h[5]), 'LP Turbine work': LPT_mass_flow * (self.h[5] - self.h[6]), 'LP Superheater Heat Input': self.superheater_1_mass_flow * (self.h[5] - self.h[4]), 'LP Evaporator Heat Input': self.evaporator_1_mass_flow * (self.h[4] - self.h[3]), 'LP Economiser Heat Input': self.economiser_1_mass_flow * (self.h[3] - self.h[2]), 'IP Superheater Heat Input': self.superheater_2_mass_flow * (self.h[10] - self.h[15]), 'IP Superheater 2 Heat Input': self.evaporator_2_mass_flow * (self.h[15] - self.h[9]), 'IP Evaporator Heat Input': self.evaporator_2_mass_flow * (self.h[9] - self.h[8]), 'IP Economiser Heat Input': self.economiser_2_mass_flow * (self.h[8] - self.h[7]), 'HP Superheater Heat Input': self.superheater_3_mass_flow * (self.h[14] - self.h[13]), 'HP Evaporator Heat Input': self.evaporator_3_mass_flow * (self.h[13] - self.h[12]), 'HP Economiser Heat Input': self.economiser_3_mass_flow * (self.h[12] - self.h[11]) } print("\nCycle Specific Works:") for work, value in self.total_works.items(): print("\n\t"+work+" = "+str(value)) #Finding Total Heat into Cycle from HRSG self.q_in = self.total_works['LP Economiser Heat Input'] + self.total_works['LP Evaporator Heat Input'] + self.total_works['LP Superheater Heat Input'] + self.total_works['IP Economiser Heat Input'] + \ self.total_works['IP Evaporator Heat Input'] + self.total_works['IP Superheater Heat Input'] + self.total_works['HP Economiser Heat Input'] + self.total_works['HP Evaporator Heat Input'] + self.total_works['HP Superheater Heat Input'] #FInding Net Work self.w_net = self.total_works['HP Turbine work'] + self.total_works['IP Turbine work'] + self.total_works['LP Turbine work'] - self.total_works['HP Pump work'] - self.total_works['IP Pump work'] - self.total_works['LP Pump work'] self.total_works['Net Work'] = self.w_net #Finding Thermal Efficiency fo Steam Cycle self.efficiency = self.w_net / self.q_in self.total_works['Efficiency'] = self.efficiency print("\nCycle Efficiency:") print("\n\tefficiency = "+str(self.efficiency*100)+"%") print("\n\tWith a Net Work of : "+str(np.round(self.w_net))+"kW") print("\n\tand a Total Heat Input of: "+str(np.round(self.q_in))+"kW\n")
def __alpha_tn_func(self, temp, params): import math import scipy.misc as diff import scipy.constants as unit import iapws.iapws97 as steam import iapws.iapws95 as steam2 pressure = steam._PSat_T(temp) d_rho = steam2.IAPWS95(P=pressure, T=temp - 1).drhodT_P #d_rho2 = diff.derivative(derivative_helper, temp) # dRho/dTm rho = 1 / steam._Region4(pressure, 0)['v'] # mass density, kg/m3 Nm = ((rho * unit.kilo) / params['mod molar mass']) * unit.N_A * ( unit.centi)**3 # number density of the moderator d_Nm = ((d_rho * unit.kilo) / params['mod molar mass']) * unit.N_A * ( unit.centi)**3 #dNm/dTm d_Nm = d_Nm * unit.zepto * unit.milli mod_macro_a = params[ 'mod micro a'] * Nm # macroscopic absorption cross section of the moderator mod_macro_s = params[ 'mod micro s'] * Nm # macroscopic scattering cross section of the moderator F = params['fuel macro a'] / (params['fuel macro a'] + mod_macro_a ) # thermal utilization, F #dF/dTm d_F = -1 * (params['fuel macro a'] * params['mod micro a'] * d_Nm) / (params['fuel macro a'] + mod_macro_a)**2 # Resonance escape integral, P P = math.exp( (-1 * params['n fuel'] * (params['fuel_volume']) * params['I']) / (mod_macro_s * 3000)) #dP/dTm d_P = P * (-1 * params['n fuel'] * params['fuel_volume'] * unit.centi**3 * params['mod micro s'] * d_Nm) / (mod_macro_s * 3000 * unit.centi**3)**2 Eth = 0.0862 * temp # convert temperature to energy in MeV E1 = mod_macro_s / math.log( params['E0'] / Eth) # neutron thermalization macroscopic cross section Df = 1 / (3 * mod_macro_s * (1 - params['mod mu0'])) # neutron diffusion coefficient tau = Df / E1 # fermi age, tau #dTau/dTm d_tau = (( (0.0862 * (Eth / params['E0'])) * 3 * Nm) - math.log(params['E0'] / Eth) * (params['mod micro s'] * d_Nm)) / ((3 * Nm)**2 * (1 - params['mod mu0'])) L = math.sqrt(1 / (3 * mod_macro_s * mod_macro_a * (1 - params['mod mu0']))) # diffusion length L # dL/dTm d_L = 1 / (2 * math.sqrt( (-2 * d_Nm * unit.zepto * unit.milli) / (3 * params['mod micro s'] * params['mod micro a'] * (Nm * unit.zepto * unit.milli)**3 * (1 - params['mod mu0'])))) # left term of the numerator of the moderator temperature feedback coefficient, alpha left_1st_term = d_tau * ( params['buckling']**2 + L**2 * params['buckling']**4 ) #holding L as constant left_2nd_term = d_L * ( 2 * L * params['buckling']**2 + 2 * L * tau * params['buckling']**4 ) # holding tau as constant left_term = (P * F) * (left_1st_term + left_2nd_term ) # combining with P and F held as constant # right term of the numerator of the moderator temperature feedback coefficient, alpha right_1st_term = (-1) * (1 + ((tau + L**2) * params['buckling']**2) + tau * L**2 * params['buckling']**4 ) # num as const right_2nd_term = F * d_P # holding thermal utilization as constant right_3rd_term = P * d_F # holding resonance escpae as constant right_term = right_1st_term * (right_2nd_term + right_3rd_term ) # combining all three terms together # numerator and denominator numerator = left_term + right_term denominator = params['eta'] * params['epsilon'] * (F * P)**2 alpha_tn = numerator / denominator alpha_tn = alpha_tn / 3 return alpha_tn
for v in isov: print(" v=%s" % v) pts = [iapws.IAPWS95(T=t, v=v) for t in Tl] x = [] y = [] for p in pts: if p.status: x.append(p.__getattribute__(xAxis)) y.append(p.__getattribute__(yAxis)) plt.plot(x, y, **isov_kw) # Plot region limits if regionBoundary: # Boundary 1-3 Po = _PSat_T(623.15) P = np.linspace(Po, 100, points) pts = [fluid(P=p, T=623.15) for p in P] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] plt.plot(x, y, **isosat_kw) # Boundary 2-3 T = np.linspace(623.15, 863.15) P = [_P23_T(t) for t in T] P[-1] = 100 # Avoid round problem with value out of range > 100 MPa pts = [fluid(P=p, T=t) for p, t in zip(P, T)] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] plt.plot(x, y, **isosat_kw)
def plot(**kwargv): ############################################################################### # Configuration section ############################################################################### show = True # Define standard to use in plot, IAPWS95 very slow! fluid = iapws.IAPWS97 # fluid = iapws.IAPWS95 # Define kind of plot xAxis = "s" yAxis = "P" if "x" in kwargv: xAxis = kwargv["x"] if "y" in kwargv: yAxis = kwargv["y"] if "show" in kwargv: show = kwargv["show"] print("Calculating %s-%s Diagram..." % (yAxis, xAxis)) # Point count for line, high value get more definition but slow calculate time points = 50 # Saturation line format isosat_kw = {"ls": "-", "color": "black", "lw": 1} # Isoquality lines to plot isoq = np.arange(0.1, 1, 0.1) isoq_kw = {"ls": "--", "color": "black", "lw": 0.5} labelq_kw = {"size": "xx-small", "ha": "right", "va": "center"} # Isotherm lines to plot, values in ºC isoT = [0, 50, 100, 200, 300, 400, 500, 600, 700, 800, 1200, 1600, 2000] isoT_kw = {"ls": "-", "color": "red", "lw": 0.5} labelT_kw = {"size": "xx-small", "ha": "right", "va": "bottom"} # Isobar lines to plot isoP = [Pt, 0.001, 0.01, 0.1, 1, 10, 20, 50, 100] isoP_kw = {"ls": "-", "color": "blue", "lw": 0.5} labelP_kw = {"size": "xx-small", "ha": "center", "va": "center"} # Isoenthalpic lines to plot isoh = np.arange(200, 4400, 200) isoh_kw = {"ls": "-", "color": "green", "lw": 0.5} labelh_kw = {"size": "xx-small", "ha": "center", "va": "center"} # Isoentropic lines to plot isos = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] isos_kw = {"ls": "-", "color": "brown", "lw": 0.5} labels_kw = {"size": "xx-small", "ha": "center", "va": "center"} # # Isochor lines to plot # isov = [0.1, 1, 10, 100] # isov_kw = {"ls": "-", "color": "green", "lw": 0.5} # Show region limits regionBoundary = False if "regionBoundary" in kwargv: regionBoundary = kwargv["regionBoundary"] # Show region5 region5 = False ############################################################################### # Calculate ############################################################################### # Set plot label title = { "T": "T, K", "P": "P, MPa", "v": "v, m³/kg", "h": "h, kJ/kg", "s": "s, kJ/kgK" } # Check axis correct definition validAxis = ", ".join(title.keys()) if xAxis not in title: raise ValueError("X axis variable don´t supported, valid only ", validAxis) if yAxis not in title: raise ValueError("Y axis variable don´t supported, valid only ", validAxis) if xAxis == yAxis: raise ValueError("X and Y axis can't show same variable") # Set plot legend plt.title("%s-%s Diagram" % (yAxis, xAxis)) xtitle = title[xAxis] plt.xlabel(xtitle) ytitle = title[yAxis] plt.ylabel(ytitle) # Set logaritmic scale if apropiate if xAxis in ["P", "v"]: plt.xscale("log") if yAxis in ["P", "v"]: plt.yscale("log") plt.grid(True) # Calculate point of isolines Ps = list( np.concatenate([ np.logspace(np.log10(Pt), np.log10(0.1 * Pc), points), np.linspace(0.1 * Pc, 0.9 * Pc, points), np.linspace(0.9 * Pc, 0.99 * Pc, points), np.linspace(0.99 * Pc, Pc, points) ])) Pl = list( np.concatenate([ np.logspace(np.log10(Pt), np.log10(0.1 * Pc), points), np.linspace(0.1 * Pc, 0.5 * Pc, points), np.linspace(0.5 * Pc, 0.9 * Pc, points), np.linspace(0.9 * Pc, 0.99 * Pc, points), np.linspace(0.99 * Pc, Pc, points), np.linspace(Pc, 1.01 * Pc, points), np.linspace(1.01 * Pc, 1.1 * Pc, points), np.linspace(1.1 * Pc, 50, points), np.linspace(50, 100, points) ])) Tl = list( np.concatenate([ np.linspace(0, 25, points), np.linspace(25, 0.5 * Tc, points), np.linspace(0.5 * Tc, 0.9 * Tc, points), np.linspace(0.9 * Tc, Tc, points), np.linspace(Tc, 1.1 * Tc, points), np.linspace(1.1 * Tc, 1.1 * Tc, points), np.linspace(1.1 * Tc, 800, points), np.linspace(800, 2000, points) ])) # Calculate saturation line print("Calculating saturation lines...") liq = [fluid(P=p, x=0) for p in Ps] xliq = [l.__getattribute__(xAxis) for l in liq] yliq = [l.__getattribute__(yAxis) for l in liq] plt.plot(xliq, yliq, **isosat_kw) vap = [fluid(P=p, x=1) for p in Ps] xvap = [v.__getattribute__(xAxis) for v in vap] yvap = [v.__getattribute__(yAxis) for v in vap] plt.plot(xvap, yvap, **isosat_kw) # Calculate isoquality lines print("Calculating isoquality lines...") Q = {} for q in isoq: Q["%s" % q] = {} txt = "x=%s" % q print(" %s" % txt) pts = [fluid(P=p, x=q) for p in Ps] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] Q["%s" % q]["x"] = x Q["%s" % q]["y"] = y plt.plot(x, y, **isoq_kw) # Calculate isotherm lines if xAxis != "T" and yAxis != "T": print("Calculating isotherm lines...") T_ = {} for T in isoT: T_["%s" % T] = {} print(" T=%sºC" % T) # Calculate the saturation point if available if T + 273.15 < Tc: liqsat = fluid(T=T + 273.15, x=0) vapsat = fluid(T=T + 273.15, x=1) sat = True else: sat = False pts = [] for p in Pl: try: point = fluid(P=p, T=T + 273.15) if fluid == iapws.IAPWS97 and not region5 and \ point.region == 5: continue # Add saturation point if neccesary if sat and T + 273.15 < Tc and point.s < vapsat.s: pts.append(vapsat) pts.append(liqsat) sat = False pts.append(point) except NotImplementedError: pass x = [] y = [] for p in pts: if p.status: x.append(p.__getattribute__(xAxis)) y.append(p.__getattribute__(yAxis)) plt.plot(x, y, **isoT_kw) T_["%s" % T]["x"] = x T_["%s" % T]["y"] = y # Calculate isobar lines if xAxis != "P" and yAxis != "P": print("Calculating isobar lines...") P_ = {} for P in isoP: print(" P=%sMPa" % P) P_["%s" % P] = {} # Calculate the saturation point if available if P < Pc: liqsat = fluid(P=P, x=0) vapsat = fluid(P=P, x=1) sat = True else: sat = False pts = [] for t in Tl: try: point = fluid(P=P, T=t + 273.15) if fluid == iapws.IAPWS97 and not region5 and \ point.region == 5: continue # Add saturation point if neccesary if sat and P < Pc and point.status and point.s > vapsat.s: pts.append(liqsat) pts.append(vapsat) sat = False pts.append(point) except NotImplementedError: pass x = [] y = [] for p in pts: if p.status: x.append(p.__getattribute__(xAxis)) y.append(p.__getattribute__(yAxis)) plt.plot(x, y, **isoP_kw) P_["%s" % P]["x"] = x P_["%s" % P]["y"] = y # Calculate isoenthalpic lines if xAxis != "h" and yAxis != "h": print("Calculating isoenthalpic lines...") H_ = {} for h in isoh: print(" h=%skJ/kg" % h) H_["%s" % h] = {} pts = [] for p in Pl: try: point = fluid(P=p, h=h) if fluid == iapws.IAPWS97 and not region5 and \ point.region == 5: continue pts.append(point) except NotImplementedError: pass x = [] y = [] for p in pts: if p.status: x.append(p.__getattribute__(xAxis)) y.append(p.__getattribute__(yAxis)) plt.plot(x, y, **isoh_kw) H_["%s" % h]["x"] = x H_["%s" % h]["y"] = y # Calculate isoentropic lines if xAxis != "s" and yAxis != "s": print("Calculating isoentropic lines...") S_ = {} for s in isos: print(" s=%skJ/kgK" % s) S_["%s" % s] = {} pts = [] for p in Pl: try: point = fluid(P=p, s=s) if fluid == iapws.IAPWS97 and not region5 and \ point.region == 5: continue pts.append(point) except NotImplementedError: pass x = [] y = [] for p in pts: if p.status: x.append(p.__getattribute__(xAxis)) y.append(p.__getattribute__(yAxis)) plt.plot(x, y, **isos_kw) S_["%s" % s]["x"] = x S_["%s" % s]["y"] = y # # Calculate isochor lines # if xAxis != "v" and yAxis != "v": # print("Calculating isochor lines...") # for v in isov: # print(" v=%s" % v) # pts = [fluid(P=p, v=v) for p in Pl] # x = [] # y = [] # for p in pts: # if p.status: # x.append(p.__getattribute__(xAxis)) # y.append(p.__getattribute__(yAxis)) # plt.plot(x, y, **isov_kw) # Plot region limits if regionBoundary: # Boundary 1-3 Po = _PSat_T(623.15) P = np.linspace(Po, 100, points) pts = [fluid(P=p, T=623.15) for p in P] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] plt.plot(x, y, **isosat_kw) # Boundary 2-3 T = np.linspace(623.15, 863.15) P = [_P23_T(t) for t in T] P[-1] = 100 # Avoid round problem with value out of range > 100 MPa pts = [fluid(P=p, T=t) for p, t in zip(P, T)] x = [p.__getattribute__(xAxis) for p in pts] y = [p.__getattribute__(yAxis) for p in pts] plt.plot(x, y, **isosat_kw) # Show annotate in plot xmin, xmax = plt.xlim() ymin, ymax = plt.ylim() for q in isoq: x = Q["%s" % q]["x"] y = Q["%s" % q]["y"] txt = "x=%s" % q i = 0 j = i + 1 if xAxis in ["P", "v"]: fx = (log(x[i]) - log(x[j])) / (log(xmax) - log(xmin)) else: fx = (x[i] - x[j]) / (xmax - xmin) if yAxis in ["P", "v"]: fy = (log(y[i]) - log(y[j])) / (log(ymax) - log(ymin)) else: fy = (y[i] - y[j]) / (ymax - ymin) rot = atan(fy / fx) * 360 / 2 / pi plt.annotate(txt, (x[i], y[i]), rotation=rot, **labelq_kw) if xAxis != "T" and yAxis != "T": for T in isoT: x = T_["%s" % T]["x"] y = T_["%s" % T]["y"] if not x: continue txt = "%sºC" % T i = 0 j = i + 2 if xAxis in ["P", "v"]: fx = (log(x[i]) - log(x[j])) / (log(xmax) - log(xmin)) else: fx = (x[i] - x[j]) / (xmax - xmin) if yAxis in ["P", "v"]: fy = (log(y[i]) - log(y[j])) / (log(ymax) - log(ymin)) else: fy = (y[i] - y[j]) / (ymax - ymin) rot = atan(fy / fx) * 360 / 2 / pi plt.annotate(txt, (x[i], y[i]), rotation=rot, **labelT_kw) if xAxis != "P" and yAxis != "P": for P in isoP: x = P_["%s" % P]["x"] y = P_["%s" % P]["y"] if not x: continue txt = "%sMPa" % P i = len(x) - 15 j = i - 2 if xAxis in ["P", "v"]: fx = (log(x[i]) - log(x[j])) / (log(xmax) - log(xmin)) else: fx = (x[i] - x[j]) / (xmax - xmin) if yAxis in ["P", "v"]: fy = (log(y[i]) - log(y[j])) / (log(ymax) - log(ymin)) else: fy = (y[i] - y[j]) / (ymax - ymin) rot = atan(fy / fx) * 360 / 2 / pi plt.annotate(txt, (x[i], y[i]), rotation=rot, **labelP_kw) if xAxis != "h" and yAxis != "h": for h in isoh: x = H_["%s" % h]["x"] y = H_["%s" % h]["y"] if not x: continue if h % 1000: continue txt = "%s J/g" % h i = points j = i + 2 if xAxis in ["P", "v"]: fx = (log(x[i]) - log(x[j])) / (log(xmax) - log(xmin)) else: fx = (x[i] - x[j]) / (xmax - xmin) if yAxis in ["P", "v"]: fy = (log(y[i]) - log(y[j])) / (log(ymax) - log(ymin)) else: fy = (y[i] - y[j]) / (ymax - ymin) rot = atan(fy / fx) * 360 / 2 / pi plt.annotate(txt, (x[i], y[i]), rotation=rot, **labelh_kw) if xAxis != "s" and yAxis != "s": for s in isos: x = S_["%s" % s]["x"] y = S_["%s" % s]["y"] txt = "%s J/gK" % s i = len(x) // 2 if s > 10: j = i + 1 else: j = i + 5 if xAxis in ["P", "v"]: fx = (log(x[i]) - log(x[j])) / (log(xmax) - log(xmin)) else: fx = (x[i] - x[j]) / (xmax - xmin) if yAxis in ["P", "v"]: fy = (log(y[i]) - log(y[j])) / (log(ymax) - log(ymin)) else: fy = (y[i] - y[j]) / (ymax - ymin) rot = atan(fy / fx) * 360 / 2 / pi plt.annotate(txt, (x[i], y[i]), rotation=rot, **labels_kw) if show: plt.show()
def __alpha_tn_func(self, temp, params): pressure = steam._PSat_T(temp) # vfda: why accessing protected method? d_rho = steam2.IAPWS95(P=pressure, T=temp-1).drhodT_P rho = 1 / steam._Region4(pressure, 0)['v'] # mass density, kg/m3 n_m = ((rho * unit.kilo)/self.mod_molar_mass) * unit.N_A * (unit.centi)**3 # number density of the moderator d_nm = ((d_rho * unit.kilo)/self.mod_molar_mass) * unit.N_A * (unit.centi)**3 #dNm/dTm d_nm = d_nm * unit.zepto * unit.milli mod_macro_a = self.mod_micro_a * n_m # macroscopic absorption cross section of the moderator mod_macro_s = self.mod_micro_s * n_m # macroscopic scattering cross section of the moderator F = self.fuel_macro_a/(self.fuel_macro_a + mod_macro_a) # thermal utilization, F #dF/dTm d_f = -1*(self.fuel_macro_a * self.mod_micro_a * d_nm)/( (self.fuel_macro_a + mod_macro_a)**2) # Resonance escape integral, P P = math.exp((-1 * self.n_fuel * (self.fuel_volume) * self.I)/ ((mod_macro_s * 3000))) #dP/dTm d_p = P * (-1 * self.n_fuel * self.fuel_volume * unit.centi**3 * (self.mod_micro_s) * d_nm)/(mod_macro_s * 3000 * unit.centi**3)**2 e_th = 0.0862 * temp # convert temperature to energy in MeV e_one = mod_macro_s/math.log(self.E0/e_th) # neutron thermalization macroscopic cross section d_f = 1/(3 * mod_macro_s * (1 - self.mod_mu0)) # neutron diffusion coefficient tau = d_f/e_one # fermi age, tau #dTau/dTm d_tau = (((0.0862 * (e_th/self.E0)) * 3 * n_m) - math.log(self.E0/e_th) * ((self.mod_micro_s * d_nm))/((3 * n_m)**2 * (1 - self.mod_mu0))) L = math.sqrt(1/(3 * mod_macro_s * mod_macro_a * (1 - self.mod_mu0))) # diffusion length L # dL/dTm d_l = 1/(2 * math.sqrt((-2 * d_nm * unit.zepto * unit.milli)/(3 * self.mod_micro_s * (self.mod_micro_a * (n_m * unit.zepto * unit.milli)**3 * ((1 - self.mod_mu0)))))) # left term of the numerator of the moderator temperature feedback coefficient, alpha left_first_term = d_tau * (self.buckling**2 + L**2 * self.buckling**4) #holding L as constant left_second_term = d_l * (2 * L * self.buckling**2 + 2 * L * (tau * self.buckling**4)) # holding tau as constant left_term = (P * F) * (left_first_term + left_second_term) # combining with P and F held as constant right_1st_term = (-1) * (1 + ((tau + d_l**2) * self.buckling**2) + \ tau * d_l**2 * self.buckling**4) # num as const right_first_term = (-1) * ((1 + ((tau + L**2) * self.buckling**2)) + tau * L**2 * self.buckling**4) # num as const right_second_term = F * d_p # holding thermal utilization as constant right_third_term = P * d_f # holding resonance escpae as constant right_term = right_first_term * (right_second_term + right_third_term) # combining all three terms together # numerator and denominator numerator = left_term + right_term denominator = self.eta * self.epsilon * \ (F * P)**2 alpha_tn = numerator/denominator alpha_tn = alpha_tn/3 return alpha_tn
def __get_coolant_outflow(self, time): """Get the coolant outflow stream. Parameters ---------- time: float Time in SI unit. Returns ------- None """ coolant_outflow_stream = dict() outflow_cool_temp = self.coolant_outflow_phase.get_value('temp', time) if outflow_cool_temp <= 373.15: coolant_outflow_stream['temp'] = outflow_cool_temp coolant_outflow_stream['pressure'] = 0 coolant_outflow_stream['quality'] = 0 coolant_outflow_stream['flowrate'] = 0 else: if self.params['valve_opened']: pressure = steam._PSat_T(outflow_cool_temp) base_temp = 373.15 base_pressure = steam._PSat_T(base_temp) base_params = steam.IAPWS97(T=base_temp, x=0) base_entropy = base_params.s base_cp = base_params.cp inlet_params = steam.IAPWS97(T=outflow_cool_temp, x=0) inlet_cp = inlet_params.cp average_cp = (base_cp + inlet_cp)/2 delta_s = average_cp * math.log(outflow_cool_temp/base_temp) - (unit.R/1000) * math.log(pressure/base_pressure) inlet_entropy = (delta_s + base_entropy) * 1.25 bubl_entropy = inlet_params.s bubl_enthalpy = inlet_params.h inlet_params = steam.IAPWS97(T=base_temp, x=1) dew_entropy = inlet_params.s dew_enthalpy = inlet_params.h quality = (inlet_entropy - bubl_entropy)/(dew_entropy - bubl_entropy) delta_t = time - self.params['valve_opening_time'] mass_flowrate = 1820 * (1 - math.exp(-1 * delta_t/(3 * unit.minute))) coolant_outflow_stream['temp'] = outflow_cool_temp coolant_outflow_stream['pressure'] = pressure coolant_outflow_stream['quality'] = quality coolant_outflow_stream['flowrate'] = mass_flowrate else: self.params['valve_opened'] = True self.params['valve_opening_time'] = time coolant_outflow_stream['temp'] = 373.15 coolant_outflow_stream['pressure'] = 0 coolant_outflow_stream['quality'] = 0 coolant_outflow_stream['flowrate'] = 0 return coolant_outflow_stream