class CEA(): def __init__(self, fuel, oxidiser, chamber_pressure): """[summary] Calcualtes hot gas properties using CEA and converts to SI units. If errors occur with FORTRAN, resart and try again! :param chamber_pressure in [Pa] :type fuel = string :type oxidiser = string """ self.chamber_pressure = chamber_pressure self.imperial_pressure = 0.000145038 * self.chamber_pressure #conversion to psia self.ispObj = CEA_Obj(oxName=oxidiser, fuelName=fuel) self.ispObj.get_full_cea_output() def chamber_gas_properties(self, mixture_ratio, expansion_ratio): self.Cp, self.visc, self.cond, self.Pr = self.ispObj.get_Chamber_Transport( Pc=self.imperial_pressure, MR=mixture_ratio, frozen=1) self.MW, self.gamma = self.ispObj.get_Chamber_MolWt_gamma( Pc=self.imperial_pressure, MR=mixture_ratio, eps=expansion_ratio) def throat_gas_properties(self, mixture_ratio, expansion_ratio): self.Cp, self.visc, self.cond, self.Pr = self.ispObj.get_Throat_Transport( Pc=self.imperial_pressure, MR=mixture_ratio, frozen=1) self.MW, self.gamma = self.ispObj.get_Throat_MolWt_gamma( Pc=self.imperial_pressure, MR=mixture_ratio, eps=expansion_ratio) def exit_gas_properties(self, mixture_ratio, expansion_ratio): self.Cp, self.visc, self.cond, self.Pr = self.ispObj.get_Exit_Transport( Pc=self.imperial_pressure, MR=mixture_ratio, frozen=1) self.MW, self.gamma = self.ispObj.get_exit_MolWt_gamma( Pc=self.imperial_pressure, MR=mixture_ratio, eps=expansion_ratio) def metric_cea_output(self, location, mixture_ratio, expansion_ratio): if location == 'chamber': self.chamber_gas_properties(mixture_ratio, expansion_ratio) elif location == 'throat': self.throat_gas_properties(mixture_ratio, expansion_ratio) elif location == 'exit': self.exit_gas_properties(mixture_ratio, expansion_ratio) else: raise ValueError( 'Invalid location, use "chamber," "throat" or "exit"') self.isp, self.cstar, _ = self.ispObj.getFrozen_IvacCstrTc( Pc=self.imperial_pressure, MR=mixture_ratio, eps=expansion_ratio) self.cstar = self.cstar * 0.3048 # coversion to m/s self.mole_fractions = self.ispObj.get_SpeciesMoleFractions( Pc=self.imperial_pressure, MR=mixture_ratio, eps=expansion_ratio, frozen=0, frozenAtThroat=0, min_fraction=5e-05) self.Cp = self.Cp * 4186.8 # coversion to J/gk/K self.mu = self.visc * 0.0001 # coversion to Pa*s self.k = self.cond * 418.4e-3 # coversion to W/m/K self.T_static = self.ispObj.get_Tcomb( Pc=self.imperial_pressure, MR=mixture_ratio) * 0.555556 # coversion to K
def test_getFrozen_IvacCstrTc(self): """ test call to getFrozen_IvacCstrTc( Pc=100.0, MR=1.0, eps=40.0, frozenAtThroat=0) """ C = CEA_Obj(oxName="LOX", fuelName="MMH") i,c,t = C.getFrozen_IvacCstrTc( Pc=100.0, MR=1.0, eps=40.0, frozenAtThroat=0) self.assertAlmostEqual(i, 335.79399488107725, places=3) del C
class CEA_Obj(object): """ RocketCEA wraps the NASA FORTRAN CEA code to calculate Isp, cstar, and Tcomb This object wraps the English unit version of CEA_Obj to enable desired user units. """ def __init__(self, propName='', oxName='', fuelName='', useFastLookup=0, makeOutput=0, isp_units='sec', cstar_units='ft/sec', pressure_units='psia', temperature_units='degR', sonic_velocity_units='ft/sec', enthalpy_units='BTU/lbm', density_units='lbm/cuft', specific_heat_units='BTU/lbm degR', viscosity_units='millipoise', thermal_cond_units='mcal/cm-K-s', fac_CR=None, make_debug_prints=False): """:: #: RocketCEA wraps the NASA FORTRAN CEA code to calculate Isp, cstar, and Tcomb #: This object wraps the English unit version of CEA_Obj to enable desired user units. #: Same as CEA_Obj with standard units except, input and output units can be specified. #: parameter default options #: isp_units = 'sec', # N-s/kg, m/s, km/s #: cstar_units = 'ft/sec', # m/s #: pressure_units = 'psia', # MPa, KPa, Pa, Bar, Atm, Torr #: temperature_units = 'degR', # K, C, F #: sonic_velocity_units = 'ft/sec', # m/s #: enthalpy_units = 'BTU/lbm', # J/g, kJ/kg, J/kg, kcal/kg, cal/g #: density_units = 'lbm/cuft', # g/cc, sg, kg/m^3 #: specific_heat_units = 'BTU/lbm degR' # kJ/kg-K, cal/g-C, J/kg-K (# note: cal/g K == BTU/lbm degR) #: viscosity_units = 'millipoise' # lbf-sec/sqin, lbf-sec/sqft, lbm/ft-sec, poise, centipoise #: thermal_cond_units = 'mcal/cm-K-s' # millical/cm-degK-sec, BTU/hr-ft-degF, BTU/s-in-degF, cal/s-cm-degC, W/cm-degC #: fac_CR, Contraction Ratio of finite area combustor (None=infinite) #: if make_debug_prints is True, print debugging info to terminal. """ self.isp_units = isp_units self.cstar_units = cstar_units self.pressure_units = pressure_units self.temperature_units = temperature_units self.sonic_velocity_units = sonic_velocity_units self.enthalpy_units = enthalpy_units self.density_units = density_units self.specific_heat_units = specific_heat_units self.viscosity_units = viscosity_units self.thermal_cond_units = thermal_cond_units self.fac_CR = fac_CR # Units objects for input/output (e.g. Pc and Pamb) self.Pc_U = get_units_obj('psia', pressure_units) # units of output quantities self.isp_U = get_units_obj('sec', isp_units) self.cstar_U = get_units_obj('ft/sec', cstar_units) self.temperature_U = get_units_obj('degR', temperature_units) self.sonic_velocity_U = get_units_obj('ft/sec', sonic_velocity_units) self.enthalpy_U = get_units_obj('BTU/lbm', enthalpy_units) self.density_U = get_units_obj('lbm/cuft', density_units) self.specific_heat_U = get_units_obj('BTU/lbm degR', specific_heat_units) self.viscosity_U = get_units_obj('millipoise', viscosity_units) self.thermal_cond_U = get_units_obj('mcal/cm-K-s', thermal_cond_units) self.cea_obj = CEA_Obj_default(propName=propName, oxName=oxName, fuelName=fuelName, useFastLookup=useFastLookup, makeOutput=makeOutput, fac_CR=fac_CR, make_debug_prints=make_debug_prints) self.desc = self.cea_obj.desc def get_IvacCstrTc(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia IspVac, Cstar, Tcomb = self.cea_obj.get_IvacCstrTc(Pc=Pc, MR=MR, eps=eps) IspVac = self.isp_U.dval_to_uval(IspVac) Cstar = self.cstar_U.dval_to_uval(Cstar) Tcomb = self.temperature_U.dval_to_uval(Tcomb) return IspVac, Cstar, Tcomb def getFrozen_IvacCstrTc(self, Pc=100.0, MR=1.0, eps=40.0, frozenAtThroat=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia IspFrozen, Cstar, Tcomb = self.cea_obj.getFrozen_IvacCstrTc( Pc=Pc, MR=MR, eps=eps, frozenAtThroat=frozenAtThroat) IspFrozen = self.isp_U.dval_to_uval(IspFrozen) Cstar = self.cstar_U.dval_to_uval(Cstar) Tcomb = self.temperature_U.dval_to_uval(Tcomb) return IspFrozen, Cstar, Tcomb def get_IvacCstrTc_exitMwGam(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia IspVac, Cstar, Tcomb, mw, gam = self.cea_obj.get_IvacCstrTc_exitMwGam( Pc=Pc, MR=MR, eps=eps) IspVac = self.isp_U.dval_to_uval(IspVac) Cstar = self.cstar_U.dval_to_uval(Cstar) Tcomb = self.temperature_U.dval_to_uval(Tcomb) return IspVac, Cstar, Tcomb, mw, gam def get_IvacCstrTc_ChmMwGam(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia IspVac, Cstar, Tcomb, mw, gam = self.cea_obj.get_IvacCstrTc_ChmMwGam( Pc=Pc, MR=MR, eps=eps) IspVac = self.isp_U.dval_to_uval(IspVac) Cstar = self.cstar_U.dval_to_uval(Cstar) Tcomb = self.temperature_U.dval_to_uval(Tcomb) return IspVac, Cstar, Tcomb, mw, gam def get_IvacCstrTc_ThtMwGam(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia IspVac, Cstar, Tcomb, mw, gam = self.cea_obj.get_IvacCstrTc_ThtMwGam( Pc=Pc, MR=MR, eps=eps) IspVac = self.isp_U.dval_to_uval(IspVac) Cstar = self.cstar_U.dval_to_uval(Cstar) Tcomb = self.temperature_U.dval_to_uval(Tcomb) return IspVac, Cstar, Tcomb, mw, gam def __call__(self, Pc=100.0, MR=1.0, eps=40.0): return self.get_Isp(Pc=Pc, MR=MR, eps=eps) def get_Isp(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia IspVac = self.cea_obj.get_Isp(Pc=Pc, MR=MR, eps=eps) IspVac = self.isp_U.dval_to_uval(IspVac) return IspVac def get_Cstar(self, Pc=100.0, MR=1.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Cstar = self.cea_obj.get_Cstar(Pc=Pc, MR=MR) Cstar = self.cstar_U.dval_to_uval(Cstar) return Cstar def get_Tcomb(self, Pc=100.0, MR=1.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Tcomb = self.cea_obj.get_Tcomb(Pc=Pc, MR=MR) Tcomb = self.temperature_U.dval_to_uval(Tcomb) return Tcomb def get_PcOvPe(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_PcOvPe(Pc=Pc, MR=MR, eps=eps) def get_eps_at_PcOvPe(self, Pc=100.0, MR=1.0, PcOvPe=1000.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_eps_at_PcOvPe(Pc=Pc, MR=MR, PcOvPe=PcOvPe) def get_Throat_PcOvPe(self, Pc=100.0, MR=1.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_Throat_PcOvPe(Pc=Pc, MR=MR) def get_MachNumber(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_MachNumber(Pc=Pc, MR=MR, eps=eps) def get_Temperatures(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0, frozenAtThroat=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia tempList = self.cea_obj.get_Temperatures(Pc=Pc, MR=MR, eps=eps, frozen=frozen, frozenAtThroat=frozenAtThroat) for i, T in enumerate(tempList): tempList[i] = self.temperature_U.dval_to_uval(T) return tempList # Tc, Tthroat, Texit def get_SonicVelocities(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia sonicList = self.cea_obj.get_SonicVelocities(Pc=Pc, MR=MR, eps=eps) for i, S in enumerate(sonicList): sonicList[i] = self.sonic_velocity_U.dval_to_uval(S) return sonicList # Chamber, Throat, Exit def get_Chamber_SonicVel(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia sonicVel = self.cea_obj.get_Chamber_SonicVel(Pc=Pc, MR=MR, eps=eps) sonicVel = self.sonic_velocity_U.dval_to_uval(sonicVel) return sonicVel def get_Enthalpies(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia hList = self.cea_obj.get_Enthalpies(Pc=Pc, MR=MR, eps=eps) for i, H in enumerate(hList): hList[i] = self.enthalpy_U.dval_to_uval(H) return hList def get_SpeciesMassFractions(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0, frozenAtThroat=0, min_fraction=0.000005): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia molWtD, massFracD = self.cea_obj.get_SpeciesMassFractions( Pc=Pc, MR=MR, eps=eps, frozenAtThroat=frozenAtThroat, min_fraction=min_fraction) return molWtD, massFracD def get_SpeciesMoleFractions(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0, frozenAtThroat=0, min_fraction=0.000005): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia molWtD, moleFracD = self.cea_obj.get_SpeciesMoleFractions( Pc=Pc, MR=MR, eps=eps, frozenAtThroat=frozenAtThroat, min_fraction=min_fraction) return molWtD, moleFracD def get_Chamber_H(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia H = self.cea_obj.get_Chamber_H(Pc=Pc, MR=MR, eps=eps) return self.enthalpy_U.dval_to_uval(H) def get_Densities(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia dList = self.cea_obj.get_Densities(Pc=Pc, MR=MR, eps=eps) for i, d in enumerate(dList): dList[i] = self.density_U.dval_to_uval(d) return dList def get_Chamber_Density(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia H = self.cea_obj.get_Chamber_Density(Pc=Pc, MR=MR, eps=eps) return self.density_U.dval_to_uval(H) def get_HeatCapacities(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia cpList = self.cea_obj.get_HeatCapacities(Pc=Pc, MR=MR, eps=eps, frozen=frozen) for i, cp in enumerate(cpList): cpList[i] = self.specific_heat_U.dval_to_uval(cp) return cpList def get_Chamber_Cp(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Cp = self.cea_obj.get_Chamber_Cp(Pc=Pc, MR=MR, eps=eps) return self.specific_heat_U.dval_to_uval(Cp) def get_Throat_Isp(self, Pc=100.0, MR=1.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Isp = self.cea_obj.get_Throat_Isp(Pc=Pc, MR=MR) Isp = self.isp_U.dval_to_uval(Isp) return Isp def get_Chamber_MolWt_gamma(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_Chamber_MolWt_gamma(Pc=Pc, MR=MR, eps=eps) def get_Throat_MolWt_gamma(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_Throat_MolWt_gamma(Pc=Pc, MR=MR, eps=eps) def get_exit_MolWt_gamma(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_exit_MolWt_gamma(Pc=Pc, MR=MR, eps=eps) def get_eqratio(self, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia return self.cea_obj.get_eqratio(Pc=Pc, MR=MR, eps=eps) def getMRforER(self, ERphi=None, ERr=None): return self.cea_obj.getMRforER(ERphi=ERphi, ERr=ERr) def get_description(self): return self.cea_obj.get_description() def estimate_Ambient_Isp(self, Pc=100.0, MR=1.0, eps=40.0, Pamb=14.7, frozen=0, frozenAtThroat=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Pamb = self.Pc_U.uval_to_dval(Pamb) # convert user units to psia IspAmb, mode = self.cea_obj.estimate_Ambient_Isp( Pc=Pc, MR=MR, eps=eps, Pamb=Pamb, frozen=frozen, frozenAtThroat=frozenAtThroat) IspAmb = self.isp_U.dval_to_uval(IspAmb) return IspAmb, mode def get_PambCf(self, Pamb=14.7, Pc=100.0, MR=1.0, eps=40.0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Pamb = self.Pc_U.uval_to_dval(Pamb) # convert user units to psia CFcea, CF, mode = self.cea_obj.get_PambCf(Pamb=Pamb, Pc=Pc, MR=MR, eps=eps) return CFcea, CF, mode def getFrozen_PambCf(self, Pamb=0.0, Pc=100.0, MR=1.0, eps=40.0, frozenAtThroat=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Pamb = self.Pc_U.uval_to_dval(Pamb) # convert user units to psia CFcea, CFfrozen, mode = self.cea_obj.getFrozen_PambCf( Pamb=Pamb, Pc=Pc, MR=MR, eps=eps, frozenAtThroat=frozenAtThroat) return CFcea, CFfrozen, mode def get_Chamber_Transport(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Cp, visc, cond, Prandtl = self.cea_obj.get_Chamber_Transport( Pc=Pc, MR=MR, eps=eps, frozen=frozen) #Cp = Cp * 8314.51 / 4184.0 # convert into BTU/lbm degR Cp = self.specific_heat_U.dval_to_uval(Cp) visc = self.viscosity_U.dval_to_uval(visc) cond = self.thermal_cond_U.dval_to_uval(cond) return Cp, visc, cond, Prandtl def get_Throat_Transport(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Cp, visc, cond, Prandtl = self.cea_obj.get_Throat_Transport( Pc=Pc, MR=MR, eps=eps, frozen=frozen) #Cp = Cp * 8314.51 / 4184.0 # convert into BTU/lbm degR Cp = self.specific_heat_U.dval_to_uval(Cp) visc = self.viscosity_U.dval_to_uval(visc) cond = self.thermal_cond_U.dval_to_uval(cond) return Cp, visc, cond, Prandtl def get_Exit_Transport(self, Pc=100.0, MR=1.0, eps=40.0, frozen=0): Pc = self.Pc_U.uval_to_dval(Pc) # convert user units to psia Cp, visc, cond, Prandtl = self.cea_obj.get_Exit_Transport( Pc=Pc, MR=MR, eps=eps, frozen=frozen) Cp = Cp * 8314.51 / 4184.0 # convert into BTU/lbm degR Cp = self.specific_heat_U.dval_to_uval(Cp) visc = self.viscosity_U.dval_to_uval(visc) cond = self.thermal_cond_U.dval_to_uval(cond) return Cp, visc, cond, Prandtl
""" prepare fuel """ meth = 39 adn = 59 h2o = 2 createPropellant(h2o, meth, adn) temp = CEA_Obj(propName="WaterMethanolADN_Mix") """ investigate falling chamber pressure """ chamber_pressure = np.linspace(0, 16, 1000) chamber_pressure = chamber_pressure[1:] expansion_ratio = 60 throat_area = 6.96e-6 #m^2 results = [] for pc in chamber_pressure: (isp, cstr, tc) = temp.getFrozen_IvacCstrTc(Pc=bar2psi(pc), eps=expansion_ratio, frozenAtThroat=1) tc /= 1.8 # rankine to kelvin thrust = isp * 9.81 * pc * 1e5 * throat_area / (cstr * 0.3048) results.append((pc, isp, tc, cstr, thrust)) print(pc, isp) results = np.vstack(results) """ plot """ plt.figure() plt.plot(results[:, 0], results[:, 4]) plt.xlabel('Chamber Pressure [bar]') plt.ylabel('Thrust [N]') plt.subplots_adjust(left=0.2) plt.grid() plt.savefig('b5/thrust_vs_pc.pdf')
class CoreStream: """ Core stream tube of liquid bipropellant thruster. :param geomObj: Geometry that describes thruster :param effObj: Efficiencies object to hold individual efficiencies :param oxName: name of oxidizer (e.g. N2O4, LOX) :param fuelName: name of fuel (e.g. MMH, LH2) :param MRcore: mixture ratio of core flow (ox flow rate / fuel flow rate) :param Pc: psia, chamber pressure :param CdThroat: Cd of throat (RocketThruster object may override) :param Pamb: psia, ambient pressure (for example sea level is 14.7 psia) :param adjCstarODE: multiplier on NASA CEA code value of cstar ODE (default is 1.0) :param adjIspIdeal: multiplier on NASA CEA code value of Isp ODE (default is 1.0) :param pcentFFC: percent fuel film cooling (if > 0 then add BarrierStream) :param ko: entrainment constant (passed to BarrierStream object, range from 0.03 to 0.06) :param ignore_noz_sep: flag to force nozzle flow separation to be ignored (USE WITH CAUTION) :type geomObj: Geometry :type effObj: Efficiencies :type oxName: str :type fuelName: str :type MRcore: float :type Pc: float :type CdThroat: float :type Pamb: float :type adjCstarODE: float :type adjIspIdeal: float :type pcentFFC: float :type ko: float :type ignore_noz_sep: bool :return: CoreStream object :rtype: CoreStream :ivar FvacTotal: lbf, total vacuum thrust :ivar FvacCore: lbf, vacuum thrust due to core stream tube :ivar MRthruster: total thruster mixture ratio') :ivar IspDel: sec, <=== thruster delivered vacuum Isp ===> :ivar Pexit: psia, nozzle exit pressure :ivar IspDel_core: sec, delivered Isp of core stream tube :ivar IspODF: sec, core frozen Isp :ivar IspODK: sec, core one dimensional kinetic Isp :ivar IspODE: sec, core one dimensional equilibrium Isp :ivar cstarERE: ft/s, delivered core cstar :ivar cstarODE: ft/s, core ideal cstar :ivar CfVacIdeal: ideal vacuum thrust coefficient :ivar CfVacDel: delivered vacuum thrust coefficient :ivar CfAmbDel: delivered ambient thrust coefficient :ivar wdotTot: lbm/s, total propellant flow rate (ox+fuel) :ivar wdotOx: lbm/s, total oxidizer flow rate :ivar wdotFl: lbm/s, total fuel flow rate :ivar TcODE: degR, ideal core gas temperature :ivar MWchm: g/gmole, core gas molecular weight :ivar gammaChm: core gas ratio of specific heats (Cp/Cv) """ def __init__( self, geomObj=Geometry(), effObj=Efficiencies(), #ERE=0.98, Noz=0.97), oxName='N2O4', fuelName='MMH', MRcore=1.9, Pc=500, CdThroat=0.995, Pamb=0.0, adjCstarODE=1.0, adjIspIdeal=1.0, pcentFFC=0.0, ko=0.035, ignore_noz_sep=False): self.geomObj = geomObj self.effObj = effObj self.oxName = oxName self.fuelName = fuelName self.MRcore = MRcore self.Pc = Pc self.Pamb = Pamb # ambient pressure self.noz_mode = '' self.CdThroat = CdThroat self.CdThroat_method = 'default' self.ignore_noz_sep = ignore_noz_sep # ignore any nozzle separation self.adjCstarODE = adjCstarODE # may want to adjust ODE cstar value self.adjIspIdeal = adjIspIdeal # may want to adjust ODE and ODF Isp values # make CEA object self.ceaObj = CEA_Obj(oxName=oxName, fuelName=fuelName) # ... if pcentFFC > 0.0, then there's barrier cooling if pcentFFC > 0.0: self.add_barrier = True else: self.add_barrier = False # barrier might need some performance parameters from CoreStream self.calc_cea_perf_params() if self.add_barrier: self.barrierObj = BarrierStream(self, pcentFFC=pcentFFC, ko=ko) else: self.barrierObj = None self.evaluate() # get input descriptions and units from doc string self.inp_descD, self.inp_unitsD, self.is_inputD = get_desc_and_units( self.__doc__) def __call__(self, name): return getattr(self, name) # let it raise exception if no name attr. def reset_CdThroat(self, value, method_name='RocketIsp', re_evaluate=True): """ reset the value of CdThroat If re_evaluate is True, then call self.evaluate() after resetting the efficiency. """ self.CdThroat = value self.CdThroat_method = method_name if re_evaluate: self.evaluate() def reset_attr(self, name, value, re_evaluate=True): """ reset the value of any existing attribute of CoreStream instance. If re_evaluate is True, then call self.evaluate() after resetting the value of the attribute. """ if hasattr(self, name): setattr(self, name, value) else: raise Exception( 'Attempting to set un-authorized CoreStream attribute named "%s"' % name) if name in ['oxName', 'fuelName']: # make CEA object self.ceaObj = CEA_Obj(oxName=self.oxName, fuelName=self.fuelName) if re_evaluate: self.evaluate() def calc_cea_perf_params(self): """Calc basic Isp values from CEA and calc implied IspODK from current effKin value.""" # calc ideal CEA performance parameters self.IspODE, self.cstarODE, self.TcODE, self.MWchm, self.gammaChm = \ self.ceaObj.get_IvacCstrTc_ChmMwGam( Pc=self.Pc, MR=self.MRcore, eps=self.geomObj.eps) self.cstarODE *= self.adjCstarODE self.IspODE *= self.adjIspIdeal self.IspODF, _, _ = self.ceaObj.getFrozen_IvacCstrTc( Pc=self.Pc, MR=self.MRcore, eps=self.geomObj.eps) self.IspODF *= self.adjIspIdeal # use user effKin to set IspODK (or most recent update) self.IspODK = self.IspODE * self.effObj('Kin') #self.IspODK = calc_IspODK(self.ceaObj, Pc=self.Pc, eps=self.geomObj.eps, # Rthrt=self.geomObj.Rthrt, # pcentBell=self.geomObj.pcentBell, # MR=self.MRcore) # fraction of equilibrium kinetics obtained self.fracKin = (self.IspODK - self.IspODF) / (self.IspODE - self.IspODF) self.Pexit = self.Pc / self.ceaObj.get_PcOvPe( Pc=self.Pc, MR=self.MRcore, eps=self.geomObj.eps) self.CfVacIdeal = 32.174 * self.IspODE / self.cstarODE def evaluate(self): """ Assume that all efficiencies have been set, either by original user value or an update by an efficiency model. """ self.effObj.evaluate() self.calc_cea_perf_params() # make final summary efficiencies effNoz = self.effObj('Noz') # want a Core-Only ERE in case a barrier calc is done effERE_core = self.effObj('ERE') if not self.add_barrier: # if no barrier, user may have input FFC effERE_core = effERE_core * self.effObj('FFC') cstarERE_core = self.cstarODE * effERE_core effIsp_core = effNoz * effERE_core self.IspDel_core = effIsp_core * self.IspODE if self.add_barrier: self.barrierObj.evaluate() fAtc = solve_At_split(self.MRcore, self.barrierObj.MRbarrier, self.barrierObj.pcentFFC / 100.0, cstarERE_core, self.barrierObj.cstarERE_b) self.frac_At_core = fAtc # core shares throat area with barrier stream self.frac_At_barrier = 1.0 - self.frac_At_core self.At_b = self.frac_At_barrier * self.geomObj.At self.wdotTot_b = self.Pc * self.At_b * self.CdThroat * 32.174 / self.barrierObj.cstarERE_b self.wdotOx_b = self.wdotTot_b * self.barrierObj.MRbarrier / ( 1.0 + self.barrierObj.MRbarrier) self.wdotFl_b = self.wdotTot_b - self.wdotOx_b self.FvacBarrier = self.wdotTot_b * self.barrierObj.IspDel_b self.MRthruster = self.MRcore * (1.0 - self.barrierObj.pcentFFC / 100.0) else: self.frac_At_core = 1.0 # core gets all of throat area if no barrier stream self.frac_At_barrier = 0.0 self.FvacBarrier = 0.0 self.MRthruster = self.MRcore self.wdotTot_b = 0.0 self.wdotOx_b = 0.0 self.wdotFl_b = 0.0 self.Atcore = self.frac_At_core * self.geomObj.At self.wdotTot_c = self.Pc * self.Atcore * self.CdThroat * 32.174 / cstarERE_core self.wdotOx_c = self.wdotTot_c * self.MRcore / (1.0 + self.MRcore) self.wdotFl_c = self.wdotTot_c - self.wdotOx_c self.FvacCore = self.wdotTot_c * self.IspDel_core self.FvacTotal = self.FvacCore + self.FvacBarrier self.wdotTot = self.wdotTot_c + self.wdotTot_b self.wdotOx = self.wdotOx_c + self.wdotOx_b self.wdotFl = self.wdotFl_c + self.wdotFl_b if self.add_barrier: self.wdotFlFFC = (self.barrierObj.pcentFFC / 100.0) * self.wdotFl self.wdotFl_cInit = self.wdotFl - self.wdotFlFFC self.wdotTot_cInit = self.wdotOx + self.wdotFl_cInit else: self.wdotFlFFC = 0.0 self.wdotFl_cInit = self.wdotFl self.wdotTot_cInit = self.wdotTot self.IspDel = self.FvacTotal / self.wdotTot self.IspDelPulse = self.IspDel * self.effObj('Pulse') if self.add_barrier: # if barrier is analysed, assume it is in addition to user input effERE effFFC = self.IspDel / self.IspDel_core self.effObj.set_value('FFC', effFFC, value_src='barrier calc') self.cstarERE = self.cstarODE * self.effObj('ERE') #self.cstarDel = self.Pc * self.Atcore * self.CdThroat * 32.174 / self.wdotTot # do any nozzle ambient performance calcs here if self.Pamb < 0.000001: self.IspAmb = self.IspDel self.noz_mode = '(Pexit=%g psia)' % self.Pexit else: CfOvCfvacAtEsep, CfOvCfvac, Cfsep, CfiVac, CfiAmbSimple, CfVac, self.epsSep, self.Psep = \ sepNozzleCf(self.gammaChm, self.geomObj.eps, self.Pc, self.Pamb) #print('epsSep=%g, Psep=%g'%(self.epsSep, self.Psep)) #print('========= Pexit=%g'%self.Pexit, ' Psep=%g'%self.Psep, ' epsSep=%g'%self.epsSep) if self.Pexit > self.Psep or self.geomObj.eps < self.epsSep or self.ignore_noz_sep: # if not separated, use theoretical equation for back-pressure correction self.IspAmb = self.IspDel - self.cstarERE * self.Pamb * self.geomObj.eps / self.Pc / 32.174 #print('----------------> subtraction term =', self.cstarERE * self.Pamb * self.geomObj.eps / self.Pc / 32.174) else: # if separated, use Kalt and Badal estimate of ambient thrust coefficient # NOTE: there are better, more modern methods available IspODEepsSep, CstarODE, Tc = \ self.ceaObj.get_IvacCstrTc(Pc=self.Pc, MR=self.MRcore, eps=self.epsSep) IspODEepsSep = IspODEepsSep - self.cstarERE * self.Pamb * self.epsSep / self.Pc / 32.174 effPamb = IspODEepsSep / self.IspODE #print('--------------> effPamb=%g'%effPamb, ' IspODEepsSep=%g'%IspODEepsSep, ' IspODE=%g'%self.IspODE) self.IspAmb = effPamb * self.IspDel #print('========= Pamb=%g'%self.Pamb, ' IspAmb=%g'%self.IspAmb) # figure out mode of nozzle operation if self.Pexit > self.Psep or self.geomObj.eps < self.epsSep: if self.Pexit > self.Pamb + 0.05: self.noz_mode = 'UnderExpanded (Pexit=%g)' % self.Pexit elif self.Pexit < self.Pamb - 0.05: self.noz_mode = 'OverExpanded (Pexit=%g)' % self.Pexit else: self.noz_mode = 'Pexit=%g' % self.Pexit else: self.noz_mode = 'Separated (Psep=%g, epsSep=%g)' % ( self.Psep, self.epsSep) self.Fambient = self.FvacTotal * self.IspAmb / self.IspDel self.CfVacDel = self.FvacTotal / (self.geomObj.At * self.Pc ) # includes impact of CdThroat self.CfAmbDel = self.Fambient / (self.geomObj.At * self.Pc ) # includes impact of CdThroat def summ_print(self): """ print to standard output, the current state of CoreStream instance. """ print(self.get_summ_str()) def get_summ_str(self, alpha_ordered=True, numbered=False, add_trailer=True, fillchar='.', max_banner=76, intro_str=''): """ return string of the current state of CoreStream instance. """ M = self.get_model_summ_obj() Me = self.effObj.get_model_summ_obj() se = '\n' + Me.summ_str( alpha_ordered=False, fillchar=' ', assumptions_first=False) if self.add_barrier: Mb = self.barrierObj.get_model_summ_obj() sb = '\n' + Mb.summ_str(alpha_ordered=alpha_ordered, numbered=numbered, add_trailer=add_trailer, fillchar=fillchar, max_banner=max_banner, intro_str=intro_str) else: sb = '' return M.summ_str(alpha_ordered=alpha_ordered, numbered=numbered, add_trailer=add_trailer, fillchar=fillchar, max_banner=max_banner, intro_str=intro_str) + se + sb def get_html_str(self, alpha_ordered=True, numbered=False, intro_str=''): M = self.get_model_summ_obj() Me = self.effObj.get_model_summ_obj() se = '\n' + Me.html_table_str(alpha_ordered=False, assumptions_first=False) if self.add_barrier: Mb = self.barrierObj.get_model_summ_obj() sb = '\n' + Mb.html_table_str(alpha_ordered=alpha_ordered, numbered=numbered, intro_str=intro_str) else: sb = '' return M.html_table_str( alpha_ordered=alpha_ordered, numbered=numbered, intro_str=intro_str)\ + se + sb def get_model_summ_obj(self): """ return ModelSummary object for current state of CoreStream instance. """ M = ModelSummary('%s/%s Core Stream Tube' % (self.oxName, self.fuelName)) M.add_alt_units('psia', ['MPa', 'atm', 'bar']) M.add_alt_units('lbf', 'N') M.add_alt_units('lbm/s', 'kg/s') M.add_alt_units('ft/s', 'm/s') M.add_alt_units('sec', ['N-sec/kg', 'km/sec']) M.add_alt_units('degR', ['degK', 'degC', 'degF']) M.add_param_fmt('Pexit', '%.4f') M.add_param_fmt('Pc', '%.1f') M.add_out_category('') # show unlabeled category 1st def add_param(name, desc='', fmt='', units='', value=None, category=''): if name in self.inp_unitsD: units = self.inp_unitsD[name] if desc == '' and name in self.inp_descD: desc = self.inp_descD[name] if value is None: value = getattr(self, name) if self.is_inputD.get(name, False): M.add_inp_param(name, value, units, desc, fmt=fmt) else: M.add_out_param(name, value, units, desc, fmt=fmt, category=category) for name in self.is_inputD.keys(): if name not in ['pcentFFC', 'ko', 'geomObj', 'effObj']: add_param(name) # parameters that are NOT attributes OR are conditional if self.add_barrier: add_param('FvacBarrier', units='lbf', desc='vacuum thrust due to barrier stream tube') if self.Pamb > 14.5: add_param('Fambient', units='lbf', desc='total sea level thrust') add_param('IspAmb', units='sec', desc='delivered sea level Isp') M.add_out_comment('Fambient', '%s' % self.noz_mode) M.add_out_comment('IspAmb', '%s' % self.noz_mode) elif self.Pamb > 0.0: add_param('Fambient', units='lbf', desc='total ambient thrust') add_param('IspAmb', units='sec', desc='delivered ambient Isp') M.add_out_comment('Fambient', '%s' % self.noz_mode) M.add_out_comment('IspAmb', '%s' % self.noz_mode) if self.effObj('Pulse') < 1.0: add_param('IspDelPulse', units='sec', desc='delivered pulsing Isp') if self.CdThroat_method != 'default': M.add_inp_comment('CdThroat', '(%s)' % self.CdThroat_method) if self.add_barrier: add_param('wdotFlFFC', units='lbm/s', desc='fuel film coolant flow rate injected at perimeter', category='At Injector Face') add_param( 'wdotFl_cInit', units='lbm/s', desc='initial core fuel flow rate (before any entrainment)', category='At Injector Face') add_param( 'wdotTot_cInit', units='lbm/s', desc='initial core total flow rate (before any entrainment)', category='At Injector Face') add_param( 'wdotTot_b', units='lbm/s', desc='total barrier propellant flow rate (includes entrained)', category='After Entrainment') add_param('wdotOx_b', units='lbm/s', desc='barrier oxidizer flow rate (all entrained)', category='After Entrainment') add_param('wdotFl_b', units='lbm/s', desc='barrier fuel flow rate (FFC + entrained)', category='After Entrainment') add_param( 'wdotTot_c', units='lbm/s', desc= 'total final core propellant flow rate (injected - entrained)', category='After Entrainment') add_param( 'wdotOx_c', units='lbm/s', desc='final core oxidizer flow rate (injected - entrained)', category='After Entrainment') add_param('wdotFl_c', units='lbm/s', desc='final core fuel flow rate (injected - entrained)', category='After Entrainment') #add_param('xxx', units='xxx', desc='xxx') return M
def createPropellant(wt1,wt2,wt3): card_str = """ name H2O H 2 O 1 wt%={:.1f} h,kj/mol=-285.8 t(k)=293.15 name Methanol C 1 H 4 O 1 wt%={:.1f} h,kj/mol=-239.2 t(k)=293.15 name ADN H 4 N 4 O 4 wt%={:.1f} h,kj/mol=-134.6 t(k)=293.15 """.format(wt1,wt2,wt3) add_new_propellant("WaterMethanolADN_Mix",card_str) def bar2psi(bar): return bar*14.504 """ prepare fuel """ meth = 39 adn = 59 h2o = 2 createPropellant(h2o,meth,adn) """ get full output """ chamber_pressure = 16 expansion_ratio = 60 temp = CEA_Obj(propName="WaterMethanolADN_Mix") (isp,cstr,tc) = temp.getFrozen_IvacCstrTc(Pc=bar2psi(chamber_pressure),eps=expansion_ratio,frozenAtThroat=1) print(isp,cstr,tc) s = temp.get_full_cea_output( Pc=bar2psi(chamber_pressure), eps=expansion_ratio, frozen=1, frozenAtThroat=1) with open("b4.out","w") as f: f.write(s) print(s)
def calculatePerformance(chamber_pressure,expansion_ratio): # chamber pressure in bar temp = CEA_Obj(propName="WaterMethanolADN_Mix") (isp,cstr,tc) = temp.getFrozen_IvacCstrTc(Pc=bar2psi(chamber_pressure),eps=expansion_ratio,frozenAtThroat=1) tc /= 1.8 # convert from rankine to kelvin return (isp, tc)