Skip to content

Commit 1e43d46

Browse files
authored
Merge pull request #2603 from mayankchetan/of_io_update
updates to handle writing OpenFAST models from weis and wind_io
2 parents 3a46cc4 + 74662f0 commit 1e43d46

File tree

9 files changed

+1332
-678
lines changed

9 files changed

+1332
-678
lines changed

openfast_io/openfast_io/FAST_reader.py

Lines changed: 220 additions & 130 deletions
Large diffs are not rendered by default.

openfast_io/openfast_io/FAST_vars_out.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Generated from FAST OutListParameters.xlsx files with AeroelasticSE/src/AeroelasticSE/Util/create_output_vars.py """
1+
""" Generated from FAST OutListParameters.xlsx files with openfast_io/openfast_io/create_output_vars.py """
22

33

44
""" AeroDyn """

openfast_io/openfast_io/FAST_writer.py

Lines changed: 186 additions & 123 deletions
Large diffs are not rendered by default.

openfast_io/openfast_io/FileTools.py

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import operator
44
import numpy as np
55
import yaml
6+
import sys
67
from functools import reduce
78
from deepdiff import DeepDiff
89
try:
@@ -137,6 +138,11 @@ def save_yaml(outdir, fname, data_out):
137138
yaml.dump(data_out, f)
138139
f.close()
139140

141+
def print_yaml(data_struct):
142+
data_struct = remove_numpy(data_struct)
143+
yaml=ry.YAML()
144+
yaml.indent(mapping=4, sequence=6, offset=3)
145+
yaml.dump(data_struct,sys.stdout)
140146

141147
def select_cases(cases, var_sel, val_sel):
142148
# Find a variable value from the AeroelasticSE case_matrix
@@ -290,10 +296,83 @@ def remove_nested_keys(dictionary, keys_to_remove):
290296

291297
return dictionary
292298

293-
def cleanup_fstvt(fst_vt, ignoreVars=None, removeFileRef=False, removeArrayProps=False):
299+
def removeDeactivatedModules(fst_vt):
300+
# Mapping of deactivated modules to their corresponding module names
301+
OFmodules = {
302+
'CompElast': {
303+
1: ['ElastoDyn', 'ElastoDynBlade', 'ElastoDynTower'],
304+
2: ['ElastoDyn', 'ElastoDynTower', 'BeamDyn', 'BeamDynBlade'],
305+
3: ['SimpleElastoDyn']
306+
},
307+
'CompInflow': {
308+
0: [],
309+
1: ['InflowWind']
310+
},
311+
'CompAero': {
312+
0: [],
313+
1: ['AeroDisk'],
314+
2: ['AeroDyn', 'AeroDynBlade', 'AeroDynPolar']
315+
},
316+
'CompServo': {
317+
0: [],
318+
1: ['ServoDyn', 'DISCON_in']
319+
},
320+
'CompSeaSt': {
321+
0: [],
322+
1: ['SeaState']
323+
},
324+
'CompHydro': {
325+
0: [],
326+
1: ['HydroDyn']
327+
},
328+
'CompSub': {
329+
0: [],
330+
1: ['SubDyn'],
331+
2: ['read_ExtPtfm']
332+
},
333+
'CompMooring': {
334+
0: [],
335+
1: ['MAP'],
336+
2: [],
337+
3: ['MoorDyn', 'WaterKin'],
338+
4: []
339+
},
340+
'CompIce': {
341+
0: [],
342+
1: [],
343+
2: []
344+
}
345+
# 'MHK': {0:[]}, # no special handling for MHK
346+
}
347+
348+
keys2keep = []
349+
keys2remove = []
350+
# loop throught the keys of OFmodules, and make two lists, one of the needed ones,
351+
# and one of the ones to remove, then remove the ones to remove
352+
for module, active in fst_vt['Fst'].items():
353+
if module in OFmodules:
354+
if active in OFmodules[module]:
355+
# get the list of modules to keep
356+
keys2keep.extend(OFmodules[module][active])
357+
358+
# get the list of modules to remove
359+
for key, value in OFmodules[module].items():
360+
if key != active:
361+
keys2remove.extend(value)
362+
363+
# remove the keys in keys2remove and NOT in keys2keep
364+
fst_vt = remove_nested_keys(fst_vt, [key for key in keys2remove if key not in keys2keep])
365+
366+
return fst_vt
367+
368+
def cleanup_fstvt(fst_vt, ignoreVars=None, removeFileRef=False, removeArrayProps=False,
369+
removeDeactivatedModules=False):
294370
# sanitize the dictionaries from numpy data types
295371
fst_vt = remove_numpy(fst_vt)
296372

373+
if ignoreVars is not None:
374+
fst_vt = remove_nested_keys(fst_vt, ignoreVars)
375+
297376
if removeFileRef: # not fair to compare file paths
298377
fileVars = ['af_coord', 'Filename_Uni', 'FileName_BTS', 'FileName_u', 'FileName_v', 'FileName_w', # TODO: orgainze these logically
299378
'AFNames', 'ADBlFile1', 'ADBlFile2', 'ADBlFile3', 'NumCoords',
@@ -333,11 +412,12 @@ def cleanup_fstvt(fst_vt, ignoreVars=None, removeFileRef=False, removeArrayProps
333412
if removeArrayProps: # we can have different array properties, if run through different tools
334413
arrayVars = ['BlSpn', 'BlCrvAC','BlSwpAC','BlCrvAng','BlTwist','BlChord','BlAFID',
335414
'ac','PC_GS_KP','PC_GS_KI','WE_FOPoles','beam_stiff','attr','units']
336-
337415
fst_vt = remove_nested_keys(fst_vt, arrayVars)
338416

339-
if ignoreVars is not None:
340-
fst_vt = remove_nested_keys(fst_vt, ignoreVars)
417+
418+
if removeDeactivatedModules:
419+
fst_vt = removeDeactivatedModules(fst_vt)
420+
341421

342422
return fst_vt
343423

openfast_io/openfast_io/IEC_CoeherentGusts.py

Lines changed: 0 additions & 256 deletions
This file was deleted.

0 commit comments

Comments
 (0)