Skip to content

Commit

Permalink
Add load_from_txt
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Sep 6, 2019
1 parent 5db06cb commit 48df286
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion WTC_toolbox/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,50 @@ def load_from_ccblade(self,fast):
self.ct_interp = interpolate.interp2d(pitch_initial, TSR_initial, np.transpose(CT), kind='cubic')
self.cq_interp = interpolate.interp2d(pitch_initial, TSR_initial, np.transpose(CQ), kind='cubic')


def load_from_txt(self,fast,txt_filename):
print('Loading rotor performace data from text file:', txt_filename)

# Assign variables
CP = []
CT = []
CQ = []

with open(txt_filename) as pfile:
for line in pfile:
# Read Blade Pitch Angles (degrees)
if line.__contains__('Pitch angle'):
# Beta.append(pfile.readline())
pitch_initial = np.array([float(x) for x in pfile.__next__().strip().split()])

# Read Tip Speed Ratios (rad)
if line.__contains__('TSR'):
TSR_initial = np.array([float(x) for x in pfile.__next__().strip().split()])

# Read Power Coefficients
if line.__contains__('Power'):
pfile.__next__()
for tsr_i in range(len(TSR_initial)):
CP = np.append(CP,np.array([float(x) for x in pfile.__next__().strip().split()]))
CP = np.reshape(CP, (len(TSR_initial),len(pitch_initial)))

# Read Thrust Coefficients
if line.__contains__('Thrust'):
pfile.__next__()
for tsr_i in range(len(TSR_initial)):
CT = np.append(CT,np.array([float(x) for x in pfile.__next__().strip().split()]))
CT = np.reshape(CT, (len(TSR_initial),len(pitch_initial)))

# Read Troque Coefficients
if line.__contains__('Torque'):
pfile.__next__()
for tsr_i in range(len(TSR_initial)):
CQ = np.append(CQ,np.array([float(x) for x in pfile.__next__().strip().split()]))
CQ = np.reshape(CQ, (len(TSR_initial),len(pitch_initial)))

# # Form the interpolant functions which can look up any arbitrary location
self.cp_interp = interpolate.interp2d(pitch_initial, TSR_initial, CP, kind='cubic',bounds_error=False)
self.ct_interp = interpolate.interp2d(pitch_initial, TSR_initial, CT, kind='cubic')
self.cq_interp = interpolate.interp2d(pitch_initial, TSR_initial, CQ, kind='cubic')


# # NOT CERTAIN OF THESE ALTERNATIVES YET
Expand Down

0 comments on commit 48df286

Please sign in to comment.