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

Commit 6e57963

Browse files
committed
FF/bugfix: Change logic of high-res boxes links
1 parent 35970ad commit 6e57963

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

pyFAST/fastfarm/FASTFarmCaseCreation.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,33 +1554,51 @@ def TS_high_slurm_submit(self, qos='normal', A=None, t=None):
15541554
def TS_high_create_symlink(self):
15551555

15561556
# Create symlink of all the high boxes for the cases with wake steering and yaw misalignment. These are the "repeated" boxes
1557+
1558+
if self.verbose>0:
1559+
print(f'Creating symlinks for all the high-resolution boxes')
1560+
15571561
notepath = os.getcwd()
15581562
os.chdir(self.path)
15591563
for cond in range(self.nConditions):
1560-
for t in range(self.nTurbines):
1561-
for seed in range(self.nSeeds):
1562-
for case in range(self.nCases):
1563-
# Let's check if the current case is source (has bts) or destination (needs a symlink to bts)
1564-
varsToDrop = ['misalignment','yawmis','yaw','yawCase','ADmodel','EDmodel','nFullAeroDyn','nFulllElastoDyn']
1565-
if case in self.allHighBoxCases['case']:
1566-
src = os.path.join('../../../..', self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', 'TurbSim', f'HighT{t+1}.bts')
1567-
xr_src = self.allCases.sel(case=case, drop=True).drop_vars(varsToDrop)
1568-
continue
1569-
else:
1570-
dst = os.path.join(self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', 'TurbSim', f'HighT{t+1}.bts')
1571-
xr_dst = self.allCases.sel(case=case, drop=True).drop_vars(varsToDrop)
1572-
1573-
# Let's make sure the src and destination are the same case, except wake steering and yaw misalign bools
1574-
xr.testing.assert_equal(xr_src, xr_dst)
1575-
1564+
for case in range(self.nCases):
1565+
# In order to do the symlink let's check if the current case is source (has bts). If so, skip if. If not, find its equivalent source
1566+
casematch = self.allHighBoxCases['case'] == case
1567+
if len(np.where(casematch)) != 1:
1568+
raise ValueError (f'Something is wrong with your allHighBoxCases array. Found repeated case number. Stopping')
1569+
1570+
src_id = np.where(casematch)[0]
1571+
1572+
if len(src_id) == 1:
1573+
# Current case is source (contains bts). Skipping
1574+
continue
1575+
1576+
# If we are here, the case is destination. Let's find the first case with the same wdir for source
1577+
varsToDrop = ['misalignment','yawmis','yaw','yawCase','ADmodel','EDmodel','nFullAeroDyn','nFulllElastoDyn']
1578+
dst_xr = self.allCases.sel(case=case, drop=True).drop_vars(varsToDrop)
1579+
currwdir = dst_xr['inflow_deg']
1580+
1581+
src_xr = self.allHighBoxCases.where(self.allHighBoxCases['inflow_deg'] == currwdir, drop=True).drop_vars(varsToDrop)
1582+
src_case = src_xr['case'].values[0]
1583+
src_xr = src_xr.sel(case=src_case, drop=True)
1584+
1585+
# Let's make sure the src and destination are the same case, except yaw misalignment and ROM bools, and yaw angles
1586+
# The xarrays we are comparing here contains all self.nTurbines turbines and no info about seed
1587+
xr.testing.assert_equal(src_xr, dst_xr)
1588+
1589+
# Now that we have the correct arrays, we perform the loop on the turbines and seeds
1590+
for t in range(self.nTurbines):
1591+
for seed in range(self.nSeeds):
1592+
src = os.path.join('../../../..', self.condDirList[cond], self.caseDirList[src_case], f'Seed_{seed}', 'TurbSim', f'HighT{t+1}.bts')
1593+
dst = os.path.join(self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', 'TurbSim', f'HighT{t+1}.bts')
1594+
15761595
try:
15771596
os.symlink(src, dst)
15781597
except FileExistsError:
15791598
if self.verbose>1: print(f'File {dst} already exists. Skipping symlink.')
15801599
os.chdir(notepath)
15811600

15821601

1583-
15841602
def FF_setup(self, outlistFF=None, **kwargs):
15851603
'''
15861604
@@ -1795,9 +1813,15 @@ def _FF_setup_LES(self, seedsToKeep=1):
17951813

17961814
def _FF_setup_TS(self):
17971815

1816+
# Let's first create the symlinks for the high-res boxes. Remember that only the cases with
1817+
# unique winddir in self.allHighBoxCases have executed high-res boxes, the rest is all links
1818+
self.TS_high_create_symlink()
1819+
17981820
# Loops on all conditions/cases and cases for FAST.Farm
17991821
for cond in range(self.nConditions):
1822+
print(f'Processing condition {self.condDirList[cond]}')
18001823
for case in range(self.nCases):
1824+
print(f' Processing all {self.nSeeds} seeds of case {self.caseDirList[case]}', end='\r')
18011825
for seed in range(self.nSeeds):
18021826
seedPath = os.path.join(self.path, self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}')
18031827

@@ -1876,6 +1900,7 @@ def _FF_setup_TS(self):
18761900
ff_file['WindVelZ'] = ', '.join(map(str, zWT[:9]+self.zhub))
18771901

18781902
ff_file.write(outputFSTF)
1903+
print(f'Done processing condition {self.condDirList[cond]} ')
18791904

18801905
return
18811906

0 commit comments

Comments
 (0)