diff --git a/io/__pycache__/__init__.cpython-37.pyc b/io/__pycache__/__init__.cpython-37.pyc index 7d2ca6b..b9f9f79 100644 Binary files a/io/__pycache__/__init__.cpython-37.pyc and b/io/__pycache__/__init__.cpython-37.pyc differ diff --git a/io/__pycache__/iosc.cpython-38.pyc b/io/__pycache__/iosc.cpython-38.pyc new file mode 100644 index 0000000..0816e88 Binary files /dev/null and b/io/__pycache__/iosc.cpython-38.pyc differ diff --git a/io/__pycache__/iovabs.cpython-38.pyc b/io/__pycache__/iovabs.cpython-38.pyc new file mode 100644 index 0000000..c97509e Binary files /dev/null and b/io/__pycache__/iovabs.cpython-38.pyc differ diff --git a/io/__pycache__/utils.cpython-37.pyc b/io/__pycache__/utils.cpython-37.pyc index ec27d9a..ad86354 100644 Binary files a/io/__pycache__/utils.cpython-37.pyc and b/io/__pycache__/utils.cpython-37.pyc differ diff --git a/io/__pycache__/utils.cpython-38.pyc b/io/__pycache__/utils.cpython-38.pyc new file mode 100644 index 0000000..ea384dd Binary files /dev/null and b/io/__pycache__/utils.cpython-38.pyc differ diff --git a/io/iovabs.py b/io/iovabs.py index 7fe3170..151e96b 100644 --- a/io/iovabs.py +++ b/io/iovabs.py @@ -220,17 +220,14 @@ def readVABSIn(fn_vabs_in): def readVABSOutHomo(fn, scrnout=True): """Read VABS homogenization results - Parameters - ---------- - fn : str - VABS output file name (e.g. example.sg.k). - scrnout : bool - Whether to print message to screen. + :param fn: VABS output file name (e.g. example.sg.k) + :type fn: string """ - sm = sgm.MaterialSection(1) + sm = sgm.MaterialSection(smdim = 1) linesRead = [] keywordsIndex = {} + with open(fn, 'r') as fin: for lineNumber, line in enumerate(fin): @@ -244,7 +241,7 @@ def readVABSOutHomo(fn, scrnout=True): if 'The Generalized Shear Center of the Cross Section in the User Coordinate System' in line: keywordsIndex['sc'] = lineNumber if 'Mass Per Unit Span' in line: - sm.eff_props[1]['density'] = float(line.split('=')[-1].strip()) + sm.density = float(line.split('=')[-1].strip()) if 'Classical Stiffness Matrix' in line: keywordsIndex['csm'] = lineNumber if 'Classical Flexibility Matrix' in line: @@ -253,18 +250,34 @@ def readVABSOutHomo(fn, scrnout=True): keywordsIndex['tsm'] = lineNumber if 'Timoshenko Flexibility Matrix' in line: keywordsIndex['tfm'] = lineNumber + if 'Vlasov Stiffness Matrix' in line: + keywordsIndex['vsm'] = lineNumber + if 'Vlasov Flexibility Matrix' in line: + keywordsIndex['vfm'] = lineNumber if 'Mass Matrix' in line: if 'Mass Center' in line: keywordsIndex['massatcenter'] = lineNumber else: keywordsIndex['mass'] = lineNumber - + if 'Trapeze Effects' in line: + keywordsIndex['te'] = lineNumber + if 'Ag1--Ag1--Ag1--Ag1' in line: + keywordsIndex['te_ag'] = lineNumber + if 'Bk1--Bk1--Bk1--Bk1' in line: + keywordsIndex['te_bk'] = lineNumber + if 'Ck2--Ck2--Ck2--Ck2' in line: + keywordsIndex['te_ck'] = lineNumber + if 'Dk3--Dk3--Dk3--Dk3' in line: + keywordsIndex['te_dk'] = lineNumber + ln = keywordsIndex['mc'] mc = np.array([ 0.0, float(linesRead[ln + 3].split()[-1]), float(linesRead[ln + 4].split()[-1]) ]) + sm.mass_center = mc + ln = keywordsIndex['gc'] gc = np.array([ @@ -272,6 +285,7 @@ def readVABSOutHomo(fn, scrnout=True): float(linesRead[ln + 3].split()[-1]), float(linesRead[ln + 4].split()[-1]) ]) + #gc has not been added in "sg.py" yet. ln = keywordsIndex['tc'] tc = np.array([ @@ -279,42 +293,148 @@ def readVABSOutHomo(fn, scrnout=True): float(linesRead[ln + 3].split()[-1]), float(linesRead[ln + 4].split()[-1]) ]) + #tc has not been added in "sg.py" yet. if 'sc' in keywordsIndex.keys(): ln = keywordsIndex['sc'] - sm.eff_props[1]['shearcenter'] = [ + sm.shear_center = [ float(linesRead[ln + 3].split()[-1]), float(linesRead[ln + 4].split()[-1]) ] + ln = keywordsIndex['mass'] - sm.eff_props[1]['mass']['origin'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) + sm.mass_origin = utl.textToMatrix(linesRead[ln + 3:ln + 9]) try: ln = keywordsIndex['massatcenter'] - sm.eff_props[1]['mass']['masscenter'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) + sm.mass_mc = utl.textToMatrix(linesRead[ln + 3:ln + 9]) except KeyError: - sm.eff_props[1]['mass']['masscenter'] = sm.eff_props[1]['mass']['origin'] - - ln = keywordsIndex['csm'] - sm.eff_props[1]['stiffness']['classical'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) - ln = keywordsIndex['cfm'] - sm.eff_props[1]['compliance']['classical'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) - - try: - ln = keywordsIndex['tsm'] - sm.eff_props[1]['stiffness']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) - except KeyError: - if scrnout: - print('No timoshenko stiffness matrix found.') - else: - pass - try: - ln = keywordsIndex['tfm'] - sm.eff_props[1]['compliance']['refined'] = utl.textToMatrix(linesRead[ln + 3:ln + 9]) - except KeyError: - if scrnout: - print('No timoshenko flexibility matrix found.') - else: - pass + sm.mass_mc = sm.mass_origin + + #check whether the analysis is Vlasov or timoshenko + #Read stiffness matrix and compliance matrix + if 'vsm' in keywordsIndex.keys(): + try: + ln = keywordsIndex['vsm'] + sm.stiffness_refined = utl.textToMatrix(linesRead[ln + 3:ln + 8]) + except KeyError: + if scrnout: + print('No Vlasov stiffness matrix found.') + else: + pass + try: + ln = keywordsIndex['vfm'] + sm.compliance_refined = utl.textToMatrix(linesRead[ln + 3:ln + 8]) + except KeyError: + if scrnout: + print('No Vlasov flexibility matrix found.') + else: + pass + #check whether trapeze effect analysis is on and read the correponding matrix + if 'te' in keywordsIndex.keys(): + try: + ln = keywordsIndex['te_ag'] + sm.trapeze_effect['ag'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Ag1--Ag1--Ag1--Ag1 matrix found.') + else: + pass + try: + ln = keywordsIndex['te_bk'] + sm.trapeze_effect['bk'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Bk1--Bk1--Bk1--Bk1 matrix found.') + else: + pass + try: + ln = keywordsIndex['te_ck'] + sm.trapeze_effect['ck'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Ck2--Ck2--Ck2--Ck2 matrix found.') + else: + pass + try: + ln = keywordsIndex['te_dk'] + sm.trapeze_effect['dk'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Dk3--Dk3--Dk3--Dk3 matrix found.') + else: + pass + else: + try: + ln = keywordsIndex['csm'] + sm.stiffness = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Classical stiffness matrix found.') + else: + pass + + try: + ln = keywordsIndex['cfm'] + sm.compliance = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Classical flexibility matrix found.') + else: + pass + + try: + ln = keywordsIndex['tsm'] + sm.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.') + else: + pass + try: + ln = keywordsIndex['tfm'] + sm.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.') + else: + pass + + #check whether trapeze effect analysis is on and read the correponding matrix + if 'te' in keywordsIndex.keys(): + try: + ln = keywordsIndex['te_ag'] + sm.trapeze_effect['ag'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Ag1--Ag1--Ag1--Ag1 matrix found.') + else: + pass + try: + ln = keywordsIndex['te_bk'] + sm.trapeze_effect['bk'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Bk1--Bk1--Bk1--Bk1 matrix found.') + else: + pass + try: + ln = keywordsIndex['te_ck'] + sm.trapeze_effect['ck'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Ck2--Ck2--Ck2--Ck2 matrix found.') + else: + pass + try: + ln = keywordsIndex['te_dk'] + sm.trapeze_effect['dk'] = utl.textToMatrix(linesRead[ln + 3:ln + 7]) + except KeyError: + if scrnout: + print('No Dk3--Dk3--Dk3--Dk3 matrix found.') + else: + pass return sm