Skip to content

Commit a9680e3

Browse files
authored
Merge pull request #33 from ombahiwal/improve/17.4
Improve/17.4: Create inflowType, inflowPath spec with options LES, TS replacing LESpath spec.
2 parents d2e2faa + 317045c commit a9680e3

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Initialize package"""

openfast_toolbox/fastfarm/FASTFarmCaseCreation.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pandas as pd
2-
import numpy as np
32
import os, sys, shutil
43
import subprocess
54
import numpy as np
@@ -83,7 +82,8 @@ def __init__(self,
8382
EDmodel = None,
8483
nSeeds = 6,
8584
seedValues = None,
86-
LESpath = None,
85+
inflowPath = None,
86+
inflowType = None,
8787
sweepYawMisalignment = False,
8888
refTurb_rot = 0,
8989
verbose = 0):
@@ -139,10 +139,13 @@ def __init__(self,
139139
Number of seeds used for TurbSim simulations. If changing this value, give seedValues
140140
seedValues: list of int
141141
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
143146
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.
146149
sweepYawMisalignment: bool
147150
Whether or not to perform a sweep with and without yaw misalignment perturbations
148151
refTurb_rot: int
@@ -173,7 +176,8 @@ def __init__(self,
173176
self.ADmodel = ADmodel
174177
self.EDmodel = EDmodel
175178
self.nSeeds = nSeeds
176-
self.LESpath = LESpath
179+
self.inflowPath = inflowPath
180+
self.inflowType = inflowType
177181
self.sweepYM = sweepYawMisalignment
178182
self.seedValues = seedValues
179183
self.refTurb_rot = refTurb_rot
@@ -205,7 +209,7 @@ def __repr__(self):
205209
s = f'Requested parameters:\n'
206210
s += f' - Case path: {self.path}\n'
207211
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':
209213
s += f' - Number of TurbSim seeds: {self.nSeeds}\n'
210214
s += f' - End time: {self.tmax} s\n'
211215
s += f'Requested farm:\n'
@@ -236,16 +240,16 @@ def __repr__(self):
236240
s += f"\n\n"
237241

238242

239-
if self.LESpath is None:
243+
if self.inflowType == 'TS':
240244
s += f'Turbulence boxes: TurbSim\n'
241245
s += f'TurbSim turbulence boxes details:\n'
242246
else:
243247
s += f'Turbulence boxes: LES\n'
244248
s += f'LES turbulence boxes details:\n'
245-
s += f' Path: {self.LESpath}\n'
249+
s += f' Path: {self.inflowPath}\n'
246250

247251

248-
if self.TSlowBoxFilesCreatedBool or self.LESpath is not None:
252+
if self.TSlowBoxFilesCreatedBool or self.inflowType == 'LES':
249253
s += f' Low-resolution domain: \n'
250254
s += f' - ds low: {self.ds_low_les} m\n'
251255
s += f' - dt low: {self.dt_low_les} s\n'
@@ -255,7 +259,7 @@ def __repr__(self):
255259
s += f'Low-res boxes not created yet.\n'
256260

257261

258-
if self.TShighBoxFilesCreatedBool or self.LESpath is not None:
262+
if self.TShighBoxFilesCreatedBool or self.inflowType == 'LES':
259263
s += f' High-resolution domain: \n'
260264
s += f' - ds high: {self.ds_high_les} m\n'
261265
s += f' - dt high: {self.dt_high_les} s\n'
@@ -416,20 +420,22 @@ def _checkInputs(self):
416420
f'to the number of seeds requested.')
417421

418422
# Check LES parameters
419-
if self.LESpath is None:
423+
if self.inflowType == 'TS':
420424
self.inflowStr = 'TurbSim'
421425
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)
424428
self.inflowStr = 'LES'
425429
self.Mod_AmbWind = 1
426-
for p in self.LESpath:
430+
for p in self.inflowPath:
427431
if not os.path.isdir(p):
428432
raise ValueError (f'The LES path {p} does not exist')
429433
# LES is requested, so domain limits must be given
430434
if None in (self.dt_high_les, self.ds_high_les, self.dt_low_les, self.ds_low_les):
431435
raise ValueError (f'An LES-driven case was requested, but one or more grid parameters were not given. '\
432436
'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}.")
433439

434440

435441
# 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):
16361642
if t is not None:
16371643
options += f'-t {t} '
16381644
if p is not None:
1639-
otions += f'-p {p} '
1645+
options += f'-p {p} '
16401646

16411647
sub_command = f"sbatch {options}{self.slurmfilename_high}"
16421648
print(f'Calling: {sub_command}')
@@ -1811,7 +1817,7 @@ def _FF_setup_LES(self, seedsToKeep=1):
18111817

18121818
# Low-res box
18131819
try:
1814-
src = os.path.join(self.LESpath[cond], 'Low')
1820+
src = os.path.join(self.inflowPath[cond], 'Low')
18151821
dst = os.path.join(self.path, self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', LESboxesDirName, 'Low')
18161822
os.symlink(src, dst)
18171823
except FileExistsError:
@@ -1820,7 +1826,7 @@ def _FF_setup_LES(self, seedsToKeep=1):
18201826
# High-res boxes
18211827
for t in range(self.nTurbines):
18221828
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")
18241830
dst = os.path.join(self.path,self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', LESboxesDirName, f'HighT{t+1}')
18251831
os.symlink(src, dst)
18261832
except FileExistsError:
@@ -2189,7 +2195,7 @@ def FF_slurm_submit(self, qos='normal', A=None, t=None, p=None, delay=4):
21892195
if t is not None:
21902196
options += f'-t {t} '
21912197
if p is not None:
2192-
otions += f'-p {p} '
2198+
options += f'-p {p} '
21932199

21942200
sub_command = f"sbatch {options}{fname}"
21952201
print(f'Calling: {sub_command}')

openfast_toolbox/fastfarm/examples/Ex3_FFarmCompleteSetup.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ def main():
7777

7878
# ----------- Execution parameters
7979
ffbin = '/full/path/to/your/binary/.../bin/FAST.Farm'
80-
81-
# ----------- LES parameters. This variable will dictate whether it is a TurbSim-driven or LES-driven case
82-
LESpath = '/full/path/to/the/LES/case'
83-
#LESpath = None # set as None if TurbSim-driven is desired
84-
85-
80+
81+
# ----------- Inflow type (LES or TS)
82+
inflowType = 'TS' # Choose 'LES' or 'TS'
83+
# If LES, then set the inflowPath below
84+
# inflowPath = '/full/path/to/LES/case'
85+
8686
# -----------------------------------------------------------------------------
8787
# ----------- Template files
8888
templatePath = '/full/path/where/template/files/are'
@@ -126,8 +126,10 @@ def main():
126126
dt_high_les, ds_high_les, extent_high,
127127
dt_low_les, ds_low_les, extent_low,
128128
ffbin=ffbin, mod_wake=mod_wake, yaw_init=yaw_init,
129-
nSeeds=nSeeds, LESpath=LESpath, refTurb_rot=refTurb_rot,
130-
verbose=1)
129+
nSeeds=nSeeds,
130+
inflowType=inflowType,
131+
#inflowPath=inflowPath, # if LES, uncomment this line
132+
refTurb_rot=refTurb_rot, verbose=1)
131133

132134
case.setTemplateFilename(templatePath, EDfilename, SEDfilename, HDfilename, SrvDfilename, ADfilename,
133135
ADskfilename, SubDfilename, IWfilename, BDfilepath, bladefilename, towerfilename,
@@ -141,7 +143,7 @@ def main():
141143
case.copyTurbineFilesForEachCase()
142144

143145
# TurbSim setup
144-
if LESpath is None:
146+
if inflowType == 'TS':
145147
case.TS_low_setup()
146148
case.TS_low_slurm_prepare(slurm_TS_low)
147149
#case.TS_low_slurm_submit()

0 commit comments

Comments
 (0)