forked from hugogarcia06/Patterson_code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeligPropellerRead.py
256 lines (220 loc) · 9.25 KB
/
SeligPropellerRead.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 20 16:29:42 2018
@author: e.nguyen-van
"""
from math import pi
from scipy.interpolate import interp1d
import numpy as np
import sys
class Propu:
# common data go here
rho=1.225
AvGearEff=0.80 # average effiency of engine+gearbox
#definition
def __init__(self, PropDia, PropPas, Ct = 0.05, Cp = 0.07):
#default value 11"10" at J=0.6 wind tunnel on
# PropDia and PropPas in inch and float
self.D=PropDia*0.0254
self.Pas=PropPas
self.Tneg_a = -0.22
self.Tneg_b = 0.22
# linear model for P is extrapolated from selig data.
self.Pneg_a = -0.12
self.Pneg_b = 0.134
# Try to find selig prop data file from here : https://m-selig.ae.illinois.edu/props/propDB.html
DataFileAvailable=True
DiaTest=0
try :
file=open("SeligProp"+str(PropDia)+str(PropPas)+".txt",'r')
except OSError:
print("No data file for this propeller, try different Diameter")
# if a propeller with different diameter but same pitch is found,
#its data are used and imposed diameter used for non-dimensional analysis
# Not the best but ok, because the forces are non-dimensionalised by the diameter. The opposite cannot be done
DiatoTest=5
for i in range(DiatoTest):
try:
DiaTest=PropDia+i
file=open("SeligProp"+str(DiaTest)+str(PropPas)+".txt",'r')
i=DiatoTest
DataFileAvailable=True
break
except OSError:
DataFileAvailable=False
if DataFileAvailable==False:
for i in range(-DiatoTest,0):
try :
DiaTest=PropDia+i
file=open("SeligProp"+str(DiaTest)+str(PropPas)+".txt",'r')
print(DiaTest)
DataFileAvailable=True
break
except OSError:
DataFileAvailable=False
if DataFileAvailable==False:
#conduct analysis with fixed Cp, Ct, know what you do, know where you are on the J interval
print("No data file for this propeller, exit program in SeligPropellerRead")
sys.exit()
else:
if DiaTest!=0:
print("Found data file for prop diameter : {0:0.0f}\"".format(DiaTest))
#read stuff, carefull format
self.Ct=np.array([])
self.Cp=np.array([])
self.J=np.array([])
Heading=file.readlines(1)
Heading_split = Heading[0].split()
Jposi=Heading_split.index('J')
CTposi=Heading_split.index("CT")
CPposi=Heading_split.index("CP")
for line in file:
words=line.split()
if len(words)!=0:
self.J=np.append(self.J,float(words[Jposi]))
self.Ct=np.append(self.Ct,float(words[CTposi]))
self.Cp=np.append(self.Cp,float(words[CPposi]))
file.close()
#self.cpJ3 = self.Cp/self.J**3 # for determination of J from deltax
#Como J[0]^3 es 0, vamos a cambiarlo por 0.0001 en plan chapuza. Intenta probar otro valor que no dispare tanto self.cpJ3
self.J[0]=0.07
self.cpJ3 = self.Cp / self.J ** 3 # for determination of J from deltax
self.Ct_f_J=interp1d(self.J,self.Ct)
self.Cp_f_J=interp1d(self.J,self.Cp)
#Functions
def rpm2rps(self, a):
return a/60
def rps2rpm(self, a):
return a*60
def rpm2rads(self, a):
return a/60*2*pi
def rps2rads(self, a):
return a*2*pi
def rads2rps(self, a):
return a/(2*pi)
def CalcJ(self, n, V):
return V/(self.D*self.rpm2rps(n))
def DetermineJ(self, dx, V, pmax):
# !!! pmax per engine !!!
f=interp1d(self.cpJ3, self.J)
a=np.zeros((len(V)))
for i in range(len(V)):
if (dx[i] * pmax / (self.rho * V[i] ** 3 * self.D ** 2)) > (self.cpJ3[0]):
a[i]=f(self.cpJ3[0])
elif (dx[i] * pmax / (self.rho * V[i] ** 3 * self.D ** 2)) < (self.cpJ3[-1]):
a[i]=f(self.cpJ3[-1])
else:
a[i]=f(dx[i] * pmax / (self.rho * V[i] ** 3 * self.D ** 2))
return a
def getCt(self, n=0, V=0,J=0):
# interpol Ct, works with one vector and a float or two float
#Works either by entering n and V or J not all three
#Examples : self.getCt(8000,15) or self.getCt(J=0.8)
# n in rpm
#V in m/s
if np.size(J) >1:
if np.size(V)>1 or np.size(n)>1:
print("ERROR: in SeligPropeller.getCt, J and V or n array given, only one or the other allowed")
sys.exit()
else:
results=np.array([])
for i in range(len(J)):
if J[i]>=self.J[-2]:
Ctneg = J[i] *self.Tneg_a + self.Tneg_b
results = np.append(results, Ctneg)
else:
try:
results = np.append(results, self.Ct_f_J(J[i]))
except:
results = np.append(results, 0)
return results
elif np.size(n) > 0 :
if np.size(V)!=np.size(n):
print("ERROR: in SeligPropeller.getCt, size of V != size of n.")
sys.exit()
else:
results=np.array([])
J = V/(self.D*self.rpm2rps(n))
if np.size(J)>1:
# loop over J
for i in range(np.size(J)):
if J[i]>=self.J[-2]:
Ctneg = J[i] *self.Tneg_a + self.Tneg_b
results = np.append(results, Ctneg)
else:
try:
results = np.append(results, self.Ct_f_J(J[i]))
except:
results = np.append(results, 0)
else:
if J>=self.J[-2]:
results = J *self.Tneg_a + self.Tneg_b
else:
try:
results = self.Ct_f_J(J)
except:
results = 0
return results
else:
print("Wrong input sequence for getCt, enter either J or n and V different than 0")
return 0
def getCp(self, n=0, V=0, J=0):
# interpol Cp, works with one vector and a float or two float
#Works either by entering n and V or J not all three
#Examples : self.getCt(8000,15) or self.getCt(J=0.8)
#n in rpm
#V in m/s
if np.size(J) >1:
if np.size(V)>1 or np.size(n)>1:
print("ERROR: in SeligPropeller.getCt, J and V or n array given, only one or the other allowed")
sys.exit()
else:
results=np.array([])
for i in range(len(J)):
if J[i]>=self.J[-2]:
Cpneg = J[i] *self.Pneg_a + self.Pneg_b
results = np.append(results, Cpneg)
else:
try:
results = np.append(results, self.Cp_f_J(J[i]))
except:
results = np.append(results, 0)
return results
elif np.size(n) > 0 :
if np.size(V)!=np.size(n):
print("ERROR: in SeligPropeller.getCt, size of V != size of n.")
sys.exit()
else:
J = V/(self.D*self.rpm2rps(n))
if np.size(J)>1:
for i in range(len(J)):
if J[i]>=self.J[-2]:
Cpneg = J[i] *self.Pneg_a + self.Pneg_b
results = np.append(results, Cpneg)
else:
try:
results = np.append(results, self.Cp_f_J(J[i]))
except:
results = np.append(results, 0)
else:
if J>=self.J[-2]:
results = J *self.Pneg_a + self.Pneg_b
else:
try:
results = self.Cp_f_J(J)
except:
results = 0
return results
else:
print("Wrong input sequence for getCp, enter either J or n and V different than 0")
return 0
def Thrust(self,n,V):
#compute thurst at given regime and velocity
#n in rpm
return self.getCt(n,V)*self.rho*self.D**4*self.rpm2rps(n)**2
def PropPower(self,n,V):
#compute thurst at given regime and velocity
#n in rpm
return self.getCp(n,V)*self.rho*self.D**5*self.rpm2rps(n)**3
def getn(self, J, V):
return V/(self.D*J)