@@ -394,8 +394,11 @@ def correction3D(
394394 / cl_slope
395395 * (1.6 * chord_over_r / 0.1267 * (a - chord_over_r ** expon ) / (b + chord_over_r ** expon ) - 1 )
396396 )
397+ # Force fcl to stay non-negative
398+ if fcl < 0. :
399+ fcl = 0.
397400 else :
398- fcl = 1 .0
401+ fcl = 0 .0
399402 elif lift_method == "Snel" :
400403 # Snel correction
401404 fcl = 3.0 * chord_over_r ** 2.0
@@ -730,7 +733,7 @@ def unsteadyParams(self, window_offset=None, nMin=720):
730733 else :
731734 window = [- 20 , 20 ]
732735 try :
733- alpha0cn = _find_alpha0 (alpha , cn , window , direction = 'up' )
736+ alpha0cn = _find_alpha0 (alpha , cn , window , direction = 'up' , value_if_constant = 0. )
734737 except NoCrossingException :
735738 print ("[WARN] Polar: Cn unsteady, cannot find zero crossing with up direction, trying down direction" )
736739 alpha0cn = _find_alpha0 (alpha , cn , window , direction = 'down' )
@@ -1265,17 +1268,17 @@ def _alpha_window_in_bounds(alpha, window):
12651268 return window
12661269
12671270
1268- def _find_alpha0 (alpha , coeff , window , direction = 'up' ):
1271+ def _find_alpha0 (alpha , coeff , window , direction = 'up' , value_if_constant = np . nan ):
12691272 """Finds the point where coeff(alpha)==0 using interpolation.
12701273 The search is narrowed to a window that can be specified by the user. The default window is yet enough for cases that make physical sense.
12711274 The angle alpha0 is found by looking at a zero up crossing in this window, and interpolation is used to find the exact location.
12721275 """
12731276 # Constant case or only one value
1274- if np .all (coeff == coeff [0 ]) or len (coeff ) == 1 :
1277+ if np .all (abs (( coeff - coeff [0 ]) < 1e-8 ) ) or len (coeff ) == 1 :
12751278 if coeff [0 ] == 0 :
12761279 return 0
12771280 else :
1278- return np . nan
1281+ return value_if_constant
12791282 # Ensuring window is within our alpha values
12801283 window = _alpha_window_in_bounds (alpha , window )
12811284
0 commit comments