Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 9d24cf5

Browse files
committed
Merge branch 'f/ffarmscript' of github.com:rthedin/OpenFAST-python-toolbox into f/ffarmscript
2 parents 8e7be56 + 6eab192 commit 9d24cf5

File tree

2 files changed

+41
-72
lines changed

2 files changed

+41
-72
lines changed

pyFAST/fastfarm/AMRWindSimulation.py

+41-27
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ def __init__(self, wts:dict,
3636
self.n_cell = n_cell
3737
self.max_level = max_level
3838
self.incflo_velocity_hh = incflo_velocity_hh
39-
self.postproc_name = postproc_name
39+
self.postproc_name_lr = f"{postproc_name}_lr"
40+
self.postproc_name_hr = f"{postproc_name}_hr"
4041
self.buffer_lr = buffer_lr
4142
self.buffer_hr = buffer_hr
4243
self.ds_hr = ds_hr
4344
self.ds_lr = ds_lr
4445

4546
# Placeholder variables, to be calculated by FFCaseCreation
46-
self.output_frequency = None
47-
self.sampling_labels = None
47+
self.output_frequency_lr = None
48+
self.output_frequency_hr = None
49+
self.sampling_labels_lr = None
50+
self.sampling_labels_hr = None
4851
self.nx_lr = None
4952
self.ny_lr = None
5053
self.nz_lr = None
@@ -105,14 +108,18 @@ def _calc_sampling_params(self):
105108
'''
106109

107110
### ~~~~~~~~~ Calculate high-level info for AMR-Wind sampling ~~~~~~~~~
108-
sampling_labels = ["Low"]
111+
sampling_labels_lr = ["Low"]
112+
self.sampling_labels_lr = sampling_labels_lr
113+
114+
sampling_labels_hr = []
109115
for turbkey in self.wts:
110116
if 'name' in self.wts[turbkey].keys():
111117
wt_name = self.wts[turbkey]['name']
112118
else:
113119
wt_name = f'T{turbkey}'
114-
sampling_labels.append(f"High{wt_name}_inflow0deg")
115-
self.sampling_labels = sampling_labels
120+
sampling_labels_hr.append(f"High{wt_name}_inflow0deg")
121+
122+
self.sampling_labels_hr = sampling_labels_hr
116123

117124
### ~~~~~~~~~ Calculate timestep values and AMR-Wind plane sampling frequency ~~~~~~~~~
118125
## Low resolution domain, dt_low_les
@@ -133,7 +140,8 @@ def _calc_sampling_params(self):
133140
self.dt_high_les = self.dt * np.floor(dt_hr_max/self.dt) # Ensure that dt_hr is a multiple of the AMR-Wind timestep
134141

135142
## Sampling frequency
136-
self.output_frequency = int(self.dt_high_les/self.dt)
143+
self.output_frequency_lr = int(np.floor(self.dt_low_les/self.dt))
144+
self.output_frequency_hr = int(np.floor(self.dt_high_les/self.dt))
137145

138146
### ~~~~~~~~~ Calculate grid resolutions ~~~~~~~~~
139147
## Low resolution domain, ds_lr (s = x/y/z)
@@ -373,25 +381,31 @@ def write_sampling_params(self, outdir=None):
373381
print(f"Writing to {outfile} ...")
374382
with open(outfile,"w") as out:
375383
# Write high-level info for sampling
376-
sampling_labels_str = " ".join(str(item) for item in self.sampling_labels)
384+
sampling_labels_lr_str = " ".join(str(item) for item in self.sampling_labels_lr)
385+
sampling_labels_hr_str = " ".join(str(item) for item in self.sampling_labels_hr)
377386
out.write(f"# Sampling info generated by AMRWindSamplingCreation.py\n")
378-
out.write(f"incflo.post_processing = {self.postproc_name} # averaging\n")
379-
out.write(f"{self.postproc_name}.output_format = netcdf\n")
380-
out.write(f"{self.postproc_name}.output_frequency = {self.output_frequency}\n")
381-
out.write(f"{self.postproc_name}.fields = velocity # temperature tke\n")
382-
out.write(f"{self.postproc_name}.labels = {sampling_labels_str}\n")
387+
out.write(f"incflo.post_processing = {self.postproc_name_lr} {self.postproc_name_hr} # averaging\n\n")
388+
out.write(f"{self.postproc_name_lr}.output_format = netcdf\n")
389+
out.write(f"{self.postproc_name_lr}.output_frequency = {self.output_frequency_lr}\n")
390+
out.write(f"{self.postproc_name_lr}.fields = velocity # temperature tke\n")
391+
out.write(f"{self.postproc_name_lr}.labels = {sampling_labels_lr_str}\n\n")
392+
393+
out.write(f"{self.postproc_name_hr}.output_format = netcdf\n")
394+
out.write(f"{self.postproc_name_hr}.output_frequency = {self.output_frequency_hr}\n")
395+
out.write(f"{self.postproc_name_hr}.fields = velocity # temperature tke\n")
396+
out.write(f"{self.postproc_name_hr}.labels = {sampling_labels_hr_str}\n")
383397

384398
# Write out low resolution sampling plane info
385399
zoffsets_lr_str = " ".join(str(int(item)) for item in self.zoffsets_lr)
386400

387401
out.write(f"\n# Low sampling grid spacing = {self.ds_lr} m\n")
388-
out.write(f"{self.postproc_name}.Low.type = PlaneSampler\n")
389-
out.write(f"{self.postproc_name}.Low.num_points = {self.nx_lr} {self.ny_lr}\n")
390-
out.write(f"{self.postproc_name}.Low.origin = {self.xlow_lr:.1f} {self.ylow_lr:.1f} {self.zlow_lr:.1f}\n") # Round the float output
391-
out.write(f"{self.postproc_name}.Low.axis1 = {self.xdist_lr:.1f} 0.0 0.0\n") # Assume: axis1 oriented parallel to AMR-Wind x-axis
392-
out.write(f"{self.postproc_name}.Low.axis2 = 0.0 {self.ydist_lr:.1f} 0.0\n") # Assume: axis2 oriented parallel to AMR-Wind y-axis
393-
out.write(f"{self.postproc_name}.Low.normal = 0.0 0.0 1.0\n")
394-
out.write(f"{self.postproc_name}.Low.offsets = {zoffsets_lr_str}\n")
402+
out.write(f"{self.postproc_name_lr}.Low.type = PlaneSampler\n")
403+
out.write(f"{self.postproc_name_lr}.Low.num_points = {self.nx_lr} {self.ny_lr}\n")
404+
out.write(f"{self.postproc_name_lr}.Low.origin = {self.xlow_lr:.1f} {self.ylow_lr:.1f} {self.zlow_lr:.1f}\n") # Round the float output
405+
out.write(f"{self.postproc_name_lr}.Low.axis1 = {self.xdist_lr:.1f} 0.0 0.0\n") # Assume: axis1 oriented parallel to AMR-Wind x-axis
406+
out.write(f"{self.postproc_name_lr}.Low.axis2 = 0.0 {self.ydist_lr:.1f} 0.0\n") # Assume: axis2 oriented parallel to AMR-Wind y-axis
407+
out.write(f"{self.postproc_name_lr}.Low.normal = 0.0 0.0 1.0\n")
408+
out.write(f"{self.postproc_name_lr}.Low.offsets = {zoffsets_lr_str}\n")
395409

396410
# Write out high resolution sampling plane info
397411
for turbkey in self.hr_domains:
@@ -414,10 +428,10 @@ def write_sampling_params(self, outdir=None):
414428
zoffsets_hr_str = " ".join(str(int(item)) for item in zoffsets_hr)
415429

416430
out.write(f"\n# Turbine {wt_name} at (x,y) = ({wt_x}, {wt_y}), with D = {wt_D}, grid spacing = {self.ds_hr} m\n")
417-
out.write(f"{self.postproc_name}.{sampling_name}.type = PlaneSampler\n")
418-
out.write(f"{self.postproc_name}.{sampling_name}.num_points = {nx_hr} {ny_hr}\n")
419-
out.write(f"{self.postproc_name}.{sampling_name}.origin = {xlow_hr:.1f} {ylow_hr:.1f} {zlow_hr:.1f}\n") # Round the float output
420-
out.write(f"{self.postproc_name}.{sampling_name}.axis1 = {xdist_hr:.1f} 0.0 0.0\n") # Assume: axis1 oriented parallel to AMR-Wind x-axis
421-
out.write(f"{self.postproc_name}.{sampling_name}.axis2 = 0.0 {ydist_hr:.1f} 0.0\n") # Assume: axis2 oriented parallel to AMR-Wind y-axis
422-
out.write(f"{self.postproc_name}.{sampling_name}.normal = 0.0 0.0 1.0\n")
423-
out.write(f"{self.postproc_name}.{sampling_name}.offsets = {zoffsets_hr_str}\n")
431+
out.write(f"{self.postproc_name_hr}.{sampling_name}.type = PlaneSampler\n")
432+
out.write(f"{self.postproc_name_hr}.{sampling_name}.num_points = {nx_hr} {ny_hr}\n")
433+
out.write(f"{self.postproc_name_hr}.{sampling_name}.origin = {xlow_hr:.1f} {ylow_hr:.1f} {zlow_hr:.1f}\n") # Round the float output
434+
out.write(f"{self.postproc_name_hr}.{sampling_name}.axis1 = {xdist_hr:.1f} 0.0 0.0\n") # Assume: axis1 oriented parallel to AMR-Wind x-axis
435+
out.write(f"{self.postproc_name_hr}.{sampling_name}.axis2 = 0.0 {ydist_hr:.1f} 0.0\n") # Assume: axis2 oriented parallel to AMR-Wind y-axis
436+
out.write(f"{self.postproc_name_hr}.{sampling_name}.normal = 0.0 0.0 1.0\n")
437+
out.write(f"{self.postproc_name_hr}.{sampling_name}.offsets = {zoffsets_hr_str}\n")

pyFAST/fastfarm/examples/Ex4_AMRWindSamplingSetup.py

-45
Original file line numberDiff line numberDiff line change
@@ -41,50 +41,5 @@ def main():
4141
# Write out sampling parameters
4242
amr.write_sampling_params(outdir)
4343

44-
'''
45-
Below are the generated contents of sampling_config.i:
46-
# Sampling info generated by AMRWindSamplingCreation.py
47-
incflo.post_processing = sampling # averaging
48-
sampling.output_frequency = 1
49-
sampling.fields = velocity # temperature tke
50-
sampling.labels = Low HighT0_inflow0deg HighT1_inflow0deg HighT2_inflow0deg
51-
52-
# Low sampling grid spacing = 10.0 m
53-
sampling.Low.type = PlaneSampler
54-
sampling.Low.num_points = 78 206
55-
sampling.Low.origin = 885.0 2165.0 5.0
56-
sampling.Low.axis1 = 770.0 0.0 0.0
57-
sampling.Low.axis2 = 0.0 2050.0 0.0
58-
sampling.Low.normal = 0.0 0.0 1.0
59-
sampling.Low.offsets = 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280
60-
61-
# Turbine T0 at (x,y) = (1280.0, 2560), with D = 126.9, grid spacing = 5.0 m
62-
sampling.HighT0_inflow0deg.type = PlaneSampler
63-
sampling.HighT0_inflow0deg.num_points = 32 32
64-
sampling.HighT0_inflow0deg.origin = 1197.5 2477.5 2.5
65-
sampling.HighT0_inflow0deg.axis1 = 155.0 0.0 0.0
66-
sampling.HighT0_inflow0deg.axis2 = 0.0 155.0 0.0
67-
sampling.HighT0_inflow0deg.normal = 0.0 0.0 1.0
68-
sampling.HighT0_inflow0deg.offsets = 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230
69-
70-
# Turbine T1 at (x,y) = (1280.0, 3200), with D = 126.9, grid spacing = 5.0 m
71-
sampling.HighT1_inflow0deg.type = PlaneSampler
72-
sampling.HighT1_inflow0deg.num_points = 32 32
73-
sampling.HighT1_inflow0deg.origin = 1197.5 3117.5 2.5
74-
sampling.HighT1_inflow0deg.axis1 = 155.0 0.0 0.0
75-
sampling.HighT1_inflow0deg.axis2 = 0.0 155.0 0.0
76-
sampling.HighT1_inflow0deg.normal = 0.0 0.0 1.0
77-
sampling.HighT1_inflow0deg.offsets = 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230
78-
79-
# Turbine T2 at (x,y) = (1280.0, 3840), with D = 126.9, grid spacing = 5.0 m
80-
sampling.HighT2_inflow0deg.type = PlaneSampler
81-
sampling.HighT2_inflow0deg.num_points = 32 32
82-
sampling.HighT2_inflow0deg.origin = 1197.5 3757.5 2.5
83-
sampling.HighT2_inflow0deg.axis1 = 155.0 0.0 0.0
84-
sampling.HighT2_inflow0deg.axis2 = 0.0 155.0 0.0
85-
sampling.HighT2_inflow0deg.normal = 0.0 0.0 1.0
86-
sampling.HighT2_inflow0deg.offsets = 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230
87-
'''
88-
8944
if __name__ == '__main__':
9045
main()

0 commit comments

Comments
 (0)