From 6462749de96f60158b1663c4fda82756e669b1f7 Mon Sep 17 00:00:00 2001 From: pibo Date: Tue, 17 Oct 2023 12:58:01 -0600 Subject: [PATCH 1/5] BD now works even when BD not defined in mid chord --- pyFAST/converters/beamDynToHawc2.py | 53 +++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/pyFAST/converters/beamDynToHawc2.py b/pyFAST/converters/beamDynToHawc2.py index 6575113..ad19ac5 100644 --- a/pyFAST/converters/beamDynToHawc2.py +++ b/pyFAST/converters/beamDynToHawc2.py @@ -9,6 +9,7 @@ from pyFAST.input_output.csv_file import CSVFile from pyFAST.input_output.fast_input_file import FASTInputFile from pyFAST.converters.beam import ComputeStiffnessProps, TransformCrossSectionMatrix +from pyFAST.input_output.fast_input_deck import FASTInputDeck from .beam import * from .hawc2 import dfstructure2stfile @@ -58,7 +59,7 @@ def arc_length(points): # --------------------------------------------------------------------------------} # ---beamDynToHawc2 # --------------------------------------------------------------------------------{ -def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, bodyname=None, A=None, E=None, G=None, theta_p_in=None, FPM=False, verbose=False): +def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, bodyname=None, A=None, E=None, G=None, fstIn=None, theta_p_in=None, FPM=False, verbose=False): """ FPM: fully populated matrix, if True, use the FPM format of hawc2 @@ -71,7 +72,7 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b bdLine = BD_mainfile.toDataFrame() prop = BD_bladefile.toDataFrame() - # --- Extract relevant info + # Define BeamDyn reference axis r_bar = prop['Span'].values kp_x_raw = bdLine['kp_xr_[m]'].values @@ -87,7 +88,7 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b kp_z = np.interp(r_bar, s_coord, kp_z_raw) twist = np.interp(r_bar, s_coord, twist_raw) - + # Create K and M matrices K = np.zeros((6,6),dtype='object') M = np.zeros((6,6),dtype='object') for i in np.arange(6): @@ -95,6 +96,52 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b K[i,j]=prop['K{}{}'.format(i+1,j+1)].values M[i,j]=prop['M{}{}'.format(i+1,j+1)].values + if fstIn != None: + fst = FASTInputDeck(fstIn, verbose=True) + Bld = fst.fst_vt['AeroDynBlade'] + AF = fst.fst_vt['af_data'] + BlSpn = Bld['BldAeroNodes'][:,0] + n_span = len(BlSpn) + ac_pos = np.zeros(n_span) + for iSpan in range(n_span): + ac_pos[iSpan] = fst.fst_vt['ac_data'][iSpan]['AirfoilRefPoint'][0] + # Define axis of aero centers + BlCrvAC = Bld['BldAeroNodes'][:,1] + BlSwpAC = Bld['BldAeroNodes'][:,2] + chord = Bld['BldAeroNodes'][:,5] + s_aero = BlSpn/BlSpn[-1] + ac_x = np.interp(r_bar, s_aero, BlCrvAC) + ac_y = np.interp(r_bar, s_aero, BlSwpAC) + ac = np.interp(r_bar, s_aero, ac_pos) + + # Get x and y coordinates of c2 axis + ac2c2 = (0.5 - ac) * chord + c2_x = ac_x + ac2c2 * np.sin(twist) + c2_y = ac_y + ac2c2 * np.cos(twist) + # # Get offsets from BD axis to c2 axis along the twisted frame of reference + c2BD_y = (c2_y - kp_y) / np.cos(twist) + c2BD_x = np.zeros_like(c2BD_y) # no x translation, we should be translating along the twisted chord + + # Translate matrices to from BD to c2 axis (translate along chord, x and twist are 0) + transform = TransformCrossSectionMatrix() + for iSpan in np.arange(len(K[0,0])): + K_bd_temp = np.zeros((6,6)) + M_bd_temp = np.zeros((6,6)) + for i in np.arange(6): + for j in np.arange(6): + K_bd_temp[i,j] = K[i,j][iSpan] + M_bd_temp[i,j] = M[i,j][iSpan] + K_c2_temp = transform.CrossSectionRotoTranslationMatrix(K_bd_temp, 0., c2BD_y[iSpan], 0.) + M_c2_temp = transform.CrossSectionRotoTranslationMatrix(M_bd_temp, 0., c2BD_y[iSpan], 0.) + for i in np.arange(6): + for j in np.arange(6): + K[i,j][iSpan]=K_c2_temp[i,j] + M[i,j][iSpan]=M_c2_temp[i,j] + + # Update BeamDyn axis to c2 axis + kp_x = c2_x + kp_y = c2_y + # Map 6x6 data to "beam" data # NOTE: theta_* are in [rad] EA, EIx, EIy, kxsGA, kysGA, GKt, x_C, y_C, x_S, y_S, theta_p, theta_s = K66toPropsDecoupled(K, theta_p_in) From 38c04ee08759239d933598a81aa4407b291019dc Mon Sep 17 00:00:00 2001 From: pibo Date: Tue, 17 Oct 2023 13:00:30 -0600 Subject: [PATCH 2/5] fix comment --- pyFAST/converters/beamDynToHawc2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyFAST/converters/beamDynToHawc2.py b/pyFAST/converters/beamDynToHawc2.py index ad19ac5..6e16204 100644 --- a/pyFAST/converters/beamDynToHawc2.py +++ b/pyFAST/converters/beamDynToHawc2.py @@ -118,7 +118,7 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b ac2c2 = (0.5 - ac) * chord c2_x = ac_x + ac2c2 * np.sin(twist) c2_y = ac_y + ac2c2 * np.cos(twist) - # # Get offsets from BD axis to c2 axis along the twisted frame of reference + # Get offsets from BD axis to c2 axis along the twisted frame of reference c2BD_y = (c2_y - kp_y) / np.cos(twist) c2BD_x = np.zeros_like(c2BD_y) # no x translation, we should be translating along the twisted chord From 00446d5a6d885927ae8e987c10c275e806bebe3a Mon Sep 17 00:00:00 2001 From: pibo Date: Tue, 17 Oct 2023 13:39:25 -0600 Subject: [PATCH 3/5] rename variables --- pyFAST/converters/beamDynToHawc2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyFAST/converters/beamDynToHawc2.py b/pyFAST/converters/beamDynToHawc2.py index 6e16204..2de28da 100644 --- a/pyFAST/converters/beamDynToHawc2.py +++ b/pyFAST/converters/beamDynToHawc2.py @@ -102,9 +102,9 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b AF = fst.fst_vt['af_data'] BlSpn = Bld['BldAeroNodes'][:,0] n_span = len(BlSpn) - ac_pos = np.zeros(n_span) + le2ac_raw = np.zeros(n_span) for iSpan in range(n_span): - ac_pos[iSpan] = fst.fst_vt['ac_data'][iSpan]['AirfoilRefPoint'][0] + le2ac_raw[iSpan] = fst.fst_vt['ac_data'][iSpan]['AirfoilRefPoint'][0] # Define axis of aero centers BlCrvAC = Bld['BldAeroNodes'][:,1] BlSwpAC = Bld['BldAeroNodes'][:,2] @@ -112,14 +112,14 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b s_aero = BlSpn/BlSpn[-1] ac_x = np.interp(r_bar, s_aero, BlCrvAC) ac_y = np.interp(r_bar, s_aero, BlSwpAC) - ac = np.interp(r_bar, s_aero, ac_pos) + le2ac = np.interp(r_bar, s_aero, le2ac_raw) # Get x and y coordinates of c2 axis - ac2c2 = (0.5 - ac) * chord + ac2c2 = (0.5 - le2ac) * chord c2_x = ac_x + ac2c2 * np.sin(twist) c2_y = ac_y + ac2c2 * np.cos(twist) # Get offsets from BD axis to c2 axis along the twisted frame of reference - c2BD_y = (c2_y - kp_y) / np.cos(twist) + c2BD_y = np.sqrt( (c2_y - kp_y)**2 + (c2_x - kp_x)**2 ) c2BD_x = np.zeros_like(c2BD_y) # no x translation, we should be translating along the twisted chord # Translate matrices to from BD to c2 axis (translate along chord, x and twist are 0) From 83c84c50736bbab11064f3b76a383bda5a5b586d Mon Sep 17 00:00:00 2001 From: pibo Date: Tue, 17 Oct 2023 13:40:24 -0600 Subject: [PATCH 4/5] add comment --- pyFAST/converters/beamDynToHawc2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyFAST/converters/beamDynToHawc2.py b/pyFAST/converters/beamDynToHawc2.py index 2de28da..0343dce 100644 --- a/pyFAST/converters/beamDynToHawc2.py +++ b/pyFAST/converters/beamDynToHawc2.py @@ -112,7 +112,7 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b s_aero = BlSpn/BlSpn[-1] ac_x = np.interp(r_bar, s_aero, BlCrvAC) ac_y = np.interp(r_bar, s_aero, BlSwpAC) - le2ac = np.interp(r_bar, s_aero, le2ac_raw) + le2ac = np.interp(r_bar, s_aero, le2ac_raw) # Leading edge to aerodynamic center (in chord) # Get x and y coordinates of c2 axis ac2c2 = (0.5 - le2ac) * chord From 18de6e161418fffcc0463129417fce58dcbb22b6 Mon Sep 17 00:00:00 2001 From: pibo Date: Tue, 17 Oct 2023 13:41:05 -0600 Subject: [PATCH 5/5] fix aother tiny comment --- pyFAST/converters/beamDynToHawc2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyFAST/converters/beamDynToHawc2.py b/pyFAST/converters/beamDynToHawc2.py index 0343dce..d596059 100644 --- a/pyFAST/converters/beamDynToHawc2.py +++ b/pyFAST/converters/beamDynToHawc2.py @@ -122,7 +122,7 @@ def beamDynToHawc2(BD_mainfile, BD_bladefile, H2_htcfile=None, H2_stfile=None, b c2BD_y = np.sqrt( (c2_y - kp_y)**2 + (c2_x - kp_x)**2 ) c2BD_x = np.zeros_like(c2BD_y) # no x translation, we should be translating along the twisted chord - # Translate matrices to from BD to c2 axis (translate along chord, x and twist are 0) + # Translate matrices from BD to c2 axis (translate along chord, x and twist are 0) transform = TransformCrossSectionMatrix() for iSpan in np.arange(len(K[0,0])): K_bd_temp = np.zeros((6,6))