def _write_f06_transient(self, header, pageStamp, pageNum=1, f=None, is_mag_phase=False):
words = [' C O M P L E X F O R C E S I N B A R E L E M E N T S ( C B A R )\n',
' (REAL/IMAGINARY)\n',
'0 ELEMENT BEND-MOMENT END-A BEND-MOMENT END-B - SHEAR - AXIAL\n',
' ID. PLANE 1 PLANE 2 PLANE 1 PLANE 2 PLANE 1 PLANE 2 FORCE TORQUE\n']
msg = []
for dt, bendA in sorted(self.bendingMomentA.items()):
header[1] = ' %s = %10.4E\n' % (self.data_code['name'], dt)
msg += header + words
for eid in sorted(bendA):
bm1a, bm2a = self.bendingMomentA[dt][eid]
bm1b, bm2b = self.bendingMomentB[dt][eid]
ts1, ts2 = self.shear[dt][eid]
af = self.axial[dt][eid]
trq = self.torque[dt][eid]
(vals2, isAllZeros) = writeImagFloats13E([bm1a, bm2a, bm1b, bm2b, ts1, ts2, af, trq], is_mag_phase)
[bm1ar, bm2ar, bm1br, bm2br, ts1r, ts2r, afr, trqr,
bm1ai, bm2ai, bm1bi, bm2bi, ts1i, ts2i, afi, trqi] = vals2
msg.append(' %8i %13s %13s %13s %13s %13s %13s %13s %-s\n' % (eid, bm1ar, bm2ar, bm1br, bm2br, ts1r, ts2r, afr, trqr))
msg.append(' %8s %13s %13s %13s %13s %13s %13s %13s %-s\n' % ('', bm1ai, bm2ai, bm1bi, bm2bi, ts1i, ts2i, afi, trqi))
msg.append(pageStamp + str(pageNum) + '\n')
if f is not None:
f.write(''.join(msg))
msg = ['']
pageNum += 1
return (''.join(msg), pageNum - 1)
def write_f06(self, header, pageStamp, page_num=1, f=None, is_mag_phase=False):
msg = []
#print self.data_code
hasCycle = hasattr(self, 'mode_cycle')
for i, (iMode, eigVals) in enumerate(sorted(iteritems(self.translations))):
msg += header
freq = self.eigrs[i]
#freq = 0.0
msg.append('%16s = %12E\n' % ('EIGENVALUE', freq))
if hasCycle:
msg.append('%16s = %12E C O M P L E X E I G E N V E C T O R N O . %10i\n \n' % ('CYCLES', self.mode_cycle, iMode))
else:
msg.append(' C O M P L E X E I G E N V E C T O R N O . %10i\n \n' % (iMode))
msg.append(' POINT ID. TYPE T1 T2 T3 R1 R2 R3\n')
for nodeID, displacement in sorted(iteritems(eigVals)):
rotation = self.rotations[iMode][nodeID]
grid_type = self.gridTypes[nodeID]
(dx, dy, dz) = displacement
(rx, ry, rz) = rotation
vals = [dx, dy, dz, rx, ry, rz]
(vals2, is_all_zeros) = writeImagFloats13E(vals, is_mag_phase)
[dxr, dyr, dzr, rxr, ryr, rzr,
dxi, dyi, dzi, rxi, ryi, rzi] = vals2
msg.append('%14i %6s %-13s %-13s %-13s %-13s %-13s %s\n' % (nodeID, grid_type, dxr, dyr, dzr, rxr, ryr, rzr))
msg.append('%14s %6s %-13s %-13s %-13s %-13s %-13s %s\n' % ('', '', dxi, dyi, dzi, rxi, ryi, rzi))
msg.append(pageStamp % page_num)
f.write(''.join(msg))
msg = ['']
page_num += 1
return page_num - 1
def _write_f06_transient(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False):
assert f is not None
words = [' C O M P L E X F O R C E S O F M U L T I P O I N T C O N S T R A I N T\n',
' (REAL/IMAGINARY)\n',
' \n',
' POINT ID. TYPE T1 T2 T3 R1 R2 R3\n']
msg = []
for dt, translations in sorted(iteritems(self.translations)):
header[1] = ' %s = %10.4E\n' % (self.data_code['name'], dt)
msg += header + words
for nodeID, translation in sorted(iteritems(translations)):
rotation = self.rotations[dt][nodeID]
grid_type = self.gridTypes[nodeID]
(dx, dy, dz) = translation
(rx, ry, rz) = rotation
vals = [dx, dy, dz, rx, ry, rz]
(vals2, is_all_zeros) = writeImagFloats13E(vals, is_mag_phase)
#if not is_all_zeros:
[v1r, v2r, v3r, v4r, v5r, v6r, v1i,
v2i, v3i, v4i, v5i, v6i] = vals2
msg.append('0%13i %6s %-13s %-13s %-13s %-13s %-13s %s\n' % (nodeID, grid_type, v1r, v2r, v3r, v4r, v5r, v6r.rstrip()))
msg.append(' %13i %6s %-13s %-13s %-13s %-13s %-13s %s\n' % (nodeID, grid_type, v1i, v2i, v3i, v4i, v5i, v6i.rstrip()))
msg.append(page_stamp % page_num)
f.write(''.join(msg))
page_num += 1
return page_num - 1
def _write_f06_transient(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False, is_sort1=True):
"""
.. todo:: improve formatting
"""
words = [
" C O M P L E X F O R C E S I N S C A L A R S P R I N G S ( C E L A S 1 )\n",
" (REAL/IMAGINARY)\n",
" \n",
" ELEMENT ELEMENT\n",
" ID. FORCE ID. FORCE\n",
]
# 1001 1.537879E+01 / 0.0 1002 1.537879E+01 / 0.0
# 1003 1.537879E+01 / 0.0 1004 1.537879E+01 / 0.0
# 1005 1.537879E+01 / 0.0 1006 1.537879E+01 / 0.0
# 1007 7.689395E+00 / 0.0 1008 7.689395E+00 / 0.0
# 1009 7.689395E+00 / 0.0 1010 7.689395E+00 / 0.0
msg = []
is_mag_phase = False
for dt, Stress in sorted(iteritems(self.stress)):
if isinstance(dt, float): # fix
header[1] = " %s = %10.4E float %s\n" % (self.data_code["name"], dt, self.analysis_code)
else:
header[1] = " %s = %10i integer %s\n" % (self.data_code["name"], dt, self.analysis_code)
msg += header + words
i = 0
for elementID, stress in sorted(iteritems(Stress)):
if is_mag_phase:
stressr = abs(stress)
stressi = angle(stress, deg=True)
else:
stressr = stress.real
stressi = stress.imag
(vals2, is_all_zeros) = writeImagFloats13E([stress], is_mag_phase)
if i == 0:
elementID1 = elementID
[stress1Real, stress1Imag] = vals2
if i == 1:
elementID2 = elementID
[stress2Real, stress2Imag] = vals2
msg.append(
"%14i %-13s / %-13s %14i %-13s / %s\n"
% (elementID1, stress1Real, stress1Imag, elementID2, stress2Real, stress2Imag)
)
i = -1
i += 1
msg.append(page_stamp % page_num)
f.write("".join(msg))
msg = [""]
page_num += 1
return page_num - 1
def write_f06(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False, is_sort1=True):
msg = []
#print self.data_code
hasCycle = hasattr(self, 'mode_cycle')
assert len(self.eigis) == len(self.translations)
for i, (iMode, eigVals) in enumerate(sorted(iteritems(self.translations))):
msg += header
eigr = self.eigrs[i]
eigi = self.eigis[i]
eigr = 0. if eigr == -0. else eigr
eigi = 0. if eigi == -0. else eigi
f.write(''.join(header))
f.write(' %16s = %12E, %12E\n' % ('COMPLEX EIGENVALUE', eigr, eigi))
if hasCycle:
f.write('%16s = %12E C O M P L E X E I G E N V E C T O R N O . %10i\n \n' % ('CYCLES', self.mode_cycle, iMode))
else:
# TODO: should there be an extra ' \n'???
f.write(' C O M P L E X E I G E N V E C T O R NO. %10i\n' % (iMode))
if is_mag_phase:
f.write(' (MAGNITUDE/PHASE)\n \n')
else:
f.write(' (REAL/IMAGINARY)\n \n')
f.write(' POINT ID. TYPE T1 T2 T3 R1 R2 R3\n')
for nodeID, displacement in sorted(iteritems(eigVals)):
rotation = self.rotations[iMode][nodeID]
grid_type = self.gridTypes[nodeID]
(dx, dy, dz) = displacement
(rx, ry, rz) = rotation
vals = [dx, dy, dz, rx, ry, rz]
(vals2, is_all_zeros) = writeImagFloats13E(vals, is_mag_phase)
[dxr, dyr, dzr, rxr, ryr, rzr,
dxi, dyi, dzi, rxi, ryi, rzi] = vals2
if grid_type == 'S':
f.write('0%13i %6s %-13s\n' % (nodeID, grid_type, dxr))
f.write(' %13s %6s %-13s\n' % ('', '', dxi))
else:
f.write('0%13i %6s %-13s %-13s %-13s %-13s %-13s %s\n' % (nodeID, grid_type, dxr, dyr, dzr, rxr, ryr, rzr))
f.write(' %13s %6s %-13s %-13s %-13s %-13s %-13s %s\n' % ('', '', dxi, dyi, dzi, rxi, ryi, rzi))
f.write(page_stamp % page_num)
msg = ['']
page_num += 1
return page_num - 1
def write_f06(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False):
if self.nonlinear_factor is not None:
return self._write_f06_transient(header, page_stamp, page_num, f, is_mag_phase)
msg = header + [
" C O M P L E X F O R C E S I N B A R E L E M E N T S ( C B A R )\n",
" (REAL/IMAGINARY)\n",
"0 ELEMENT BEND-MOMENT END-A BEND-MOMENT END-B - SHEAR - AXIAL\n",
" ID. PLANE 1 PLANE 2 PLANE 1 PLANE 2 PLANE 1 PLANE 2 FORCE TORQUE\n",
]
for eid in sorted(self.bendingMomentA):
bm1a, bm2a = self.bendingMomentA[eid]
bm1b, bm2b = self.bendingMomentB[eid]
ts1, ts2 = self.shear[eid]
af = self.axial[eid]
trq = self.torque[eid]
(vals2, is_all_zeros) = writeImagFloats13E([bm1a, bm2a, bm1b, bm2b, ts1, ts2, af, trq], is_mag_phase)
[
bm1ar,
bm2ar,
bm1br,
bm2br,
ts1r,
ts2r,
afr,
trqr,
bm1ai,
bm2ai,
bm1bi,
bm2bi,
ts1i,
ts2i,
afi,
trqi,
] = vals2
msg.append(
" %8i %-13s %-13s %-13s %-13s %-13s %-13s %-13s %s\n"
% (eid, bm1ar, bm2ar, bm1br, bm2br, ts1r, ts2r, afr, trqr)
)
msg.append(
" %8s %-13s %-13s %-13s %-13s %-13s %-13s %-13s %s\n"
% ("", bm1ai, bm2ai, bm1bi, bm2bi, ts1i, ts2i, afi, trqi)
)
msg.append(page_stamp % page_num)
f.write("".join(msg))
return page_num
def _write_f06_transient(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False):
if self.element_type == 1:
element_header = ' C O M P L E X S T R A I N S I N R O D E L E M E N T S ( C R O D )\n'
elif self.element_type == 3:
element_header = ' C O M P L E X S T R A I N S I N R O D E L E M E N T S ( C T U B E )\n'
elif self.element_type == 10:
element_header = ' C O M P L E X S T R A I N S I N R O D E L E M E N T S ( C O N R O D )\n'
else:
raise NotImplementedError('element_name=%r element_type=%s' % (self.element_name, self.element_type))
if is_mag_phase:
mag_phase = ' (MAG/PHASE)\n' # not tested
else:
mag_phase = ' (REAL/IMAGINARY)\n'
words = [element_header,
mag_phase,
' \n',
' ELEMENT AXIAL TORQUE\n',
' ID. FORCE\n',
' 1 -2.459512E+05 / 3.377728E+04 0.0 / 0.0\n',]
words = [' S T R A I N S I N R O D E L E M E N T S ( C R O D )\n',
' ELEMENT AXIAL SAFETY TORSIONAL SAFETY ELEMENT AXIAL SAFETY TORSIONAL SAFETY\n',
' ID. STRAIN MARGIN STRAIN MARGIN ID. STRAIN MARGIN STRAIN MARGIN\n']
msg = []
for dt, axials in sorted(iteritems(self.axial)):
dtLine = '%14s = %12.5E\n' % (self.data_code['name'], dt)
header[2] = dtLine
msg += header + words
out = []
for eid in sorted(axials):
axial = self.axial[dt][eid]
torsion = self.torsion[dt][eid]
([axialr, torsionr, axiali, torsioni], is_all_zeros) = writeImagFloats13E([axial, torsion], is_mag_phase)
f.write(' %8i %-13s / %-13s %-13s / %s\n' % (eid, axialr, axiali, torsionr, torsioni))
msg.append(page_stamp % page_num)
page_num += 1
f.write(''.join(msg))
return page_num - 1
请发表评论