Skip to content

Commit b1aa2f4

Browse files
committed
inflow switch between TS, LES, change params
1 parent d464fa8 commit b1aa2f4

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

openfast_toolbox/fastfarm/FASTFarmCaseCreation.py

Lines changed: 20 additions & 16 deletions
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 = 'TS',
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' (default is TS, TurbSim-driven)
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 != 'TS':
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 != 'TS':
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,14 +420,14 @@ 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
422426
else:
423-
if isinstance(self.LESpath,str): self.LESpath = [self.LESpath]*len(self.vhub)
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
@@ -1811,7 +1815,7 @@ def _FF_setup_LES(self, seedsToKeep=1):
18111815

18121816
# Low-res box
18131817
try:
1814-
src = os.path.join(self.LESpath[cond], 'Low')
1818+
src = os.path.join(self.inflowPath[cond], 'Low')
18151819
dst = os.path.join(self.path, self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', LESboxesDirName, 'Low')
18161820
os.symlink(src, dst)
18171821
except FileExistsError:
@@ -1820,7 +1824,7 @@ def _FF_setup_LES(self, seedsToKeep=1):
18201824
# High-res boxes
18211825
for t in range(self.nTurbines):
18221826
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")
1827+
src = os.path.join(self.inflowPath[cond], f"HighT{t+1}_inflow{str(self.allCases.sel(case=case).inflow_deg.values).replace('-','m')}deg")
18241828
dst = os.path.join(self.path,self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', LESboxesDirName, f'HighT{t+1}')
18251829
os.symlink(src, dst)
18261830
except FileExistsError:

openfast_toolbox/fastfarm/examples/Ex3_FFarmCompleteSetup.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ 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) This variable will dictate whether it is a TurbSim-driven or LES-driven case
82+
inflowType = 'TS' # Choose 'LES' or 'TS' (default is TS, TurbSim-driven)
83+
inflowPath = None # '/full/path/to/TS/or/LES/case' set as None if TurbSim-driven is desired
84+
8685
# -----------------------------------------------------------------------------
8786
# ----------- Template files
8887
templatePath = '/full/path/where/template/files/are'
@@ -126,7 +125,8 @@ def main():
126125
dt_high_les, ds_high_les, extent_high,
127126
dt_low_les, ds_low_les, extent_low,
128127
ffbin=ffbin, mod_wake=mod_wake, yaw_init=yaw_init,
129-
nSeeds=nSeeds, LESpath=LESpath, refTurb_rot=refTurb_rot,
128+
nSeeds=nSeeds, refTurb_rot=refTurb_rot,
129+
inflowType='LES', inflowPath=inflowPath,
130130
verbose=1)
131131

132132
case.setTemplateFilename(templatePath, EDfilename, SEDfilename, HDfilename, SrvDfilename, ADfilename,
@@ -141,7 +141,7 @@ def main():
141141
case.copyTurbineFilesForEachCase()
142142

143143
# TurbSim setup
144-
if LESpath is None:
144+
if inflowType == 'TS':
145145
case.TS_low_setup()
146146
case.TS_low_slurm_prepare(slurm_TS_low)
147147
#case.TS_low_slurm_submit()

0 commit comments

Comments
 (0)