clear all;

% Lower and upper bounds of input parameters

hgas  = [1500, 4500];    % TBC-gas heat transfer coef. (W/(m^2 K))
Tgas  = [1500, 2500];    % Mixed gas temperature (K)
ktbc  = [1.0, 1.3];      % TBC   thermal conduct. (W/mK)
Ltbc  = [0.00025, 0.00075];  % TBC   thickness (m)
km    = [20.0, 22.0];    % Metal thermal conduct. (W/mK)
Lm    = [0.003, 0.005];  % Metal thickness (m)
hcool = [1000, 2000];    % Coolant-metal heat transfer
                         % coef. (W/(m^2 K)
Tcool = [ 600, 800];     % Coolant temperature (K)

% Place parameter bounds into a vector

Pbound = [hgas; ...
	  Tgas; ...
	  ktbc; ...
	  Ltbc; ...
	  km; ...
	  Lm; ...
	  hcool; ...
	  Tcool];

% Number of Monte Carlo trials
N = 10000;

for n = 1:N,
  
  % generate Ltbc values using a uniform distribution

  P(:,n) = Pbound(:,1) + (Pbound(:,2)-Pbound(:,1)).*rand(8,1);

  % Solve heat transfer problem

  [Ttbc, Tmh(n), Tmc, q] = blade1D(P(1,n), P(2,n), P(3,n), P(4,n), ...
				   P(5,n), P(6,n), P(7,n), P(8,n));

end

figure(1);
hist(Tmh,20);
xlabel('T_{mh} (K)');

fprintf('Mean Tmh = %6.1f\n',mean(Tmh));
