diff --git a/__init__.py b/__init__.py index d8968bc..df3cf39 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +1 @@ -"""Initializes the package""" +"""Initialize package""" \ No newline at end of file diff --git a/openfast_toolbox/fastfarm/FASTFarmCaseCreation.py b/openfast_toolbox/fastfarm/FASTFarmCaseCreation.py index 7205583..b8dfee2 100644 --- a/openfast_toolbox/fastfarm/FASTFarmCaseCreation.py +++ b/openfast_toolbox/fastfarm/FASTFarmCaseCreation.py @@ -1,5 +1,4 @@ import pandas as pd -import numpy as np import os, sys, shutil import subprocess import numpy as np @@ -83,7 +82,8 @@ def __init__(self, EDmodel = None, nSeeds = 6, seedValues = None, - LESpath = None, + inflowPath = None, + inflowType = None, sweepYawMisalignment = False, refTurb_rot = 0, verbose = 0): @@ -139,10 +139,13 @@ def __init__(self, Number of seeds used for TurbSim simulations. If changing this value, give seedValues seedValues: list of int Seed value for each seed of requested TurbSim simulations if nSeeds!=6 - LESpath: str or list of strings + inflowType: str + Inflow type (LES or TS) This variable will dictate whether it is a TurbSim-driven or LES-driven case + Choose 'LES' or 'TS' (no default is set) + inflowPath: str or list of strings Full path of the LES data, if driven by LES. If None, the setup will be for TurbSim inflow. - LESpath can be a single path, or a list of paths of the same length as the sweep in conditions. - For example, if TIvalue=[8,10,12], then LESpath can be 3 paths, related to each condition. + inflowPath can be a single path, or a list of paths of the same length as the sweep in conditions. + For example, if TIvalue=[8,10,12], then inflowPath can be 3 paths, related to each condition. sweepYawMisalignment: bool Whether or not to perform a sweep with and without yaw misalignment perturbations refTurb_rot: int @@ -173,7 +176,8 @@ def __init__(self, self.ADmodel = ADmodel self.EDmodel = EDmodel self.nSeeds = nSeeds - self.LESpath = LESpath + self.inflowPath = inflowPath + self.inflowType = inflowType self.sweepYM = sweepYawMisalignment self.seedValues = seedValues self.refTurb_rot = refTurb_rot @@ -205,7 +209,7 @@ def __repr__(self): s = f'Requested parameters:\n' s += f' - Case path: {self.path}\n' s += f' - Wake model: {self.mod_wake} (1:Polar; 2:Curl; 3:Cartesian)\n' - if self.LESpath is None: + if self.inflowType == 'TS': s += f' - Number of TurbSim seeds: {self.nSeeds}\n' s += f' - End time: {self.tmax} s\n' s += f'Requested farm:\n' @@ -236,16 +240,16 @@ def __repr__(self): s += f"\n\n" - if self.LESpath is None: + if self.inflowType == 'TS': s += f'Turbulence boxes: TurbSim\n' s += f'TurbSim turbulence boxes details:\n' else: s += f'Turbulence boxes: LES\n' s += f'LES turbulence boxes details:\n' - s += f' Path: {self.LESpath}\n' + s += f' Path: {self.inflowPath}\n' - if self.TSlowBoxFilesCreatedBool or self.LESpath is not None: + if self.TSlowBoxFilesCreatedBool or self.inflowType == 'LES': s += f' Low-resolution domain: \n' s += f' - ds low: {self.ds_low_les} m\n' s += f' - dt low: {self.dt_low_les} s\n' @@ -255,7 +259,7 @@ def __repr__(self): s += f'Low-res boxes not created yet.\n' - if self.TShighBoxFilesCreatedBool or self.LESpath is not None: + if self.TShighBoxFilesCreatedBool or self.inflowType == 'LES': s += f' High-resolution domain: \n' s += f' - ds high: {self.ds_high_les} m\n' s += f' - dt high: {self.dt_high_les} s\n' @@ -416,20 +420,22 @@ def _checkInputs(self): f'to the number of seeds requested.') # Check LES parameters - if self.LESpath is None: + if self.inflowType == 'TS': self.inflowStr = 'TurbSim' self.Mod_AmbWind = 3 - else: - if isinstance(self.LESpath,str): self.LESpath = [self.LESpath]*len(self.vhub) + elif self.inflowType == 'LES': + if isinstance(self.inflowPath,str): self.inflowPath = [self.inflowPath]*len(self.vhub) self.inflowStr = 'LES' self.Mod_AmbWind = 1 - for p in self.LESpath: + for p in self.inflowPath: if not os.path.isdir(p): raise ValueError (f'The LES path {p} does not exist') # LES is requested, so domain limits must be given if None in (self.dt_high_les, self.ds_high_les, self.dt_low_les, self.ds_low_les): raise ValueError (f'An LES-driven case was requested, but one or more grid parameters were not given. '\ 'Set `dt_high_les`, `ds_high_les`, `dt_low_les`, and `ds_low_les` based on your LES boxes.') + else: + raise ValueError (f"Inflow type `inflowType` should be 'TS' or 'LES'. Received {self.inflowType}.") # 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): if t is not None: options += f'-t {t} ' if p is not None: - otions += f'-p {p} ' + options += f'-p {p} ' sub_command = f"sbatch {options}{self.slurmfilename_high}" print(f'Calling: {sub_command}') @@ -1811,7 +1817,7 @@ def _FF_setup_LES(self, seedsToKeep=1): # Low-res box try: - src = os.path.join(self.LESpath[cond], 'Low') + src = os.path.join(self.inflowPath[cond], 'Low') dst = os.path.join(self.path, self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', LESboxesDirName, 'Low') os.symlink(src, dst) except FileExistsError: @@ -1820,7 +1826,7 @@ def _FF_setup_LES(self, seedsToKeep=1): # High-res boxes for t in range(self.nTurbines): try: - src = os.path.join(self.LESpath[cond], f"HighT{t+1}_inflow{str(self.allCases.sel(case=case).inflow_deg.values).replace('-','m')}deg") + src = os.path.join(self.inflowPath[cond], f"HighT{t+1}_inflow{str(self.allCases.sel(case=case).inflow_deg.values).replace('-','m')}deg") dst = os.path.join(self.path,self.condDirList[cond], self.caseDirList[case], f'Seed_{seed}', LESboxesDirName, f'HighT{t+1}') os.symlink(src, dst) except FileExistsError: @@ -2189,7 +2195,7 @@ def FF_slurm_submit(self, qos='normal', A=None, t=None, p=None, delay=4): if t is not None: options += f'-t {t} ' if p is not None: - otions += f'-p {p} ' + options += f'-p {p} ' sub_command = f"sbatch {options}{fname}" print(f'Calling: {sub_command}') diff --git a/openfast_toolbox/fastfarm/examples/Ex3_FFarmCompleteSetup.py b/openfast_toolbox/fastfarm/examples/Ex3_FFarmCompleteSetup.py index f4914f6..0420af8 100644 --- a/openfast_toolbox/fastfarm/examples/Ex3_FFarmCompleteSetup.py +++ b/openfast_toolbox/fastfarm/examples/Ex3_FFarmCompleteSetup.py @@ -77,12 +77,12 @@ def main(): # ----------- Execution parameters ffbin = '/full/path/to/your/binary/.../bin/FAST.Farm' - - # ----------- LES parameters. This variable will dictate whether it is a TurbSim-driven or LES-driven case - LESpath = '/full/path/to/the/LES/case' - #LESpath = None # set as None if TurbSim-driven is desired - - + + # ----------- Inflow type (LES or TS) + inflowType = 'TS' # Choose 'LES' or 'TS' + # If LES, then set the inflowPath below + # inflowPath = '/full/path/to/LES/case' + # ----------------------------------------------------------------------------- # ----------- Template files templatePath = '/full/path/where/template/files/are' @@ -126,8 +126,10 @@ def main(): dt_high_les, ds_high_les, extent_high, dt_low_les, ds_low_les, extent_low, ffbin=ffbin, mod_wake=mod_wake, yaw_init=yaw_init, - nSeeds=nSeeds, LESpath=LESpath, refTurb_rot=refTurb_rot, - verbose=1) + nSeeds=nSeeds, + inflowType=inflowType, + #inflowPath=inflowPath, # if LES, uncomment this line + refTurb_rot=refTurb_rot, verbose=1) case.setTemplateFilename(templatePath, EDfilename, SEDfilename, HDfilename, SrvDfilename, ADfilename, ADskfilename, SubDfilename, IWfilename, BDfilepath, bladefilename, towerfilename, @@ -141,7 +143,7 @@ def main(): case.copyTurbineFilesForEachCase() # TurbSim setup - if LESpath is None: + if inflowType == 'TS': case.TS_low_setup() case.TS_low_slurm_prepare(slurm_TS_low) #case.TS_low_slurm_submit()