function ramjetPicture = astramjet
%  ASTRAMJET is a helper function that is used to plot a schematic of a
%  ramjet engine in the example ASTHEATTRANSFER.

%   Copyright 2009-2012 The MathWorks, Inc.

x0 = 0; x1 = .1; x2 = .2; x3 = .3; x4 = .325; x5 = .35; x6 = .55; x7 = .75; x8 = 1;
y0 = 0; y1 = .08; y2 = .0825; y3 = .07; y4 = .02; y5 = .06; y6 = .12; y7 = .08; y8 = .12;

% Diffuser
diffuser1x = [x0 x2]; diffuser1y = [y0 y2];
diffuser2x = [x2 x3]; diffuser2y = [y2 y3];
diffuser3x = [x3 x3]; diffuser3y = [y3 y0];

% Flame Holders
flamex = [x4 x5];
flame1y = [y0 y4]; flame2y = [y5 y5-y4]; flame3y = [y5 y5+y4];

% Engine wall
wall1x = x1:0.001:x5; 
wall1y = y1 + (y6 - y1) * sqrt( 1/(x5 - x1) * (wall1x - x1) );
wall2x = [x5 x6]; wall2y = [y6 y6];
wall3x = [x6 x7]; wall3y = [y6 y7];
wall4x = [x7 x8]; wall4y = [y7 y8];

% Shocks
shock1x = [x0 x2]; shock1y = [y0 4*y2];
shock2x = [x1 0.11366]; shock2y = [y1 0.046885];

% Plot

ramjetPicture = figure('name','ramjetPicture');

plot(wall1x,  wall1y, 'k', wall2x,  wall2y, 'k', wall3x,  wall3y, 'k', wall4x,  wall4y, 'k', ...
     wall1x, -wall1y, 'k', wall2x, -wall2y, 'k', wall3x, -wall3y, 'k', wall4x, -wall4y, 'k', 'lineWidth', 3)

hold on
plot(diffuser1x,  diffuser1y, 'k', diffuser2x,  diffuser2y, 'k', diffuser3x,  diffuser3y, 'k', ...
     diffuser1x, -diffuser1y, 'k', diffuser2x, -diffuser2y, 'k', diffuser3x, -diffuser3y, 'k', 'lineWidth', 2)

plot(flamex,  flame1y, 'r', flamex,  flame2y, 'r', flamex,  flame3y, 'r', ...
     flamex, -flame1y, 'r', flamex, -flame2y, 'r', flamex, -flame3y, 'r', 'lineWidth', 2)

plot(shock1x, shock1y, 'b', shock2x, shock2y, 'b', shock1x, -shock1y, 'b', shock2x, -shock2y, 'b')

axis([-.1 1.1 -.4 .4])

set(gca, 'Ytick',[], 'Xtick', [x1 x5 x6 x8], 'XtickLabel',{'enter (RJ)', 'inlet (CC)', 'outlet (CC)', 'exit (RJ)'})

hold off
