def calculate(self, prop, p1, pe): try: self.calc_prop = prop self.p1 = p1/14.696 #converting psi to atm self.pe = pe/14.696 ppp.init() self.p = ppp.FrozenPerformance() self.calc_prop_var = [0]*len(self.calc_prop) list_tuple = [] self.prop_weight = 0 self.propellant_list = [] for i in range(0, len(self.calc_prop)): self.propellant_list.append(self.calc_prop[i][0]) self.calc_prop_var[i] = ppp.PROPELLANTS[self.calc_prop[i][0]] self.prop_weight += float(self.calc_prop[i][1]) list_tuple.append((self.calc_prop_var[i], float(self.calc_prop[i][1]))) self.p.add_propellants_by_mass(list_tuple) self.p.set_state(P = float(self.p1), Pe = float(self.pe)) self.calculate_button.config(state = 'disabled') self.display_button.config(state = 'active') self.reset_button.grid(column = 2, row = 7, columnspan = 2, rowspan = 2, sticky = 'n') self.validation_label.configure(text = "Total Weight: " + str(self.prop_weight), fg = 'white', bg = "#222831") #self.validation_label.configure(text = "Sucess :)", bg = 'green', fg = 'white', font = ("Garamond", 20)) propellant_calculations.prop_variable = self.p global outsidep outsidep = self.p except Exception as e: print("ERROR") self.validation_label.configure(text = "System Error :/", fg = 'white', bg = 'red')
import numpy as np from matplotlib import pyplot as plt from matplotlib import rc from matplotlib.ticker import FormatStrFormatter import pandas as pd import pypropep as ppp ppp.init() rc('figure', figsize=(4, 2.5)) rc('legend', fontsize='small') rc('font', family='serif') rc('xtick', labelsize='small') rc('ytick', labelsize='small') with open('JANAF_O2_g.txt', 'r') as f: o2_tbl = pd.read_csv(f, sep='\t', header=1, na_values='INFINITE') with open('JANAF_O_g.txt', 'r') as f: o_tbl = pd.read_csv(f, sep='\t', header=1, na_values='INFINITE') def f_T(tbl, T, name): return np.interp(T, tbl['T(K)'], tbl[name]) R = 8.314 Tref = 298.15 Pref = 1e5 Rref = Pref / R / Tref T = np.linspace(500, 6000, 30)
def pypropep(): import pypropep pypropep.init() return pypropep
def test_thermo_file_override(pypropep): therm_file = os.path.dirname(pypropep.__file__) + '/data/thermo.dat' pypropep.init(thermo_file=therm_file)
def test_prop_file_override(pypropep): prop_file = os.path.dirname(pypropep.__file__) + '/data/propellant.dat' pypropep.init(propellant_file=prop_file)
def white_dwarf_cooling_data(water_mass_fraction): '''Engine dimensions''' Ac = np.pi*0.1**2 #Chamber cross-sectional area (m^2) L_star = 1.5 #L_star = Volume_c/Area_t wall_thickness = 2e-3 '''Chamber conditions''' pc = 15e5 #Chamber pressure (Pa) p_tank = 20e5 #Tank / inlet coolant stagnation pressure (Pa) - used for cooling jacket mdot = 5.4489 #Mass flow rate (kg/s) p_amb = 1.01325e5 #Ambient pressure (Pa). 1.01325e5 is sea level atmospheric. OF_ratio = 3.5 #Oxidiser/fuel mass ratio '''Coolant jacket''' wall_material = bam.materials.CopperC700 mdot_coolant = mdot/(OF_ratio + 1) inlet_T = 298.15 #Coolant inlet temperature '''Get combustion properties from pypropep''' #Initialise and get propellants ppp.init() e = ppp.Equilibrium() p = ppp.ShiftingPerformance() ipa = ppp.PROPELLANTS['ISOPROPYL ALCOHOL'] water = ppp.PROPELLANTS['WATER'] n2o = ppp.PROPELLANTS['NITROUS OXIDE'] #Add propellants by mass fractions (note the mass fractions can add up to more than 1) e.add_propellants_by_mass([(ipa, 1), (water, water_mass_fraction), (n2o, OF_ratio)]) p.add_propellants_by_mass([(ipa, 1), (water, water_mass_fraction), (n2o, OF_ratio)]) #Adiabatic combustion e.set_state(P = pc/p_amb, type = 'HP') #Set chamber pressure and exit pressure in atmospheres p.set_state(P = pc/p_amb, Pe = 1) gamma = e.properties.Isex #I don't know why they use 'Isex' for gamma. cp = 1000*e.properties.Cp #Cp is given in kJ/kg/K, we want J/kg/K Tc = e.properties.T '''Choose the models we want to use for transport properties of the coolant and exhaust gas''' thermo_coolant = thermo.mixture.Mixture(['isopropanol', 'water'], ws = [1 - water_mass_fraction, water_mass_fraction]) thermo_gas = thermo.mixture.Mixture(['N2', 'H2O', 'CO2'], zs = [e.composition['N2'], e.composition['H2O'], e.composition['CO2']]) gas_transport = cool.TransportProperties(model = "thermo", thermo_object = thermo_gas, force_phase = 'g') coolant_transport = cool.TransportProperties(model = "thermo", thermo_object = thermo_coolant, force_phase = 'l') '''Create the engine object''' perfect_gas = bam.PerfectGas(gamma = gamma, cp = cp) #Gas for frozen flow chamber_conditions = bam.ChamberConditions(pc, Tc, mdot) nozzle = bam.Nozzle.from_engine_components(perfect_gas, chamber_conditions, p_amb, type = "rao", length_fraction = 0.8) white_dwarf = bam.Engine(perfect_gas, chamber_conditions, nozzle) chamber_length = L_star*nozzle.At/Ac '''Add the cooling system to the engine''' white_dwarf.add_geometry(chamber_length, Ac, wall_thickness) white_dwarf.add_exhaust_transport(gas_transport) #Spiral channels #white_dwarf.add_cooling_jacket(wall_material, inlet_T, p_tank, coolant_transport, mdot_coolant, # configuration = "spiral", channel_shape = "semi-circle", channel_width = 0.020) #Or vertical channels white_dwarf.add_cooling_jacket(wall_material, inlet_T, p_tank, coolant_transport, mdot_coolant, configuration = "vertical", channel_height = 0.001) '''Run the heating analysis''' cooling_data = white_dwarf.steady_heating_analysis(number_of_points = 250, to_json = False) return cooling_data, white_dwarf.isp(p_amb)