我正在运行一个非常简单的代码,但它花了很多时间,原因是什么。
for k2=1:length(Num)
for k=1:length(W)
thrust=0.0;
torque=0.0;
a1=a_tot(k,:);
b1=b_tot(k,:);
for i=1:size(dr,2)
翼型截面的%loop%
d1=1;
n=1;
d2=1;
dr(i);
%setting the element length%
a=0.0;b=0.0;
fin=0;
%它是解决非线性方程式的迭代方法%
while (fin==0),
%iterating for the values of the coefficients a & b%
V=(1+a)*V_inf;
Wf=(1-b)*W(k)*dr(i);
Vlocal=sqrt(V^2+Wf^2);
theta=atand(V/Wf);
pha=B-theta;
Cl_n=interp1(alpha,Cl,pha,"extrap");
Cd_n=interp1(alpha,Cd,pha,"extrap");
%从问题%
中未包含的文本文件中查找值 Cn(k)=Cl_n*cosd(theta)-Cd_n*sind(theta);
Ct(k)=Cl_n*sind(theta)+Cd_n*cosd(theta);
sigma_r(i,k2)=((c*Num(k2))/(2*pi*dr(i)));
a_new=1/(((4*sind(theta)^2)/(sigma_r(k2,i)*Cn(k))-1));
b_new=1/(((4*sind(theta)*cosd(theta))/(sigma_r(k2,i)*Ct(k))+1));
d1=abs(a_new-a);
d2=abs(b_new-b);
if (d1<1e-5 && d1>0) && (d2<1e-5 && d2>0)
fin=1;
endif;
n++;
a=a_new;
b=b_new;
if(n==5000)
fin=1;
endif;
endwhile;
a1(i)=a_new;
b1(i)=b_new;
DT(i)=0.5*r*Vlocal^2*c*((Cl_n*cosd(theta)) - (Cd_n*sind(theta)))*Num(k2);
DQ(i)=0.5*r*Vlocal^2*c*((Cl_n*sind(theta)) +(Cd_n*cosd(theta)))*Num(k2)*dr(i);
thrust=thrust+(DT(i)*r_step);%rad_1)
torque=torque+(DQ(i)*r_step);%rad_1)
endfor;
thrust_tot(k,k2)=thrust;
torque_tot(k,k2)=torque;
%将前一个等式中的值组合成矩阵%
disp('thrust');
disp(thrust_tot(k));
disp('torque');
disp(torque_tot(k));
C_T(k,k2)=thrust/(r*n_rev(k)^2*D^4);
C_Q(k,k2)=torque/(r*n_rev(k)^2*D^5);
J(k,k2)=V_inf/(n_rev(k)*D);#
if (C_T(k,k2)<0),
eff(k,k2)=0;
else
eff(k,k2)=C_T(k,k2)/C_Q(k,k2)*J(k,k2)/(2*pi)
end;
a_tot(k,:)=a1;b_tot(k,:)=b1;
end;
end;
它在我添加第二个for循环((k2))之前工作正常,但现在需要很长时间