def CalcTorqueCoef(self): self.rpm = toRPM(self.angVel) self.rps = self.rpm / 60 self.J = self.vInf / (self.rps * self.diameter / 12) a = fit.poly_func(self.powerCoefs.T, self.rpm) if (a[-1] > 0): #Quadratic coefficient should always be non-positive a[-1] = 0 self.Cl = fit.poly_func(a, self.J) / 2 * np.pi
def CalcThrustCoef(self): self.rpm = toRPM(self.angVel) self.rps = self.rpm/60 if abs(self.rps)<1e-10: self.J = 10000 #To prevent errors. Since angular velocity is 0, actual value w_ill also be 0. else: self.J = self.v_inf/(self.rps*self.diameter/12) a = fit.poly_func(self.thrustCoefs.T, self.rpm) if(a[-1]>0):#Quadratic coefficient should always be non-positive a[-1] = 0 self.Ct = fit.poly_func(a, self.J)
def __init__(self, name, dia, pitch, coefs): self.name = name self.diameter = float(dia) * 0.0254 self.pitch = float(pitch) * 0.0254 self.thrustFitOrder = int(coefs[0]) self.fitOfThrustFitOrder = int(coefs[1]) self.powerFitOrder = int(coefs[2]) self.fitOfPowerFitOrder = int(coefs[3]) numThrustCoefs = (self.thrustFitOrder + 1) * (self.fitOfThrustFitOrder + 1) self.thrustCoefs = coefs[4:numThrustCoefs + 4].reshape( (self.thrustFitOrder + 1, self.fitOfThrustFitOrder + 1)).astype(np.float) self.powerCoefs = coefs[numThrustCoefs + 4:].reshape( (self.powerFitOrder + 1, self.fitOfPowerFitOrder + 1)).astype(np.float) #These parameters will be set by later functions self.vInf = 0.0 self.angVel = 0.0 #Plot thrust and torque coefficients rpms = np.linspace(0, 6000, 10) Js = np.linspace(0, 1.4, 10) fig = plt.figure(figsize=plt.figaspect(1.)) ax = fig.add_subplot(1, 2, 1, projection='3d') for rpm in rpms: a = fit.poly_func(self.thrustCoefs.T, rpm) thrust = fit.poly_func(a, Js) rpmForPlot = np.full(len(thrust), rpm) ax.plot(Js, rpmForPlot, thrust, 'r-') ax.set_title("Predicted Thrust") ax.set_xlabel("Advance Ratio") ax.set_ylabel("RPM") ax.set_zlabel("Thrust Coefficient") ax = fig.add_subplot(1, 2, 2, projection='3d') for rpm in rpms: a = fit.poly_func(self.powerCoefs.T, rpm) power = fit.poly_func(a, Js) rpmForPlot = np.full(len(power), rpm) ax.plot(Js, rpmForPlot, power, 'r-') ax.set_title("Predicted Power") ax.set_xlabel("Advance Ratio") ax.set_ylabel("RPM") ax.set_zlabel("Power Coefficient") plt.show()
def PlotCoefs(self): #Plot thrust and torque coefficients rpms = np.linspace(0, 6000, 10) Js = np.linspace(0, 1.4, 10) fig = plt.figure(figsize=plt.figaspect(1.)) fig.suptitle(self.name) ax = fig.add_subplot(1, 2, 1, projection='3d') for rpm in rpms: a = fit.poly_func(self.thrustCoefs.T, rpm) if (a[-1] > 0): #Quadratic coefficient should always be non-positive a[-1] = 0 thrust = fit.poly_func(a, Js) rpmForPlot = np.full(len(thrust), rpm) ax.plot(Js, rpmForPlot, thrust, 'r-') ax.set_title("Predicted Thrust") ax.set_xlabel("Advance Ratio") ax.set_ylabel("RPM") ax.set_zlabel("Thrust Coefficient") ax = fig.add_subplot(1, 2, 2, projection='3d') for rpm in rpms: a = fit.poly_func(self.powerCoefs.T, rpm) if (a[-1] > 0): #Quadratic coefficient should always be non-positive a[-1] = 0 power = fit.poly_func(a, Js) rpmForPlot = np.full(len(power), rpm) ax.plot(Js, rpmForPlot, power, 'r-') ax.set_title("Predicted Power") ax.set_xlabel("Advance Ratio") ax.set_ylabel("RPM") ax.set_zlabel("Power Coefficient") plt.show()
def CalcThrustCoef(self): self.rpm = toRPM(self.angVel) self.J = self.vInf / (self.rpm * self.diameter) a = fit.poly_func(self.thrustCoefs.T, self.rpm) self.Ct = fit.poly_func(a, self.J)
def CalcTorqueCoef(self): self.rpm = toRPM(self.angVel) self.J = self.vInf / (self.rpm * self.diameter) a = fit.poly_func(self.powerCoefs.T, self.rpm) self.Cl = fit.poly_func(a, self.J) / 2 * np.pi
plt.subplot(1, 2, 2) plt.plot(staticArray[:, 0], staticArray[:, 2]) plt.xlabel("RPM") plt.ylabel("Power Coef") plt.suptitle("Static data for " + propFolder) plt.show() #Fit dynamic data thrustFitArray = np.zeros((rpmCount, thrustFitOrder + 1)) powerFitArray = np.zeros((rpmCount, powerFitOrder + 1)) propCoefDict = {} for rpmIndex in range(rpmCount): staticThrust = fit.poly_func(staticThrustFit, rpms[rpmIndex]) staticPower = fit.poly_func(staticPowerFit, rpms[rpmIndex]) advRatioInit = np.append(0, coefArray[rpmIndex, :, 0]) thrustInit = np.append(staticThrust, coefArray[rpmIndex, :, 2]) powerInit = np.append(staticPower, coefArray[rpmIndex, :, 3]) good = np.where((thrustInit != 0.) & (powerInit != 0.)) advRatio = advRatioInit[good] thrust = thrustInit[good] power = powerInit[good] propCoefDict[rpms[rpmIndex]] = np.asarray( [advRatio, np.zeros(len(advRatio)), thrust, power]).T