I would to get my equation to iterate 15 times
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have three equations that are connected to my solution and I need them to iterate 15 times to get a specific solution.
Example here shown in Excle.
The first guess is assigned as Vt_guess and it should calculate the Re, Cd and Vt. after that I want to use the new Vt to be used to calcalute for Re, Cd and the new Vt for 15 times.
My coding:
% Given Temperture and Pressure
T = 308.15; % K - Given Temperture
P = 101.325 ; % kPa - Pressure
% Standard Temperture and Mu at SATP
Ts0 = 298.15; % K
Ts = 110.4; % K
Rair = 0.287; % kJ / kg * K
Mu_s = 1.849*10^-5; % kg/m*s
g = 9.81;
% Calculate Air Density
Pa = P / (Rair * T);
% Viscosity Mu and v
Mu = Mu_s * (T/Ts0)^(3/2) * (Ts0+Ts)/(T+Ts);
v = Mu / Pa;
% lamda - Mean free path
lamda1 = (Mu/0.499) * sqrt(pi/(8*Pa*P*1000)); % Unit m
lamda = lamda1 *10^6; % Unit Mu*m
% Specific Diameters given
Dp1 = 150;
Dp = Dp1 * 10^-6;
%Actual particle Density given.
Pp = 1450; % kg/m^3
% Knudsen number
Kn = lamda1 / Dp;
% Cunningham Correction Factor
C = 1 + Kn * (2.514+0.80*exp(-0.55/Kn));
% Calcualte
Vt_guess = (((Pp-Pa)/18)*Dp^2*g*(C/Mu));
Re = (Pa*Vt_guess*Dp)/Mu;
Cd = (24/Re) + ((2.6*(Re/5.0)) / (1 + (Re/5.0)^1.52)) + ((0.411*(Re/(2.63*10^5))^-7.94) / (1+(Re/(2.63*10^5))^-8)) + ((0.25*(Re/10^6)) / (1+(Re/10^6)));
Vt = sqrt((4/3)*((Pp-Pa)/Pa)*g*Dp*(C/Cd));
0 Commenti
Risposta accettata
Voss
il 27 Mar 2022
format long
% Given Temperture and Pressure
T = 308.15; % K - Given Temperture
P = 101.325 ; % kPa - Pressure
% Standard Temperture and Mu at SATP
Ts0 = 298.15; % K
Ts = 110.4; % K
Rair = 0.287; % kJ / kg * K
Mu_s = 1.849*10^-5; % kg/m*s
g = 9.81;
% Calculate Air Density
Pa = P / (Rair * T);
% Viscosity Mu and v
Mu = Mu_s * (T/Ts0)^(3/2) * (Ts0+Ts)/(T+Ts);
v = Mu / Pa;
% lamda - Mean free path
lamda1 = (Mu/0.499) * sqrt(pi/(8*Pa*P*1000)); % Unit m
lamda = lamda1 *10^6; % Unit Mu*m
% Specific Diameters given
Dp1 = 150;
Dp = Dp1 * 10^-6;
%Actual particle Density given.
Pp = 1450; % kg/m^3
% Knudsen number
Kn = lamda1 / Dp;
% Cunningham Correction Factor
C = 1 + Kn * (2.514+0.80*exp(-0.55/Kn));
% Calcualte
Vt_guess = (((Pp-Pa)/18)*Dp^2*g*(C/Mu))
n_iterations = 0;
while n_iterations < 15
Re = (Pa*Vt_guess*Dp)/Mu;
Cd = (24/Re) + ((2.6*(Re/5.0)) / (1 + (Re/5.0)^1.52)) + ((0.411*(Re/(2.63*10^5))^-7.94) / (1+(Re/(2.63*10^5))^-8)) + ((0.25*(Re/10^6)) / (1+(Re/10^6)));
Vt = sqrt((4/3)*((Pp-Pa)/Pa)*g*Dp*(C/Cd));
n_iterations = n_iterations+1;
Vt_guess = Vt
end
2 Commenti
Voss
il 27 Mar 2022
You're welcome!
Yes, simply remove the semicolon at the end of the lines where they are calculated:
Re = (Pa*Vt_guess*Dp)/Mu % no semicolon now, which displays the value to the Command Window
Cd = (24/Re) + ((2.6*(Re/5.0)) / (1 + (Re/5.0)^1.52)) + ((0.411*(Re/(2.63*10^5))^-7.94) / (1+(Re/(2.63*10^5))^-8)) + ((0.25*(Re/10^6)) / (1+(Re/10^6)))
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Language Fundamentals in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!