def __init__(self): self.datapathname = './.lookup.npy' self.configpathname = './.lookupconfig.json' self.data = None self.config = None self.__loaded = False # This str provides molecular structure, wt% of fuel, heat of formation, and density information to underlying CEA code fuel_str = """ fuel ABS(S) C 3.85 H 4.85 N 0.43 wt%=100.0 h,kJ=62.63 t(k)=298.15 rho,kg=1224 """ add_new_fuel('ABS', fuel_str) self.cea = CEA_Obj(oxName='N2O', fuelName='ABS', cstar_units='m/s', pressure_units='Pa', temperature_units='K', sonic_velocity_units='m/s', enthalpy_units='J/kg', density_units='kg/m^3', specific_heat_units='J/kg-K', viscosity_units='poise', thermal_cond_units='W/cm-degC', make_debug_prints=True)
def test_new_propellants(self): card_str = """ oxid N2O4(L) N 2 O 4 wt%=96.5 h,cal=-4676.0 t(k)=298.15 oxid SIO2 SI 1 O 2 wt%=3,5 h,cal=-216000.0 t(k)=298.15 rho.g/cc=1.48 """ add_new_oxidizer('GelN2O4', card_str) # ========== card_str = """ fuel CH6N2(L) C 1 H 6 N 2 wt%=60.00 h,cal=12900.0 t(k)=298.15 rho=.874 fuel AL 1 wt%=40.00 h,cal=0.0 t(k)=298.15 rho=.1 """ add_new_fuel('MMH_AL', card_str) C = CEA_Obj(oxName="GelN2O4", fuelName="MMH_AL", fac_CR=None) IspODE = C.get_Isp(Pc=1850.0, MR=0.7, eps=40.0) self.assertAlmostEqual(IspODE, 380.83236183365057, places=3) # ========== card_str = """ name H2O2(L) H 2 O 2 wt%=100.00 h,cal=-44880.0 t(k)=298.15 rho.g/cc=1.407 """ add_new_propellant('MyProp', card_str) C = CEA_Obj(propName="MyProp", fac_CR=None) IspODE = C.get_Isp(Pc=1850.0, eps=40.0) self.assertAlmostEqual(IspODE, 189.9709005711723, places=3)
def addCustomSpecies(self): # Add custom species to CEA card_str = """ fuel ABS C 3.85 H 4.85 N 0.43 wt%=100.00 h,cal=14990 t(k)=298.15 rho=0.975 """ add_new_fuel('ABS', card_str) card_str = """ fuel Acrylic C 5 H 8 O 2 wt%=100.00 h,cal=91396 t(k)=298.15 rho=1.18 """ add_new_fuel('Acrylic', card_str)
def define_propellants(): """ define the string that characterizes the fuel """ # Introduce the fuel definition fuel_card = "fuel=Air wt=0.01 t(k)=298 " \ "fuel=ABS wt=99.9 t(k)=298 " \ "h,kj/mol=62.63 C 3.85 H 4.85 N 0.43" # Introduce the oxidizer definition oxidizer_card = "oxid=H2O2(L) wt=87.5 t(k)=298 " \ "oxid=H2O(L) wt=12.5 t(k)=298" # Add the new fuel and oxidizer cea_obj.add_new_fuel("3DPrinted_ABS", fuel_card) cea_obj.add_new_oxidizer("GriffonOxydizer_H2O2", oxidizer_card)
def cea_card(self): # Create cea card and rocketcea fuel/oxidizer self.card += self.name + " " self.card += self.formula + " " self.card += "wt%=100" + " " # self.card += "h,cal={:.3f}".format(self.storage_enthalpy/4.184) + " " self.card += "t(k)={:.3f}".format(self.storage_temperature) + " " self.card += ("rho={:.3f}".format(self.storage_density / 1000) + " " ) # convert density to g/cc if self.fluid_type == "oxidizer": self.card = "oxid " + self.card add_new_oxidizer(self.name, self.card) elif self.fluid_type == "fuel": self.card = "fuel " + self.card add_new_fuel(self.name, self.card) return self.card
def define_fuel(fuel_table): """ define_fuel constructs the propellant card (str) that's associated to the fuel. :param fuel_table: dict containing the fuel table as specified in the data-layer :return: Nothing """ # Initialize the fuel card card = [] # Loop through the fuels list and generate the string associated to it for fuel_type in fuel_table['components']: # Define the basic fields card.append("fuel={name}".format(name=fuel_type['fuel'])) card.append("wt={wt}".format(wt=fuel_type['wt'])) card.append("t{units}={value}".format( units=fuel_type['t']['units'], value=fuel_type['t']['value'])) # Check if more complex fields are present for the fuel if "h" in fuel_type: card.append("h,{units}={value}".format( units=fuel_type['h']['units'], value=fuel_type['h']['value'])) if "composition" in fuel_type: card.append(" ".join( ("{name} {value}".format(name=key, value=val) for key, val in fuel_type['composition'].items()))) # Join the card card = " ".join(card) # Add the fuel to the cea_obj cea_obj.add_new_fuel(fuel_table['name'], card)
## inputs P = range(150, 500, 20) # range of chamber pressures to test ## add PMMA definition card_str = ''' fuel PMMA C 5 H 8 O 2 h,kj=-430.5 t(k)=299.82 ''' # Greg Zilliac's recommendation for modeling PMMA # HTPB Definition (not used right now) card_str2 = ''' fuel HTPB C 7.3165 H 10.3360 O 0.1063 wt%=100.00 h,cal= 1200.0 t(k)=298.15 rho=0.9220 ''' add_new_fuel('PMMA', card_str) # rocketCEA function to add PMMA to inputs def rocket_vars(fu, ox, pcham): C = CEA_Obj( oxName=ox, fuelName=fu, isp_units='sec', cstar_units='m/s') # define CEA object to operate on for rocketCEA OFratio = np.linspace(0.1, 5., 50, endpoint=True) # OF ratio by mass ISP = np.zeros(OFratio.shape) # isp Cstar = np.zeros(OFratio.shape) # cstar efficiency PCPE = np.zeros(OFratio.shape) # p_chamber / p_exit supAR = 1 # supersonic area ratio (1 = converging nozzle only) for i in range(50): ISP[i] = C.get_Isp(pcham, MR=OFratio[i], eps=supAR) # ISP vacuum Cstar[i] = C.get_Cstar(pcham, MR=OFratio[i]) # Cstar efficiency PCPE[i] = C.get_Throat_PcOvPe(
def getPerformanceParameters(self, combustionPressure, ambientPressure, oxidizerTemperature, expansionRatio, mixtureRatio): CpAve = CP.PropsSI('CP0MOLAR', 'T', oxidizerTemperature, 'P', combustionPressure, "N2O") MolWt = CP.PropsSI('M', 'T', oxidizerTemperature, 'P', combustionPressure, "N2O") * 1e3 HMOLAR = CP.PropsSI('HMOLAR', 'T', oxidizerTemperature, 'P', combustionPressure, "N2O") / 1e3 RHO = CP.PropsSI('D', 'T', oxidizerTemperature, 'P', combustionPressure, "N2O") * 1e3 / (1e2 * 1e2 * 1e2) # print(HMOLAR, RHO) card_str = """ oxid=NITROUS wt=1.0 t,K={:.4f} h,kj/mol={:.4f} rho,g/cc={:.4f} N 2 O 1 """.format(oxidizerTemperature, HMOLAR, RHO) add_new_oxidizer('NITROUS_COOLPROP', card_str.format(oxidizerTemperature)) fuelTemperature = 293 card_str = """ fuel=C(gr) wt=0.02 t,K={:.4f} fuel=SASOL907 wt=0.98 t,K={:.4f} h,kj/mol=-1438.200 rho,g/cc=0.720 C 50 H 102 """.format(fuelTemperature, fuelTemperature) add_new_fuel('SASOLWAX907_CARBONBLACK', card_str) # cea = CEA_Obj( # oxName="NITROUS_COOLPROP", # fuelName="SASOLWAX907_CARBONBLACK" # ) # s = cea.get_full_cea_output(Pc=combustionPressure/1e5, MR=mixtureRatio, eps=expansionRatio, pc_units="bar", output='siunits') # print(s) # # pass with hiddenPrints: cea = CEA_Obj_W_Units(oxName="NITROUS_COOLPROP", fuelName="SASOLWAX907_CARBONBLACK", pressure_units='Pa', cstar_units='m/s', temperature_units='K', sonic_velocity_units='m/s', enthalpy_units='J/kg', density_units='kg/m^3', specific_heat_units='J/kg-K', viscosity_units='poise', thermal_cond_units="W/cm-degC") Isp, mode = cea.estimate_Ambient_Isp(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio, Pamb=ambientPressure) IspVac, Cstar, Tc, MW, gamma = cea.get_IvacCstrTc_ChmMwGam( Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio) # cea = CEA_Obj( # oxName=oxidizerCard, # fuelName="SASOLWAX907_CARBONBLACK" # ) # s = cea.get_full_cea_output(Pc=combustionPressure/1e5, MR=mixtureRatio, eps=expansionRatio, pc_units="bar", output='siunits') # print(s) return Isp, CpAve, MolWt, Cstar, Tc, gamma
from rocketcea.cea_obj import CEA_Obj, add_new_fuel, add_new_oxidizer, add_new_propellant card_str = """ fuel NASA_RP-1 C 1.0 H 1.95 wt%=100.00 h,cal=-5907.672 t(k)=298.15 rho=.773 """ add_new_fuel( 'NASA_RP_1', card_str ) C = CEA_Obj(oxName="GOX", fuelName="NASA_RP_1") s = C.get_full_cea_output( Pc=1000.0, MR=3.0, eps=40.0, short_output=1) print( s )
def getPerformanceParameters(self, combustionPressure, ambientPressure, oxidizerTemperature, expansionRatio, mixtureRatio): import CoolProp.CoolProp as CP from rocketcea.cea_obj import CEA_Obj, add_new_fuel, add_new_oxidizer, add_new_propellant from rocketcea.cea_obj_w_units import CEA_Obj as CEA_Obj_W_Units from rocketcea.blends import makeCardForNewTemperature combustionPressure = max(10, combustionPressure) # Limitation of the library... fuelTemperature = 293 HMOLAR = CP.PropsSI('HMOLAR','T',oxidizerTemperature,'P',combustionPressure,"N2O") / 1e3 oxidizerDensity = CP.PropsSI('D','T',oxidizerTemperature,'P',combustionPressure,"N2O") RHO = oxidizerDensity * 1e3 / (1e2 * 1e2 * 1e2) oxid_card_str = """ oxid=NITROUS wt=1.0 t,K={:.2f} h,kj/mol={:.2f} rho,g/cc={:.2f} N 2 O 1 """.format(oxidizerTemperature, HMOLAR, RHO) fuel_card_str = """ fuel=C(gr) wt={:.4f} t,K={:.2f} fuel=SASOL907 wt={:.4f} t,K={:.2f} h,kj/mol={:.2f} rho,g/cc={:.3f} C 50 H 102 """.format( assumptions.carbonBlackFraction.get(), fuelTemperature, 1 - assumptions.carbonBlackFraction.get(), fuelTemperature, assumptions.fuelEnthalpyOfFormation.get(), assumptions.fuelDensityLiquid.get() / 1e3) problemString = "Pc={:.2f},Pa={:.2f},To={:.2f},Tf={:.2f},ER={:.2f},MR={:.2f},oxid={:},fuel={:}".format( combustionPressure, ambientPressure, oxidizerTemperature, fuelTemperature, expansionRatio, mixtureRatio, oxid_card_str, fuel_card_str ) strHash = hashlib.md5(problemString.encode()).hexdigest() NasaCEA.totalHits = NasaCEA.totalHits + 1 if options.enableCeaLookup and strHash in NasaCEA.inMemoryCache: # print("Hit cache") NasaCEA.cacheHits = NasaCEA.cacheHits + 1 return NasaCEA.inMemoryCache[strHash] # print(HMOLAR, RHO) add_new_oxidizer('NITROUS_COOLPROP', oxid_card_str) add_new_fuel('SASOLWAX907_CARBONBLACK', fuel_card_str) with hiddenPrints: combustionPressure = round(combustionPressure, 2) mixtureRatio = round(mixtureRatio, 2) expansionRatio = round(expansionRatio, 2) ambientPressure = round(ambientPressure, 2) cea = CEA_Obj_W_Units( oxName="NITROUS_COOLPROP", fuelName="SASOLWAX907_CARBONBLACK", pressure_units='Pa', cstar_units='m/s', temperature_units='K', sonic_velocity_units='m/s', enthalpy_units='J/kg', density_units='kg/m^3', specific_heat_units='J/kg-K', viscosity_units='poise', thermal_cond_units="W/cm-degC" ) Isp,mode = cea.estimate_Ambient_Isp(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio, Pamb=ambientPressure) IspVac, Cstar, Tc, MW, gamma = cea.get_IvacCstrTc_ThtMwGam(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio) Cp = cea.get_Chamber_Cp(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio) rho = cea.get_Chamber_Density(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio) CfVac, Cf, mode = cea.get_PambCf(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio) PcOvPe = cea.get_PcOvPe(Pc=combustionPressure, MR=mixtureRatio, eps=expansionRatio) exitPressure = combustionPressure / PcOvPe result = (Isp, Cp, MW, Cstar, Tc, gamma, rho, Cf, exitPressure, oxidizerDensity) if options.enableCeaLookup: NasaCEA.inMemoryCache[strHash] = result return result
from rocketcea.cea_obj import CEA_Obj, add_new_fuel, add_new_oxidizer, add_new_propellant card_str = """ oxid N2O4(L) N 2 O 4 wt%=96.5 h,cal=-4676.0 t(k)=298.15 oxid SiO2 Si 1.0 O 2.0 wt%=3.5 h,cal=-216000.0 t(k)=298.15 rho=1.48 """ add_new_oxidizer('GelN2O4', card_str) # ========== card_str = """ fuel CH6N2(L) C 1.0 H 6.0 N 2.0 wt%=60.00 h,cal=12900.0 t(k)=298.15 rho=.874 fuel AL AL 1.0 wt%=40.00 h,cal=0.0 t(k)=298.15 rho=0.1 """ add_new_fuel('MMH_AL', card_str) C = CEA_Obj(oxName="GelN2O4", fuelName="MMH_AL") s = C.get_full_cea_output(Pc=1850.0, MR=0.7, eps=40.0, short_output=1) print(s)
plt.xlabel(xname) plt.ylabel(yname) plt.title(plttit) plt.legend(loc="lower right") plt.savefig(pltname) plt.close ### ANALYSIS SET UP ### # defining fuel will add it's information to the master list of fuels to run rocketCEA with. # define PMMA card_str = ''' fuel PMMA C 5 H 8 O 2 h,kj=-430.5 t(k)=299.82 ''' # Greg Zilliac's recommendation for modeling PMMA add_new_fuel('PMMA', card_str) # rocketCEA function to add PMMA to possible inputs # define HTPB card_str2 = ''' fuel HTPB C 7.3165 H 10.3360 O 0.1063 h,kj/mol= 456 t(k)=298.15 rho=0.9220 ''' add_new_fuel('HTPB', card_str2) # rocketCEA function to add HTPB to possible inputs # define ABS (monomer of ABS) card_str3 = ''' fuel ABS C 3 H 3 N 1 h,kj/mol=172 t(k)=299.82 ''' add_new_fuel('ABS (Monomer)',