def vector(odb_name, field_name, desc, s1, s2, s3): """Build a vector. Parameters ---------- odb_name : str Name of output databse. field_name : str Name of field to be generated. desc : str Description of field to be generated. s1 : str Name of 11 component. s2 : str Name of 22 component. s3 : str Name of 33 component. """ # close ODB and open with write permissions odb = session.openOdb(name=odb_name) odb.close() odb = session.openOdb(name=odb_name, readOnly=False) # for each step for stepName in odb.steps.keys(): # for each frame N = len(odb.steps[stepName].frames) for i, frame in enumerate(odb.steps[stepName].frames): milestone("Adding field to frames in step %s" % stepName, "Frame", i, N) sv1 = frame.fieldOutputs[s1] sv2 = frame.fieldOutputs[s2] sv3 = frame.fieldOutputs[s3] # create empty field output Field = frame.FieldOutput( name=field_name, description=desc, type=VECTOR, validInvariants=(MAGNITUDE,), ) _add_to_field(Field, odb, sv1, sv2, sv3) odb.save() odb.close() odb = session.openOdb(name=odb_name) current_viewport = session.currentViewportName session.viewports[current_viewport].setValues(displayedObject=odb) print("Done.") return 1
def _perform_post_processing(self): for model_name, model in reversed(self.models.items()): # avoid doing again post-processing if model_name in self.post_processing.keys(): continue # do post-processing of current model if isinstance(model, WrapperModel) and not callable( model.post_processing_fnc) or model.abort: self.post_processing[model_name] = None else: odb_name = '%s.odb' % model.job_info['name'] odb = session.openOdb(name=odb_name) self.post_processing[ model_name] = model.perform_post_processing(odb) odb.close() # save post-processing of previous model (if applicable) if model.previous_model_results is not None and model.previous_model.name not in self.post_processing.keys( ): self.post_processing[ model.previous_model.name] = model.previous_model_results self.post_processing = OrderedDict( reversed(list(self.post_processing.items())))
def __init__(self, odbname1): """this is executed with the object is instantiated""" # odbname1 = 'C:/Users/ngordon/Desktop/abaqus-scripting/customBeamExample/customBeamExample.odb' if ' ' in odbname1: print('Remove all spaces from file path %s' % odbname1) sys.exit(0) else: if odbAccess.isUpgradeRequiredForOdb( upgradeRequiredOdbPath=odbname1): newodb = odbname1.name.replace('.odb', '_new.odb') odbAccess.upgradeOdb(existingOdbPath=odbname, upgradedOdbPath=newodb) odbname1 = newodb self.myOdbDat = session.openOdb(name=odbname1, readOnly=True) self.myAssembly = self.myOdbDat.rootAssembly self.xyp = session.XYPlot(name='XYPlot-1') ## can be run multiple times but the line >>>session.xyPlots['XYPlot-1'] , can only be run once >>>ession.XYPlot('XYPlot-1') chartName = self.xyp.charts.keys()[0] self.chart = self.xyp.charts[chartName] # self.chart.legend.textStyle.setValues(font='-*-verdana-medium-r-normal-*-*-340-*-*-p-*-*-*') self.chart.legend.setValues(show=False) self.chart.legend.titleStyle.setValues( font='-*-verdana-medium-r-normal-*-*-240-*-*-p-*-*-*') self.chart.gridArea.style.setValues(fill=False) self.xyp.title.style.setValues( font='-*-arial-medium-r-normal-*-*-240-*-*-p-*-*-*') # 30 <= width <= 423 30 <= height <= 564 self.myVp = session.Viewport(name='myVp1', origin=(0, 0), width=400, height=550) self.myVp.setValues(displayedObject=self.myOdbDat) self.csysCyn = self.myOdbDat.rootAssembly.DatumCsysByThreePoints( name='CSYS-CYN', coordSysType=CYLINDRICAL, origin=(0.0, 0.0, 0.0), point1=(1.0, 0.0, 0.0), point2=(0.0, 1.0, 0.0)) # default view self.myView = 'Iso' # session settings session.printOptions.setValues(vpBackground=OFF, rendition=COLOR, vpDecorations=FALSE, compass=OFF) session.psOptions.setValues(orientation=LANDSCAPE) session.pageSetupOptions.setValues(imageSize=SIZE_ON_SCREEN, quality=FINE, orientation=LANDSCAPE, logo=OFF)
def __init__(self, odbname1): """this is executed with the object is instantiated""" # odbname1 = 'C:/Users/ngordon/Desktop/abaqus-scripting/customBeamExample/customBeamExample.odb' if ' ' in odbname1: print('Remove all spaces from file path %s' % odbname1) sys.exit(0) else: if odbAccess.isUpgradeRequiredForOdb(upgradeRequiredOdbPath=odbname1): newodb = odbname1.name.replace('.odb','_new.odb') odbAccess.upgradeOdb(existingOdbPath=odbname, upgradedOdbPath=newodb) odbname1 = newodb self.myOdbDat = session.openOdb(name=odbname1, readOnly=True) self.myAssembly = self.myOdbDat.rootAssembly self.xyp = session.XYPlot(name='XYPlot-1') ## can be run multiple times but the line >>>session.xyPlots['XYPlot-1'] , can only be run once >>>ession.XYPlot('XYPlot-1') chartName = self.xyp.charts.keys()[0] self.chart = self.xyp.charts[chartName] # self.chart.legend.textStyle.setValues(font='-*-verdana-medium-r-normal-*-*-340-*-*-p-*-*-*') self.chart.legend.setValues(show=False) self.chart.legend.titleStyle.setValues(font='-*-verdana-medium-r-normal-*-*-240-*-*-p-*-*-*') self.chart.gridArea.style.setValues(fill=False) self.xyp.title.style.setValues(font='-*-arial-medium-r-normal-*-*-240-*-*-p-*-*-*') # 30 <= width <= 423 30 <= height <= 564 self.myVp = session.Viewport(name='myVp1', origin=(0, 0), width=400, height=550) self.myVp.setValues(displayedObject=self.myOdbDat) self.csysCyn = self.myOdbDat.rootAssembly.DatumCsysByThreePoints(name='CSYS-CYN', coordSysType=CYLINDRICAL, origin=(0.0, 0.0, 0.0), point1=(1.0, 0.0, 0.0), point2=(0.0, 1.0, 0.0)) # default view self.myView = 'Iso' # session settings session.printOptions.setValues(vpBackground=OFF, rendition=COLOR, vpDecorations=FALSE, compass=OFF) session.psOptions.setValues(orientation=LANDSCAPE) session.pageSetupOptions.setValues(imageSize=SIZE_ON_SCREEN, quality=FINE, orientation=LANDSCAPE, logo=OFF)
def _verify_coilability(self): ''' Notes ----- -Assumes odb of the previous simulation is available in the working directory. ''' # TODO: coilable as integer if self.previous_model_results is None: # access odb odb_name = '%s.odb' % self.previous_model.job_info['name'] odb = session.openOdb(name=odb_name) self.previous_model_results = self.previous_model.perform_post_processing( odb) odb.close() return int(self.previous_model_results['coilable'])
def _get_moment_for_riks(self): ''' Notes ----- -Assumes odb of the previous simulation is available in the working directory. ''' # access odb odb_name = '%s.odb' % self.previous_model.job_name odb = session.openOdb(name=odb_name) # get results if self.previous_model_results is None: self.previous_model_results = self.previous_model.perform_post_processing( odb) return self.previous_model_results['critical_moment']
''' Created on 2020-09-22 15:35:10 Last modified on 2020-09-29 14:42:51 @author: L. F. Pereira ([email protected])) ''' # imports from abaqus import session # variable initialization and odb opening job_name = 'Simul_SUPERCOMPRESSIBLE_LIN_BUCKLE' odb_name = '{}.odb'.format(job_name) odb = session.openOdb(name=odb_name) # initialization step = odb.steps[odb.steps.keys()[-1]] frames = step.frames # get maximum displacements variable = 'UR' directions = (1, 2, 3) nodeSet = odb.rootAssembly.nodeSets[' ALL NODES'] values = [] for frame in frames: varFieldOutputs = frame.fieldOutputs[variable] outputs = varFieldOutputs.getSubset(region=nodeSet).values output_frame = [] for direction in directions: output_frame.append([output.data[direction - 1] for output in outputs]) values.append(output_frame)
def tensor(odb_name, field_name, desc, s1, s2, s3, s4, s5, s6, frame_list): """Build a tensor. Parameters ---------- odb_name : str Name of output databse. field_name : str Name of field to be generated. desc : str Description of field to be generated. s1 : str Name of 11 component. s2 : str Name of 22 component. s3 : str Name of 33 component. s4 : str Name of 12 component. s5 : str Name of 23 component. s6 : str Name of 13 component. frame_list : str Name with frames """ # close ODB and open with write permissions odb = session.openOdb(name=odb_name) odb.close() odb = session.openOdb(name=odb_name, readOnly=False) # define invariants to be computed invariants = (MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL) # for each step for stepName in odb.steps.keys(): # transfer frame_list string to array frame_list_new = frame_list[1:-1].split(',') N = len(odb.steps[stepName].frames) if len(frame_list_new) == 1: if int(frame_list_new[0]) == -1: frame_list_new[0] = N - 1 reference_frames = [frame_list_new[0]] field_name = field_name + "_Frame_" + str(frame_list_new[0]) else: if int(frame_list_new[1]) == -1: frame_list_new[1] = N - 1 reference_frames = list(range(int(frame_list_new[0]), (int(frame_list_new[1])-int(frame_list_new[0])))) field_name = (field_name + "_Frames_" + str(frame_list_new[0]) + "_to_" + str(frame_list_new[1]) + "_") N = len(reference_frames) # for preselected frames for i, frame in enumerate(odb.steps[stepName].frames): if i in reference_frames: milestone("Adding field to frames in step %s" % stepName, "Frame", i, N) sv1 = frame.fieldOutputs[s1] sv2 = frame.fieldOutputs[s2] sv3 = frame.fieldOutputs[s3] sv4 = frame.fieldOutputs[s4] sv5 = frame.fieldOutputs[s6] # different order in ODB (WTF ABQ?!) sv6 = frame.fieldOutputs[s5] # different order in ODB (WTF ABQ?!) # create empty field output Field = frame.FieldOutput( name=field_name, description=desc, type=TENSOR_3D_FULL, validInvariants=invariants, ) _add_to_field(Field, odb, sv1, sv2, sv3, sv4, sv5, sv6) odb.save() odb.close() odb = session.openOdb(name=odb_name) current_viewport = session.currentViewportName session.viewports[current_viewport].setValues(displayedObject=odb) print("Done.") return 1
def tensor(odb_name, field_name, desc, s1, s2, s3, s4, s5, s6): """Build a tensor. Parameters ---------- odb_name : str Name of output databse. field_name : str Name of field to be generated. desc : str Description of field to be generated. s1 : str Name of 11 component. s2 : str Name of 22 component. s3 : str Name of 33 component. s4 : str Name of 12 component. s5 : str Name of 23 component. s6 : str Name of 13 component. """ # close ODB and open with write permissions odb = session.openOdb(name=odb_name) odb.close() odb = session.openOdb(name=odb_name, readOnly=False) # define invariants to be computed invariants = (MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL) # for each step for stepName in odb.steps.keys(): # for each frame N = len(odb.steps[stepName].frames) for i, frame in enumerate(odb.steps[stepName].frames): milestone("Adding field to frames in step %s" % stepName, "Frame", i, N) sdv1 = frame.fieldOutputs[s1] sdv2 = frame.fieldOutputs[s2] sdv3 = frame.fieldOutputs[s3] sdv4 = frame.fieldOutputs[s4] sdv5 = frame.fieldOutputs[s6] # different order in ODB (WTF ABQ?!) sdv6 = frame.fieldOutputs[s5] # different order in ODB (WTF ABQ?!) labels = [] data = [] for s1c, s2c, s3c, s4c, s5c, s6c in zip( sdv1.values, sdv2.values, sdv3.values, sdv4.values, sdv5.values, sdv6.values, ): if s1c.precision == SINGLE_PRECISION: data.append((s1c.data, s2c.data, s3c.data, s4c.data, s5c.data, s6c.data)) else: data.append(( s1c.dataDouble, s2c.dataDouble, s3c.dataDouble, s4c.dataDouble, s5c.dataDouble, s6c.dataDouble, )) labels.append(s1c.elementLabel) # create empty field output Field = frame.FieldOutput( name=field_name, description=desc, type=TENSOR_3D_FULL, validInvariants=invariants, ) # fill field output with values instance = sdv1.values[0].instance if (instance.name == sdv2.values[0].instance.name and instance.name == sdv3.values[0].instance.name and instance.name == sdv4.values[0].instance.name and instance.name == sdv5.values[0].instance.name and instance.name == sdv6.values[0].instance.name): Field.addData( position=INTEGRATION_POINT, instance=instance, labels=labels, data=data, ) else: print("Could not create field, data is from different" " instances.") odb.save() odb.close() odb = session.openOdb(name=odb_name) current_viewport = session.currentViewportName session.viewports[current_viewport].setValues(displayedObject=odb) print("Done.") return 1
def vector(odb_name, field_name, desc, s1, s2, s3): """Build a vector. Parameters ---------- odb_name : str Name of output databse. field_name : str Name of field to be generated. desc : str Description of field to be generated. s1 : str Name of 11 component. s2 : str Name of 22 component. s3 : str Name of 33 component. """ # close ODB and open with write permissions odb = session.openOdb(name=odb_name) odb.close() odb = session.openOdb(name=odb_name, readOnly=False) # for each step for stepName in odb.steps.keys(): # for each frame N = len(odb.steps[stepName].frames) for i, frame in enumerate(odb.steps[stepName].frames): milestone("Adding field to frames in step %s" % stepName, "Frame", i, N) sdv1 = frame.fieldOutputs[s1] sdv2 = frame.fieldOutputs[s2] sdv3 = frame.fieldOutputs[s3] labels = [] data = [] for s1c, s2c, s3c in zip(sdv1.values, sdv2.values, sdv3.values): if s1c.precision == SINGLE_PRECISION: data.append((s1c.data, s2c.data, s3c.data)) else: data.append( (s1c.dataDouble, s2c.dataDouble, s3c.dataDouble)) labels.append(s1c.nodeLabel) # create empty field output Field = frame.FieldOutput(name=field_name, description=desc, type=VECTOR) # fill field output with values instance = sdv1.values[0].instance if (instance.name == sdv2.values[0].instance.name and instance.name == sdv3.values[0].instance.name): Field.addData(position=NODAL, instance=instance, labels=labels, data=data) else: print("Could not create field, data is from different" " instances.") odb.save() odb.close() odb = session.openOdb(name=odb_name) current_viewport = session.currentViewportName session.viewports[current_viewport].setValues(displayedObject=odb) print("Done.") return 1