Skip to content

Commit 2e83ceb

Browse files
committed
FF: completely remove sweep on yaw misalignment
1 parent 4442277 commit 2e83ceb

1 file changed

Lines changed: 12 additions & 46 deletions

File tree

‎openfast_toolbox/fastfarm/FASTFarmCaseCreation.py‎

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ def __init__(self,
189189
seedValues = None,
190190
inflowPath = None,
191191
inflowType = None,
192-
sweepYawMisalignment = False,
193192
refTurb_rot = 0,
194193
#ptfm_rot = False,
195194
flat=False,
@@ -258,8 +257,6 @@ def __init__(self,
258257
Full path of the LES data, if driven by LES. If None, the setup will be for TurbSim inflow.
259258
inflowPath can be a single path, or a list of paths of the same length as the sweep in conditions.
260259
For example, if TIvalue=[8,10,12], then inflowPath can be 3 paths, related to each condition.
261-
sweepYawMisalignment: bool
262-
Whether or not to perform a sweep with and without yaw misalignment perturbations
263260
refTurb_rot: int
264261
Index of reference turbine which the rotation of the farm will occur. Default is 0, the first one.
265262
Not fully tested.
@@ -298,7 +295,6 @@ def __init__(self,
298295
self.nSeeds = nSeeds
299296
self.inflowPath = inflowPath
300297
self.inflowType = inflowType
301-
self.sweepYM = sweepYawMisalignment
302298
self.seedValues = seedValues
303299
self.refTurb_rot = refTurb_rot
304300
#self.ptfm_rot = ptfm_rot
@@ -320,10 +316,11 @@ def __init__(self,
320316
self.hasBD = False
321317
self.multi_HD = False
322318
self.multi_MD = False
323-
self.condDirList = []
324-
self.caseDirList = []
325-
self.DLLfilepath = None
326-
self.DLLext = None
319+
self.tmax_low = tmax
320+
self.condDirList = []
321+
self.caseDirList = []
322+
self.DLLfilepath = None
323+
self.DLLext = None
327324
self.batchfile_high = ''
328325
self.batchfile_low = ''
329326
self.batchfile_ff = ''
@@ -863,7 +860,6 @@ def _create_dir_structure(self):
863860
for case in range(self.nCases):
864861
# Recover information about current case for directory naming purposes
865862
inflow_deg_ = self.allCases['inflow_deg' ].sel(case=case).values
866-
misalignment_ = self.allCases['misalignment' ].sel(case=case).values
867863
nADyn_ = self.allCases['nFullAeroDyn' ].sel(case=case).values
868864
nFED_ = self.allCases['nFulllElastoDyn'].sel(case=case).values
869865
yawCase_ = self.allCases['yawCase' ].sel(case=case).values
@@ -872,8 +868,6 @@ def _create_dir_structure(self):
872868
ndigits = len(str(self.nCases))
873869
caseStr = f"Case{case:0{ndigits}d}_wdir{f'{int(inflow_deg_):+03d}'.replace('+','p').replace('-','m')}"
874870
# Add standard sweeps to the case name
875-
#if self.sweepYM:
876-
# caseStr += f"_YM{str(misalignment_).lower()}"
877871
if self.sweepEDmodel:
878872
caseStr += f"_{nFED_}fED"
879873
if self.sweepADmodel:
@@ -1076,25 +1070,18 @@ def copyTurbineFilesForEachCase(self, writeFiles=True):
10761070
for t in range(self.nTurbines):
10771071
# Recover info about the current turbine in CondXX_*/CaseYY_
10781072
yaw_deg_ = self.allCases.sel(case=case, turbine=t)['yaw'].values
1079-
yaw_mis_deg_ = self.allCases.sel(case=case, turbine=t)['yawmis'].values
10801073
phi_deg_ = self.allCases.sel(case=case, turbine=t)['phi'].values
10811074
ADmodel_ = self.allCases.sel(case=case, turbine=t)['ADmodel'].values
10821075
EDmodel_ = self.allCases.sel(case=case, turbine=t)['EDmodel'].values
10831076

1084-
# Quickly check that yaw misaligned value is zero if case does not contain yaw misalignment
1085-
if self.allCases.sel(case=case, turbine=t)['misalignment'].values:
1086-
assert yaw_mis_deg_ != 0
1087-
else:
1088-
assert yaw_mis_deg_ == 0
1089-
10901077
# Update each turbine's elastic model
10911078
if EDmodel_ == 'FED':
10921079
self.ElastoDynFile['RotSpeed'] = self.bins.sel(wspd=Vhub_, method='nearest').RotSpeed.values
10931080
self.ElastoDynFile['BlPitch(1)'] = self.bins.sel(wspd=Vhub_, method='nearest').BlPitch.values
10941081
self.ElastoDynFile['BlPitch(2)'] = self.bins.sel(wspd=Vhub_, method='nearest').BlPitch.values
10951082
self.ElastoDynFile['BlPitch(3)'] = self.bins.sel(wspd=Vhub_, method='nearest').BlPitch.values
10961083

1097-
self.ElastoDynFile['NacYaw'] = yaw_deg_ + yaw_mis_deg_
1084+
self.ElastoDynFile['NacYaw'] = yaw_deg_
10981085
self.ElastoDynFile['PtfmYaw'] = phi_deg_
10991086
# The blade file entry `BldFile[1-3]` is not actually read. Sometimes we see `BldFile([1-3])`.
11001087
if 'BldFile1' in self.ElastoDynFile.keys():
@@ -1117,7 +1104,7 @@ def copyTurbineFilesForEachCase(self, writeFiles=True):
11171104

11181105
self.SElastoDynFile['BlPitch'] = self.bins.sel(wspd=Vhub_, method='nearest').BlPitch.values
11191106
self.SElastoDynFile['RotSpeed'] = self.bins.sel(wspd=Vhub_, method='nearest').RotSpeed.values
1120-
self.SElastoDynFile['NacYaw'] = yaw_deg_ + yaw_mis_deg_
1107+
self.SElastoDynFile['NacYaw'] = yaw_deg_
11211108
if writeFiles:
11221109
self.SElastoDynFile.write(os.path.join(currPath,f'{self.SEDfilename}{t+1}_mod.dat'))
11231110

@@ -1142,7 +1129,7 @@ def copyTurbineFilesForEachCase(self, writeFiles=True):
11421129

11431130
# Update each turbine's ServoDyn
11441131
if self.hasSrvD:
1145-
self.ServoDynFile['YawNeut'] = yaw_deg_ + yaw_mis_deg_
1132+
self.ServoDynFile['YawNeut'] = yaw_deg_
11461133
self.ServoDynFile['VSContrl'] = 5
11471134
self.ServoDynFile['DLL_FileName'] = f'"{self.DLLfilepath}{t+1}.{self.DLLext}"'
11481135
self.ServoDynFile['DLL_InFile'] = f'"{self.controllerInputfilename}"'
@@ -1876,10 +1863,8 @@ def _create_all_cond(self):
18761863

18771864
def _create_all_cases(self):
18781865
# Generate the different "cases" (inflow angle).
1879-
# If misalignment true, then the actual yaw is yaw[turb]=np.random.uniform(low=-8.0, high=8.0).
18801866

18811867
# Set sweep bools and multipliers
1882-
nCasesYMmultiplier = 2 if self.sweepYM else 1
18831868
nCasesROmultiplier = len(self.EDmodel)
18841869
if len(self.ADmodel) == 1:
18851870
self.sweepEDmodel = False
@@ -1960,26 +1945,8 @@ def _create_all_cases(self):
19601945

19611946
allCases = ds.copy()
19621947

1963-
# ------------------------------------------------- SWEEP YAW MISALIGNMENT
1964-
# Get the number of cases at before this current sweep
1965-
nCases_before_sweep = len(allCases.case)
1966-
1967-
# Concat instances of allCases and adjust the case numbering
1968-
ds = xr.concat([allCases for i in range(nCasesYMmultiplier)], dim='case')
1969-
ds['case'] = np.arange(len(ds['case']))
1970-
1971-
# Create an full no-misalignment array to fill when non-aligned
1972-
ds['yawmis'] = (('case','turbine'), np.zeros_like(ds['yaw']))
1973-
ds['misalignment'] = (('case'), np.full_like(ds['inflow_deg'], False, dtype=bool))
1974-
1975-
if self.sweepYM:
1976-
# Now, we fill the array with the new values on the second half (first half has no misalignment)
1977-
for c in range(nCases_before_sweep):
1978-
currCase = nCases_before_sweep + c
1979-
ds['yawmis'].loc[dict(case=currCase, turbine=slice(None))] = np.random.uniform(size=case.nTurbines,low=-8,high=8)
1980-
ds['misalignment'].loc[dict(case=currCase)] = True
1981-
19821948
self.allCases = ds.copy()
1949+
19831950
self.nCases = len(self.allCases['case'])
19841951

19851952

@@ -2335,11 +2302,10 @@ def getDomainParameters(self):
23352302
if self.verbose>1: print(' Running a TurbSim setup once to get domain extents')
23362303
self.TS_low_setup(writeFiles=False, runOnce=True)
23372304

2338-
# Figure out how many (and which) high boxes actually need to be executed. Remember that yaw misalignment, SED/ADsk models,
2305+
# Figure out how many (and which) high boxes actually need to be executed. Remember that SED/ADsk models
23392306
# and sweep in yaw do not require extra TurbSim runs
23402307
self.nHighBoxCases = len(np.unique(self.inflow_deg)) # some wind dir might be repeated for sweep on yaws
23412308

2342-
# This is a new method, but I'm not sure if it will work always, so let's leave the one above and check it
23432309
uniquewdir = np.unique(self.allCases.inflow_deg)
23442310
allHighBoxCases = []
23452311
for currwdir in uniquewdir:
@@ -2649,7 +2615,7 @@ def TS_high_slurm_submit(self, qos='normal', A=None, t=None, p=None, inplace=Tru
26492615

26502616
def TS_high_create_symlink(self):
26512617

2652-
# Create symlink of all the high boxes for the cases with yaw misalignment. These are the "repeated" boxes
2618+
# Create symlink of all the high boxes for the cases with different turbine properties (e.g. yaw). These are the "repeated" boxes
26532619

26542620
if self.verbose>0:
26552621
print(f'Creating symlinks for all the high-resolution boxes')
@@ -2668,7 +2634,7 @@ def TS_high_create_symlink(self):
26682634
continue
26692635

26702636
# If we are here, the case is destination. Let's find the first case with the same wdir for source
2671-
varsToDrop = ['misalignment','yawmis','yaw','yawCase','ADmodel','EDmodel','nFullAeroDyn','nFulllElastoDyn']
2637+
varsToDrop = ['yaw','yawCase','ADmodel','EDmodel','nFullAeroDyn','nFulllElastoDyn']
26722638
dst_xr = self.allCases.sel(case=case, drop=True).drop_vars(varsToDrop)
26732639
currwdir = dst_xr['inflow_deg']
26742640

0 commit comments

Comments
 (0)