Plot Examples

The following examples show easy approaches to plotting RocketCEA results.

Copy and Paste any of the code below into your text editor, save it and run it. (For many text editors, hitting the F5 key will execute the code)

Cstar Plot

The script below plots Cstar Values for LOX/LH2 for several values of chamber pressure and a range of mixture ratio.



from rocketcea.cea_obj import CEA_Obj
from pylab import *

pcL = [ 2000., 500., 70.]

ispObj = CEA_Obj(propName='', oxName='LOX', fuelName="LH2")

for Pc in pcL:
    cstarArr = []
    MR = 2.0
    mrArr = []
    while MR < 8.0:
        cstarArr.append( ispObj.get_Cstar( Pc=Pc, MR=MR) )
        mrArr.append(MR)
        MR += 0.05
    plot(mrArr, cstarArr, label='Pc=%g psia'%Pc)

legend(loc='best')
grid(True)
title( ispObj.desc )
xlabel( 'Mixture Ratio' )
ylabel( 'Cstar (ft/sec)' )
savefig('cea_cstar_plot.png', dpi=120)

show()
_images/cea_cstar_plot.png

Click images to see full size

Isp Plot

Plot several area ratios over a range of mixture ratio.


from rocketcea.cea_obj import CEA_Obj
from pylab import *

Pc = 500.0

ispIRFNA = CEA_Obj(propName='', oxName='IRFNA', fuelName="MHF3")
for e in [50.0,20.0,10.0]:
    ispArr = []
    MR = 1.1
    mrArr = []
    while MR < 3.5:
        ispArr.append( ispIRFNA(Pc, MR, e ))
        mrArr.append(MR)
        MR += 0.05
    plot(mrArr, ispArr, label='AreaRatio %g'%e)

legend(loc='best')
grid(True)
title( ispIRFNA.desc )
xlabel( 'Mixture Ratio' )
ylabel( 'Isp ODE (sec)' )
savefig('cea_plot.png', dpi=120)

show()
_images/cea_plot.png

Click images to see full size

Isp Comparisons

Compare propellant combinations.

Notice that the plots are sorted by max Isp to make them easier to interpret.



from rocketcea.cea_obj import CEA_Obj
from pylab import *

Pc = 500.0
eps = 25.0
mrMin = 1.0
mrStep = 0.05
mrMax = 4.0

mrL = [mrMin + i*mrStep for i in range( int((mrMax-mrMin)/mrStep))]
ispLL = [] # a list of lists of Isp data

for oxName,fuelName in [('N2O4','N2H4'),('N2O4','MMH'),('N2O4','M20'),
    ('CLF5','N2H4'),('CLF5','NH3')]:

    ispObj = CEA_Obj( oxName=oxName, fuelName=fuelName )
    
    ispL = [ispObj.get_Isp(Pc=Pc, MR=MR, eps=eps) for MR in mrL]
    ispLL.append( [max(ispL), '%s/%s'%(oxName,fuelName), ispL] )

ispLL.sort(reverse=True) # sort in-place from high to low

for maxIsp, name, ispL in ispLL:
    plot(mrL, ispL, label=name, linewidth=2)

legend(loc='best')
grid(True)
title( 'Propellant Performance Comparison at Eps=%g, Pc=%g psia'%(eps,Pc) )
xlabel( 'Mixture Ratio' )
ylabel( 'Isp ODE (sec)' )
savefig('cea_compare2.png', dpi=120)

show()
_images/cea_compare2.png _images/cea_compare3.png

Click images to see full size