def solve(config, t, R, mdot_ox, mdot_fuel, Pc, OF, Cstar, Pe, thrust, ISP): rho_fuel = config.getfloat('Params', 'rho_fuel') L = config.getfloat('Params', 'fuel_length') / M_TO_IN a = config.getfloat('Params', 'a') n = config.getfloat('Params', 'n') Rt = config.getfloat('Params', 'throat_radius') AR = config.getfloat('Params', 'area_ratio') P0 = config.getfloat('Params', 'p0') throat_area = np.pi * Rt**2 N = t.shape[0] for i in range(N-1): dt = t[i+1] - t[i] R[i+1] = advance_R(a, n, R[i], mdot_ox[i], dt) mdot_fuel[i+1] = utils.get_mdot_fuel(R[i+1], L, rho_fuel, mdot_ox[i+1], a, n) mdot = mdot_fuel[i+1] + mdot_ox[i+1] Pc[i+1] = Cstar[i] / throat_area * mdot OF[i+1] = mdot_ox[i+1] / mdot_fuel[i+1] gamma, _, Cstar[i+1] = utils.get_CEA_results(CEA_object, Pc[i+1], P0, OF[i+1], AR) Pe[i+1] = utils.get_exit_pressure(Pc[i+1], gamma, AR, guess=Pe[i]) CF = utils.get_thrust_coeff(Pc[i+1], Pe[i+1], P0, gamma, AR) thrust[i+1] = Pc[i+1]*throat_area*CF ISP[i+1] = thrust[i+1] / G0 / (mdot_ox[i+1] + mdot_fuel[i+1])
def initialize(config, R_0, mdot_ox_0, Cstar_0): n_timesteps = config.getint('Params', 'n_timesteps') burn_time = config.getfloat('Params', 'burn_time') P0 = config.getfloat('Params', 'p0') rho_fuel = config.getfloat('Params', 'rho_fuel') L = config.getfloat('Params', 'fuel_length') / M_TO_IN a = config.getfloat('Params', 'a') n = config.getfloat('Params', 'n') Rt = config.getfloat('Params', 'throat_radius') AR = config.getfloat('Params', 'area_ratio') throat_area = np.pi * Rt**2 t = np.linspace(0, burn_time, num=n_timesteps+1) R = np.zeros(t.shape) R[0] = R_0 mdot_ox = np.zeros(t.shape) mdot_ox[0] = mdot_ox_0 mdot_fuel = np.zeros(t.shape) mdot_fuel[0] = utils.get_mdot_fuel(R[0], L, rho_fuel, mdot_ox[0], a, n) Pc = np.zeros(t.shape) Pc[0] = Cstar_0 / throat_area * (mdot_ox[0]+mdot_fuel[0]) OF = np.zeros(t.shape) OF[0] = mdot_ox[0] / mdot_fuel[0] Cstar = np.zeros(t.shape) thrust = np.zeros(t.shape) Pe = np.zeros(t.shape) ISP = np.zeros(t.shape) gamma, _, Cstar[0] = utils.get_CEA_results(CEA_object, Pc[0], P0, OF[0], AR) Pe[0] = utils.get_exit_pressure(Pc[0], gamma, AR) CF = utils.get_thrust_coeff(Pc[0], Pe[0], P0, gamma, AR) thrust[0] = Pc[0] * throat_area * CF ISP[0] = thrust[0] / G0 / (mdot_ox[0] + mdot_fuel[0]) return t, R, mdot_ox, mdot_fuel, Pc, OF, Cstar, Pe, thrust, ISP
def get_initial_guess(config): Pc_0 = config.getfloat('Params', 'initial_pc') * PSI_TO_PA P0 = config.getfloat('Params', 'p0') OF_0 = config.getfloat('Params', 'initial_of') AR = config.getfloat('Params', 'area_ratio') rho_fuel = config.getfloat('Params', 'rho_fuel') a = config.getfloat('Params', 'a') n = config.getfloat('Params', 'n') L = config.getfloat('Params', 'fuel_length') / M_TO_IN Rt = config.getfloat('Params', 'throat_radius') throat_area = np.pi * Rt**2 gamma, ISP, Cstar = utils.get_CEA_results(CEA_object, Pc_0, P0, OF_0, AR) Pe = utils.get_exit_pressure(Pc_0, gamma, AR) CF = utils.get_thrust_coeff(Pc_0, Pe, P0, gamma, AR) mdot, mdot_ox, mdot_fuel = utils.get_mdots_from_Cstar( Pc_0, throat_area, OF_0, Cstar) R = utils.get_radius_from_flow_rates(mdot_ox, mdot_fuel, rho_fuel, L, a, n) return R, mdot_ox, Cstar