Skip to content

Commit 07a3cb5

Browse files
authored
Merge pull request #58 from rthedin/f/amrfix
Fixes for AMR-Wind sampling
2 parents 2dc2156 + 141d650 commit 07a3cb5

File tree

4 files changed

+20
-190
lines changed

4 files changed

+20
-190
lines changed

openfast_toolbox/fastfarm/AMRWindSimulation.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,21 +642,34 @@ def _check_grid_placement_single(self, sampling_xyzgrid_lhr, amr_xyzgrid_at_lhr_
642642

643643

644644

645-
def write_sampling_params(self, out=None, format='netcdf', overwrite=False):
645+
def write_sampling_params(self, out=None, format='netcdf', terrain=None, overwrite=False):
646646
'''
647647
Write out text that can be used for the sampling planes in an
648648
AMR-Wind input file
649649
650650
out: str
651651
Output path or full filename for Input file to be written
652652
to. If None, result is written to screen.
653+
format: str
654+
Format requested for the output to be saved from AMR-Wind. Options are
655+
native and netcdf
656+
terrain: bool (required)
657+
If the case contains terrain. If it does, mu_turb will also be requested. This
658+
is necessary to process terrain files and set NaN inside the terrain.
653659
overwrite: bool
654660
If saving to a file, whether or not to overwrite potentially
655661
existing file
656662
'''
657663
if format not in ['netcdf','native']:
658664
raise ValueError(f'format should be either native or netcdf')
659665

666+
if terrain == True:
667+
fields = 'velocity mu_turb'
668+
elif terrain == False:
669+
fields = 'velocity'
670+
else:
671+
raise ValueError(f'The `terrain` input should be explicitly set to True or False')
672+
660673
# Write time step information for consistenty with sampling frequency
661674
s = f"time.fixed_dt = {self.dt}\n\n"
662675
# Write flow velocity info for consistency
@@ -674,7 +687,7 @@ def write_sampling_params(self, out=None, format='netcdf', overwrite=False):
674687
s += f"# ---- Low-res sampling parameters ----\n"
675688
s += f"{self.postproc_name_lr}.output_format = {format}\n"
676689
s += f"{self.postproc_name_lr}.output_frequency = {self.output_frequency_lr}\n"
677-
s += f"{self.postproc_name_lr}.fields = velocity # temperature tke\n"
690+
s += f"{self.postproc_name_lr}.fields = {fields}\n"
678691
s += f"{self.postproc_name_lr}.labels = {sampling_labels_lr_str}\n\n"
679692

680693
# Write out low resolution sampling plane info
@@ -692,7 +705,7 @@ def write_sampling_params(self, out=None, format='netcdf', overwrite=False):
692705
s += f"# ---- High-res sampling parameters ----\n"
693706
s += f"{self.postproc_name_hr}.output_format = {format}\n"
694707
s += f"{self.postproc_name_hr}.output_frequency = {self.output_frequency_hr}\n"
695-
s += f"{self.postproc_name_hr}.fields = velocity # temperature tke\n"
708+
s += f"{self.postproc_name_hr}.fields = {fields}\n"
696709
s += f"{self.postproc_name_hr}.labels = {sampling_labels_hr_str}\n"
697710

698711
# Write out high resolution sampling plane info

openfast_toolbox/fastfarm/FASTFarmCaseCreation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def __init__(self,
165165
ADmodel: list of strings
166166
List of AeroDyn/AeroDisk models to use for each case
167167
EDmodel: list of strings
168-
List of ElastoDym/SimplifiedElastoDyn models to use for each case
168+
List of ElastoDyn/SimplifiedElastoDyn models to use for each case
169169
nSeeds: int
170170
Number of seeds used for TurbSim simulations. If changing this value, give seedValues
171171
seedValues: list of int
@@ -805,6 +805,9 @@ def copyTurbineFilesForEachCase(self, writeFiles=True):
805805
if ADmodel_ == 'ADyn':
806806
self.AeroDynFile['ADBlFile(1)'] = self.AeroDynFile['ADBlFile(2)'] = self.AeroDynFile['ADBlFile(3)'] = f'"{self.ADbladefilename}"'
807807
self.AeroDynFile['Wake_Mod'] = 1
808+
if 'Skew_Mod' in self.AeroDynFile.keys():
809+
self.AeroDynFile['Skew_Mod'] = 1
810+
self.AeroDynFile['SkewMomCorr'] = True
808811
# self.AeroDynFile['UA_Mod'] = 0
809812
# Adjust the Airfoil path to point to the templatePath (1:-1 to remove quotes)
810813
self.AeroDynFile['AFNames'] = [f'"{os.path.join(self.templatePathabs, "Airfoils", i[1:-1].split("Airfoils/", 1)[-1])}"'

0 commit comments

Comments
 (0)