def write_f06(self, f, header=None, page_stamp='PAGE %s', page_num=1, is_mag_phase=False, is_sort1=True): if header is None: header = [] """ ' EIGENVALUE = 2.005177E+05' ' CYCLES = 7.126832E+01' ' E L E M E N T S T R A I N E N E R G I E S' ' ' ' ELEMENT-TYPE = TETRA * TOTAL ENERGY OF ALL ELEMENTS IN PROBLEM = 1.002589E+05' ' MODE 1 * TOTAL ENERGY OF ALL ELEMENTS IN SET -1 = 1.002589E+05' '0' ' ELEMENT-ID STRAIN-ENERGY PERCENT OF TOTAL STRAIN-ENERGY-DENSITY' ' 4 3.247409E+00 0.0032 1.948445E+01' ' 5 3.977916E+00 0.0040 2.386749E+01' '' ' TYPE = TETRA SUBTOTAL 7.225325E+00 0.0072' """ msg_temp = ( ' E L E M E N T S T R A I N E N E R G I E S\n' ' \n' ' ELEMENT-TYPE = TETRA * TOTAL ENERGY OF ALL ELEMENTS IN PROBLEM = %s\n' ' MODE %8i * TOTAL ENERGY OF ALL ELEMENTS IN SET -1 = %s\n' '0\n' ' ELEMENT-ID STRAIN-ENERGY PERCENT OF TOTAL STRAIN-ENERGY-DENSITY\n' ) ntimes = self.data.shape[0] eids = self.element #etype = self.element_data_type for itime in range(ntimes): dt = self._times[itime] # TODO: rename this... header = _eigenvalue_header(self, header, itime, ntimes, dt) total_energy = 0. total_set_energy = 0. msg_temp2 = [msg_temp % (total_energy, itime, total_set_energy)] f.write(''.join(header + msg_temp2)) # energy, percent, density energy = self.data[itime, :, 0] percent = self.data[itime, :, 1] density = self.data[itime, :, 2] for (eid, energyi, percenti, densityi) in zip(eids, energy, percent, density): senergyi = write_float_13e(energyi) sdensityi = write_float_13e(densityi) f.write(' %8i %-13s %.4fs %s\n' % ( eid, senergyi, percenti, sdensityi)) f.write(page_stamp % page_num) page_num += 1 return page_num - 1
def _write_sort1_as_sort1(self, header, page_stamp, page_num, f, msg_temp): ntimes = self.data.shape[0] eids = self.element is_odd = False nwrite = len(eids) nrows = nwrite // 4 nleftover = nwrite - nrows * 4 for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f.write(''.join(header + msg_temp)) stress = self.data[itime, :, 0] out = [] for eid, stressi in zip(eids, stress): out.append([eid, write_float_13e(stressi)]) for i in range(0, nrows * 4, 4): f.write(' %10i %13s %10i %13s %10i %13s %10i %13s\n' % ( tuple(out[i] + out[i + 1] + out[i + 2] + out[i + 3]))) i = nrows * 4 if nleftover == 3: f.write(' %10i %13s %10i %13s %10i %13s\n' % ( tuple(out[i] + out[i + 1] + out[i + 2]))) elif nleftover == 2: f.write(' %10i %13s %10i %13s\n' % ( tuple(out[i] + out[i + 1]))) elif nleftover == 1: f.write(' %10i %13s\n' % tuple(out[i])) f.write(page_stamp % page_num) page_num += 1 return page_num - 1
def _write_f06_quad4_bilinear_transient(self, f, itime, n, is_magnitude_phase, cen): """ CQUAD4 bilinear CQUAD8 CTRIAR CTRIA6 """ fds = self.fiber_curvature oxx = self.data[itime, :, 0] oyy = self.data[itime, :, 1] txy = self.data[itime, :, 2] eids = self.element_node[:, 0] nodes = self.element_node[:, 1] ilayer0 = True for eid, node, fd, doxx, doyy, dtxy in zip(eids, nodes, fds, oxx, oyy, txy): fdr = write_float_13e(fd) [oxxr, oyyr, txyr, oxxi, oyyi, txyi,] = write_imag_floats_13e([doxx, doyy, dtxy], is_magnitude_phase) if node == 0 and ilayer0: f.write('0 %8i %8s %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n' % (eid, cen, fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) elif ilayer0: # TODO: assuming 2 layers? f.write(' %8s %8i %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n' % ('', node, fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) else: f.write(' %8s %8s %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n\n' % ('', '', fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) ilayer0 = not ilayer0
def _write_f06_tri3_transient(self, f, itime, n, is_magnitude_phase, cen): """ CQUAD4 linear CTRIA3 """ fds = self.fiber_curvature oxx = self.data[itime, :, 0] oyy = self.data[itime, :, 1] txy = self.data[itime, :, 2] eids = self.element_node[:, 0] nodes = self.element_node[:, 1] ilayer0 = True for eid, node, fdr, doxx, doyy, dtxy in zip(eids, nodes, fds, oxx, oyy, txy): vals = write_float_13e(fdr) fdr = vals[0] [oxxr, oyyr, txyr, oxxi, oyyi, txyi,] = write_imag_floats_13e([doxx, doyy, dtxy], is_magnitude_phase) if ilayer0: # TODO: assuming 2 layers? f.write('0 %6i %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n' % (eid, fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) else: f.write(' %6s %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n' % ('', fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) ilayer0 = not ilayer0
def _write_f06_tri3_transient(self, f06_file, itime, n, is_magnitude_phase, cen): """ CQUAD4 linear CTRIA3 """ fds = self.fiber_curvature oxx = self.data[itime, :, 0] oyy = self.data[itime, :, 1] txy = self.data[itime, :, 2] eids = self.element_node[:, 0] nodes = self.element_node[:, 1] ilayer0 = True for eid, node, fd, doxx, doyy, dtxy in zip(eids, nodes, fds, oxx, oyy, txy): fdr = write_float_13e(fd) [ oxxr, oyyr, txyr, oxxi, oyyi, txyi, ] = write_imag_floats_13e([doxx, doyy, dtxy], is_magnitude_phase) if ilayer0: # TODO: assuming 2 layers? f06_file.write( '0 %6i %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n' % (eid, fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) else: f06_file.write( ' %6s %-13s %-13s / %-13s %-13s / %-13s %-13s / %s\n' % ('', fdr, oxxr, oxxi, oyyr, oyyi, txyr, txyi)) ilayer0 = not ilayer0
def _write_sort1_as_sort1(self, header, page_stamp, page_num, f06_file, msg_temp): ntimes = self.data.shape[0] eids = self.element nwrite = len(eids) nrows = nwrite // 4 nleftover = nwrite - nrows * 4 for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f06_file.write(''.join(header + msg_temp)) stress = self.data[itime, :, 0] out = [] for eid, stressi in zip(eids, stress): out.append([eid, write_float_13e(stressi)]) for i in range(0, nrows * 4, 4): f06_file.write( ' %10i %13s %10i %13s %10i %13s %10i %13s\n' % (tuple(out[i] + out[i + 1] + out[i + 2] + out[i + 3]))) i = nrows * 4 if nleftover == 3: f06_file.write(' %10i %13s %10i %13s %10i %13s\n' % (tuple(out[i] + out[i + 1] + out[i + 2]))) elif nleftover == 2: f06_file.write(' %10i %13s %10i %13s\n' % (tuple(out[i] + out[i + 1]))) elif nleftover == 1: f06_file.write(' %10i %13s\n' % tuple(out[i])) f06_file.write(page_stamp % page_num) page_num += 1 return page_num - 1
def _write_sort1_as_sort1(self, header, page_stamp, page_num, f, msg_temp): """ :: ELEMENT-ID = 20 N O N L I N E A R F O R C E S A N D S T R E S S E S I N S C A L A R S P R I N G S ( C E L A S 1 ) STEP FORCE STRESS STEP FORCE STRESS 5.000000E-02 2.000000E+01 1.000000E+01 1.000000E-01 4.000000E+01 2.000000E+01 1.500000E-01 6.000000E+01 3.000000E+01 2.000000E-01 8.000000E+01 4.000000E+01 """ ntimes = self.data.shape[0] eids = self.element neids = len(eids) is_odd = neids % 2 == 1 if is_odd: neids -= 1 for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f.write(''.join(header + msg_temp)) force = self.data[itime, :, 0] stress = self.data[itime, :, 1] for i, eid, forcei, stressi, in zip(count(step=2), eids[:neids:2], force[:neids:2], stress[:neids:2]): f.write(' %-13i %-13s %-13s %-13s %-13s %s\n' % ( eid, write_float_13e(forcei), write_float_13e(stressi), eids[i + 1], write_float_13e(force[i + 1]), write_float_13e(stress[i + 1]) )) if is_odd: f.write(' %-13i %-13s %s\n' % ( eids[neids], write_float_13e(force[neids]), write_float_13e(stress[neids]) )) f.write(page_stamp % page_num) page_num += 1 return page_num - 1
def _write_sort1_as_sort1(self, header, page_stamp, page_num, f06_file, msg_temp): """ :: ELEMENT-ID = 20 N O N L I N E A R F O R C E S A N D S T R E S S E S I N S C A L A R S P R I N G S ( C E L A S 1 ) STEP FORCE STRESS STEP FORCE STRESS 5.000000E-02 2.000000E+01 1.000000E+01 1.000000E-01 4.000000E+01 2.000000E+01 1.500000E-01 6.000000E+01 3.000000E+01 2.000000E-01 8.000000E+01 4.000000E+01 """ ntimes = self.data.shape[0] eids = self.element neids = len(eids) is_odd = neids % 2 == 1 if is_odd: neids -= 1 for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f06_file.write(''.join(header + msg_temp)) force = self.data[itime, :, 0] stress = self.data[itime, :, 1] for i, eid, forcei, stressi, in zip(count(step=2), eids[:neids:2], force[:neids:2], stress[:neids:2]): f06_file.write( ' %-13i %-13s %-13s %-13s %-13s %s\n' % (eid, write_float_13e(forcei), write_float_13e(stressi), eids[i + 1], write_float_13e( force[i + 1]), write_float_13e(stress[i + 1]))) if is_odd: f06_file.write(' %-13i %-13s %s\n' % (eids[neids], write_float_13e(force[neids]), write_float_13e(stress[neids]))) f06_file.write(page_stamp % page_num) page_num += 1 return page_num - 1
def write_f06(self, f06_file, header=None, page_stamp='PAGE %s', page_num=1, is_mag_phase=False, is_sort1=True): if header is None: header = [] #msg, nnodes, cen = _get_plate_msg(self) if self.element_type == 88: msg = [ ' N O N L I N E A R S T R E S S E S I N T R I A N G U L A R E L E M E N T S ( T R I A 3 )\n' ' \n' ' ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n' ' ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n' ] elif self.element_type == 90: msg = [ ' N O N L I N E A R S T R E S S E S I N Q U A D R I L A T E R A L E L E M E N T S ( Q U A D 4 )\n' ' \n' ' ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n' ' ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n' #'0 1 -2.500000E-02 -4.829193E+00 -1.640651E-05 -1.907010E-04 4.829185E+00 0.0 0.0\n' #' -4.829188E-05 1.448741E-05 -4.958226E-09\n' #' 2.500000E-02 4.770547E+00 1.493975E-04 1.907012E-04 4.770473E+00 0.0 0.0\n' #' 4.770502E-05 -1.431015E-05 4.958231E-09\n' ] else: # pragma: no cover raise NotImplementedError('element_name=%s self.element_type=%s' % (self.element_name, self.element_type)) #msg = [ #' N O N L I N E A R S T R E S S E S I N Q U A D R I L A T E R A L E L E M E N T S ( Q U A D 4 )\n' #' \n' #' ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n' #' ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n' #'0 1 -2.500000E-02 -4.829193E+00 -1.640651E-05 -1.907010E-04 4.829185E+00 0.0 0.0\n' #' -4.829188E-05 1.448741E-05 -4.958226E-09\n' #' 2.500000E-02 4.770547E+00 1.493975E-04 1.907012E-04 4.770473E+00 0.0 0.0\n' #' 4.770502E-05 -1.431015E-05 4.958231E-09\n' #] # write the f06 ntimes = self.data.shape[0] eids = self.element #cen_word = 'CEN/%i' % nnodes for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f06_file.write(''.join(header + msg)) #print("self.data.shape=%s itime=%s ieids=%s" % (str(self.data.shape), itime, str(ieids))) #[fiber_dist, oxx, oyy, ozz, txy, es, eps, ecs, exx, eyy, ezz, etxy] fiber_dist = self.data[itime, :, 0] oxx = self.data[itime, :, 1] oyy = self.data[itime, :, 2] ozz = self.data[itime, :, 3] txy = self.data[itime, :, 4] es = self.data[itime, :, 5] eps = self.data[itime, :, 6] ecs = self.data[itime, :, 7] exx = self.data[itime, :, 8] eyy = self.data[itime, :, 9] ezz = self.data[itime, :, 10] exy = self.data[itime, :, 11] for (i, eid, fdi, oxxi, oyyi, ozzi, txyi, exxi, eyyi, ezzi, exyi, esi, epsi, ecsi) in zip(cycle([0, 1]), eids, fiber_dist, oxx, oyy, ozz, txy, exx, eyy, ezz, exy, es, eps, ecs): #[fdi, oxxi, oyyi, txyi, major, minor, ovmi] = write_floats_13e( #[fdi, oxxi, oyyi, txyi, major, minor, ovmi]) #' ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n' #' ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n' #'0 1 -2.500000E-02 -4.829193E+00 -1.640651E-05 -1.907010E-04 4.829185E+00 0.0 0.0\n' #' -4.829188E-05 1.448741E-05 -4.958226E-09\n' #' 2.500000E-02 4.770547E+00 1.493975E-04 1.907012E-04 4.770473E+00 0.0 0.0\n' #' 4.770502E-05 -1.431015E-05 4.958231E-09\n' if i == 0: f06_file.write( '0 %8i %-13s %-13s %-13s %-13s %-13s %-13s %s\n' ' %-13s %-13s %s\n' % ( # A # ELEMENT FIBER XYZ STRESS EQUIVALENT EFF.STRAIN EFF.CREEP\n' eid, write_float_13e(fdi), write_float_13e(oxxi), write_float_13e(oyyi), #write_float_13e(ozzi), write_float_13e(txyi), write_float_13e(esi), write_float_13e(epsi), write_float_13e(ecsi), write_float_13e(exxi), write_float_13e(eyyi), #write_float_13e(ezzi), write_float_13e(exyi), )) else: f06_file.write( ' %-13s %-13s %-13s %-13s %-13s %-13s %s\n' ' %-13s %-13s %s\n' % ( write_float_13e(fdi), write_float_13e(oxxi), write_float_13e(oyyi), #write_float_13e(ozzi), write_float_13e(txyi), write_float_13e(esi), write_float_13e(epsi), write_float_13e(ecsi), write_float_13e(exxi), write_float_13e(eyyi), #write_float_13e(ezzi), write_float_13e(exyi), )) f06_file.write(page_stamp % page_num) page_num += 1 return page_num - 1
def nanmin13s(nparray): if np.any(np.isfinite(nparray)): return write_float_13e(np.nanmin(nparray)) return ' '
def write_f06(self, f06_file, header=None, page_stamp='PAGE %s', page_num: int = 1, is_mag_phase: bool = False, is_sort1: bool = True): """ ' S T R E N G T H R A T I O S F O R L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )' ' ELEMENT FAILURE PLY SRP-STRENGTH RATIO FOR PLY SRB-STRENGTH RATIO FOR BONDING STRENGTH RATIO FOR ELEMENT FLAG' ' ID THEORY ID (DIRECT STRESSES/STRAINS) (INTER-LAMINAR STRESSES) MIN OF SRP,SRB FOR ALL PLIES' ' 57 TSAI-WU 1 1.420811E+00 ' ' 8.824254E+05 ' ' 2 1.130841E+01 ' ' 8.670931E+05 ' ' 3 4.838508E+00 ' ' 8.183240E+05 ' ' 4 2.312551E+00 ' ' 8.036290E+05 ' ' 5 2.316453E+00 ' ' 8.183240E+05 ' ' 6 4.871836E+00 ' ' 8.670931E+05 ' ' 7 1.148123E+01 ' ' 8.824254E+05 ' ' 8 1.443441E+00 ' ' 1.420811E+00 ' ' 59 TSAI-WU 1 1.069008E+00 ' """ #raise NotImplementedError('write_f06') if header is None: header = [] #msg, nnodes, is_bilinear = self._get_msgs() #if self.is_von_mises: #von = 'VON' #mises = 'MISES' #else: #von = 'MAX' #mises = 'SHEAR' if self.element_type == 95: # CQUAD4 etype = ' S T R E N G T H R A T I O S F O R L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' elif self.element_type == 96: # CQUAD8 etype = ' F A I L U R E I N D I C E S F O R L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 8 )\n' elif self.element_type == 97: # CTRIA3 etype = ' S T R E N G T H R A T I O S F O R L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' elif self.element_type == 98: # CTRIA6 etype = ' F A I L U R E I N D I C E S F O R L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 6 )\n' else: print(''.join(self.get_stats())) msg = 'element_name=%s element_type=%s' % (self.element_name, self.element_type) raise NotImplementedError(msg) msg = [ etype, ' ELEMENT FAILURE PLY SRP-STRENGTH RATIO FOR PLY SRB-STRENGTH RATIO FOR BONDING STRENGTH RATIO FOR ELEMENT FLAG\n' ' ID THEORY ID (DIRECT STRESSES/STRAINS) (INTER-LAMINAR STRESSES) MIN OF SRP,SRB FOR ALL PLIES\n' ] # write the f06 ntimes = self.data.shape[0] eids = self.element_layer[:, 0] layers = self.element_layer[:, 1] element_by_layer, ueids = pivot_table(layers, eids, layers) nlayers = np.nanmax(element_by_layer, axis=1) assert len(nlayers) == len(ueids) for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f06_file.write(''.join(header + msg)) #print("self.data.shape=%s itime=%s ieids=%s" % (str(self.data.shape), itime, str(ieids))) # min_sr_bonding_fi_bonding #[strength_ratio_ply, failure_index_bonding, strength_ratio_bonding] strength_ratio_ply = self.data[itime, :, 0] failure_index_bonding = self.data[itime, :, 1] strength_ratio_bonding = self.data[itime, :, 2] i = 0 is_nans_sr_bonding = np.isnan(strength_ratio_bonding) #is_nans_fi_bonding = np.isnan(failure_index_bonding) #print(is_nans.tolist()) #print("nlayers =", nlayers.tolist()) if 1: for eid, nlayer in zip(ueids, nlayers): i0 = i i1 = i + nlayer #ft = failure_theory[i] sr_ply = strength_ratio_ply[i] sr_plys = write_float_13e(sr_ply) #sr_bonding = strength_ratio_bonding[i] #sr_bondings = write_float_13e(sr_bonding) #fi_bondings = ' ' if is_nans_fi_bonding[i] else write_float_13e(failure_index_bonding[i]) sr_bondings = ' ' if is_nans_sr_bonding[ i] else write_float_13e(strength_ratio_bonding[i]) ft = self.failure_theory_flag[i, 0] flag = self.failure_theory_flag[i, 1] # layer1 f06_file.write( ' %8d %8s %5d %s \n' ' %s \n' % (eid, ft, 1, sr_plys, sr_bondings)) i += 1 for jlayer in range(1, nlayer - 1): ilayer = layers[i] sr_ply = strength_ratio_ply[i] sr_plys = write_float_13e(sr_ply) #sr_bonding = strength_ratio_bonding[i] #sr_bondings = write_float_13e(sr_bonding) #fi_bondings = ' ' if is_nans_fi_bonding[i] else write_float_13e(failure_index_bonding[i]) sr_bondings = ' ' if is_nans_sr_bonding[ i] else write_float_13e(strength_ratio_bonding[i]) f06_file.write( ' %5d %s \n' ' %s \n' % (ilayer, sr_plys, sr_bondings)) i += 1 # final sr_ply = strength_ratio_ply[i] sr_plys = write_float_13e(sr_ply) sr_ply = strength_ratio_ply[i] sr_plys = write_float_13e(sr_ply) all_data = strength_ratio_ply[i0:i1] min_sr_plys = nanmin13s(all_data) #min_sr_ply = np.nanmin(strength_ratio_ply[i0:i1]) #min_sr_plys = write_float_13e(min_sr_ply) #min_sr_plys = ' ?.??????E+00' f06_file.write( ' %5d %s \n' ' %13s \n' % (nlayer, sr_plys, min_sr_plys)) i += 1 else: # loop over nlayers max and ueids failure_theory = self.failure_theory_flag[:, 0] flags = self.failure_theory_flag[:, 1] for eid, layer, ft, sr_ply, fi_bonding, sr_bonding, flag in zip( eids, layers, failure_theory, strength_ratio_ply, failure_index_bonding, strength_ratio_bonding, flags): # TODO: super slow way to get the max layer id irows = np.where(eids == eid)[0] nlayers = len(irows) #ft = 'TSAI-WU' sr_plys = write_float_12e(sr_ply) sr_bondings = write_float_12e(sr_bonding) if layer == 1: #eid=3; #sr_ply=1.34007; fi_bonding='' sr_bonding=34482.3; min(sr_bonding, fi_bonding)=nan flag='' #print(eid, layer, sr_plys, fi_bonding, sr_bondings) f06_file.write( ' %8d %8s %5d %s \n' ' %s \n' % (eid, ft, layer, sr_plys, sr_bondings)) elif layer == nlayers: f06_file.write( ' %5d %s \n' ' ?.??????E+00 \n' % (layer, sr_plys)) else: f06_file.write( ' %5d %s \n' ' %s \n' % (layer, sr_plys, sr_bondings)) f06_file.write(page_stamp % page_num) page_num += 1 return page_num - 1
def write_f06(self, f06_file, header=None, page_stamp='PAGE %s', page_num=1, is_mag_phase=False, is_sort1=True): if header is None: header = [] # ' EIGENVALUE = 2.005177E+05' # ' CYCLES = 7.126832E+01' # ' E L E M E N T S T R A I N E N E R G I E S' # ' ' # ' ELEMENT-TYPE = TETRA * TOTAL ENERGY OF ALL ELEMENTS IN PROBLEM = 1.002589E+05' # ' MODE 1 * TOTAL ENERGY OF ALL ELEMENTS IN SET -1 = 1.002589E+05' # '0' # ' ELEMENT-ID STRAIN-ENERGY PERCENT OF TOTAL STRAIN-ENERGY-DENSITY' # ' 4 3.247409E+00 0.0032 1.948445E+01' # ' 5 3.977916E+00 0.0040 2.386749E+01' # '' # ' TYPE = TETRA SUBTOTAL 7.225325E+00 0.0072' msg_temp = ( ' E L E M E N T S T R A I N E N E R G I E S\n' ' \n' ' ELEMENT-TYPE = %s * TOTAL ENERGY OF ALL ELEMENTS IN PROBLEM = %s\n' ' MODE %8i * TOTAL ENERGY OF ALL ELEMENTS IN SET -1 = %s\n' '0\n' ' ELEMENT-ID STRAIN-ENERGY PERCENT OF TOTAL STRAIN-ENERGY-DENSITY\n' ) ntimes = self.data.shape[0] #etype = self.element_data_type for itime in range(ntimes): dt = self._times[itime] # TODO: rename this... header = _eigenvalue_header(self, header, itime, ntimes, dt) total_energy = 0. total_set_energy = 0. eids = self.element[itime, :] # energy, percent, density energy = self.data[itime, :, 0] percent = self.data[itime, :, 1] density = self.data[itime, :, 2] #itotal = np.where(eids == 100000000)[0][0] #total_energy = self.data[:, :, 0].sum() #total_set_energy = energy.sum() #total_set_energy = energy[itotal] #total_percent = percent.sum() msg_temp2 = [ msg_temp % (self.element_name, total_energy, itime + 1, total_set_energy) ] f06_file.write(''.join(header + msg_temp2)) fmt1 = ' ' * 36 + '%10s %-13s %.4f %s\n' fmt1_nan = ' ' * 36 + '%10s %-13s %.4f %s\n' fmt2 = '\n TYPE = %-8s SUBTOTAL %13s %.4f\n' for (eid, energyi, percenti, densityi) in zip(eids, energy, percent, density): senergyi = write_float_13e(energyi) sdensityi = write_float_13e(densityi) # ELEMENT-ID STRAIN-ENERGY PERCENT OF TOTAL STRAIN-ENERGY-DENSITY # 1 -8.307121E-12 0.0052 -2.886861E-12 if eid == 100000000: f06_file.write(fmt2 % (self.element_name, senergyi, percenti)) break try: f06_file.write(fmt1 % (eid, senergyi, percenti, sdensityi)) except TypeError: #print('eid = %r; type=%s' % (eid, type(eid))) #print('senergyi = %r; type=%s' % (senergyi, type(senergyi))) #print('percenti = %r; type=%s' % (percenti, type(percenti))) #print('sdensityi = %r; type=%s' % (sdensityi, type(sdensityi))) assert np.isnan( sdensityi), 'eid=%s sdensityi=%s' % (eid, sdensityi) f06_file.write(fmt1_nan % (eid, senergyi, percenti, '')) #if 0: #print('senergyi = %r; type=%s' % (senergyi, type(senergyi))) #print('percenti = %r; type=%s' % (percenti, type(percenti))) #print('sdensityi = %r; type=%s' % (sdensityi, type(sdensityi))) #msg = fmt1 % (eid, senergyi, percenti, sdensityi) #raise TypeError(msg) #raise RuntimeError(msg) f06_file.write(page_stamp % page_num) page_num += 1 break return page_num - 1
def write_f06(self, f06_file, header=None, page_stamp='PAGE %s', page_num=1, is_mag_phase=False, is_sort1=True): if header is None: header = [] msg_temp = ( ' E L E M E N T S T R A I N E N E R G I E S ( A V E R A G E ) \n' ' \n' ' ELEMENT-TYPE = %-5s * TOTAL ENERGY OF ALL ELEMENTS IN PROBLEM = %s\n' ' SUBCASE 1 * TOTAL ENERGY OF ALL ELEMENTS IN SET -1 = %s\n' '0\n' ' ELEMENT-ID STRAIN-ENERGY (MAG/PHASE) PERCENT OF TOTAL STRAIN-ENERGY-DENSITY\n' #' 5 2.027844E-10 / 0.0 1.2581 2.027844E-09' ) ntimes = self.data.shape[0] #etype = self.element_data_type for itime in range(ntimes): dt = self._times[itime] # TODO: rename this... header = _eigenvalue_header(self, header, itime, ntimes, dt) total_energy = 0. total_set_energy = 0. eids = self.element[itime, :] # energyr, energyi, percent, density energyr = self.data[itime, :, 0] energyi = self.data[itime, :, 1] percent = self.data[itime, :, 2] density = self.data[itime, :, 3] #total_energy = self.data[:, :, 0].sum() #total_set_energy = energy.sum() #total_set_energy = energy[itotal] #total_percent = percent.sum() msg_temp2 = [ msg_temp % (self.element_name, total_energy, total_set_energy) ] f06_file.write(''.join(header + msg_temp2)) fmt1 = ' ' * 23 + '%10i %-13s / %-13s %7.4f %s\n' fmt2 = '\n TYPE = %-8s SUBTOTAL %13s %.4f\n' for (eid, energyri, energyii, percenti, densityi) in zip(eids, energyr, energyi, percent, density): senergyr = write_float_13e(energyri) senergyi = write_float_13e(energyii) sdensityi = write_float_13e(densityi) # ELEMENT-ID STRAIN-ENERGY PERCENT OF TOTAL STRAIN-ENERGY-DENSITY # 1 -8.307121E-12 0.0052 -2.886861E-12 #if eid == 100000000: #f06_file.write(fmt2 % (self.element_name, senergyi, percenti)) #break f06_file.write(fmt1 % (eid, senergyr, senergyi, percenti, sdensityi)) f06_file.write(page_stamp % page_num) page_num += 1 #break return page_num - 1
def write_f06(self, f, header=None, page_stamp="PAGE %s", page_num=1, is_mag_phase=False, is_sort1=True): if header is None: header = [] # msg, nnodes, cen = _get_plate_msg(self) if self.element_type == 88: msg = [ " N O N L I N E A R S T R E S S E S I N T R I A N G U L A R E L E M E N T S ( T R I A 3 )\n" " \n" " ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n" " ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n" ] elif self.element_type == 90: msg = [ " N O N L I N E A R S T R E S S E S I N Q U A D R I L A T E R A L E L E M E N T S ( Q U A D 4 )\n" " \n" " ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n" " ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n" #'0 1 -2.500000E-02 -4.829193E+00 -1.640651E-05 -1.907010E-04 4.829185E+00 0.0 0.0\n' #' -4.829188E-05 1.448741E-05 -4.958226E-09\n' #' 2.500000E-02 4.770547E+00 1.493975E-04 1.907012E-04 4.770473E+00 0.0 0.0\n' #' 4.770502E-05 -1.431015E-05 4.958231E-09\n' ] else: raise NotImplementedError("element_name=%s self.element_type=%s" % (self.element_name, self.element_type)) # msg = [ #' N O N L I N E A R S T R E S S E S I N Q U A D R I L A T E R A L E L E M E N T S ( Q U A D 4 )\n' #' \n' #' ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n' #' ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n' ##'0 1 -2.500000E-02 -4.829193E+00 -1.640651E-05 -1.907010E-04 4.829185E+00 0.0 0.0\n' ##' -4.829188E-05 1.448741E-05 -4.958226E-09\n' ##' 2.500000E-02 4.770547E+00 1.493975E-04 1.907012E-04 4.770473E+00 0.0 0.0\n' ##' 4.770502E-05 -1.431015E-05 4.958231E-09\n' # ] # write the f06 ntimes = self.data.shape[0] eids = self.element_node[:, 0] nids = self.element_node[:, 1] # cen_word = 'CEN/%i' % nnodes for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f.write("".join(header + msg)) # print("self.data.shape=%s itime=%s ieids=%s" % (str(self.data.shape), itime, str(ieids))) # [fiber_dist, oxx, oyy, ozz, txy, es, eps, ecs, exx, eyy, ezz, etxy] fiber_dist = self.data[itime, :, 0] oxx = self.data[itime, :, 1] oyy = self.data[itime, :, 2] ozz = self.data[itime, :, 3] txy = self.data[itime, :, 4] es = self.data[itime, :, 5] eps = self.data[itime, :, 6] ecs = self.data[itime, :, 7] exx = self.data[itime, :, 8] eyy = self.data[itime, :, 9] ezz = self.data[itime, :, 10] exy = self.data[itime, :, 11] for (i, eid, nid, fdi, oxxi, oyyi, ozzi, txyi, exxi, eyyi, ezzi, exyi, esi, epsi, ecsi) in zip( cycle([0, 1]), eids, nids, fiber_dist, oxx, oyy, ozz, txy, exx, eyy, ezz, exy, es, eps, ecs ): # [fdi, oxxi, oyyi, txyi, major, minor, ovmi] = write_floats_13e( # [fdi, oxxi, oyyi, txyi, major, minor, ovmi]) #' ELEMENT FIBER STRESSES/ TOTAL STRAINS EQUIVALENT EFF. STRAIN EFF. CREEP\n' #' ID DISTANCE X Y Z XY STRESS PLASTIC/NLELAST STRAIN\n' #'0 1 -2.500000E-02 -4.829193E+00 -1.640651E-05 -1.907010E-04 4.829185E+00 0.0 0.0\n' #' -4.829188E-05 1.448741E-05 -4.958226E-09\n' #' 2.500000E-02 4.770547E+00 1.493975E-04 1.907012E-04 4.770473E+00 0.0 0.0\n' #' 4.770502E-05 -1.431015E-05 4.958231E-09\n' if i == 0: f.write( "0 %8i %-13s %-13s %-13s %-13s %-13s %-13s %s\n" " %-13s %-13s %s\n" % ( # A # eid, write_float_13e(fdi), # write_float_13e(oxxi), write_float_13e(oyyi), ##write_float_13e(ozzi), # write_float_13e(txyi), # write_float_13e(esi), write_float_13e(epsi), # write_float_13e(ecsi), # write_float_13e(exxi), write_float_13e(eyyi), ##write_float_13e(ezzi), # write_float_13e(exyi), # ELEMENT FIBER XYZ STRESS EQUIVALENT EFF.STRAIN EFF.CREEP\n' eid, write_float_13e(fdi), write_float_13e(oxxi), write_float_13e(oyyi), # write_float_13e(ozzi), write_float_13e(txyi), write_float_13e(esi), write_float_13e(epsi), write_float_13e(ecsi), write_float_13e(exxi), write_float_13e(eyyi), # write_float_13e(ezzi), write_float_13e(exyi), ) ) else: f.write( " %-13s %-13s %-13s %-13s %-13s %-13s %s\n" " %-13s %-13s %s\n" % ( write_float_13e(fdi), write_float_13e(oxxi), write_float_13e(oyyi), # write_float_13e(ozzi), write_float_13e(txyi), write_float_13e(esi), write_float_13e(epsi), write_float_13e(ecsi), write_float_13e(exxi), write_float_13e(eyyi), # write_float_13e(ezzi), write_float_13e(exyi), ) ) f.write(page_stamp % page_num) page_num += 1 return page_num - 1