def test_static_temperature(): """ This function tests the static_temperature() function """ stag_temp = 803.59 stat_temp = Stagnation.static_temperature(stag_temp, mach_number, gamma) assert isclose(stat_temp, 800.0, rel_tol=1.0e-3)
def test_speed_of_sound(): """ This function tests the speed_of_sound() function """ temp = 800.0 sos = Stagnation.speed_of_sound(gamma, temp, 28.014) assert isclose(576.53, sos, rel_tol=1.0e-3)
def test_static_pressure(): """ This function tests the static_pressure() function """ stag_pres = 6095032.0 stat_pres = Stagnation.static_pressure(stag_pres, mach_number, gamma) assert isclose(stat_pres, 6000000.0, rel_tol=1.0e-3)
def test_pressure_based_mach(): """ This function tests the pressure_based_mach() function """ stag_pressure = 6095032.0 stat_pressure = 6000000.0 mach = Stagnation.pressure_based_mach(stag_pressure, stat_pressure, gamma) assert isclose(mach, 0.15, rel_tol=1.0e-3)
def test_temperature_based_mach(): """ This function tests the temperature_based_mach() function """ stag_temp = 803.59 stat_temp = 800.0 mach = Stagnation.temperature_based_mach(stag_temp, stat_temp, gamma) assert isclose(mach, 0.15, rel_tol=1.0e-2)
def test_mach_number(): """ This function tests the mach_number() function """ temp = 800.0 velocity = 600.0 molar_mass = 28.014 mach = Stagnation.mach_number(gamma, temp, molar_mass, velocity) assert isclose(1.04, mach, rel_tol=1.0e-2)
def test_press_exit_mach(): """ This function tests the press_exit_mach() function """ entrance_mach = 0.25 exit_mach = 0.05 inlet_press = 6000000.0 exit_press = 6236000.0 remainder = Stagnation.press_exit_mach(exit_mach, entrance_mach, gamma, inlet_press, exit_press) assert isclose(remainder, -7.58682e-5, rel_tol=1.0e-3)
def test_temp_exit_mach(): """ This function tests the temp_exit_mach() function """ entrance_mach = 0.19 exit_mach = 0.2151 inlet_temp = 800.0 exit_temp = 1000.0 remainder = Stagnation.temp_exit_mach(exit_mach, entrance_mach, gamma, inlet_temp, exit_temp) assert isclose(-9.00597e-5, remainder, rel_tol=1.0e-3)
def test_reactor_loop(): elec_power = 50000.0 species = 'nitrogen' gas = Chemical(species) heat_eff = 0.90 turb_eff = 0.90 comp_rat_guess = 1.18 comp_eff = 0.90 conv_eff = 0.25 inlet_stat_temp = 800.0 # Kelvins inlet_stat_pres = 6000000.0 # Pascals gas.calculate(T=inlet_stat_temp, P=inlet_stat_pres) mw = gas.MW gamma1 = gas.Cp / gas.Cvg cp = gas.Cp inlet_mach_number = 0.1 inlet_stag_temp = Stagnation.stagnation_temperature(inlet_stat_temp, inlet_mach_number, gamma1) inlet_stag_pres = Stagnation.stagnation_pressure(inlet_stat_pres, inlet_mach_number, gamma1) deltat = 50.0 # Kelvins mdot = (elec_power / conv_eff) / (cp * deltat) reac = ReactorLoop(heat_eff, turb_eff, species) dicts = reac.performance(inlet_stag_temp, inlet_stag_pres, inlet_mach_number, inlet_stat_temp, inlet_stat_pres, elec_power, comp_rat_guess, comp_eff, conv_eff, mdot) print('Compressor') print(dicts[0]) print('Heat') print(dicts[1]) print('Turbine') print(dicts[2]) print('Rejection') print(dicts[3])
def test_turbo_prop(): species = 'nitrogen' gas = Chemical(species) prop_eff = 0.98 prop_work = 200000.0 dif_eff = 0.95 diff_inlet_area = 0.0729 diff_outlet_area = 0.2 comp_ratio = 2.5 comp_eff = 0.9 heat_eff = 0.98 nozzle_eff = 0.95 turb_eff = 0.95 turb_work = 89286.33 nozzle_inlet_area = 0.462 nozzle_outlet_area = 0.23 temp = 81.05 # Kelvins pres = 49300.0 # Pascals gas.calculate(T=temp, P=pres) density = gas.rho gamma1 = gas.Cp / gas.Cvg mw = gas.MW sos = (gamma1 * ((1000.0 * 8.314) / mw) * temp) ** 0.5 velocity = 100.0 # m/s mach = velocity / sos mdot = density * velocity * diff_inlet_area # kg/s stat_temp = Stagnation.static_temperature(temp, mach, gamma1) stat_pres = Stagnation.static_pressure(pres, mach, gamma1) jet = TurboProp(dif_eff, diff_inlet_area, diff_outlet_area, comp_ratio, comp_eff, heat_eff, turb_eff, nozzle_eff, nozzle_inlet_area, nozzle_outlet_area, prop_eff, species) prop, dif, comp, heat, turb, noz = jet.performance(prop_work, temp, mdot, pres, mach, stat_temp, stat_pres, 10000.0, turb_work) assert isclose(prop['static_temperature'], 86.526, rel_tol=1.0e-3) assert isclose(prop['static_pressure'], 22255.00, rel_tol=1.0e-3) assert isclose(prop['stagnation_temperature'], 93.969, rel_tol=1.0e-3) assert isclose(prop['stagnation_pressure'], 29707.25, rel_tol=1.0e-3) assert isclose(prop['velocity'], 124.35, rel_tol=1.0e-3) assert isclose(prop['mach_number'], 0.6558, rel_tol=1.0e-3) assert isclose(prop['total_work'], 204081.63, rel_tol= 1.0e-3) assert isclose(dif['static_temperature'], 92.608, rel_tol=1.0e-3) assert isclose(dif['stagnation_pressure'], 29297.508, rel_tol=1.0e-3) assert isclose(dif['static_pressure'], 28228.34, rel_tol=1.0e-3) assert isclose(dif['stagnation_temperature'], 93.597, rel_tol=1.0e-3) assert isclose(dif['velocity'], 45.326, rel_tol=1.0e-3) assert isclose(dif['mach_number'], 0.2310, rel_tol=1.0e-3) assert isclose(dif['density'], 1.6773, rel_tol=1.0e-3) assert isclose(comp['static_temperature'], 122.88, rel_tol=1.0e-3) assert isclose(comp['stagnation_pressure'], 73243.77, rel_tol=1.0e-3) assert isclose(comp['static_pressure'], 69531.38, rel_tol=1.0e-3) assert isclose(comp['stagnation_temperature'], 124.72, rel_tol=1.0e-3) assert isclose(comp['velocity'], 61.82, rel_tol=1.0e-3) assert isclose(comp['mach_number'], 0.2736, rel_tol=1.0e-3) assert isclose(comp['work'], 546239.28, rel_tol=1.0e-3) assert isclose(heat['static_temperature'], 123.49, rel_tol=1.0e-3) assert isclose(heat['stagnation_pressure'], 73224.28, rel_tol=1.0e-3) assert isclose(heat['static_pressure'], 69509.28, rel_tol=1.0e-3) assert isclose(heat['stagnation_temperature'], 125.35, rel_tol=1.0e-3) assert isclose(heat['velocity'], 62.16, rel_tol=1.0e-3) assert isclose(heat['mach_number'], 0.2744, rel_tol=1.0e-3) assert isclose(heat['power'], 10204.08, rel_tol=1.0e-3) assert isclose(turb['static_temperature'], 117.73, rel_tol=1.0e-3) assert isclose(turb['stagnation_pressure'], 61199.27, rel_tol=1.0e-3) assert isclose(turb['static_pressure'], 58251.17, rel_tol=1.0e-3) assert isclose(turb['stagnation_temperature'], 119.40, rel_tol=1.0e-3) assert isclose(turb['velocity'], 58.94, rel_tol=1.0e-3) assert isclose(turb['mach_number'], 0.2665, rel_tol=1.0e-3) assert isclose(turb['extracted_work'], 93985.61, rel_tol=1.0e-3) assert isclose(noz['static_temperature'], 112.57, rel_tol=1.0e-3) assert isclose(noz['stagnation_pressure'], 61049.38, rel_tol=1.0e-3) assert isclose(noz['static_pressure'], 49795.29, rel_tol=1.0e-3) assert isclose(noz['stagnation_temperature'], 119.31, rel_tol=1.0e-3) assert isclose(noz['velocity'], 118.40, rel_tol=1.0e-3) assert isclose(noz['mach_number'], 0.5474, rel_tol=1.0e-3) assert isclose(noz['density'], 0.5583, rel_tol=1.0e-3)