import math
#calcualte Diameter of the SSME nozzle exit area
print("Example 11.1")
Ts=470000. ##in lb
Tv=375000. ##in lb
A2=(Ts-Tv)/(14.7*144.)
D=(4.*A2/math.pi)**(1./2.)
print'%s %.1f %s'%("Diameter of the SSME nozzle exit area :",D,"")
import math
print("Example 11.2")
#calculate rocket thurst and effective thurst
m=1000 ##in kg/s
g=9.8 ##m/s**2
Is=340. ##in s
F=m*g*Is
print'%s %.1f %s'%("(a)Rocket thrust F in N :",F,"")
c=F/m
print'%s %.1f %s'%("(b)Effective exhaust velocity c in m/s :",c,"")
import math
print("Example 11.3")
#calculate optimum thurst and nozzle exit mach number and nozzle area exapnsion
pc=200. ##in atm
p2=1. ##in atm
gm=1.3
Ath=25. ##in m**2
Cf=((2.*gm**2.)/(gm-1.)*(2./(gm+1.))**((gm+1.)/(gm-1.))*(1.-(p2/pc)**((gm-1.)/gm)))**(1/2.)
print'%s %.1f %s'%("(a)Optimum thrust coefficient Cf,opt :",Cf,"")
pc=200.*101. ##converting to MPa
F=Ath*Cf*pc
print'%s %.1f %s'%("(b)thrust F in N",F,"")
pc=200.
M2=((2./(gm-1.))*((pc/p2)**((gm-1.)/gm)-1.))**(1/2.)
print'%s %.1f %s'%("(c)Nozzle exit Mach no. M2 :",M2,"")
A=1./M2*(2./(gm+1)*(1+(gm-1.)/2.*M2**2.))**((gm+1.)/(2.*(gm-1.)))
print'%s %.1f %s'%("(d)Nozzle area expansion ratio A2/Ath :",A,"")
import math
print("Example 11.4")
#estimate combustion gas constant and moleculare weight
Tc=2999 ##in K
Ccr=2432 ##in m/s
gm=1.26
f=4.02
R=((Ccr*gm*(2./(gm+1))**((gm+1.)/(2.*(gm-1))))**2.)/(gm*Tc)
print'%s %.1f %s'%("Combustion gas constant R in J/kg.K:",R,"")
RU=8314.6 ##in j/kmol.K
MW=RU/R
print'%s %.1f %s'%("Molecular weight of the mixture in kg/kmol :",MW,"")
#calcualte The oxidizer-to-fuel mixture ratio and The molecular weight of the mixture of gases in the product of combustion in kg/kmol
import math
print("Example 11.5")
f=4.
MW=(2.*18+2*2)/4. ##from equation
print'%s %.1f %s'%("(a)The oxidizer-to-fuel mixture ratio :",f,"")
print'%s %.1f %s'%("(b)The molecular weight of the mixture of gases in the product of combustion in kg/kmol:",MW,"")
import math
print("Example 11.6")
#calculate imporvement in Delv
g=9.8 ##in m/s**2
Is=400. ##in s
delv1=g*Is*math.log(1./0.1) ##for pmf=0.9
delv2=g*Is*math.log(1./0.05) ##for pmf=0.95
delp=(delv2-delv1)/delv1*100.
print'%s %.1f %s'%("% improvement in delv :",delp,"")
import math
#calcualte reduction in terminal speed
print("Example 11.7")
g=9.8 ##in m/s**2
Is=420. ##in s
the=90. ##in degree
tb=30. ##in s
gavg=9.65 ##in m/s**2
MR=0.1
delv1=-g*Is*math.log(MR) ##in m/s
delv2=-g*Is*math.log(MR)-gavg*tb
delp=abs(delv2-delv1)/delv1*100
print'%s %.1f %s'%("% reduction in terminal speed :",delp,"")
import math
print("Example 11.8")
#calculate Terminal speed of rocket vehical excluding gravitatinal effect in m/s
mf=0.8
g=9.8 ##in m/s**2
Is=345. ##in s
delvt=-g*Is*math.log(1-mf)
m=500000. ##in kg
q0=100000. ##in Pa
tb=60. ##in s
Af=20.##in m**2
Cd=0.3 ##mean drag coefficient
delvd=math.log(1-mf)*(Af/m)*q0*(tb/(1-mf))*Cd
delv=delvt+delvd
print'%s %.1f %s'%("Terminal speed of rocket vehical excluding gravitatinal effect in m/s :",delv,"")
import math
#calcualte Effective exhaust speed and propulsive efficiency and Overall efficiency
print("Example 11.9")
g=9.8 ##in m/s**2
Is=421. ##in s
Qr=120000000.
v=5000. ##in m/s
c=g*Is
print'%s %.1f %s'%("(a)Effective exhaust speed c in m/s :",c,"")
ep=2.*(v/c)/(1.+(v/c)**2.)
print'%s %.1f %s'%("(b)propulsive efficiency :",ep,"")
eo=c*v/Qr
print'%s %.1f %s'%("(c)Overall efficiency :",eo,"")
import math
print("Example 11.11")
#calcualte the new chamber pressure and burning rate and the corresponding reduction in burn time
p=7. ##in MPa,
n=0.5 ##and
a=5. ##cm/s
Tdg=15. ##in degree C
Td=15+273 ##in K
br=0.002 ##per degree C
pk=0.004 ##per degree C
t=60.##s,
DT=30. ## temp difference in degree C
pc=p*(1.+pk*DT)
print'%s %.1f %s'%("(a)The new chamber pressure when the initial grain temp. is 45 degree C in MPa",pc,"")
r=a*(pc/p)**n
r=r*(1+br*DT) ##correcting for the effect of the grain temperature on burning rate.
print'%s %.1f %s'%("Burning rate when grain temp. is 45 degree C",r,"")
L=a*t/100.
tb=L*100./r ##time to burn 3m of end burning grain at 5.61cm/s
tbn=t*(p/pc) ##burn time for a constant total impulse
dt=t-tb
print'%s %.1f %s'%("(b)The corresponding reduction in burn time in seconds:",dt,"")
import math
#calculate heat flux and total heat flux and convection heat flux and wall temperature on the gas side
print("Example 11.12")
Tg=2750. ##in K
Ttg=Tg
Tc=300. ## coolant bulk temp. in K
tw=0.002 ##Wall thickness in m
kw=43. ##thermal conductivity of the wall in W/m.C
hg=657. ##Gas side film coefficient in W/m**2K
hc=26000. ##Coolant side film coefficient in W/m**2K
eg=0.05 ##emissivity of the gas
sigma=5.67*10**(-8)##in W/m**2K
Taw=Ttg
rhf=eg*sigma*Tg**4/1000.
print'%s %.1f %s'%("(a)The radiation heat flux in kW/m**2 :",rhf,"")
qw=(Ttg-Tc+(rhf*1000./hg))/((1./hg)+(tw/kw)+(1./hc))/1000.
print'%s %.1f %s'%("(b)The total heat flux in kW/m**2:",qw,"")
qc=qw-rhf
print'%s %.1f %s'%("(c)The convection heat in kW/m**2:",qc,"")
Twg=Taw-qc*1000./hg
print'%s %.1f %s'%("(d)Wall temp. on the gas side in K:",Twg,"")
Twc=Tc+(qw*1000./hc)
print'%s %.1f %s'%("(e)Wall temp. on the coolant side in K:",Twc,"")
import math
#calculate ratio of specific impulse
print("Example 11.13")
Cpg=2006. ##in J/kg.K
Cs=903. ##J/kg.K
X1=0.18
X2=0.16
Tr=1.057
Ir=(((1.-X1)*Cpg+X1*Cs)*Tr/((1.-X2)*Cpg+X2*Cs))**(1/2.) ##Ratio of specific impulse
print'%s %.3f %s'%("Raio of specific impulse :",Ir,"")