def test_hole_leak_Crane(self): LHe = ht.ThermState('helium') LHe.update('P', ht.P_NTP, 'Q', Q_('0')) Portable_500L = odh.Source('Portable 500L', LHe, Q_(500, ureg.L)) Portable_500L.dewar_insulation_failure(1054 * ureg('ft^3/min')) fluid = ht.ThermState('water', P=Q_(2, ureg.psig), T=Q_(60, ureg.degF)) tube = ht.piping.Pipe(3, SCH=80) d_hole = 2 * ureg.inch area = 3.14159 * d_hole**2 / 4 self.assertApproxEqual(131 * ureg.gal / ureg.min, odh.hole_leak(tube, area, fluid), uncertainty=0.2)
def test_White_9_4(self): fluid_static = ht.ThermState('air', P=500 * ureg.kPa, T=470 * ureg.K) area = 0.05 * ureg.m**2 v = 180 * ureg.m / ureg.s m_dot = v * area * fluid_static.Dmass M = ht.piping.Mach(fluid_static, v) M_exp = 0.414 self.assertApproxEqual(M_exp, M, uncertainty=0.005) P0 = 563 * ureg.kPa T0 = 486 * ureg.K fluid_total = ht.ThermState('air', P=P0, T=T0) M_total = ht.piping.Mach_total(fluid_total, m_dot, area) self.assertApproxEqual(M_exp, M_total, uncertainty=0.005)
def test_White_9_3(self): v = 240 * ureg.m / ureg.s T1 = 320 * ureg.K P1 = 170 * ureg.kPa T01 = 349 * ureg.K P01 = 230 * ureg.kPa fluid_static = ht.ThermState('air', P=P1, T=T1) area = 0.05 * ureg.m**2 # Assumed value M = ht.piping.Mach(fluid_static, v) M_exp = 0.67 self.assertApproxEqual(M_exp, M, uncertainty=0.005) fluid_total = ht.ThermState('air', P=P01, T=T01) m_dot = v * area * fluid_static.Dmass M_total = ht.piping.Mach_total(fluid_total, m_dot, area) self.assertApproxEqual(M_exp, M_total, uncertainty=0.005)
def test_oxygen(self): fluid = ht.ThermState('oxygen', backend='REFPROP') T = 100 * ureg.K P = 1000 * ureg.kPa fluid.update_kw(T=T, P=P) self.assertNIST(153.886680663753, fluid.viscosity.to(ureg.uPa * ureg.s).magnitude)
def test_hole_leak_voirin(self): P_150 = Q_(150, ureg.psig) P_15 = Q_(15, ureg.psig) T = Q_(60, ureg.degF) V_flux_150 = 2.856 * ureg.ft**3 / (ureg.min * ureg.mm**2) V_flux_15 = 0.515 * ureg.ft**3 / (ureg.min * ureg.mm**2) area = 1 * ureg.mm**2 # Chosen for simplicity ID = (4 * area / pi)**0.5 # Assuming tube ID based on area tube = ht.piping.Tube(ID, wall=0 * ureg.m) fluid = ht.ThermState('nitrogen', P=P_150, T=T) m_dot = ht.odh.hole_leak(tube, area, fluid) self.assertApproxEqual(V_flux_150 * area, m_dot) fluid = ht.ThermState('nitrogen', P=P_15, T=T) m_dot = ht.odh.hole_leak(tube, area, fluid) self.assertApproxEqual(V_flux_15 * area, m_dot)
def test_nitrogen(self): fluid = ht.ThermState('nitrogen', backend='REFPROP') T = 100 * ureg.K fluid.update_kw(T=T, Q=0) self.assertNIST( 100.111748964945, fluid.conductivity.to(ureg.W / (ureg.m * ureg.K)).magnitude * 1000)
def test_Rennels_4_5(self): pipe = ht.piping.Pipe(4, SCH=40, L=100 * ureg.ft) fluid = ht.ThermState('nitrogen', P=100 * ureg.psi, T=530 * ureg.degR) piping = ht.piping.Piping(pipe) P_out = 84.056 * ureg.psi m_dot_isot = ht.piping.m_dot_isot(fluid, pipe, P_out) self.assertApproxEqual(10, m_dot_isot.m_as(ureg.lb / ureg.s))
def test_r134a(self): fluid = ht.ThermState('r134a', backend='REFPROP') T = 400 * ureg.K D = 50 / fluid.M * ureg.mol / ureg.L fluid.update_kw(T=T, Dmolar=D) self.assertNIST(1.45691892789737, fluid.P.to(ureg.kPa).magnitude / 1000)
def test_ammonia_water(self): fluid = ht.ThermState('ammonia&water', backend='REFPROP') fluid.set_mole_fractions(0.4, 0.6) T = (((300 - 32) * 5 / 9) + 273.15) * ureg.K P = 10000 / 14.50377377 * (10**5) / 1000 * ureg.kPa fluid.update_kw(T=T, P=P) self.assertNIST( 5536.79144924071, fluid.speed_sound.to(ureg.m / ureg.s).magnitude * 1000 / 25.4 / 12)
def test_air_density(self): fluid = ht.ThermState('air.mix', backend='REFPROP') T = (((70 - 32) * 5 / 9) + 273.15) * ureg.K P = 14.7 / 14.50377377 * (10**5) / 1000 * ureg.kPa fluid.update_kw(P=P, T=T) self.assertNIST( 0.0749156384666842, fluid.Dmolar.to(ureg.mol / ureg.L).magnitude * fluid.M * 0.062427974)
def test_White_9_12(self): fluid_total = ht.ThermState('air', P=200 * ureg.kPa, T=500 * ureg.K) v = 100 * ureg.m / ureg.s pipe = ht.piping.Tube(3 * ureg.cm, L=15 * ureg.m) m_dot = 0.0961 * ureg.kg / ureg.s # Based on static density from the source f = 0.02 Ma = ht.piping.Mach_total(fluid_total, m_dot, pipe.area) K_lim = ht.piping.K_lim(Ma, fluid_total.gamma) Lstar = K_lim * pipe.ID / f self.assertApproxEqual(16.5 * ureg.m, Lstar)
def test_Crane_7_16(self): air = ht.ThermState('air', P=Q_(65, ureg.psig), T=Q_(110, ureg.degF)) pipe = ht.piping.Pipe(1, SCH=40, L=75 * ureg.ft) flow = 100 * ureg.ft**3 / ureg.min m_dot = flow * ht.AIR.Dmass piping = ht.piping.Piping(pipe, ht.piping.Exit(pipe.ID)) dP = ht.piping.dP_incomp(m_dot, air, piping) self.assertApproxEqual(2.61, dP.m_as(ureg.psi)) dP_isot = ht.piping.dP_isot(m_dot, air, pipe) self.assertApproxEqual(2.61, dP_isot.m_as(ureg.psi))
def test_API_sonic(self): """Example from API 5.6""" m_dot = 53500 * ureg.lb / ureg.hr fluid = ht.ThermState('propane&butane', backend='REFPROP') fluid.set_mole_fractions(0.5, 0.5) fluid.update_kw(T=627 * ureg.degR, P=97.2 * ureg.psi) P_back = Q_(0, ureg.psig) A_expect = 5.73 * ureg.inch**2 A_calc = ht.A_relief_API(m_dot, fluid, P_back=P_back) self.assertApproxEqual(A_expect, A_calc, uncertainty=0.05)
def test_M_from_K(self): air = ht.ThermState('air', P=300 * ureg.kPa, T=500 * ureg.K) self.assertApproxEqual(0.225, ht.piping.M_from_K_lim(11, air.gamma)) self.assertApproxEqual(0.2, ht.piping.M_from_K_lim(14.533, air.gamma)) self.assertApproxEqual(0.15, ht.piping.M_from_K_lim(27.932, air.gamma)) self.assertApproxEqual(0.17, ht.piping.M_from_K_lim(21.115, air.gamma)) self.assertApproxEqual(0.175, ht.piping.M_from_K_lim(19.772, air.gamma)) self.assertApproxEqual(0.1741, ht.piping.M_from_K_lim(20, air.gamma)) self.assertApproxEqual(1, ht.piping.M_from_K_lim(0, air.gamma))
def test_White_9_13(self): fluid_static = ht.ThermState('air', P=220 * ureg.kPa, T=300 * ureg.K) P_out = 140 * ureg.kPa pipe = ht.piping.Tube(1 * ureg.cm, wall=0 * ureg.m, L=1.2 * ureg.m) K = 0.025 * pipe.L / pipe.ID pipe.K = MagicMock(return_value=K) m_dot_adiab = ht.piping.m_dot_adiab(fluid_static, pipe, P_out, state='static') self.assertApproxEqual(0.0233 * ureg.kg / ureg.s, m_dot_adiab)
def test_Crane_7_22(self): air = ht.ThermState('air', P=Q_(19.3, ureg.psig), T=Q_(100, ureg.degF)) pipe = ht.piping.Pipe(1 / 2, SCH=80, L=7.04 / 6.04 * 10 * ureg.ft) # Adjust for entrance K = 1, total 7.04 dP = 19.3 * ureg.psi P_out = air.P - dP q_expected = 3762 * ureg.ft**3 / ureg.hr # STD flow m_dot_expected = ht.to_mass_flow(q_expected, air) Re = ht.Re(air, m_dot_expected, pipe.ID, pipe.area) f = 0.0275 m_dot_isot = ht.piping.m_dot_isot(air, pipe) self.assertApproxEqual(m_dot_expected, m_dot_isot)
def test_White_P_9_100(self): fluid = ht.ThermState('methane', T=Q_(68, ureg.degF), P=5 * ureg.bar + 101325 * ureg.Pa) P_out = 1 * ureg.bar + 101325 * ureg.Pa pipe = ht.piping.Pipe(6, L=31 * ureg.mile) K = 0.019 * pipe.L / pipe.ID pipe.K = MagicMock(return_value=K) m_dot_isot = ht.piping.m_dot_isot(fluid, pipe, P_out) self.assertApproxEqual(0.345 * ureg.kg / ureg.s, m_dot_isot) dP_isot = ht.piping.dP_isot(m_dot_isot, fluid, pipe) self.assertApproxEqual(fluid.P - P_out, dP_isot)
def test_White_9_11(self): f = 0.024 d = 2 * ureg.cm Ma1 = 0.1 Ma2 = 0.5 P1 = 600 * ureg.kPa T1 = 450 * ureg.K fluid = ht.ThermState('air', P=P1, T=T1) k = fluid.gamma P2 = ht.piping.P_from_M(P1, Ma1, Ma2, k) self.assertApproxEqual(117 * ureg.kPa, P2) P02 = ht.piping.P_total(P2, Ma2, k) self.assertApproxEqual(139 * ureg.kPa, P02)
def test_White_P_9_101(self): air = ht.ThermState('air', T=Q_(20, ureg.degC), P=102 * ureg.kPa) P_out = 100 * ureg.kPa pipe = ht.piping.Tube(3 * ureg.cm, wall=0 * ureg.m, L=1 * ureg.m) K = 0.028 * pipe.L / pipe.ID pipe.K = MagicMock(return_value=K) m_dot_incomp = ht.piping.m_dot_incomp(air, ht.piping.Piping(pipe), P_out=P_out) m_dot_isot = ht.piping.m_dot_isot(air, pipe, P_out) self.assertApproxEqual(m_dot_incomp, m_dot_isot) m_dot_adiab = ht.piping.m_dot_adiab(air, pipe, P_out) self.assertApproxEqual(m_dot_incomp, m_dot_adiab) dP_incomp = ht.piping.dP_incomp(m_dot_incomp, air, [pipe]) self.assertApproxEqual(air.P - P_out, dP_incomp) dP_isot = ht.piping.dP_isot(m_dot_isot, air, pipe) self.assertApproxEqual(air.P - P_out, dP_isot)
def combine(name, sources): """Combine several ODH sources sharing volume. Can be used for failure modes affecting several sources in parallel. Parameters ---------- name : str Name of the new combined source. sources : list of Source Sources connected together. Returns ------- Source Combined source of inert gas. """ fluid = ht.ThermState(sources[0].fluid.name, T=ht.T_NTP, P=ht.P_NTP) if all([source.fluid.name == fluid.name for source in sources]): total_volume = sum([source.volume for source in sources]) return Source(name, fluid, total_volume) else: print('\nAll volumes should contain the same fluid') return None
def test_octane(self): fluid = ht.ThermState('octane', backend='REFPROP') T = (100 + 273.15) * ureg.K fluid.update_kw(T=T, Q=0) self.assertNIST(319.167499870568, fluid.latent_heat.to(ureg.J / ureg.g).magnitude)
def test_argon(self): fluid = ht.ThermState('argon', backend='REFPROP') P = 2 * 1000 * ureg.kPa D = 15 / fluid.M * ureg.mol / ureg.L fluid.update_kw(P=P, Dmolar=D) self.assertNIST(637.377588657857, fluid.T.to(ureg.K).magnitude)
def test_R410A_mole_fraction(self): fluid = ht.ThermState('R410A.MIX', backend='REFPROP') self.assertNIST(0.697614699375863, fluid.mole_fractions[0])
def test_R410A_mass_fraction(self): fluid = ht.ThermState('R410A.MIX', backend='REFPROP') self.assertNIST(0.5, fluid.mass_fractions[0])
def test_air(self): fluid = ht.ThermState('air.mix', backend='REFPROP') self.assertNIST(fluid.M, 28.958600656)
def test_copy(self): """Minimal test of copy method""" test_state = ht.ThermState('nitrogen') test_state.copy() test_state.update_kw(T=300 * ureg.K, P=1 * ureg.MPa) test_state.copy()
def test_direct_integration(self): fluid = ht.ThermState('helium', P=200 * ureg.psi, T=7 * ureg.K) self.assertApproxEqual(13920 * ureg.kg / (ureg.s * ureg.m**2), ht.piping.G_nozzle(fluid, P_out=1 * ureg.atm), uncertainty=0.01)