Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ECheynet authored Mar 15, 2023
1 parent 8bdba43 commit baf4445
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 43 deletions.
81 changes: 38 additions & 43 deletions RUN_ME.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,75 +12,70 @@
import shutil
import glob
import re
import pandas as pd
##

filename = 'driver_EX1'

if not os.path.exists('outputFiles'):
os.makedirs('outputFiles')


# %%
os.system('bin/AeroDyn_Driver_x64 ' + filename + '.dvr') #Execute the AeroDyn driver

os.system(r'.\bin\AeroDyn_Driver_x64 ' + filename + '.dvr') #Execute the AeroDyn driver

# %%
# Moves the output files into the correct folder
sourcepath = os.getcwd()
target_folder = './outputFiles'
target_folder = r'./outputFiles'
sourcefiles = '*.out'
filelist=glob.glob(sourcefiles)
for single_file in filelist:
shutil.move(os.path.join(sourcepath, single_file), os.path.join(target_folder, single_file))
# %%

# Number of cases simulated
filelist=glob.glob(target_folder + '/' + sourcefiles)
NumCases=len(filelist)

# Preallocation
TSR_curve=[0]*NumCases
Cp_curve=[0]*NumCases
Ct_curve=[0]*NumCases
thrust_curve=[0]*NumCases
speed_curve=[0]*NumCases
wndspeed=[0]*NumCases
power_curve=[0]*NumCases
TSR_curve=np.zeros([NumCases])
Cp_curve=np.zeros([NumCases])
Ct_curve=np.zeros([NumCases])
thrust_curve=np.zeros([NumCases])
speed_curve=np.zeros([NumCases])
wndspeed=np.zeros([NumCases])
power_curve=np.zeros([NumCases])

for i in range (1,NumCases):
for i in range (NumCases):

myFile = r'./outputFiles/' + filename + '.'+ str(i+1) + '.out'

outputfile= np.loadtxt('./outputFiles/'+filename + '.'+ str(i) + '.out',
skiprows=4, max_rows = 1,unpack=True, delimiter=';',
dtype={'names': ('case', 'wndspeed'),'formats': ('|S25', '|S15')})


a = outputfile[0].tostring()
a = a.decode('utf-8')
a = (re.findall( r'\d+\.*\d*', a))
# Read wind speed
s = pd.read_csv(myFile, skiprows=3, nrows=2)
a = (re.findall( r'\d+\.*\d*', str(s.head())))
wndspeed[i] = float(a[1])

outputfile= np.loadtxt('./outputFiles/'+filename + '.'+ str(i) + '.out', skiprows=9,
unpack=True,
dtype={'names': ('time', 'speed', 'TSR','power', 'thrust', 'Cp', 'Ct'),
'formats': ('f8', 'f8', 'f8', 'f8', 'f8', 'f8' ,'f8')})

# Read outputs
s = pd.read_csv(myFile, header=5, sep='\s+')
outputfile = np.array(s)
time= outputfile[:,0]
ind = np.argmin(np.abs(time-8)) # read only the last 2 seconds

speed_curve[i]= np.mean(outputfile[ind:-1,1])
TSR_curve[i]= np.mean(outputfile[ind:-1,2])
power_curve[i]= np.mean(outputfile[ind:-1,3])
thrust_curve[i]= np.mean(outputfile[ind:-1,4])
Cp_curve[i]= np.mean(outputfile[ind:-1,5])
Ct_curve[i]= np.mean(outputfile[ind:-1,6])



time= np.array(outputfile[0], copy=True)
speed= np.array(outputfile[1], copy=True)
TSR= np.array(outputfile[2], copy=True)
power= np.array(outputfile[3], copy=True)
thrust= np.array(outputfile[4], copy=True)
Cp= np.array(outputfile[5], copy=True)
Ct= np.array(outputfile[6], copy=True)

TSR_curve[i] = np.mean(TSR) #Save the mean values at each case number in an array
Cp_curve[i] = np.mean(Cp)
Ct_curve[i] = np.mean(Ct)
thrust_curve[i] = np.mean(thrust)
speed_curve[i] = np.mean(speed)
power_curve[i] = np.mean(power)


#Remove the zeros in the first position on each array
TSR_curve.remove(0)
Cp_curve.remove(0)
Ct_curve.remove(0)
thrust_curve.remove(0)
speed_curve.remove(0)
wndspeed.remove(0)
power_curve.remove(0)
#%%

# short test: plt.plot(wndspeed,power_curve)
1 change: 1 addition & 0 deletions functions/runAerodyn.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
elseif isunix
status = system(['wine ',command]); % Code to run on Linux platform
elseif ispc
command=['.\bin\AeroDyn_Driver_x64 ',filename,'.dvr'] ;
status = system(command); %Zero means it worked!
else
disp('Platform not supported')
Expand Down

0 comments on commit baf4445

Please sign in to comment.