1function isentropic(g) 2% ISENTROPIC isentropic, adiabatic flow example 3% 4% In this example, the area ratio vs. Mach number curve is 5% computed for a hydrogen/nitrogen gas mixture. 6% 7help isentropic 8 9if nargin == 1 10 gas = g; 11else 12 gas = Solution('gri30.yaml'); 13end 14 15% set the stagnation state 16set(gas,'T',1200.0,'P',10.0*oneatm,'X','H2:1,N2:0.1'); 17s0 = entropy_mass(gas); 18h0 = enthalpy_mass(gas); 19p0 = pressure(gas); 20 21mdot = 1; % arbitrary 22 23mach = []; 24a = []; 25i = 1; 26amin = 1.e14; 27 28% compute values for a range of pressure ratios 29for r = 0.005:0.0025:0.995 30 p = p0*r; 31 32 % set the state using (p,s0) 33 set(gas,'P',p,'S',s0); 34 35 h = enthalpy_mass(gas); 36 rho = density(gas); 37 38 v2 = 2.0*(h0 - h); % h + V^2/2 = h0 39 v = sqrt(v2); 40 a(i) = mdot/(rho*v); % rho*v*A = constant 41 42 if a(i) < amin 43 amin = a(i); 44 end 45 mach(i) = v/soundspeed(gas); 46 i = i + 1; 47end 48 49a = a/amin; 50 51% plot results 52 53clf; 54plot(mach,a); 55ylabel('Area Ratio'); 56xlabel('Mach Number'); 57title('Isentropic Flow: Area Ratio vs. Mach Number'); 58