Skip to content

Commit

Permalink
expand readVABSOutHomo function to read Vlasov analysis and Trapeze e…
Browse files Browse the repository at this point in the history
…ffect output
  • Loading branch information
tfei committed Aug 25, 2020
1 parent 1828868 commit f013c0c
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 35 deletions.
Binary file modified io/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added io/__pycache__/iosc.cpython-38.pyc
Binary file not shown.
Binary file added io/__pycache__/iovabs.cpython-38.pyc
Binary file not shown.
Binary file modified io/__pycache__/utils.cpython-37.pyc
Binary file not shown.
Binary file added io/__pycache__/utils.cpython-38.pyc
Binary file not shown.
190 changes: 155 additions & 35 deletions io/iovabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -253,68 +250,191 @@ 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([
0.0,
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([
0.0,
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

Expand Down

0 comments on commit f013c0c

Please sign in to comment.