Skip to content

Commit

Permalink
Merge pull request #30 from rthedin/f/ff
Browse files Browse the repository at this point in the history
Further FAST.Farm improvements
  • Loading branch information
rthedin authored Feb 28, 2025
2 parents d764333 + d5915bc commit 4406c36
Show file tree
Hide file tree
Showing 5 changed files with 1,313 additions and 48 deletions.
42 changes: 23 additions & 19 deletions openfast_toolbox/fastfarm/AMRWindSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ def _checkInputs(self):
# Check that level_lr is >= 0
# check that level_hr is <=self.max_level

# For convenience, the turbines should not be zero-indexed
if self.wts[0]['name'] != 'T1':
print(f"--- WARNING: Recommended turbine numbering should start at 1. Currently it is zero-indexed.")


# Flags of given/calculated spatial resolution for warning/error printing purposes
self.given_ds_hr = False
Expand Down Expand Up @@ -652,7 +656,7 @@ def write_sampling_params(self, out=None, overwrite=False):
sampling_labels_lr_str = " ".join(str(item) for item in self.sampling_labels_lr)
sampling_labels_hr_str = " ".join(str(item) for item in self.sampling_labels_hr)
s += f"#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#\n"
s += f"# POST-Processing #\n"
s += f"# POST-PROCESSING #\n"
s += f"#.......................................#\n"
s += f"# Sampling info generated by AMRWindSamplingCreation.py on {self.curr_datetime}\n"
s += f"incflo.post_processing = {self.postproc_name_lr} {self.postproc_name_hr} # averaging\n\n\n"
Expand All @@ -667,19 +671,19 @@ def write_sampling_params(self, out=None, overwrite=False):
zoffsets_lr_str = " ".join(str(item) for item in self.zoffsets_lr)

s += f"# Low sampling grid spacing = {self.ds_lr} m\n"
s += f"{self.postproc_name_lr}.Low.type = PlaneSampler\n"
s += f"{self.postproc_name_lr}.Low.num_points = {self.nx_lr} {self.ny_lr}\n"
s += f"{self.postproc_name_lr}.Low.origin = {self.xlow_lr:.4f} {self.ylow_lr:.4f} {self.zlow_lr:.4f}\n" # Round the float output
s += f"{self.postproc_name_lr}.Low.axis1 = {self.xdist_lr:.4f} 0.0 0.0\n" # Assume: axis1 oriented parallel to AMR-Wind x-axis
s += f"{self.postproc_name_lr}.Low.axis2 = 0.0 {self.ydist_lr:.4f} 0.0\n" # Assume: axis2 oriented parallel to AMR-Wind y-axis
s += f"{self.postproc_name_lr}.Low.normal = 0.0 0.0 1.0\n"
s += f"{self.postproc_name_lr}.Low.offsets = {zoffsets_lr_str}\n\n\n"
s += f"{self.postproc_name_lr}.Low.type = PlaneSampler\n"
s += f"{self.postproc_name_lr}.Low.num_points = {self.nx_lr} {self.ny_lr}\n"
s += f"{self.postproc_name_lr}.Low.origin = {self.xlow_lr:.4f} {self.ylow_lr:.4f} {self.zlow_lr:.4f}\n" # Round the float output
s += f"{self.postproc_name_lr}.Low.axis1 = {self.xdist_lr:.4f} 0.0 0.0\n" # Assume: axis1 oriented parallel to AMR-Wind x-axis
s += f"{self.postproc_name_lr}.Low.axis2 = 0.0 {self.ydist_lr:.4f} 0.0\n" # Assume: axis2 oriented parallel to AMR-Wind y-axis
s += f"{self.postproc_name_lr}.Low.offset_vector = 0.0 0.0 1.0\n"
s += f"{self.postproc_name_lr}.Low.offsets = {zoffsets_lr_str}\n\n\n"

s += f"# ---- High-res sampling parameters ----\n"
s += f"{self.postproc_name_hr}.output_format = netcdf\n"
s += f"{self.postproc_name_hr}.output_frequency = {self.output_frequency_hr}\n"
s += f"{self.postproc_name_hr}.fields = velocity # temperature tke\n"
s += f"{self.postproc_name_hr}.labels = {sampling_labels_hr_str}\n"
s += f"{self.postproc_name_hr}.output_format = netcdf\n"
s += f"{self.postproc_name_hr}.output_frequency = {self.output_frequency_hr}\n"
s += f"{self.postproc_name_hr}.fields = velocity # temperature tke\n"
s += f"{self.postproc_name_hr}.labels = {sampling_labels_hr_str}\n"

# Write out high resolution sampling plane info
for turbkey in self.hr_domains:
Expand All @@ -704,13 +708,13 @@ def write_sampling_params(self, out=None, overwrite=False):
zoffsets_hr_str = " ".join(str(item) for item in zoffsets_hr)

s += f"\n# Turbine {wt_name} with base at (x,y,z) = ({wt_x:.4f}, {wt_y:.4f}, {wt_z:.4f}), with hh = {wt_h}, D = {wt_D}, grid spacing = {self.ds_hr} m\n"
s += f"{self.postproc_name_hr}.{sampling_name}.type = PlaneSampler\n"
s += f"{self.postproc_name_hr}.{sampling_name}.num_points = {nx_hr} {ny_hr}\n"
s += f"{self.postproc_name_hr}.{sampling_name}.origin = {xlow_hr:.4f} {ylow_hr:.4f} {zlow_hr:.4f}\n" # Round the float output
s += f"{self.postproc_name_hr}.{sampling_name}.axis1 = {xdist_hr:.4f} 0.0 0.0\n" # Assume: axis1 oriented parallel to AMR-Wind x-axis
s += f"{self.postproc_name_hr}.{sampling_name}.axis2 = 0.0 {ydist_hr:.4f} 0.0\n" # Assume: axis2 oriented parallel to AMR-Wind y-axis
s += f"{self.postproc_name_hr}.{sampling_name}.normal = 0.0 0.0 1.0\n"
s += f"{self.postproc_name_hr}.{sampling_name}.offsets = {zoffsets_hr_str}\n"
s += f"{self.postproc_name_hr}.{sampling_name}.type = PlaneSampler\n"
s += f"{self.postproc_name_hr}.{sampling_name}.num_points = {nx_hr} {ny_hr}\n"
s += f"{self.postproc_name_hr}.{sampling_name}.origin = {xlow_hr:.4f} {ylow_hr:.4f} {zlow_hr:.4f}\n" # Round the float output
s += f"{self.postproc_name_hr}.{sampling_name}.axis1 = {xdist_hr:.4f} 0.0 0.0\n" # Assume: axis1 oriented parallel to AMR-Wind x-axis
s += f"{self.postproc_name_hr}.{sampling_name}.axis2 = 0.0 {ydist_hr:.4f} 0.0\n" # Assume: axis2 oriented parallel to AMR-Wind y-axis
s += f"{self.postproc_name_hr}.{sampling_name}.offset_vector = 0.0 0.0 1.0\n"
s += f"{self.postproc_name_hr}.{sampling_name}.offsets = {zoffsets_hr_str}\n"


if out is None:
Expand Down
Loading

0 comments on commit 4406c36

Please sign in to comment.