def test_use_Mpa_as_input_Pc(self):
     """test use Mpa as input Pc"""
     
     C = CEA_Obj( oxName='LOX', fuelName='LH2', fac_CR=None)
     CwU = CEA_Obj_w_units( oxName='LOX', fuelName='LH2', pressure_units='MPa', fac_CR=None)
     
     a = C.get_Isp(Pc=1000.0, MR=6.0, eps=40.0)
     b = CwU.get_Isp(Pc=1000.0/145.037738, MR=6.0, eps=40.0)
     self.assertAlmostEqual(a, b, delta=0.01)
def OFtrade(fu, ox, P, N, OFratio,
            pltname):  # O/F ratio trade (OFratio needs to be a vector array)
    # fu: name of fuel (string, as defined in rocketcea documentation or newly added fuels)
    # ox: name of ox (string, as defined in rocketcea documentation of newly added fuels)
    # P: chamber pressure (either a single number, list of numbers, or range())
    # N: number of desired O/F ratios to sweep over
    # OFratio: values of O/F ratios (length of this list must match value of N)
    # supAR: fixed nozzle expansion ratio
    C = CEA_Obj(
        oxName=ox, fuelName=fu, isp_units='sec',
        cstar_units='m/s')  # define CEA object to operate on for rocketCEA
    if isinstance(P, int) == True:  # if P is only one value
        y = 1
    else:
        y = len(P)
    # preallocate vars
    ISP = np.zeros([y, OFratio.shape[0]])  # isp
    Cstar = np.zeros([y, OFratio.shape[0]])  # cstar eff
    PCPE = np.zeros([y, OFratio.shape[0]])  # pc/pe
    cpcv = np.zeros([y, OFratio.shape[0]
                     ])  # ratio of specific heats in thrust chamber
    fe_pcpe = np.zeros([y, OFratio.shape[0]
                        ])  # nozzle area ratio for fully expanded flow
    for x in range(y):
        if y == 1:
            Pc = P  # integers can't be called :(
            legends = str(Pc)
        else:
            Pc = P[x]  # chamber pressure
            legends = P
        pr = Pc / 14.7  # pc/pe for fully expanded flo
        for i in range(N):
            fe_pcpe[x, :] = C.get_eps_at_PcOvPe(Pc=Pc,
                                                MR=OFratio[i],
                                                PcOvPe=pr)
            ISP[x, i] = C.get_Isp(Pc=Pc, MR=OFratio[i],
                                  eps=fe_pcpe[x, i])  # ISP vacuum
            Cstar[x, i] = C.get_Cstar(Pc=Pc, MR=OFratio[i])  # Cstar efficiency
            fe_pcpe[x, i] = C.get_PcOvPe(Pc=Pc,
                                         MR=OFratio[i],
                                         eps=fe_pcpe[x, i])  # Pc/Pe
            cpcv[x, i] = C.get_Chamber_Cp(Pc=Pc,
                                          MR=OFratio[i],
                                          eps=fe_pcpe[x, i])  # cp/cv

    # generate plots for ISP, Cstar, and Pchamb/Pexit
    # plots(OFratio,ISP,"O/F ratio","ISP (s)",    pltname+"isp.png"   , legends     ) # isp plot
    # plots(OFratio,Cstar,"O/F ratio","Cstar",    pltname+"cstar.png" , legends     ) # Cstar plot
    # plots(OFratio,PCPE,"O/F ratio","Pc/Pe",     pltname+"pcpe.png"  , legends     ) # Pc/Pe plot
    return ISP, Cstar, fe_pcpe, cpcv
示例#3
0
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(
            pcham, MR=OFratio[i]
        )  # throat Pc/Pe (we will be using a converging nozzle)

    return ISP, Cstar, PCPE
def ARtrade(fu, ox, P, N, OFratio, supAR, pltname):  # expansion ratio trade
    # fu: name of fuel (string, as defined in rocketcea documentation or newly added fuels)
    # ox: name of ox (string, as defined in rocketcea documentation of newly added fuels)
    # P: chamber pressure (either a single number, list of numbers, or range())
    # N: number of desired supersonic area ratios (nozzle expansion ratio) to sweep over
    # OFratio: fixed O/F ratio for this trade
    # supAR: values of supersonic area ratios (length of this list must match value of N)
    C = CEA_Obj(
        oxName=ox, fuelName=fu, isp_units='sec',
        cstar_units='m/s')  # define CEA object to operate on for rocketCEA
    if isinstance(P, int) == True:  # if P is only one value
        y = 1
    else:
        y = len(P)
    # preallocate vars
    ISP = np.zeros([y, supAR.shape[0]])  # isp
    Cstar = np.zeros([y, supAR.shape[0]])  # cstar eff
    PCPE = np.zeros([y, supAR.shape[0]])  # pc/pe
    cpcv = np.zeros([y, supAR.shape[0]
                     ])  # ratio of specific heats in thrust chamber
    for x in range(y):
        if y == 1:
            Pc = P  # integers can't be called :(
            legends = str(Pc)
        else:
            Pc = P[x]  # chamber pressure
            legends = P
        for i in range(N):
            ISP[x, i] = C.get_Isp(Pc=Pc, MR=OFratio,
                                  eps=supAR[i])  # ISP vacuum
            Cstar[x, i] = C.get_Cstar(Pc=Pc, MR=OFratio)  # Cstar efficiency
            PCPE[x, i] = C.get_PcOvPe(Pc=Pc, MR=OFratio, eps=supAR[i])  # Pc/Pe
            cpcv[x, i] = C.get_Chamber_Cp(Pc=Pc, MR=OFratio,
                                          eps=supAR[i])  # cp/cv

    # generate plots for ISP, Cstar, and Pchamb/Pexit. Replace the last input with the vectory array of pressures
    # plots(supAR,ISP,"Ae/At","ISP (s)",  pltname+"isp.png"   , legends     ) # isp plot
    # plots(supAR,Cstar,"Ae/At","Cstar",  pltname+"cstar.png" , legends     ) # Cstar plot
    # plots(supAR,PCPE,"Ae/At","Pc/Pe",   pltname+"pcpe.png"  , legends     ) # Pc/Pe plot
    return ISP, Cstar, PCPE, cpcv