diff --git a/modules/aerodyn/src/AirfoilInfo.f90 b/modules/aerodyn/src/AirfoilInfo.f90 index e11f3b8656..717c8596b2 100644 --- a/modules/aerodyn/src/AirfoilInfo.f90 +++ b/modules/aerodyn/src/AirfoilInfo.f90 @@ -990,6 +990,8 @@ SUBROUTINE CalculateUACoeffs(CalcDefaults,p,ColCl,ColCd,ColCm,ColUAf,UAMod) ! find bounding indices for limitAlphaRange iHighLimit = min( maxloc( alpha_ , DIM=1, MASK=alpha_ < LimitAlphaRange) + 1, size(alpha_) ) ! we can limit this to some range iLowLimit = max( minloc( alpha_ , DIM=1, MASK=alpha_ > -LimitAlphaRange) - 1, 1 ) ! we can limit this to some range + if (iHighLimit - iLowLimit < 3) iHighLimit = min(iLowLimit+2,size(alpha_)) ! this could still be an issue if we don't have very many points in the airfoil table. If that's the case, this data is not worth anything anyway + if (iHighLimit - iLowLimit < 3) iLowLimit = max(iHighLimit-2,1) ! this could still be an issue if we don't have very many points in the airfoil table. If that's the case, this data is not worth anything anyway ! find alphaUpper (using smoothed Cn values): if (CalcDefaults%alphaUpper) then @@ -1053,12 +1055,12 @@ SUBROUTINE CalculateUACoeffs(CalcDefaults,p,ColCl,ColCd,ColCm,ColUAf,UAMod) !mask = p%alpha >= p%UA_BL%alphaLower+alphaMargin & p%alpha <= p%UA_BL%alphaUpper-alphaMargin; iLow2 = iLowLimit - do while (iLow2 < iHighLimit .and. p%alpha(iLow2) < p%UA_BL%alphaLower + alphaMargin) + do while (iLow2 < iHighLimit-1 .and. p%alpha(iLow2) < p%UA_BL%alphaLower + alphaMargin) iLow2 = iLow2 + 1 end do iHigh2 = iHighLimit - do while (iHigh2 > iLowLimit .and. p%alpha(iHigh2) > p%UA_BL%alphaUpper - alphaMargin) + do while (iHigh2 > iLow2+1 .and. p%alpha(iHigh2) > p%UA_BL%alphaUpper - alphaMargin) iHigh2 = iHigh2 - 1 end do @@ -1181,6 +1183,15 @@ SUBROUTINE Calculate_C_alpha(alpha, Cn, Cl, Default_Cn_alpha, Default_Cl_alpha, REAL(ReKi) :: A( size(alpha), 2) REAL(ReKi) :: B(max(2,size(alpha)),2) + if (SIZE(B,1) < 2) then + ErrMsg='Calculate_C_alpha: Not enough data points to compute Cn and Cl slopes.' + ErrStat=ErrID_Fatal + Default_Cn_alpha = EPSILON(Default_Cn_alpha) + Default_Cl_alpha = EPSILON(Default_Cl_alpha) + Default_alpha0 = 0.0_ReKi + return + end if + A(:,1) = alpha A(:,2) = 1.0_ReKi