def test_inverse(self): """Test that pressure_from_er is the inverse of area_from_mach.""" for gamma in np.linspace(1.1, 1.6, 5): for er in np.linspace(2, 400, 10): pr = nozzle.pressure_from_er(er, gamma) p_e = 1. p_c = p_e / pr er_calc = nozzle.er_from_p(p_c, p_e, gamma) self.assertTrue(np.isclose(er_calc, er, rtol=1e-3))
def test_rpe_3_3(self): """Test against example problem 3-3 from Rocket Propulsion Elements.""" gamma = 1.20 # Given ratio of specific heats [units: dimensionless]. er_rpe = 60. # Given area expansion ratio [units: dimensionless]. p_c_rpe = 2.039e6 # Given chamber pressure [units: pascal]. p_e_rpe = 2.549e3 # Given exit pressure [units: pascal]. er = nozzle.er_from_p(p_c_rpe, p_e_rpe, gamma) self.assertTrue(np.isclose(er, er_rpe, rtol=1e-2)) pr = nozzle.pressure_from_er(er_rpe, gamma) self.assertTrue(np.isclose(pr, p_e_rpe / p_c_rpe, rtol=1e-2))
"""Plot C_F vs altitude.""" import numpy as np from matplotlib import pyplot as plt import skaero.atmosphere.coesa as atmo from proptools import nozzle p_c = 10e6 # Chamber pressure [units: pascal] gamma = 1.2 # Exhaust heat capacity ratio [units: dimensionless] p_e_1 = 100e3 # Nozzle exit pressure, 1st stage [units: pascal] exp_ratio_1 = nozzle.er_from_p(p_c, p_e_1, gamma) # Nozzle expansion ratio [units: dimensionless] p_e_2 = 15e3 # Nozzle exit pressure, 2nd stage [units: pascal] exp_ratio_2 = nozzle.er_from_p(p_c, p_e_2, gamma) # Nozzle expansion ratio [units: dimensionless] alt = np.linspace(0, 84e3) # Altitude [units: meter] p_a = atmo.pressure(alt) # Ambient pressure [units: pascal] # Compute the thrust coeffieicient of the fixed-area nozzle, 1st stage [units: dimensionless] C_F_fixed_1 = nozzle.thrust_coef(p_c, p_e_1, gamma, p_a=p_a, er=exp_ratio_1) # Compute the thrust coeffieicient of the fixed-area nozzle, 2nd stage [units: dimensionless] C_F_fixed_2 = nozzle.thrust_coef(p_c, p_e_2, gamma, p_a=p_a, er=exp_ratio_2) # Compute the thrust coeffieicient of a variable-area matched nozzle [units: dimensionless] C_F_matched = nozzle.thrust_coef(p_c, p_a, gamma) plt.plot(alt * 1e-3, C_F_fixed_1, label='1st stage $\\epsilon_1 = {:.1f}$'.format(exp_ratio_1)) plt.plot(alt[0.4 * p_a < p_e_2] * 1e-3, C_F_fixed_2[0.4 * p_a < p_e_2], label='2nd stage $\\epsilon_2 = {:.1f}$'.format(exp_ratio_2)) plt.plot(alt * 1e-3, C_F_matched, label='matched', color='grey', linestyle=':') plt.xlabel('Altitude [km]') plt.ylabel('Thrust coefficient $C_F$ [-]')
"""Compute the expansion ratio for a given pressure ratio.""" from proptools import nozzle p_c = 10e6 # Chamber pressure [units: pascal] p_e = 100e3 # Exit pressure [units: pascal] gamma = 1.2 # Exhaust heat capacity ratio [units: dimensionless] # Solve for the expansion ratio [units: dimensionless] exp_ratio = nozzle.er_from_p(p_c, p_e, gamma) print 'Expansion ratio = {:.1f}'.format(exp_ratio)
import skaero.atmosphere.coesa as atmo from proptools import nozzle p_c = 10e6 # Chamber pressure [units: pascal] p_e = 100e3 # Exit pressure [units: pascal] p_a = np.linspace(0, 100e3) # Ambient pressure [units: pascal] gamma = 1.2 # Exhaust heat capacity ratio [units: dimensionless] A_t = np.pi * (0.1 / 2)**2 # Throat area [units: meter**2] # Compute thrust [units: newton] F = nozzle.thrust(A_t, p_c, p_e, gamma, p_a=p_a, er=nozzle.er_from_p(p_c, p_e, gamma)) ax1 = plt.subplot(111) plt.plot(p_a * 1e-3, F * 1e-3) plt.xlabel('Ambient pressure $p_a$ [kPa]') plt.ylabel('Thrust $F$ [kN]') plt.suptitle( 'Thrust vs ambient pressure at $p_c = {:.0f}$ MPa, $p_e = {:.0f}$ kPa'. format(p_c * 1e-6, p_e * 1e-3)) # Add altitude on second axis ylim = plt.ylim() ax2 = ax1.twiny() new_tick_locations = np.array([100, 75, 50, 25, 1]) ax2.set_xlim(ax1.get_xlim()) ax2.set_xticks(new_tick_locations)
"""Effect of expansion ratio on thrust coefficient.""" import numpy as np from matplotlib import pyplot as plt from proptools import nozzle p_c = 10e6 # Chamber pressure [units: pascal] p_a = 100e3 # Ambient pressure [units: pascal] gamma = 1.2 # Exhaust heat capacity ratio [units: dimensionless] p_e = np.linspace(0.4 * p_a, 2 * p_a) # Exit pressure [units: pascal] # Compute the expansion ratio and thrust coefficient for each p_e exp_ratio = nozzle.er_from_p(p_c, p_e, gamma) C_F = nozzle.thrust_coef(p_c, p_e, gamma, p_a=p_a, er=exp_ratio) # Compute the matched (p_e = p_a) expansion ratio exp_ratio_matched = nozzle.er_from_p(p_c, p_a, gamma) plt.plot(exp_ratio, C_F) plt.axvline(x=exp_ratio_matched, color='grey') plt.annotate('matched $p_e = p_a$, $\epsilon = {:.1f}$'.format(exp_ratio_matched), xy=(exp_ratio_matched - 0.7, 1.62), xytext=(exp_ratio_matched - 0.7, 1.62), color='black', fontsize=10, rotation=90 ) plt.xlabel('Expansion ratio $\\epsilon = A_e / A_t$ [-]') plt.ylabel('Thrust coefficient $C_F$ [-]') plt.title('$C_F$ vs expansion ratio at $p_c = {:.0f}$ MPa, $p_a = {:.0f}$ kPa'.format( p_c *1e-6, p_a * 1e-3)) plt.show()
"""Effect of expansion ratio on thrust coefficient.""" import numpy as np from matplotlib import pyplot as plt from proptools import nozzle p_c = 10e6 # Chamber pressure [units: pascal] p_a = 100e3 # Ambient pressure [units: pascal] gamma = 1.2 # Exhaust heat capacity ratio [units: dimensionless] p_e = np.linspace(0.4 * p_a, 2 * p_a) # Exit pressure [units: pascal] # Compute the expansion ratio and thrust coefficient for each p_e exp_ratio = nozzle.er_from_p(p_c, p_e, gamma) C_F = nozzle.thrust_coef(p_c, p_e, gamma, p_a=p_a, er=exp_ratio) # Compute the matched (p_e = p_a) expansion ratio exp_ratio_matched = nozzle.er_from_p(p_c, p_a, gamma) plt.plot(exp_ratio, C_F) plt.axvline(x=exp_ratio_matched, color='grey') plt.annotate( 'matched $p_e = p_a$, $\epsilon = {:.1f}$'.format(exp_ratio_matched), xy=(exp_ratio_matched - 0.7, 1.62), xytext=(exp_ratio_matched - 0.7, 1.62), color='black', fontsize=10, rotation=90) plt.xlabel('Expansion ratio $\\epsilon = A_e / A_t$ [-]') plt.ylabel('Thrust coefficient $C_F$ [-]') plt.title('$C_F$ vs expansion ratio at $p_c = {:.0f}$ MPa, $p_a = {:.0f}$ kPa'. format(p_c * 1e-6, p_a * 1e-3)) plt.show()
"""Plot thrust vs ambient pressure.""" import numpy as np from matplotlib import pyplot as plt import skaero.atmosphere.coesa as atmo from proptools import nozzle p_c = 10e6 # Chamber pressure [units: pascal] p_e = 100e3 # Exit pressure [units: pascal] p_a = np.linspace(0, 100e3) # Ambient pressure [units: pascal] gamma = 1.2 # Exhaust heat capacity ratio [units: dimensionless] A_t = np.pi * (0.1 / 2)**2 # Throat area [units: meter**2] # Compute thrust [units: newton] F = nozzle.thrust(A_t, p_c, p_e, gamma, p_a=p_a, er=nozzle.er_from_p(p_c, p_e, gamma)) ax1 = plt.subplot(111) plt.plot(p_a * 1e-3, F * 1e-3) plt.xlabel('Ambient pressure $p_a$ [kPa]') plt.ylabel('Thrust $F$ [kN]') plt.suptitle('Thrust vs ambient pressure at $p_c = {:.0f}$ MPa, $p_e = {:.0f}$ kPa'.format( p_c *1e-6, p_e * 1e-3)) # Add altitude on second axis ylim = plt.ylim() ax2 = ax1.twiny() new_tick_locations = np.array([100, 75, 50, 25, 1]) ax2.set_xlim(ax1.get_xlim()) ax2.set_xticks(new_tick_locations)