refactor [airfoilpolars]: faster interpolation with scipy interp1d
import numpy as np
# import sharpy.utils.algebra as algebra
from sharpy.utils.constants import deg2rad
+from scipy.interpolate import interp1d
class Polar:
@@ -51,11 +52,15 @@ class Polar:
iaoacl0 = imin
self.aoa_cl0_deg = matches[iaoacl0]
+ self.cl_interp = interp1d(self.table[:, 0], self.table[:, 1])
+ self.cd_interp = interp1d(self.table[:, 0], self.table[:, 2])
+ self.cm_interp = interp1d(self.table[:, 0], self.table[:, 3])
+
def get_coefs(self, aoa_deg):
- cl = np.interp(aoa_deg, self.table[:, 0], self.table[:, 1])
- cd = np.interp(aoa_deg, self.table[:, 0], self.table[:, 2])
- cm = np.interp(aoa_deg, self.table[:, 0], self.table[:, 3])
+ cl = self.cl_interp(aoa_deg)
+ cd = self.cd_interp(aoa_deg)
+ cm = self.cm_interp(aoa_deg)
return cl, cd, cm
