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