@@ -306,7 +306,7 @@ def __init__(self,
306306 self .attempt = 1
307307 self .skipchecks = skipchecks
308308 self .flat = flat
309- # Set aux variable
309+ # Initialize aux variable
310310 self .templateFilesCreatedBool = False
311311 self .TSlowBoxFilesCreatedBool = False
312312 self .TShighBoxFilesCreatedBool = False
@@ -345,13 +345,11 @@ def __init__(self,
345345 self ._setRotorParameters ()
346346 if self .verbose > 0 : print (f'Setting rotor parameters... Done.' )
347347
348-
349348 # TODO: Creating Cases and Conditions should have its own function interface so the user can call
350349 if self .verbose > 0 : print (f'Creating auxiliary arrays for all conditions and cases...' , end = '\r ' )
351350 self .createAuxArrays ()
352351 if self .verbose > 0 : print (f'Creating auxiliary arrays for all conditions and cases... Done.' )
353352
354-
355353 if self .path is not None :
356354 # TODO this should only be done when user ask for input file creation
357355 if self .verbose > 0 : print (f'Creating directory structure and copying files...' , end = '\r ' )
@@ -759,12 +757,14 @@ def _checkInputs(self):
759757 elif self .inflowType .lower () == 'les_amrex' :
760758 self .inflowType = 'LES_AMReX'
761759
760+ # Format inflowPath
761+ if isinstance (self .inflowPath ,str ): self .inflowPath = [self .inflowPath ]* len (self .vhub )
762+
762763 # Check LES parameters
763764 if self .inflowType == 'TS' :
764765 self .inflowStr = 'TurbSim'
765766 self .Mod_AmbWind = 3
766767 elif self .inflowType in ['LES_VTK' , 'LES_AMReX' ]:
767- if isinstance (self .inflowPath ,str ): self .inflowPath = [self .inflowPath ]* len (self .vhub )
768768 if self .inflowType == 'LES_VTK' :
769769 self .inflowStr = 'LES_VTK'
770770 self .Mod_AmbWind = 1
@@ -2051,7 +2051,7 @@ def _isclose(a, b, tol=1):
20512051
20522052
20532053 elif _isclose (self .D , 178 ): # DTU 10MW W turbine
2054- print (f'CHANGE THE _setRotorParameters of the DTU 10MW turbine' )
2054+ WARN (f'CHANGE THE _setRotorParameters of the DTU 10MW turbine' )
20552055 self .bins = xr .Dataset ({'WaveHs' : (['wspd' ], [ 1.429 , 1.429 ]), # 1.429 comes from Matt's hydrodyn input file
20562056 'WaveTp' : (['wspd' ], [ 7.073 , 7.073 ]), # 7.073 comes from Matt's hydrodyn input file
20572057 'RotSpeed' : (['wspd' ], [ 4.0 , 4.0 ]), # 4 rpm comes from Matt's ED input file
@@ -2062,7 +2062,7 @@ def _isclose(a, b, tol=1):
20622062
20632063
20642064 elif _isclose (self .D , 82 ): # Vestas V82, 1.5MW, 82 m diameter
2065- print (f'CHANGE THE _setRotorParameters of the V82 1.5MW turbine' )
2065+ WARN (f'CHANGE THE _setRotorParameters of the V82 1.5MW turbine' )
20662066 self .bins = xr .Dataset ({'WaveHs' : (['wspd' ], [ 1.429 , 1.429 ]), # 1.429 comes from Matt's hydrodyn input file
20672067 'WaveTp' : (['wspd' ], [ 7.073 , 7.073 ]), # 7.073 comes from Matt's hydrodyn input file
20682068 'RotSpeed' : (['wspd' ], [ 4.0 , 4.0 ]), # 4 rpm comes from Matt's ED input file
@@ -2086,7 +2086,9 @@ def _isclose(a, b, tol=1):
20862086
20872087
20882088 def TS_low_setup (self , writeFiles = True , runOnce = False ):
2089- INFO ('Preparing TurbSim low resolution input files.' )
2089+ if self .inflowType == 'TS' :
2090+ # This function is called once for domain limits even when LES, so only printing the info when relevant
2091+ INFO ('Preparing TurbSim low resolution input files.' )
20902092
20912093 boxType = 'lowres'
20922094 lowFilesName = []
@@ -2302,11 +2304,10 @@ def TS_low_createSymlinks(self):
23022304
23032305
23042306 def getDomainParameters (self ):
2305- INFO ('Computing low and high res extent according to TurbSim capabilities ' )
2307+ INFO ('Computing low- and high- res extents ' )
23062308
23072309 # If the low box setup hasn't been called (e.g. LES run), do it once to get domain extents
23082310 if not self .TSlowBoxFilesCreatedBool :
2309- if self .verbose > 1 : print (' Running a TurbSim setup once to get domain extents' )
23102311 self .TS_low_setup (writeFiles = False , runOnce = True )
23112312
23122313 # Figure out how many (and which) high boxes actually need to be executed. Remember that SED/ADsk models
@@ -2837,16 +2838,22 @@ def _FF_setup_LES(self, seedsToKeep=1, wind_dir_prefix='ffboxes', dir_start_inde
28372838 # Clean unnecessary directories and files created by the general setup
28382839 for cond in range (self .nConditions ):
28392840 for seed in range (self .nSeeds ):
2841+ # Delete all cond/seed
28402842 currpath = self .getCondSeedPath (cond , seed )
2841- if os .path .isdir (currpath ): shutil .rmtree (currpath )
2843+ if os .path .isdir (currpath ): shutil .rmtree (currpath )
28422844 for case in range (self .nCases ):
28432845 for seed in range (seedsToKeep ,self .nSeeds ):
2846+ # Delete all-but-seedsToKeep cond/case/seed
28442847 currpath = self .getCaseSeedPath (cond , case , seed )
2845- if os .path .isdir (currpath ): shutil .rmtree (currpath )
2848+ if os .path .isdir (currpath ): shutil .rmtree (currpath )
2849+ for seed in range (seedsToKeep - 1 ,self .nSeeds ):
2850+ # Delete all cond/case/seed/TurbSim
2851+ currpath = self .getHRTurbSimPath (cond , case , seed )
2852+ if os .path .isdir (currpath ): shutil .rmtree (currpath )
28462853
28472854
28482855 if self .inflowStr == 'LES_VTK' :
2849- # Create symlinks for the processed-and-renamed vtk files
2856+ # Create symlinks for the processed-and-renamed vtk files; okay if LES path does not exist
28502857 LESboxesDirName = 'LESboxes'
28512858 for cond in range (self .nConditions ):
28522859 for case in range (self .nCases ):
@@ -2911,12 +2918,9 @@ def _FF_setup_LES(self, seedsToKeep=1, wind_dir_prefix='ffboxes', dir_start_inde
29112918 elif self .inflowStr == 'LES_AMReX' :
29122919 ff_file ['DT_Low-AMReX' ] = self .dt_low
29132920 ff_file ['DT_High-AMReX' ] = self .dt_high
2914- ff_file ['WindDirPrefix' ] = f'''"{ os .path .join (self .inflowPath [cond ], 'ffboxes' )} "'''
2915- ff_file ['DirStartIndex' ] = 0 # TODO
2916- WARN ('For LES_AMReX, make sure to set the correct DirStartIndex and that the files are named accordingly.' )
2917-
2921+ ff_file ['WindDirPrefix' ] = f'''"{ os .path .join (self .inflowPath [cond ], self .wind_dir_prefix )} "'''
2922+ ff_file ['DirStartIndex' ] = f'"{ self .dir_start_index_str_by_cond [cond ]} "'
29182923
2919-
29202924 # Super controller
29212925 if 'UseSC' in ff_file .keys ():
29222926 ff_file ['UseSC' ] = False
@@ -2954,7 +2958,7 @@ def _FF_setup_LES(self, seedsToKeep=1, wind_dir_prefix='ffboxes', dir_start_inde
29542958
29552959 # Vizualization outputs
29562960 ff_file ['WrDisWind' ] = 'False'
2957- ff_file ['WrDisDT' ] = ff_file [ 'DT_Low-VTK' ] # default is the same as DT_Low-VTK
2961+ ff_file ['WrDisDT' ] = self . dt_low # default is the same as DT_Low-VTK
29582962 ff_file ['NOutDisWindXY' ] = len (self .planes_xy )
29592963 ff_file ['OutDisWindZ' ] = ', ' .join (map (str , self .planes_xy ))
29602964 ff_file ['NOutDisWindYZ' ] = len (self .planes_yz )
0 commit comments