Skip to content

Commit

Permalink
0730
Browse files Browse the repository at this point in the history
  • Loading branch information
Su Tian committed Jul 30, 2021
1 parent b35a198 commit 5309c74
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 79 deletions.
172 changes: 116 additions & 56 deletions msgpi/io/iosc.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,122 @@ def readSCOutBeamProperty(fn, scrnout=True, logger=None):



def readSCOutShellProperty(fn, scrnout=True, logger=None):
if logger is None:
logger = mlog.initLogger(__name__)

# sm = sgm.MaterialSection(smdim = 1)
sp = sgm.ShellProperty()

linesRead = []
keywordsIndex = {}

with open(fn, 'r') as fin:
ln = -1
prop_plane = None
for line in fin:

line = line.strip()

if len(line) > 0:
linesRead.append(line)
ln += 1
else:
continue

if '-----' in line:
continue

# Inertial properties
# -------------------

elif 'Effective Mass Matrix' in line:
keywordsIndex['mass'] = ln
elif 'Mass Center Location' in line:
sp.xm3 = float(line.split()[-1])
elif 'i11' in line:
sp.i11 = float(line.split()[-1])
sp.i22 = sp.i11


# Structural properties
# ---------------------

elif 'Effective Stiffness Matrix' in line:
keywordsIndex['stff'] = ln
elif 'Effective Compliance Matrix' in line:
keywordsIndex['cmpl'] = ln

elif 'In-Plane' in line:
prop_plane = 'in'
elif 'Flexural' in line:
prop_plane = 'out'

elif 'E1' in line:
if prop_plane == 'in':
sp.e1_i = float(line.split('=')[-1])
elif prop_plane == 'out':
sp.e1_o = float(line.split('=')[-1])
elif 'E2' in line:
if prop_plane == 'in':
sp.e2_i = float(line.split('=')[-1])
elif prop_plane == 'out':
sp.e2_o = float(line.split('=')[-1])
elif 'G12' in line:
if prop_plane == 'in':
sp.g12_i = float(line.split('=')[-1])
elif prop_plane == 'out':
sp.g12_o = float(line.split('=')[-1])
elif 'nu12' in line:
if prop_plane == 'in':
sp.nu12_i = float(line.split('=')[-1])
elif prop_plane == 'out':
sp.nu12_o = float(line.split('=')[-1])
elif 'eta121' in line:
if prop_plane == 'in':
sp.eta121_i = float(line.split('=')[-1])
elif prop_plane == 'out':
sp.eta121_o = float(line.split('=')[-1])
elif 'eta122' in line:
if prop_plane == 'in':
sp.eta122_i = float(line.split('=')[-1])
elif prop_plane == 'out':
sp.eta122_o = float(line.split('=')[-1])


ln = keywordsIndex['mass']
sp.mass = utl.textToMatrix(linesRead[ln + 2:ln + 8])

try:
ln = keywordsIndex['stff']
sp.stff = utl.textToMatrix(linesRead[ln + 2:ln + 6])
except KeyError:
if scrnout:
print('No classical stiffness matrix found.')
else:
pass

try:
ln = keywordsIndex['cmpl']
sp.cmpl = utl.textToMatrix(linesRead[ln + 2:ln + 6])
except KeyError:
if scrnout:
print('No classical flexibility matrix found.')
else:
pass



return sp









def readSCOutHomo(fn, smdim, scrnout=True, logger=None):
"""Read SwiftComp homogenization results.
Expand Down Expand Up @@ -645,13 +761,6 @@ def writeSCNodes(sg, fobj, sfi, sff):
return









def writeSCElements(sg, fobj, sfi):
for eid in sg.elementids1d:
elem = np.zeros(7, dtype=int)
Expand Down Expand Up @@ -692,40 +801,19 @@ def writeSCElements(sg, fobj, sfi):
return









def writeSCElementOrientations(sg, fobj, sfi, sff):
for eid, orient in sg.elem_orient.items():
fobj.write(sfi.format(eid))
utl.writeFormatFloats(fobj, np.hstack(orient))
return









def writeSCMOCombos(sg, fobj, sfi, sff):
for cid, combo in sg.mocombos.items():
fobj.write((sfi + sfi + sff + '\n').format(cid, combo[0], combo[1]))
return









def writeSCMaterials(sg, fobj, sfi, sff):
for mid, m in sg.materials.items():
# itype = 0
Expand Down Expand Up @@ -753,13 +841,6 @@ def writeSCMaterials(sg, fobj, sfi, sff):
return









def writeSCInH(sg, fn, sfi, sff):
with open(fn, 'w') as fobj:
# Extra inputs for dimensionally reducible structures
Expand Down Expand Up @@ -823,13 +904,6 @@ def writeSCInH(sg, fn, sfi, sff):
fobj.write('\n')









def writeSCInD(sg, fn, sfi, sff):
with open(fn, 'w') as fobj:
utl.writeFormatFloats(fobj, sg.global_displacements, sff[2:-1])
Expand All @@ -838,13 +912,6 @@ def writeSCInD(sg, fn, sfi, sff):
utl.writeFormatFloats(fobj, sg.global_loads, sff[2:-1])









def writeSCInF(sg, fn, sfi, sff):
with open(fn, 'w') as fobj:
# Addtional material properties
Expand All @@ -866,13 +933,6 @@ def writeSCInF(sg, fn, sfi, sff):
utl.writeFormatFloats(fobj, sg.global_loads, sff[2:-1])









def writeSCIn(sg, fn, analysis='h'):
""" Write SG input files for SwiftComp
Expand Down
Loading

0 comments on commit 5309c74

Please sign in to comment.