Skip to content

Commit

Permalink
Merge pull request #2603 from mayankchetan/of_io_update
Browse files Browse the repository at this point in the history
updates to handle writing OpenFAST models from weis and wind_io
  • Loading branch information
andrew-platt authored Jan 24, 2025
2 parents 3a46cc4 + 74662f0 commit 1e43d46
Show file tree
Hide file tree
Showing 9 changed files with 1,332 additions and 678 deletions.
350 changes: 220 additions & 130 deletions openfast_io/openfast_io/FAST_reader.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion openfast_io/openfast_io/FAST_vars_out.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Generated from FAST OutListParameters.xlsx files with AeroelasticSE/src/AeroelasticSE/Util/create_output_vars.py """
""" Generated from FAST OutListParameters.xlsx files with openfast_io/openfast_io/create_output_vars.py """


""" AeroDyn """
Expand Down
309 changes: 186 additions & 123 deletions openfast_io/openfast_io/FAST_writer.py

Large diffs are not rendered by default.

88 changes: 84 additions & 4 deletions openfast_io/openfast_io/FileTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import operator
import numpy as np
import yaml
import sys
from functools import reduce
from deepdiff import DeepDiff
try:
Expand Down Expand Up @@ -137,6 +138,11 @@ def save_yaml(outdir, fname, data_out):
yaml.dump(data_out, f)
f.close()

def print_yaml(data_struct):
data_struct = remove_numpy(data_struct)
yaml=ry.YAML()
yaml.indent(mapping=4, sequence=6, offset=3)
yaml.dump(data_struct,sys.stdout)

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

return dictionary

def cleanup_fstvt(fst_vt, ignoreVars=None, removeFileRef=False, removeArrayProps=False):
def removeDeactivatedModules(fst_vt):
# Mapping of deactivated modules to their corresponding module names
OFmodules = {
'CompElast': {
1: ['ElastoDyn', 'ElastoDynBlade', 'ElastoDynTower'],
2: ['ElastoDyn', 'ElastoDynTower', 'BeamDyn', 'BeamDynBlade'],
3: ['SimpleElastoDyn']
},
'CompInflow': {
0: [],
1: ['InflowWind']
},
'CompAero': {
0: [],
1: ['AeroDisk'],
2: ['AeroDyn', 'AeroDynBlade', 'AeroDynPolar']
},
'CompServo': {
0: [],
1: ['ServoDyn', 'DISCON_in']
},
'CompSeaSt': {
0: [],
1: ['SeaState']
},
'CompHydro': {
0: [],
1: ['HydroDyn']
},
'CompSub': {
0: [],
1: ['SubDyn'],
2: ['read_ExtPtfm']
},
'CompMooring': {
0: [],
1: ['MAP'],
2: [],
3: ['MoorDyn', 'WaterKin'],
4: []
},
'CompIce': {
0: [],
1: [],
2: []
}
# 'MHK': {0:[]}, # no special handling for MHK
}

keys2keep = []
keys2remove = []
# loop throught the keys of OFmodules, and make two lists, one of the needed ones,
# and one of the ones to remove, then remove the ones to remove
for module, active in fst_vt['Fst'].items():
if module in OFmodules:
if active in OFmodules[module]:
# get the list of modules to keep
keys2keep.extend(OFmodules[module][active])

# get the list of modules to remove
for key, value in OFmodules[module].items():
if key != active:
keys2remove.extend(value)

# remove the keys in keys2remove and NOT in keys2keep
fst_vt = remove_nested_keys(fst_vt, [key for key in keys2remove if key not in keys2keep])

return fst_vt

def cleanup_fstvt(fst_vt, ignoreVars=None, removeFileRef=False, removeArrayProps=False,
removeDeactivatedModules=False):
# sanitize the dictionaries from numpy data types
fst_vt = remove_numpy(fst_vt)

if ignoreVars is not None:
fst_vt = remove_nested_keys(fst_vt, ignoreVars)

if removeFileRef: # not fair to compare file paths
fileVars = ['af_coord', 'Filename_Uni', 'FileName_BTS', 'FileName_u', 'FileName_v', 'FileName_w', # TODO: orgainze these logically
'AFNames', 'ADBlFile1', 'ADBlFile2', 'ADBlFile3', 'NumCoords',
Expand Down Expand Up @@ -333,11 +412,12 @@ def cleanup_fstvt(fst_vt, ignoreVars=None, removeFileRef=False, removeArrayProps
if removeArrayProps: # we can have different array properties, if run through different tools
arrayVars = ['BlSpn', 'BlCrvAC','BlSwpAC','BlCrvAng','BlTwist','BlChord','BlAFID',
'ac','PC_GS_KP','PC_GS_KI','WE_FOPoles','beam_stiff','attr','units']

fst_vt = remove_nested_keys(fst_vt, arrayVars)

if ignoreVars is not None:
fst_vt = remove_nested_keys(fst_vt, ignoreVars)

if removeDeactivatedModules:
fst_vt = removeDeactivatedModules(fst_vt)


return fst_vt

Expand Down
256 changes: 0 additions & 256 deletions openfast_io/openfast_io/IEC_CoeherentGusts.py

This file was deleted.

Loading

0 comments on commit 1e43d46

Please sign in to comment.