Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 046b6cc

Browse files
authored
Merge pull request #70 from ptrbortolotti/dev
fcl non negative, try except around 3d corrections
2 parents 3f4fce7 + b7a4bf2 commit 046b6cc

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

pyFAST/airfoils/Polar.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

pyFAST/converters/hawc2ToOpenfast.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,15 @@ def AE_PC_C2_toAD(ae_filename, pc_filename, blade_c2def, r_AD=None, ADbldFilenam
192192
P = Polar(Re=Re, alpha=vAlpha, cl=M[:,1], cd=M[:,2], cm=M[:,3], radians=False)
193193
# Apply 3D correction
194194
if r>0 and correction3D:
195-
P = P.correction3D(
196-
r_over_R = r/r_max,
197-
chord_over_r = c/r,
198-
tsr=tsr,
199-
lift_method="DuSelig", drag_method="None", blending_method="linear_25_45",
200-
max_cl_corr=0.25)
195+
try:
196+
P = P.correction3D(
197+
r_over_R = r/r_max,
198+
chord_over_r = c/r,
199+
tsr=tsr,
200+
lift_method="DuSelig", drag_method="None", blending_method="linear_25_45",
201+
max_cl_corr=0.25)
202+
except:
203+
print('3D correction not applied at station ', ir)
201204

202205
# Store polars
203206
M = np.column_stack((P.alpha, P.cl, P.cd, P.cm))

0 commit comments

Comments
 (0)