import math
#calculate the polyefficency and overall total to total efficiency
##given data
gamma = 1.4;
pi = 8.;##pressure ratio
T01 = 300.;##inlet temperature in K
T02 = 586.4;##outlet temperature in K
##Calculations
##Calculation of Overall Total to Total efficiency
Tot_eff = ((pi**((gamma-1.)/gamma))-1.)/((T02/T01)-1.);
##Calculation of polytropic efficiency
Poly_eff = ((gamma-1.)/gamma)*((math.log(pi))/math.log(T02/T01));
##Results
print'%s %.2f %s'%('The Overall total-to-total efficiency is ',Tot_eff,'');
print'%s %.2f %s'%('The polytropic efficiency is ',Poly_eff,'');
import math
#calculate the
##given data
T01 = 1200.;##Stagnation temperature at which gas enters in K
p01 = 4.;##Stagnation pressure at which gas enters in bar
c2 = 572.;##exit velocity in m/s
p2 = 2.36;##exit pressure in bar
Cp = 1.160*1000.;##in J/kgK
gamma = 1.33
##calculations
T2 = T01 - 0.5*(c2**2)/Cp;##Calculation of exit temperature in K
Noz_eff = ((1.-(T2/T01))/(1.-(p2/p01)**((gamma-1.)/gamma)));##Nozzle efficiency
##Results
print'%s %.2f %s'%('Nozzle efficiency is ',Noz_eff,'');
import math
#calculate the
##given data
cp = 0.6;##coefficient of pressure
AR = 2.13;##Area ratio
N_R1 = 4.66;
##calculations
cpi = 1. - (1./(AR**2));
Diff_eff = cp/cpi;##diffuser efficiency
theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle
##Results
print'%s %.2f %s'%('cpi = \n',cpi,'');
print'%s %.2f %s'%('The included cone angle can be found = ',theta,' deg.');
import math
#calculate the
##given data
AR = 1.8;##Area ratio
cp = 0.6;##coefficient of pressure
N_R1 = 7.85;
##calculations
Theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle
cpi = 1.-(1./(AR**2));
Diff_eff = cp/cpi;##diffuser efficeincy
##Results
print'%s %.2f %s'%('The included cone angle can be found = ',Theta,' deg.\n');
print'%s %.2f %s'%('cpi = \n',cpi,'');
print'%s %.2f %s'%('Diffuser efficiency = ',Diff_eff,'');
import math
#calculate the
##given data
AR = 2.0;##Area ratio
alpha1 = 1.059;
B1 = 0.109;
alpha2 = 1.543;
B2 = 0.364;
cp = 0.577;##coefficient of pressure
##calculations
cp = (alpha1 - (alpha2/(AR**2))) - 0.09;
Diff_eff = cp/(1.-(1./(AR**2)));##Diffuser efficiency
##Results
print'%s %.2f %s'%('The diffuser efficiency = ',Diff_eff,'');