Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit ff9584c

Browse files
committed
FF: fix selection of unique cases for high-res boxes
1 parent a9315c0 commit ff9584c

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

pyFAST/fastfarm/FASTFarmCaseCreation.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,12 +1291,42 @@ def getDomainParameters(self):
12911291
# and sweep in yaw do not require extra TurbSim runs
12921292
self.nHighBoxCases = len(np.unique(self.inflow_deg)) # some wind dir might be repeated for sweep on yaws
12931293

1294-
self.allHighBoxCases = self.allCases.where(~self.allCases['wakeSteering'],drop=True).drop_vars('wakeSteering')\
1294+
# Old method to get allHighBoxCases. Doesn't work well if I have weird manual sweeps
1295+
allHighBoxCases_old = self.allCases.where(~self.allCases['wakeSteering'],drop=True).drop_vars('wakeSteering')\
12951296
.where(~self.allCases['misalignment'], drop=True).drop_vars('misalignment')\
12961297
.where(self.allCases['nFullAeroDyn']==self.nTurbines, drop=True).drop_vars('ADmodel')\
12971298
.where(self.allCases['nFulllElastoDyn']==self.nTurbines, drop=True).drop_vars('EDmodel')\
12981299
.where(self.allCases['yawCase']==1, drop=True).drop_vars('yawCase')
1299-
1300+
1301+
# This is a new method, but I'm not sure if it will work always, so let's leave the one above and check it
1302+
uniquewdir = np.unique(self.allCases.inflow_deg)
1303+
allHighBoxCases = []
1304+
for currwdir in uniquewdir:
1305+
# Get first case to have the wind direction currwdir
1306+
firstCaseWithInflow_i = self.allCases.where(self.allCases['inflow_deg'] == currwdir, drop=True).isel(case=0)
1307+
allHighBoxCases.append(firstCaseWithInflow_i)
1308+
self.allHighBoxCases = xr.concat(allHighBoxCases, dim='case')
1309+
# But, before I change the algorithm, I want to time-test it, so let's compare both ways
1310+
if not allHighBoxCases_old.identical(self.allHighBoxCases):
1311+
self.allHighBoxCases_old = allHighBoxCases_old
1312+
print(f'!!!!!! WARNING !!!!!!!!!')
1313+
print(f'The new method for computing all the high-box cases is not producing the same set of cases as the old algorithm.')
1314+
print(f'This should only happen if you have complex sweeps that you modified manually after the code creates the initial arrays')
1315+
print(f'Check the variable <obj>.allHighBoxCases_old to see the cases using the old algorithm')
1316+
print(f'Check the variable <obj>.allHighBoxCases to see the cases using the new algorithm')
1317+
print(f'You should check which xr.dataset has the correct, unique inflow_deg values. The correct array will only have unique values')
1318+
print(f'')
1319+
if len(self.allHighBoxCases_old['inflow_deg']) != len(np.unique(self.allHighBoxCases_old['inflow_deg'])):
1320+
print(f' Checking the inflow_deg variable, it looks like the old method has non-unique wind directions. The old method is wrong here.')
1321+
if len(self.allHighBoxCases['inflow_deg']) != len(np.unique(self.allHighBoxCases['inflow_deg'])):
1322+
print(f' Checking the inflow_deg variable, it looks like the new method has non-unique wind directions. The new method is wrong here.')
1323+
else:
1324+
print(' The new method appears to be correct here! Trust but verify')
1325+
print('')
1326+
print(f'!!!!!!!!!!!!!!!!!!!!!!!!')
1327+
print(f'')
1328+
1329+
13001330
if self.nHighBoxCases != len(self.allHighBoxCases.case):
13011331
raise ValueError(f'The number of cases do not match as expected. {self.nHighBoxCases} unique wind directions, but {len(self.allHighBoxCases.case)} unique cases.')
13021332

@@ -1431,6 +1461,7 @@ def TS_high_setup(self, writeFiles=True):
14311461
# Create and write new Low.inp files creating the proper box with proper resolution
14321462
currentTS = TSCaseCreation(D_, HubHt_, Vhub_, tivalue_, shear_, x=xloc_, y=yloc_, zbot=self.zbot,
14331463
cmax=self.cmax, fmax=self.fmax, Cmeander=self.Cmeander, boxType=boxType, high_ext=self.extent_high)
1464+
# !!!!!!!!!!! I have to give the resolution on the call above!!!!
14341465
currentTS.writeTSFile(self.turbsimHighfilepath, currentTSHighFile, tmax=self.tmax, turb=t, verbose=self.verbose)
14351466

14361467
# Modify some values and save file (some have already been set in the call above)

0 commit comments

Comments
 (0)