def plot_forces(self, step_num=2, along_edge=False, gui=False): import __main__ step_name = self.get_step_name(step_num) names = [] do_norm = False if self.study: if self.study.calc_Pcr: do_norm = True Pcr = self.study.ccs[0].zload[0] if gui: names.append('%s_load_shortening_curve' % self.model_name) if do_norm: names.append('%s_load_shortening_curve_norm' % self.model_name) else: names.append('%s_Step_%02d_Displacement_X_Force' % (self.model_name, step_num)) if do_norm: names.append('%s_Step_%02d_Displacement_X_Force_norm' % (self.model_name, step_num)) lamt = sum(self.plyts) tmp_displ_f = [] tmp_displ_f_norm = [] fb_load = utils.find_fb_load(self.zload) for i in range(len(self.zload)): zload = self.zload[i] tmp_displ_f.append((abs(self.zdisp[i]), 0.001 * zload)) if do_norm: tmp_displ_f_norm.append((abs(self.zdisp[i] / lamt), zload / Pcr)) if len(tmp_displ_f) == 0: print 'ERROR - plot_forces - run read_outputs first' return if self.impconf.ploads <> []: text = ('perturbation load = %2.1f N, first buckling load = %2.2f kN' % (self.impconf.ploads[0].pltotal, 0.001 * fb_load)) legendLabel = text else: legendLabel = self.model_name session = __main__.session session.XYData(name=names[0], data=tmp_displ_f, xValuesLabel='End-Shortening, mm', yValuesLabel='Reaction Load, kN', legendLabel=legendLabel) if do_norm: session.XYData(name=names[1], data=tmp_displ_f_norm, xValuesLabel='Normalized End-Shortening', yValuesLabel='Normalized Reaction Load', legendLabel=legendLabel) if along_edge: names.append('%s_Step_%02d_Force_along_loaded_edge' % (self.model_name, step_num)) tmp = [] zload = 0 for node in self.cross_sections[-1].nodes: if node <> None: fz = node.fz[step_name][-1] zload += fz tmp.append((node.theta, 0.001 * fz)) frmlen = len(node.fz[step_name]) session.XYData(name=names[1], data=tmp, xValuesLabel='Circumferential position, degrees', yValuesLabel='Reaction Load, kN', legendLabel='%s, total force = %2.2f kN' % (self.model_name, 0.001 * sum(self.zload))) self.ls_curve = tmp_displ_f if do_norm: return tmp_displ_f, tmp_displ_f_norm else: return tmp_displ_f, None
def plot(self, configure_session = False, gui = False, put_in_Excel = True, open_Excel = False, global_second = False): import desicos.abaqus.utils as utils import abaqus_functions for cc in self.ccs: cc.outputs_ok = cc.read_outputs() laminate_t = sum(t for t in self.ccs[0].plyts) session = __main__.session numcharts = 4 if self.calc_Pcr == False: calc_Pcr = False numcharts = 2 start = 0 else: calc_Pcr = True pcr_kN = 0.001*self.ccs[0].zload[0] start = 1 curves_dict = {} limit = len(self.ccs[start].impconf.imperfections) for i in range(limit): imp_ref = self.ccs[start].impconf.imperfections[i] if not any(cc.impconf.imperfections[i] for cc in self.ccs[start:]): warn("imperfection '{0}' is zero for all ConeCyl objects, skipping...".format( imp_ref.name)) continue xaxis_label = imp_ref.xaxis_label for pre in ['fb','gb']: curve = [] curve_amp = [] for cc in self.ccs[start:]: # if cc.check_completed() and cc.outputs_ok: if pre == 'fb': b_load = utils.find_fb_load(cc.zload) else: b_load = max(cc.zload) if i < len(cc.impconf.imperfections): imp = cc.impconf.imperfections[i] imp_xaxis = getattr(imp, imp.xaxis) amplitude = imp.calc_amplitude() else: imp_xaxis = getattr(imp_ref, imp_ref.xaxis) amplitude = 0. # curve.append((imp_xaxis, 0.001 * b_load)) curve_amp.append((amplitude, 0.001 * b_load)) elif not cc.outputs_ok: warn('error in {0}.odb, skipping...'.format( cc.model_name)) # # sorting curves curve.sort(key = lambda x: x[0]) curve_amp.sort(key = lambda x: x[0]) # # yaxis_label = 'Reaction Load, kN' name = '{0}_imp_{1:02d}_KD_curve_{2}'.format(self.name, i, pre) curves_dict[name] = [xaxis_label, yaxis_label, curve] session.XYData( name = name, data = curve, xValuesLabel = xaxis_label, yValuesLabel = yaxis_label, legendLabel = imp_ref.name) name = '{0}_imp_{1:02d}_KD_curve_{2}_amplitude'.format( self.name, i, pre) curves_dict[name] = ['Imperfection amplitude, mm', yaxis_label, curve_amp] session.XYData(name=name, data=curve_amp, xValuesLabel='Imperfection amplitude, mm', yValuesLabel=yaxis_label, legendLabel=imp_ref.name,) if calc_Pcr: yaxis_label = 'Knock-Down Factor (P/Pcr)' name = '{0}_imp_{1:02d}_norm_KD_curve_{2}'.format( self.name, i, pre) norm_curve = np.array(curve) norm_curve[:,1] /= pcr_kN curves_dict[name] = [xaxis_label, yaxis_label, norm_curve] session.XYData(name=name, data=norm_curve, xValuesLabel=xaxis_label, yValuesLabel=yaxis_label, legendLabel=imp_ref.name) name = ('{0}_imp_{1:02d}_norm_KD_curve_{2}_amplitude'. format(self.name, i, pre)) norm_curve_amp = np.array(curve_amp) norm_curve_amp[:,0] /= laminate_t norm_curve_amp[:,1] /= pcr_kN curves_dict[name] = ['Imperfection amplitude / laminate thickness', yaxis_label, norm_curve_amp] session.XYData(name=name, data=norm_curve_amp, xValuesLabel='Imperfection amplitude / laminate thickness', yValuesLabel=yaxis_label, legendLabel=imp_ref.name) if configure_session: abaqus_functions.configure_session(session=session) if put_in_Excel: sheet_name = 'kd_curves' keys = curves_dict.keys() keys.sort() book, sheet = utils.get_book_sheet(self.excel_name, sheet_name) for i, name in enumerate(keys): value = curves_dict[name] xaxis_label = value[0] yaxis_label = value[1] curve = value[2] sheet.write(0,0 + i*2, name) sheet.write(1,0 + i*2, xaxis_label) sheet.write(1,1 + i*2, yaxis_label) for j, xy in enumerate(curve): sheet.write(j+2,0 + i*2,xy[0]) sheet.write(j+2,1 + i*2,xy[1]) book.save(self.excel_name) del book if open_Excel: self.open_excel() self.kd_curves = curves_dict
def plot_forces(self, step_num=2, along_edge=False, gui=False): import __main__ step_name = self.get_step_name(step_num) names = [] do_norm = False if self.study: if self.study.calc_Pcr: do_norm = True Pcr = self.study.ccs[0].zload[0] if gui: names.append('%s_load_shortening_curve' % self.model_name) if do_norm: names.append('%s_load_shortening_curve_norm' % self.model_name) else: names.append('%s_Step_%02d_Displacement_X_Force' % (self.model_name, step_num)) if do_norm: names.append('%s_Step_%02d_Displacement_X_Force_norm' % (self.model_name, step_num)) lamt = sum(self.plyts) tmp_displ_f = [] tmp_displ_f_norm = [] fb_load = utils.find_fb_load(self.zload) for i in range(len(self.zload)): zload = self.zload[i] tmp_displ_f.append((abs(self.zdisp[i]), 0.001 * zload)) if do_norm: tmp_displ_f_norm.append((abs(self.zdisp[i]/lamt), zload/Pcr)) if len(tmp_displ_f) == 0: print 'ERROR - plot_forces - run read_outputs first' return if self.impconf.ploads <> []: text = ('perturbation load = %2.1f N, first buckling load = %2.2f kN' % (self.impconf.ploads[0].pltotal, 0.001 * fb_load)) legendLabel = text else: legendLabel = self.model_name session = __main__.session session.XYData( name = names[0], data = tmp_displ_f, xValuesLabel = 'End-Shortening, mm', yValuesLabel = 'Reaction Load, kN', legendLabel = legendLabel) if do_norm: session.XYData( name = names[1], data = tmp_displ_f_norm, xValuesLabel = 'Normalized End-Shortening', yValuesLabel = 'Normalized Reaction Load', legendLabel = legendLabel) if along_edge: names.append( '%s_Step_%02d_Force_along_loaded_edge' % (self.model_name, step_num)) tmp = [] zload = 0 for node in self.cross_sections[-1].nodes: if node <> None: fz = node.fz[step_name][-1] zload += fz tmp.append((node.theta, 0.001 * fz)) frmlen = len(node.fz[step_name]) session.XYData( name = names[1], data = tmp, xValuesLabel = 'Circumferential position, degrees', yValuesLabel = 'Reaction Load, kN', legendLabel = '%s, total force = %2.2f kN' % (self.model_name, 0.001 * sum(self.zload))) self.ls_curve = tmp_displ_f if do_norm: return tmp_displ_f, tmp_displ_f_norm else: return tmp_displ_f, None