Skip to content

Commit 79b25ca

Browse files
authored
Merge pull request #68 from rthedin/bugfix/hydro
Fix HydroDyn reader for openfast version 4
2 parents c42f200 + 5422347 commit 79b25ca

File tree

3 files changed

+80
-32
lines changed

3 files changed

+80
-32
lines changed

openfast_toolbox/fastfarm/postpro/ff_postpro.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ def readTurbineOutput(caseobj, dt_openfast, dt_processing=1, saveOutput=True, ou
206206
turbs_t=[]
207207
for t in np.arange(iTurbine, fTurbine, 1):
208208
print(f'Processing Condition {cond}, Case {case}, Seed {seed}, turbine {t+1}')
209-
ff_file = os.path.join(caseobj.path, caseobj.condDirList[cond], caseobj.caseDirList[case], f'Seed_{seed}', f'{_get_fstf_filename(caseobj)}.T{t+1}.outb')
209+
ff_file = os.path.join(caseobj.path, caseobj.condDirList[cond], caseobj.caseDirList[case], f'Seed_{seed}', f'{_get_fstf_filename(caseobj)}.T{t+1}')
210+
if os.path.isfile(ff_file+'.outb'):
211+
ff_file = ff_file + '.outb'
212+
elif os.path.isfile(ff_file+'.out'):
213+
ff_file = ff_file + '.out'
214+
else:
215+
raise ValueError(f'ERROR: neither output file {ff_file}.out[b] exists. ')
210216
df = FASTOutputFile(ff_file).toDataFrame()
211217
# Won't be able to send to xarray if columns are non-unique
212218
if not df.columns.is_unique:

openfast_toolbox/io/fast_input_file.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ def _read(self, IComment=None):
391391

392392
# --- Tables that can be detected based on the "Value" (first entry on line)
393393
# TODO members for BeamDyn with mutliple key point ####### TODO PropSetID is Duplicate SubDyn and used in HydroDyn
394-
NUMTAB_FROM_VAL_DETECT = ['HtFract' , 'TwrElev' , 'BlFract' , 'Genspd_TLU' , 'BlSpn' , 'HvCoefID' , 'AxCoefID' , 'JointID' , 'Dpth' , 'FillNumM' , 'MGDpth' , 'SimplCd' , 'RNodes' , 'kp_xr' , 'mu1' , 'TwrHtFr' , 'TwrRe' , 'WT_X']
395-
NUMTAB_FROM_VAL_DIM_VAR = ['NTwInpSt' , 'NumTwrNds' , 'NBlInpSt' , 'DLL_NumTrq' , 'NumBlNds' , 'NHvCoef' , 'NAxCoef' , 'NJoints' , 'NCoefDpth' , 'NFillGroups' , 'NMGDepths' , 1 , 'BldNodes' , 'kp_total' , 1 , 'NTwrHt' , 'NTwrRe' , 'NumTurbines']
396-
NUMTAB_FROM_VAL_VARNAME = ['TowProp' , 'TowProp' , 'BldProp' , 'DLLProp' , 'BldAeroNodes' , 'HvCoefs' , 'AxCoefs' , 'Joints' , 'DpthProp' , 'FillGroups' , 'MGProp' , 'SmplProp' , 'BldAeroNodes' , 'MemberGeom' , 'DampingCoeffs' , 'TowerProp' , 'TowerRe', 'WindTurbines']
397-
NUMTAB_FROM_VAL_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 2 , 2 , 1 , 1 , 2 ]
398-
NUMTAB_FROM_VAL_TYPE = ['num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'mix' , 'num' , 'num' , 'num' , 'num' , 'mix']
394+
NUMTAB_FROM_VAL_DETECT = ['HtFract' , 'TwrElev' , 'BlFract' , 'Genspd_TLU' , 'BlSpn' , 'HvCoefID' , 'AxCoefID' , 'JointID' , 'DpthCd' , 'DpthCdA' , 'FillNumM' , 'MGDpth' , 'SimplCd' , 'RNodes' , 'kp_xr' , 'mu1' , 'TwrHtFr' , 'TwrRe' , 'WT_X']
395+
NUMTAB_FROM_VAL_DIM_VAR = ['NTwInpSt' , 'NumTwrNds' , 'NBlInpSt' , 'DLL_NumTrq' , 'NumBlNds' , 'NHvCoef' , 'NAxCoef' , 'NJoints' , 'NCoefDpthCyl', 'NCoefDpthRec', 'NFillGroups' , 'NMGDepths' , 1 , 'BldNodes' , 'kp_total' , 1 , 'NTwrHt' , 'NTwrRe' , 'NumTurbines']
396+
NUMTAB_FROM_VAL_VARNAME = ['TowProp' , 'TowProp' , 'BldProp' , 'DLLProp' , 'BldAeroNodes' , 'HvCoefs' , 'AxCoefs' , 'Joints' , 'DpthCylProp' , 'DpthRecProp' , 'FillGroups' , 'MGProp' , 'SmplProp' , 'BldAeroNodes' , 'MemberGeom' , 'DampingCoeffs' , 'TowerProp' , 'TowerRe', 'WindTurbines']
397+
NUMTAB_FROM_VAL_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 2 , 2 , 1 , 1 , 2 ]
398+
NUMTAB_FROM_VAL_TYPE = ['num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'num' , 'mix' , 'num' , 'num' , 'num' , 'num' , 'mix']
399399
# SubDyn
400400
NUMTAB_FROM_VAL_DETECT += [ 'RJointID' , 'IJointID' , 'COSMID' , 'CMJointID' ]
401401
NUMTAB_FROM_VAL_DIM_VAR += [ 'NReact' , 'NInterf' , 'NCOSMs' , 'NCmass' ]
@@ -411,12 +411,12 @@ def _read(self, IComment=None):
411411

412412
# --- Tables that can be detected based on the "Label" (second entry on line)
413413
# NOTE: MJointID1, used by SubDyn and HydroDyn
414-
NUMTAB_FROM_LAB_DETECT = ['NumAlf' , 'F_X' , 'MemberCd1' , 'MJointID1' , 'NOutLoc' , 'NOutCnt' , 'PropD' ]
415-
NUMTAB_FROM_LAB_DIM_VAR = ['NumAlf' , 'NKInpSt' , 'NCoefMembers' , 'NMembers' , 'NMOutputs' , 'NMOutputs' , 'NPropSets' ]
416-
NUMTAB_FROM_LAB_VARNAME = ['AFCoeff' , 'TMDspProp' , 'MemberProp' , 'Members' , 'MemberOuts' , 'MemberOuts' , 'SectionProp' ]
417-
NUMTAB_FROM_LAB_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 ]
418-
NUMTAB_FROM_LAB_NOFFSET = [0 , 0 , 0 , 0 , 0 , 0 , 0 ]
419-
NUMTAB_FROM_LAB_TYPE = ['num' , 'num' , 'num' , 'mix' , 'num' , 'sdout' , 'num' ]
414+
NUMTAB_FROM_LAB_DETECT = ['NumAlf' , 'F_X' , 'MemberCd1' , 'MemberCdA1' , 'MJointID1' , 'NOutLoc' , 'NOutCnt' , 'PropD' , 'PropA' ]
415+
NUMTAB_FROM_LAB_DIM_VAR = ['NumAlf' , 'NKInpSt' , 'NCoefMembersCyl' , 'NCoefMembersRec' , 'NMembers' , 'NMOutputs' , 'NMOutputs' , 'NPropSetsCyl' , 'NPropSetsRec' ]
416+
NUMTAB_FROM_LAB_VARNAME = ['AFCoeff' , 'TMDspProp' , 'MemberCylProp' , 'MemberRecProp' , 'Members' , 'MemberOuts' , 'MemberOuts' , 'SectionCylProp', 'SectionRecProp' ]
417+
NUMTAB_FROM_LAB_NHEADER = [2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
418+
NUMTAB_FROM_LAB_NOFFSET = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
419+
NUMTAB_FROM_LAB_TYPE = ['num' , 'num' , 'num' , 'num' , 'mix' , 'num' , 'sdout' , 'num' , 'num' ]
420420
# MoorDyn Version 1 and 2 (with AUTO for LAB_DIM_VAR)
421421
NUMTAB_FROM_LAB_DETECT += ['Diam' ,'Type' ,'LineType' , 'Attachment']
422422
NUMTAB_FROM_LAB_DIM_VAR += ['NTypes:AUTO','NConnects' ,'NLines:AUTO' , 'AUTO']
@@ -668,7 +668,7 @@ def _read(self, IComment=None):
668668
nTabLines = d['tabDimVar']
669669
else:
670670
nTabLines = self[d['tabDimVar']]
671-
#print('Reading table {} Dimension {} (based on {})'.format(d['label'],nTabLines,d['tabDimVar']));
671+
#print('Reading table (based on value) {} Dimension {} (based on {})'.format(d['label'],nTabLines,d['tabDimVar']));
672672
d['value'], d['tabColumnNames'], d['tabUnits'] = parseFASTNumTable(self.filename,lines[i:i+nTabLines+nHeaders], nTabLines, i, nHeaders, tableType=tab_type, varNumLines=d['tabDimVar'])
673673
_, d['descr'] = splitAfterChar(lines[i], '!')
674674
i += nTabLines+nHeaders-1
@@ -735,7 +735,7 @@ def _read(self, IComment=None):
735735
pass
736736

737737
d['label'] += labOffset
738-
#print('Reading table {} Dimension {} (based on {})'.format(d['label'],nTabLines,d['tabDimVar']));
738+
#print('Reading table (based on label) {} Dimension {} (based on {})'.format(d['label'],nTabLines,d['tabDimVar']));
739739
d['value'], d['tabColumnNames'], d['tabUnits'] = parseFASTNumTable(self.filename,lines[i:i+nTabLines+nHeaders+nOffset],nTabLines,i, nHeaders, tableType=tab_type, nOffset=nOffset, varNumLines=d['tabDimVar'])
740740
d['descr'] = '' #
741741
i += nTabLines+1-nOffset
@@ -767,7 +767,6 @@ def _read(self, IComment=None):
767767
i += 1
768768
# --- Safety checks
769769
if d['isComment']:
770-
#print(line)
771770
nComments +=1
772771
else:
773772
if hasSpecialChars(d['label']):

openfast_toolbox/io/fast_input_file_graph.py

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,29 @@ def type2Color(Pot):
153153
Graph = GraphModel()
154154

155155
# --- Properties
156-
if 'SectionProp' in hd.keys():
156+
#if 'SectionProp' in hd.keys():
157+
# # NOTE: setting it as element property since two memebrs may connect on the same node with different diameters/thicknesses
158+
# Graph.addNodePropertySet('Section')
159+
# for ip,P in enumerate(hd['SectionProp']):
160+
# # PropSetID PropD PropThck
161+
# prop= NodeProperty(ID=P[0], D=P[1], t=P[2])
162+
# Graph.addNodeProperty('Section',prop)
163+
164+
if 'SectionCylProp' in hd.keys():
157165
# NOTE: setting it as element property since two memebrs may connect on the same node with different diameters/thicknesses
158-
Graph.addNodePropertySet('Section')
159-
for ip,P in enumerate(hd['SectionProp']):
166+
Graph.addNodePropertySet('SectionCyl')
167+
for ip,P in enumerate(hd['SectionCylProp']):
160168
# PropSetID PropD PropThck
161169
prop= NodeProperty(ID=P[0], D=P[1], t=P[2])
162-
Graph.addNodeProperty('Section',prop)
170+
Graph.addNodeProperty('SectionCyl',prop)
171+
172+
if 'SectionRecProp' in hd.keys():
173+
# NOTE: setting it as element property since two memebrs may connect on the same node with different diameters/thicknesses
174+
Graph.addNodePropertySet('SectionRec')
175+
for ip,P in enumerate(hd['SectionRecProp']):
176+
# MPropSetID PropA ProbB PropThck
177+
prop= NodeProperty(ID=P[0], D=P[1], t=P[2], t=P[3])
178+
Graph.addNodeProperty('SectionRec',prop)
163179

164180
# --- Hydro Coefs - will be stored in AxCoefs, SimpleCoefs, DepthCoefs, MemberCoefs
165181
if 'AxCoefs' in hd.keys():
@@ -178,20 +194,47 @@ def type2Color(Pot):
178194
else:
179195
raise NotImplementedError()
180196
Graph.addNodeProperty('SimpleCoefs',prop)
181-
if 'DpthProp' in hd.keys():
182-
Graph.addMiscPropertySet('DepthCoefs')
183-
for ip,P in enumerate(hd['DpthProp']):
184-
# Dpth DpthCd DpthCdMG DpthCa DpthCaMG DpthCp DpthCpMG DpthAxCd DpthAxCdMG DpthAxCa DpthAxCaMG DpthAxCp DpthAxCpMG
185-
prop= Property(ID=ip+1, Dpth=P[0], Cd=P[1], CdMG=P[2], Ca=P[3], CaMG=P[4], Cp=P[5], CpMG=P[6], AxCd=P[7], AxCdMG=P[8], AxCa=P[9], AxCaMG=P[10], AxCp=P[11], AxCpMG=P[12])
186-
Graph.addMiscProperty('DepthCoefs',prop)
187-
188-
if 'MemberProp' in hd.keys():
197+
198+
#if 'DpthProp' in hd.keys():
199+
# Graph.addMiscPropertySet('DepthCoefs')
200+
# for ip,P in enumerate(hd['DpthProp']):
201+
# # Dpth DpthCd DpthCdMG DpthCa DpthCaMG DpthCp DpthCpMG DpthAxCd DpthAxCdMG DpthAxCa DpthAxCaMG DpthAxCp DpthAxCpMG
202+
# prop= Property(ID=ip+1, Dpth=P[0], Cd=P[1], CdMG=P[2], Ca=P[3], CaMG=P[4], Cp=P[5], CpMG=P[6], AxCd=P[7], AxCdMG=P[8], AxCa=P[9], AxCaMG=P[10], AxCp=P[11], AxCpMG=P[12])
203+
# Graph.addMiscProperty('DepthCoefs',prop)
204+
if 'DpthCylProp' in hd.keys():
205+
Graph.addMiscPropertySet('DepthCylCoefs')
206+
for ip,P in enumerate(hd['DpthCylProp']):
207+
# Dpth DpthCd DpthCdMG DpthCa DpthCaMG DpthCp DpthCpMG DpthAxCd DpthAxCdMG DpthAxCa DpthAxCaMG DpthAxCp DpthAxCpMG DpthCb DpthCbMG
208+
prop= Property(ID=ip+1, Dpth=P[0], Cd=P[1], CdMG=P[2], Ca=P[3], CaMG=P[4], Cp=P[5], CpMG=P[6], AxCd=P[7], AxCdMG=P[8], AxCa=P[9], AxCaMG=P[10], AxCp=P[11], AxCpMG=P[12], Cb=P[13], CbMG=P[14])
209+
Graph.addMiscProperty('DepthCylCoefs',prop)
210+
if 'DpthRecProp' in hd.keys():
211+
Graph.addMiscPropertySet('DepthRecCoefs')
212+
for ip,P in enumerate(hd['DpthRecProp']):
213+
# Dpth DpthCdA DpthCdAMG DpthCdB DpthCdBMG DpthCaA DpthCaAMG DpthCaB DpthCaBMG DpthCp DpthCpMG DpthAxCd DpthAxCdMG DpthAxCa DpthAxCaMG DpthAxCp DpthAxCpMG DpthCb DpthCbMG
214+
prop= Property(ID=ip+1, Dpth=P[0], CdA=P[1], CdAMG=P[2], CdB=P[3], CdBMG=P[4], CaA=P[5], CaAMG=P[6], CaB=P[7], CaBMG=P[8], Cp=P[9], CpMG=P[10], AxCd=P[11], AxCdMG=P[12], AxCa=P[13], AxCaMg=P[14], AxCp=P[15], AxCpMG=P[16], Cb=P[17], CbMG=P[18])
215+
Graph.addMiscProperty('DepthRecCoefs',prop)
216+
217+
#if 'MemberProp' in hd.keys():
218+
# # Member-based hydro coefficinet
219+
# Graph.addMiscPropertySet('MemberCoefs')
220+
# for ip,P in enumerate(hd['MemberProp']):
221+
# # MemberID MemberCd1 MemberCd2 MemberCdMG1 MemberCdMG2 MemberCa1 MemberCa2 MemberCaMG1 MemberCaMG2 MemberCp1 MemberCp2 MemberCpMG1 MemberCpMG2 MemberAxCd1 MemberAxCd2 MemberAxCdMG1 MemberAxCdMG2 MemberAxCa1 MemberAxCa2 MemberAxCaMG1 MemberAxCaMG2 MemberAxCp1 MemberAxCp2 MemberAxCpMG1 MemberAxCpMG2
222+
# prop = ElemProperty(ID=ip+1, MemberID=P[0], Cd1=P[1], Cd2=P[2], CdMG1=P[3], CdMG2=P[4], Ca1=P[5], Ca2=P[6], CaMG1=P[7], CaMG2=P[8], Cp1=P[9], Cp2=P[10], CpMG1=P[11], CpMG2=P[12], AxCd1=P[13], AxCd2=P[14], axCdMG1=P[15], axCdMG2=P[16], AxCa1=P[17], AxCa2=P[18], AxCaMG1=P[19], AxCaMG2=P[20], AxCp1=P[21], AxCp2=P[22], axCpMG1=P[23], AxCpMG2=P[24])
223+
# Graph.addMiscProperty('MemberCoefs',prop)
224+
if 'MemberCylProp' in hd.keys():
225+
# Member-based hydro coefficinet
226+
Graph.addMiscPropertySet('MemberCylCoefs')
227+
for ip,P in enumerate(hd['MemberCylProp']):
228+
# MemberID MemberCd1 MemberCd2 MemberCdMG1 MemberCdMG2 MemberCa1 MemberCa2 MemberCaMG1 MemberCaMG2 MemberCp1 MemberCp2 MemberCpMG1 MemberCpMG2 MemberAxCd1 MemberAxCd2 MemberAxCdMG1 MemberAxCdMG2 MemberAxCa1 MemberAxCa2 MemberAxCaMG1 MemberAxCaMG2 MemberAxCp1 MemberAxCp2 MemberAxCpMG1 MemberAxCpMG2 MemberCb1 MemberCb2 MemberCbMG1 MemberCbMG2
229+
prop = ElemProperty(ID=ip+1, MemberID=P[0], Cd1=P[1], Cd2=P[2], CdMG1=P[3], CdMG2=P[4], Ca1=P[5], Ca2=P[6], CaMG1=P[7], CaMG2=P[8], Cp1=P[9], Cp2=P[10], CpMG1=P[11], CpMG2=P[12], AxCd1=P[13], AxCd2=P[14], axCdMG1=P[15], axCdMG2=P[16], AxCa1=P[17], AxCa2=P[18], AxCaMG1=P[19], AxCaMG2=P[20], AxCp1=P[21], AxCp2=P[22], axCpMG1=P[23], AxCpMG2=P[24], Cb1=P[25], Cb2=P[26], CbMG1=P[27], CbMG2=P[28])
230+
Graph.addMiscProperty('MemberCylCoefs',prop)
231+
if 'MemberRecProp' in hd.keys():
189232
# Member-based hydro coefficinet
190-
Graph.addMiscPropertySet('MemberCoefs')
191-
for ip,P in enumerate(hd['MemberProp']):
192-
# MemberID MemberCd1 MemberCd2 MemberCdMG1 MemberCdMG2 MemberCa1 MemberCa2 MemberCaMG1 MemberCaMG2 MemberCp1 MemberCp2 MemberCpMG1 MemberCpMG2 MemberAxCd1 MemberAxCd2 MemberAxCdMG1 MemberAxCdMG2 MemberAxCa1 MemberAxCa2 MemberAxCaMG1 MemberAxCaMG2 MemberAxCp1 MemberAxCp2 MemberAxCpMG1 MemberAxCpMG2
193-
prop = ElemProperty(ID=ip+1, MemberID=P[0], Cd1=P[1], Cd2=P[2], CdMG1=P[3], CdMG2=P[4], Ca1=P[5], Ca2=P[6], CaMG1=P[7], CaMG2=P[8], Cp1=P[9], Cp2=P[10], CpMG1=P[11], CpMG2=P[12], AxCd1=P[14], AxCd2=P[15], axCdMG1=P[16], axCdMG2=P[17], AxCa1=P[18], AxCa2=P[19], AxCaMG1=P[20], AxCaMG2=P[21], AxCp1=P[22], AxCp2=P[23])
194-
Graph.addMiscProperty('MemberCoefs',prop)
233+
Graph.addMiscPropertySet('MemberRecCoefs')
234+
for ip,P in enumerate(hd['MemberRecProp']):
235+
# MemberID MemberCdA1 MemberCdA2 MemberCdAMG1 MemberCdAMG2 MemberCdB1 MemberCdB2 MemberCdBMG1 MemberCdBMG2 MemberCaA1 MemberCaA2 MemberCaAMG1 MemberCaAMG2 MemberCaB1 MemberCaB2 MemberCaBMG1 MemberCaBMG2 MemberCp1 MemberCp2 MemberCpMG1 MemberCpMG2 MemberAxCd1 MemberAxCd2 MemberAxCdMG1 MemberAxCdMG2 MemberAxCa1 MemberAxCa2 MemberAxCaMG1 MemberAxCaMG2 MemberAxCp1 MemberAxCp2 MemberAxCpMG1 MemberAxCpMG2 MemberCb1 MemberCb2 MemberCbMG1 MemberCbMG2
236+
prop = ElemProperty(ID=ip+1, MemberID=P[1], CdA1=P[2], CdA2=P[3], CdAMG1=P[4], CdAMG2=P[5], CdB1=P[6], CdB2=P[7], CdBMG1=P[8], CdBMG2=P[9], CaA1=P[10], CaA2=P[11], CaAMG1=P[12], CaAMG2=P[13], CaB1=P[14], CaB2=P[15], CaBMG1=P[16], CaBMG2=P[17], Cp1=P[18], Cp2=P[19], CpMG1=P[20], CpMG2=P[21], AxCd1=P[22], AxCd2=P[23], AxCdMG1=P[24], AxCdMG2=P[25], AxCa1=P[26], AxCa2=P[27], AxCaMG1=P[28], AxCaMG2=P[29], AxCp1=P[30], AxCp2=P[31], AxCpMG1=P[32], AxCpMG2=P[33], Cb1=P[34], Cb2=P[35], CbMG1=P[36], CbMG2=P[37] ]
237+
Graph.addMiscProperty('MemberRecCoefs',prop)
195238
# ---
196239
if 'FillGroups' in hd.keys():
197240
# Filled members

0 commit comments

Comments
 (0)