1
1
import pandas as pd
2
- import numpy as np
3
2
import os , sys , shutil
4
3
import subprocess
5
4
import numpy as np
@@ -83,7 +82,8 @@ def __init__(self,
83
82
EDmodel = None ,
84
83
nSeeds = 6 ,
85
84
seedValues = None ,
86
- LESpath = None ,
85
+ inflowPath = None ,
86
+ inflowType = None ,
87
87
sweepYawMisalignment = False ,
88
88
refTurb_rot = 0 ,
89
89
verbose = 0 ):
@@ -139,10 +139,13 @@ def __init__(self,
139
139
Number of seeds used for TurbSim simulations. If changing this value, give seedValues
140
140
seedValues: list of int
141
141
Seed value for each seed of requested TurbSim simulations if nSeeds!=6
142
- LESpath: str or list of strings
142
+ inflowType: str
143
+ Inflow type (LES or TS) This variable will dictate whether it is a TurbSim-driven or LES-driven case
144
+ Choose 'LES' or 'TS' (no default is set)
145
+ inflowPath: str or list of strings
143
146
Full path of the LES data, if driven by LES. If None, the setup will be for TurbSim inflow.
144
- LESpath can be a single path, or a list of paths of the same length as the sweep in conditions.
145
- For example, if TIvalue=[8,10,12], then LESpath can be 3 paths, related to each condition.
147
+ inflowPath can be a single path, or a list of paths of the same length as the sweep in conditions.
148
+ For example, if TIvalue=[8,10,12], then inflowPath can be 3 paths, related to each condition.
146
149
sweepYawMisalignment: bool
147
150
Whether or not to perform a sweep with and without yaw misalignment perturbations
148
151
refTurb_rot: int
@@ -173,7 +176,8 @@ def __init__(self,
173
176
self .ADmodel = ADmodel
174
177
self .EDmodel = EDmodel
175
178
self .nSeeds = nSeeds
176
- self .LESpath = LESpath
179
+ self .inflowPath = inflowPath
180
+ self .inflowType = inflowType
177
181
self .sweepYM = sweepYawMisalignment
178
182
self .seedValues = seedValues
179
183
self .refTurb_rot = refTurb_rot
@@ -205,7 +209,7 @@ def __repr__(self):
205
209
s = f'Requested parameters:\n '
206
210
s += f' - Case path: { self .path } \n '
207
211
s += f' - Wake model: { self .mod_wake } (1:Polar; 2:Curl; 3:Cartesian)\n '
208
- if self .LESpath is None :
212
+ if self .inflowType == 'TS' :
209
213
s += f' - Number of TurbSim seeds: { self .nSeeds } \n '
210
214
s += f' - End time: { self .tmax } s\n '
211
215
s += f'Requested farm:\n '
@@ -236,16 +240,16 @@ def __repr__(self):
236
240
s += f"\n \n "
237
241
238
242
239
- if self .LESpath is None :
243
+ if self .inflowType == 'TS' :
240
244
s += f'Turbulence boxes: TurbSim\n '
241
245
s += f'TurbSim turbulence boxes details:\n '
242
246
else :
243
247
s += f'Turbulence boxes: LES\n '
244
248
s += f'LES turbulence boxes details:\n '
245
- s += f' Path: { self .LESpath } \n '
249
+ s += f' Path: { self .inflowPath } \n '
246
250
247
251
248
- if self .TSlowBoxFilesCreatedBool or self .LESpath is not None :
252
+ if self .TSlowBoxFilesCreatedBool or self .inflowType == 'LES' :
249
253
s += f' Low-resolution domain: \n '
250
254
s += f' - ds low: { self .ds_low_les } m\n '
251
255
s += f' - dt low: { self .dt_low_les } s\n '
@@ -255,7 +259,7 @@ def __repr__(self):
255
259
s += f'Low-res boxes not created yet.\n '
256
260
257
261
258
- if self .TShighBoxFilesCreatedBool or self .LESpath is not None :
262
+ if self .TShighBoxFilesCreatedBool or self .inflowType == 'LES' :
259
263
s += f' High-resolution domain: \n '
260
264
s += f' - ds high: { self .ds_high_les } m\n '
261
265
s += f' - dt high: { self .dt_high_les } s\n '
@@ -416,20 +420,22 @@ def _checkInputs(self):
416
420
f'to the number of seeds requested.' )
417
421
418
422
# Check LES parameters
419
- if self .LESpath is None :
423
+ if self .inflowType == 'TS' :
420
424
self .inflowStr = 'TurbSim'
421
425
self .Mod_AmbWind = 3
422
- else :
423
- if isinstance (self .LESpath ,str ): self .LESpath = [self .LESpath ]* len (self .vhub )
426
+ elif self . inflowType == 'LES' :
427
+ if isinstance (self .inflowPath ,str ): self .inflowPath = [self .inflowPath ]* len (self .vhub )
424
428
self .inflowStr = 'LES'
425
429
self .Mod_AmbWind = 1
426
- for p in self .LESpath :
430
+ for p in self .inflowPath :
427
431
if not os .path .isdir (p ):
428
432
raise ValueError (f'The LES path { p } does not exist' )
429
433
# LES is requested, so domain limits must be given
430
434
if None in (self .dt_high_les , self .ds_high_les , self .dt_low_les , self .ds_low_les ):
431
435
raise ValueError (f'An LES-driven case was requested, but one or more grid parameters were not given. ' \
432
436
'Set `dt_high_les`, `ds_high_les`, `dt_low_les`, and `ds_low_les` based on your LES boxes.' )
437
+ else :
438
+ raise ValueError (f"Inflow type `inflowType` should be 'TS' or 'LES'. Received { self .inflowType } ." )
433
439
434
440
435
441
# Check the wake model (1:Polar; 2:Curl; 3:Cartesian)
@@ -1636,7 +1642,7 @@ def TS_high_slurm_submit(self, qos='normal', A=None, t=None, p=None):
1636
1642
if t is not None :
1637
1643
options += f'-t { t } '
1638
1644
if p is not None :
1639
- otions += f'-p { p } '
1645
+ options += f'-p { p } '
1640
1646
1641
1647
sub_command = f"sbatch { options } { self .slurmfilename_high } "
1642
1648
print (f'Calling: { sub_command } ' )
@@ -1811,7 +1817,7 @@ def _FF_setup_LES(self, seedsToKeep=1):
1811
1817
1812
1818
# Low-res box
1813
1819
try :
1814
- src = os .path .join (self .LESpath [cond ], 'Low' )
1820
+ src = os .path .join (self .inflowPath [cond ], 'Low' )
1815
1821
dst = os .path .join (self .path , self .condDirList [cond ], self .caseDirList [case ], f'Seed_{ seed } ' , LESboxesDirName , 'Low' )
1816
1822
os .symlink (src , dst )
1817
1823
except FileExistsError :
@@ -1820,7 +1826,7 @@ def _FF_setup_LES(self, seedsToKeep=1):
1820
1826
# High-res boxes
1821
1827
for t in range (self .nTurbines ):
1822
1828
try :
1823
- src = os .path .join (self .LESpath [cond ], f"HighT{ t + 1 } _inflow{ str (self .allCases .sel (case = case ).inflow_deg .values ).replace ('-' ,'m' )} deg" )
1829
+ src = os .path .join (self .inflowPath [cond ], f"HighT{ t + 1 } _inflow{ str (self .allCases .sel (case = case ).inflow_deg .values ).replace ('-' ,'m' )} deg" )
1824
1830
dst = os .path .join (self .path ,self .condDirList [cond ], self .caseDirList [case ], f'Seed_{ seed } ' , LESboxesDirName , f'HighT{ t + 1 } ' )
1825
1831
os .symlink (src , dst )
1826
1832
except FileExistsError :
@@ -2189,7 +2195,7 @@ def FF_slurm_submit(self, qos='normal', A=None, t=None, p=None, delay=4):
2189
2195
if t is not None :
2190
2196
options += f'-t { t } '
2191
2197
if p is not None :
2192
- otions += f'-p { p } '
2198
+ options += f'-p { p } '
2193
2199
2194
2200
sub_command = f"sbatch { options } { fname } "
2195
2201
print (f'Calling: { sub_command } ' )
0 commit comments