Question:
Estimate the uncertainty in drag coefficient for the same conditions as below, but using a Monte Carlo code with Gaussian distributions for each variable. Write your own code and use at least 10,000 iterations to ensure convergence of statistics. You may employ the large sample assumption for determining t. Optional challenge: can you write a concise Monte Carlo code in Matlab without using a for-loop? Be sure to include a copy of your code with your results. Estimate the uncertainty in drag coefficient of a circular cylinder at the following conditions. Provide your answer as CD ± UCD, as well as UCD/CD.
D = 1 lb (drag force) UD = 0.02 lb
V = 50 ft/s (freestream velocity) UV = 0.5 ft/s
P = 14.69 psia (freestream static pressure) UP / P = 0.001
T = 70F (freestream temperature) UT / T = 0.01
d = 2 inches (cylinder diameter) Ud = 0.1 inch
L = 2 ft (cylinder length) UL = 0.1 inch
Answer:
MATLAB Script:
%% This code solves (Montecarlo simulation)
% Author : Arif Hossain - 02/03/2016
clear all
close all
R = 287;
tau = 1.96; % considering 95% confidence
for i = 1:10000
D(i) = 4.448 + (0.0889/tau)*randn(1);
V(i) = 15.24 + (0.152/tau)*randn(1);
T(i)= 294.11 + (2.94/ tau)*randn(1);
P(i) = 101283.93 + (101.2839/ tau)*randn(1);
d(i) = 0.0508 + (0.00254/ tau)*randn(1);
L(i) = 0.6096 + (0.00254/ tau)*randn(1);
Cd(i) = (2*R*D(i)*T(i))/(P(i)*(V(i).^2)*d(i)*L(i));
end
mean(Cd)
std(Cd)
%% Histogram
hist(Cd,75)
set(gca,'fontsize',12,'fontweight','bold')
xlabel('Cd')
grid on
xlim([0.9 1.15])
%% Alternate method
R = 287;
tau = 1.96; % considering 95% confidence
count = 10000;
D = 4.448 + (0.0889/ tau)*randn(count,1);
V = 15.24 + (0.152/ tau)*randn(count,1);
T = 294.11 + (2.94/ tau)*randn(count,1);
P = 101283.93 + (101.2839/ tau)*randn(count,1);
d = 0.0508 + (0.00254/ tau)*randn(count,1);
L = 0.6096 + (0.00254/ tau)*randn(count,1);
Cd_new = (2*R.*D.*T)./(P.*(V.^2).*d.*L);
mean(Cd_new)
std(Cd_new)