From 68bf22a92948a53186b14fb66b42b4d76424d37e Mon Sep 17 00:00:00 2001 From: Su Tian Date: Thu, 26 Nov 2020 23:51:51 -0500 Subject: [PATCH] 1126 added function in sg module to calculate beam properties with offset frame --- dakota_interface.py | 2 +- io/iovabs.py | 44 +++++++------- sg.py | 143 +++++++++++++++++++++++++------------------- 3 files changed, 103 insertions(+), 86 deletions(-) diff --git a/dakota_interface.py b/dakota_interface.py index e110604..3debb82 100644 --- a/dakota_interface.py +++ b/dakota_interface.py @@ -20,7 +20,7 @@ fsi = ' > [{0:%H}:{0:%M}:{0:%S}] EVAL {1:d}: {2:s}' -def interface(fn_json_args): +def process(fn_json_args): # Load JSON arguments with open(fn_json_args, 'r') as fo: interface_args = json.load(fo) diff --git a/io/iovabs.py b/io/iovabs.py index 3f8056b..5841bd3 100644 --- a/io/iovabs.py +++ b/io/iovabs.py @@ -156,7 +156,7 @@ def readVABSIn(fn_vabs_in): mid = int(line[0].split(',')[0]) mtype = int(line[1]) sg.materials[mid] = sgm.MaterialSection() - sg.materials[mid].eff_props[3]['type'] = mtype + # sg.materials[mid].eff_props[3]['type'] = mtype line_material += 1 continue @@ -165,8 +165,8 @@ def readVABSIn(fn_vabs_in): if line_material == 1: e = float(line[0]) nu = float(line[1]) - sg.materials[mid].eff_props[3]['constants']['e'] = e - sg.materials[mid].eff_props[3]['constants']['nu'] = nu + # sg.materials[mid].eff_props[3]['constants']['e'] = e + # sg.materials[mid].eff_props[3]['constants']['nu'] = nu line_material = 99 continue elif mtype == 1: @@ -174,9 +174,9 @@ def readVABSIn(fn_vabs_in): if line_material == 1: # pe = [] e = list(map(float, line)) - sg.materials[mid].eff_props[3]['constants']['e1'] = e[0] - sg.materials[mid].eff_props[3]['constants']['e2'] = e[1] - sg.materials[mid].eff_props[3]['constants']['e3'] = e[2] + # sg.materials[mid].eff_props[3]['constants']['e1'] = e[0] + # sg.materials[mid].eff_props[3]['constants']['e2'] = e[1] + # sg.materials[mid].eff_props[3]['constants']['e3'] = e[2] # for ei in e: # pe.append(ei) # sg.materials[mid].property_elastic += e @@ -184,9 +184,9 @@ def readVABSIn(fn_vabs_in): continue elif line_material == 2: g = list(map(float, line)) - sg.materials[mid].eff_props[3]['constants']['g12'] = g[0] - sg.materials[mid].eff_props[3]['constants']['g13'] = g[1] - sg.materials[mid].eff_props[3]['constants']['g23'] = g[2] + # sg.materials[mid].eff_props[3]['constants']['g12'] = g[0] + # sg.materials[mid].eff_props[3]['constants']['g13'] = g[1] + # sg.materials[mid].eff_props[3]['constants']['g23'] = g[2] # for gi in g: # pe.append(gi) # self.materials[mid].property_elastic += g @@ -194,9 +194,9 @@ def readVABSIn(fn_vabs_in): continue elif line_material == 3: nu = list(map(float, line)) - sg.materials[mid].eff_props[3]['constants']['nu12'] = nu[0] - sg.materials[mid].eff_props[3]['constants']['nu13'] = nu[1] - sg.materials[mid].eff_props[3]['constants']['nu23'] = nu[2] + # sg.materials[mid].eff_props[3]['constants']['nu12'] = nu[0] + # sg.materials[mid].eff_props[3]['constants']['nu13'] = nu[1] + # sg.materials[mid].eff_props[3]['constants']['nu23'] = nu[2] # for nui in nu: # pe.append(nui) # sg.materials[mid].property_elastic.append(pe) @@ -208,7 +208,7 @@ def readVABSIn(fn_vabs_in): if line_material == 99: dens = float(line[0]) - sg.materials[mid].eff_props[3]['density'] = dens + # sg.materials[mid].eff_props[3]['density'] = dens # self.mate_propt[mid].append(dens) line_material = 0 count_material += 1 # next material @@ -257,7 +257,7 @@ def readVABSOutHomo(fn, scrnout=True): if 'Mass Per Unit Span' in line: sm.density = float(line.split('=')[-1].strip()) #old dic method to save density - sm.eff_props[1]['density'] = float(line.split('=')[-1].strip()) + # sm.eff_props[1]['density'] = float(line.split('=')[-1].strip()) if 'Mass Moments of Intertia' in line: if 'x1' in line: sm.mmoi[0] = float(line.split('=')[-1].strip()) @@ -335,13 +335,13 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['mass'] sm.mass_origin = utl.textToMatrix(linesRead[ln + 3:ln + 9]) #old dic method to save mass origin - sm.eff_props[1]['mass']['origin'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) + # sm.eff_props[1]['mass']['origin'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) try: ln = keywordsIndex['massatcenter'] sm.mass_mc = utl.textToMatrix(linesRead[ln + 3:ln + 9]) #old dic method to save mass center - sm.eff_props[1]['mass']['masscenter'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) + # sm.eff_props[1]['mass']['masscenter'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) except KeyError: sm.mass_mc = sm.mass_origin @@ -352,7 +352,7 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['vsm'] sm.stiffness_refined = utl.textToMatrix(linesRead[ln + 3:ln + 8]) #old dic to save valsov stiffness matrix - sm.eff_props[1]['stiffness']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 8]) + # sm.eff_props[1]['stiffness']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 8]) except KeyError: if scrnout: print('No Vlasov stiffness matrix found.') @@ -362,7 +362,7 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['vfm'] sm.compliance_refined = utl.textToMatrix(linesRead[ln + 3:ln + 8]) #old dic to save valsov compliance matrix - sm.eff_props[1]['compliance']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 8]) + # sm.eff_props[1]['compliance']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 8]) except KeyError: if scrnout: print('No Vlasov flexibility matrix found.') @@ -407,7 +407,7 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['csm'] sm.stiffness = utl.textToMatrix(linesRead[ln + 3:ln + 7]) #old dic method to save classical stiffness - sm.eff_props[1]['stiffness']['classical'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + # sm.eff_props[1]['stiffness']['classical'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) except KeyError: if scrnout: print('No Classical stiffness matrix found.') @@ -418,7 +418,7 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['cfm'] sm.compliance = utl.textToMatrix(linesRead[ln + 3:ln + 7]) #old dic method to save classical compliance - sm.eff_props[1]['compliance']['classical'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + # sm.eff_props[1]['compliance']['classical'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) except KeyError: if scrnout: print('No Classical flexibility matrix found.') @@ -429,7 +429,7 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['tsm'] sm.stiffness_refined = utl.textToMatrix(linesRead[ln + 3:ln + 9]) #old dic method to save refined stiffness matrix - sm.eff_props[1]['stiffness']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) + # sm.eff_props[1]['stiffness']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) except KeyError: if scrnout: print('No timoshenko stiffness matrix found.') @@ -439,7 +439,7 @@ def readVABSOutHomo(fn, scrnout=True): ln = keywordsIndex['tfm'] sm.compliance_refined = utl.textToMatrix(linesRead[ln + 3:ln + 9]) #old dic method to save refined compliance matrix - sm.eff_props[1]['compliance']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) + # sm.eff_props[1]['compliance']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) except KeyError: if scrnout: print('No timoshenko flexibility matrix found.') diff --git a/sg.py b/sg.py index bc069d2..47c1956 100644 --- a/sg.py +++ b/sg.py @@ -59,49 +59,6 @@ def __init__(self, smdim=3): #: dict: Strength properties. self.strength = None - #: dict: - #: (will be deprecated) Effective properties of the material/structure - self.eff_props = { - 3: { - 'density': 0, - 'type': 0, # 0: isotropic, 1: orthotropic, 2: anisotropic - 'stiffness': [], - 'compliance': [], - 'constants': {} - }, - 2: { - 'density': 0, - 'stiffness': { - 'classical': [], - 'refined': [] - }, - 'compliance': { - 'classical': [], - 'refined': [] - }, - 'constants': { - 'inplane': {}, - 'flexural': {} - } - }, - 1: { - 'density': 0, - 'mass': { - 'origin': [], - 'masscenter': [] - }, - 'stiffness': { - 'classical': [], - 'refined': [] - }, - 'compliance': { - 'classical': [], - 'refined': [] - }, - 'shearcenter': [] - } - } - # self.strength = { # 'criterion': 0, # 'chara_len': 0, @@ -143,7 +100,7 @@ def summary(self): print(row) - def getBeamProperty(self, label): + def getBeamProperty(self, label, center=None): """Get beam properties using specific labels. Parameters @@ -181,58 +138,70 @@ def getBeamProperty(self, label): * scy/sc2 - y (or x2) component of the shear center * scz/sc3 - z (or x3) component of the shear center """ + + mm = self.mass_origin + stf_c = self.stiffness + cmp_c = self.compliance + stf_r = self.stiffness_refined + cmp_r = self.compliance_refined + + if type(center).__name__ == 'str': + if center == 'tc': + mm, stf_c, cmp_c, stf_r, cmp_r = calcOffsetBeamProperty(self.tension_center[1], self.tension_center[2]) + elif center == 'sc': + mm, stf_c, cmp_c, stf_r, cmp_r = calcOffsetBeamProperty(self.shear_center[1], self.shear_center[2]) + elif center == 'mc': + mm, stf_c, cmp_c, stf_r, cmp_r = calcOffsetBeamProperty(self.mass_center[1], self.mass_center[2]) + # Mass if label.startswith('ms'): - if label[-1] == 'o': - return self.mass_origin[int(label[2])-1][int(label[3])-1] - elif label[-1] == 'c': - return self.mass_mc[int(label[2])-1][int(label[3])-1] + return mm[int(label[2])-1][int(label[3])-1] if label == 'mpl': return self.density if label == 'mmoi1': - return self.mmoi[0] + return mm[3, 3] if label == 'mmoi2': - return self.mmoi[1] + return mm[4, 4] if label == 'mmoi3': - return self.mmoi[2] + return mm[5, 5] # Stiffness if label.startswith('stf'): if label[-1] == 'c': - return self.stiffness[int(label[3])-1][int(label[4])-1] + return stf_c[int(label[3])-1][int(label[4])-1] elif label[-1] == 'r': - return self.stiffness_refined[int(label[3])-1][int(label[4])-1] + return stf_r[int(label[3])-1][int(label[4])-1] if label.startswith('ea'): # Axial stiffness if label[-1] == 'c': - return self.stiffness[0][0] + return stf_c[0][0] elif label[-1] == 'r': - return self.stiffness_refined[0][0] + return stf_r[0][0] if label.startswith('gj'): # Torsional stiffness if label[-1] == 'c': - return self.stiffness[1][1] + return stf_c[1][1] elif label[-1] == 'r': - return self.stiffness_refined[3][3] + return stf_r[3][3] if label.startswith('ei2') or label.startswith('eif'): # Bending stiffness around x2 (flapwise) if label[-1] == 'c': - return self.stiffness[2][2] + return stf_c[2][2] elif label[-1] == 'r': - return self.stiffness_refined[4][4] + return stf_r[4][4] if label.startswith('ei3') or label.startswith('eic'): # Bending stiffness around x3 (chordwise or lead-lag) if label[-1] == 'c': - return self.stiffness[3][3] + return stf_c[3][3] elif label[-1] == 'r': - return self.stiffness_refined[5][5] + return stf_r[5][5] # Compliance if label.startswith('cmp'): if label[-1] == 'c': - return self.compliance[int(label[3])-1][int(label[4])-1] + return cmp_c[int(label[3])-1][int(label[4])-1] elif label[-1] == 'r': - return self.compliance_refined[int(label[3])-1][int(label[4])-1] + return cmp_r[int(label[3])-1][int(label[4])-1] # Various centers if label == 'mcy' or label == 'mc2': @@ -249,6 +218,54 @@ def getBeamProperty(self, label): return self.shear_center[2] + def calcOffsetBeamProperty(self, offset_x2=0.0, offset_x3=0.0): + + # Offset mass matrix + mm_o = np.asarray(self.mass_mc) + if (offset_x2 != self.mass_center[1]) or (offset_x3 != self.mass_center[2]): + # mm_c = np.asarray(self.mass_mc) + mu = mm_o[0, 0] + mi_c = mm_o[3:, 3:] + + x2 = self.mass_center[1] - offset_x2 + x3 = self.mass_center[2] - offset_x3 + r_tilde = np.array([ + [0, -x3, x2], + [x3, 0, 0], + [-x2, 0, 0] + ]) + + mm_o[:3, 3:] = mu * r_tilde.T + mm_o[3:, :3] = mu * r_tilde + + # I_o = I_c + m * r_tilde.r_tilde^T + mm_o[3:, 3:] = mm_o[3:, 3:] + mu * np.dot(r_tilde, r_tilde.T) + + + # Offset stiffness and compliance + trfm_4 = np.eye(4) + trfm_6 = np.eye(6) + + trfm_4[2, 0] = offset_x3 + trfm_4[3, 0] = -offset_x2 + + trfm_6[4, 0] = offset_x3 + trfm_6[5, 0] = -offset_x2 + trfm_6[3, 1] = -offset_x3 + trfm_6[3, 2] = offset_x2 + + cmp_4 = np.asarray(self.compliance) + cmp_6 = np.asarray(self.compliance_refined) + + cmp_4_trf = np.dot(trfm_4.T, np.dot(cmp_4, trfm_4)) + cmp_6_trf = np.dot(trfm_6.T, np.dot(cmp_6, trfm_6)) + + stf_4_trf = np.linalg.inv(cmp_4_trf) + stf_6_trf = np.linalg.inv(cmp_6_trf) + + return mm_o, stf_4_trf, cmp_4_trf, stf_6_trf, cmp_6_trf + +