- Jul 20, 2004
- 706
- 1
- 81
This is some Matlab code that my group has been working on. None of us really code all that much, and have only had one year of Comp Sci. It doesn't help that this is all our our first times using Matlab, either. :/
The problem is calculating a value for a and aPrime. We're trying to use recursion to calculate the correct value for them. The way it's supposed to work:
wRelative : defined in terms of a and aPrime
phi : defined in terms of a and wRelative
alpha : defined in terms of phi
a is calculated based on an equation we were given in terms of phi
aPrime is calculated based on an equation we were given in terms of phi
What I'm trying to do is calculate a value for 'a' (and aPrime). I use 'a' to calculate phi, and then use phi to calculate 'a'. I want it to constantly re-calculate 'a' and phi so that it converges to a specific value. However, instead of the values converging, they just alternate between 2 values (values with a fairly large difference). Can someone try and pinpoint our error? Thanks.
What I'm trying to do is calculate a value for 'a' (and aPrime). I use 'a' to calculate phi, and then use phi to calculate 'a'. I want it to constantly re-calculate 'a' and phi so that it converges to a specific value.
*If anyone can tell me why my code is posting improperly, that'd be great. For some reason it's not retaining the proper spacing in the "attach code" window.
while(aBMT < 1)% (abs(aDif) > .1) && (abs(aPrimeDif) > .1)) Finds values for a and a' such that they are within .1% of the last recursion
%*PROBLEM HERE v*
wRelative = sqrt(windSpeed^2 * (1-aBMT)^2 + (w^2*r^2) * (1 + aPrimeBMT)^2);
phiRad = asin((windSpeed * (1-aBMT))/wRelative);
phi = phiRad * (180/pi);
alpha = phi - beta;
%*PROBLEM HERE ^*
%FINDING CL
if(alpha>0 && alpha <= 8)
Cl = -0.0001*alpha^5 + 0.0016*alpha^4 - 0.0093*alpha^3 + 0.0219*alpha^2 + 0.0928*alpha + 0.0006;
elseif(alpha > 8 && alpha <= 27)
Cl = -.00001*alpha^2 + 0.0542*alpha - 0.5037;
elseif(alpha > 27 && alpha <= 90)
Cl = -.00000009*alpha^4 + .00003*alpha^3 - 0.0036*alpha^2 + 0.1761*alpha - 1.8521;
else
Cl=0;
end
%FINDING CD
if(alpha >= 0 && alpha <= 8)
Cd = -.00001*alpha^3 + 0.0003*alpha^2 - 0.0003*alpha + 0.0134;
elseif(alpha > 8 && alpha <= 90)
Cd = -.0000000004*alpha^5 + .0000002*alpha^4 - .00003*alpha^3 + 0.0018*alpha^2 - 0.0196*alpha + 0.1616;
else
Cd = 0;
end
sigma = numBlades * chord / (2 * pi * r);
%*PROBLEM HERE v*
aBMT = (1 / (1 + (4*sin(phi)^2) / (Cl * sigma * cos(phi))));
aPrimeBMT = (1 / ((4*cos(phi)) / (Cl * sigma))-1)
%*PROBLEM HERE ^*
end
The problem is calculating a value for a and aPrime. We're trying to use recursion to calculate the correct value for them. The way it's supposed to work:
wRelative : defined in terms of a and aPrime
phi : defined in terms of a and wRelative
alpha : defined in terms of phi
a is calculated based on an equation we were given in terms of phi
aPrime is calculated based on an equation we were given in terms of phi
What I'm trying to do is calculate a value for 'a' (and aPrime). I use 'a' to calculate phi, and then use phi to calculate 'a'. I want it to constantly re-calculate 'a' and phi so that it converges to a specific value. However, instead of the values converging, they just alternate between 2 values (values with a fairly large difference). Can someone try and pinpoint our error? Thanks.
What I'm trying to do is calculate a value for 'a' (and aPrime). I use 'a' to calculate phi, and then use phi to calculate 'a'. I want it to constantly re-calculate 'a' and phi so that it converges to a specific value.
*If anyone can tell me why my code is posting improperly, that'd be great. For some reason it's not retaining the proper spacing in the "attach code" window.
while(aBMT < 1)% (abs(aDif) > .1) && (abs(aPrimeDif) > .1)) Finds values for a and a' such that they are within .1% of the last recursion
%*PROBLEM HERE v*
wRelative = sqrt(windSpeed^2 * (1-aBMT)^2 + (w^2*r^2) * (1 + aPrimeBMT)^2);
phiRad = asin((windSpeed * (1-aBMT))/wRelative);
phi = phiRad * (180/pi);
alpha = phi - beta;
%*PROBLEM HERE ^*
%FINDING CL
if(alpha>0 && alpha <= 8)
Cl = -0.0001*alpha^5 + 0.0016*alpha^4 - 0.0093*alpha^3 + 0.0219*alpha^2 + 0.0928*alpha + 0.0006;
elseif(alpha > 8 && alpha <= 27)
Cl = -.00001*alpha^2 + 0.0542*alpha - 0.5037;
elseif(alpha > 27 && alpha <= 90)
Cl = -.00000009*alpha^4 + .00003*alpha^3 - 0.0036*alpha^2 + 0.1761*alpha - 1.8521;
else
Cl=0;
end
%FINDING CD
if(alpha >= 0 && alpha <= 8)
Cd = -.00001*alpha^3 + 0.0003*alpha^2 - 0.0003*alpha + 0.0134;
elseif(alpha > 8 && alpha <= 90)
Cd = -.0000000004*alpha^5 + .0000002*alpha^4 - .00003*alpha^3 + 0.0018*alpha^2 - 0.0196*alpha + 0.1616;
else
Cd = 0;
end
sigma = numBlades * chord / (2 * pi * r);
%*PROBLEM HERE v*
aBMT = (1 / (1 + (4*sin(phi)^2) / (Cl * sigma * cos(phi))));
aPrimeBMT = (1 / ((4*cos(phi)) / (Cl * sigma))-1)
%*PROBLEM HERE ^*
end
