Looping for a specified number of iteration

3 次查看(过去 30 天)
clc
clear all
%-------------------------------------------------------------------------%
% Specify the variable %
oil_SAE = 10;
Temp_in = 85; % Sump Temperature (°C)
d = 0.15; % Shaft Journal Diameter (Meter, m)
r = (d/2); % Shaft Journal Radius (Meter, m)
N = (166.69/60); % Shaft Speed (revolution per second,rps)
W = 9000; % Radial Load (Newton, N)
L = 0.3; % Bearing Length (Meter, m)
c = 0.000026; % Bearing clearance (Meter,m)
%-------------------------------------------------------------------------%
% Calculate the variable %
C_ratio = r/c; % Clearance ratio
P = W/(d*L); % Nominal Pressure (Pascal)
Slenderness = L/d ; % Bearing Aspect Ratio
%-------------------------------------------------------------------------%
% Viscosity - Temperature Chart
Temperature = xlsread ('MFT','viscosity-temperature chart','A4:A30');
if oil_SAE == 10
V0 = 0.1089*10^(-3);
b = 1157.5 ;
elseif oil_SAE == 20
V0 = 0.0937*10^(-3);
b = 1271.6;
elseif oil_SAE == 30
V0 = 0.0971*10^(-3);
b = 1360.0;
elseif oil_SAE == 40
V0 = 0.0827*10^(-3);
b = 1474.4;
elseif oil_SAE == 50
V0 = 0.1171*10^(-3);
b = 1509.6;
elseif oil_SAE == 60
V0 = 0.1288*10^(-3);
b = 1564.0;
end
%-------------------------------------------------------------------------%
% Calculation to find average temperature and viscosity %
Tf = Temp_in + 3; % Assumed Average Temperature (°C)
V = V0*exp (b/((1.8*Tf)+127)); % Viscosity (Pa.s)
S = (C_ratio)^2*((V*N)/P); % Sommerfeld Number
if Slenderness == 1
delta_T = (0.349109 + (6.00940*S)+(0.047467*(S^2)))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1
elseif Slenderness == 1/2
delta_T = (0.394552 + (6.392527*S)-(0.036013*(S^2)))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1/2
elseif Slenderness == 1/4
delta_T = 0.933828 + (6.437512*S)- (0.011048*(S^2))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1/4
else
delta_T = ((33405*(S)^6)-(51557*(S)^5)+(30669*(S)^4)-(8871.9*(S)^3)+(1297.4*(S)^2)-(85.088*(S))+2.6111)*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=Infinity
end
T_average = Temp_in + (delta_T/2); % Average temperature (°C)
iter=0;
while iter <= 5 && abs (Tf-T_average)>0.001
iter = iter + 1;
delta = (Tf-T_average)/2;
Tf = Tf-delta;
V = V0*exp (b/((1.8*Tf)+127)); % Viscosity (Pa.s)
S = (C_ratio)^2*((V*N)/P); % Sommerfeld Number
if Slenderness == 1
delta_T = (0.349109 + (6.00940*S)+(0.047467*(S^2)))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1
elseif Slenderness == 1/2
delta_T = (0.394552 + (6.392527*S)-(0.036013*(S^2)))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1/2
elseif Slenderness == 1/4
delta_T = 0.933828 + (6.437512*S)- (0.011048*(S^2))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1/4
else
delta_T = ((33405*(S)^6)-(51557*(S)^5)+(30669*(S)^4)-(8871.9*(S)^3)+(1297.4*(S)^2)-(85.088*(S))+2.6111)*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=Infinity
end
T_average = Temp_in + (delta_T/2); % Average temperature (°C)
disp ('Table for iteration');disp (' c Tf V S deltaT T average ');
format shortG
disp ([c',Tf', V',S',delta_T', T_average'])
end
** I want to loop the iteration as long as Tf-T_average is not in negative value and also not more than 0.001 which is 0 for 5th iteration. If the 5th iteration this is still not satisfied, then I want to increase the c where c=c+0.000001 for the next iteration until Tf-T_average=0. Please help me.Thanks

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by