在Abaqus Command 中输入 ,然后会在工作目录中出现viewer_tutorial.odb.
abaqus fetch job=viewer_tutorial按照代码文件,在Abaqus命令行窗口,一行行输入命令。
# ODb commands availablefrom odbAccess import *from abaqusConstants import * # material and section Odb commands availablefrom odbMaterial import *from odbSection import * # opening an output databaseodb = openOdb(path=r'C:\AbaqusWorkfile\test_pythonOdb\viewer_tutorial.odb') # Reading model data # The root assemblymyAssembly = odb.rootAssembly # Part instance determine how many instancesfor instanceName in odb.rootAssembly.instances.keys(): print instanceName # Regions: A Node set An element set A surface for NodeSets in odb.rootAssembly.instances[ 'PART-1-1'].nodeSets.keys(): print 'Node sets = ', NodeSets # dispaly the nodes sets and the element setsprint 'Node sets = ', odb.rootAssembly.instances[ 'PART-1-1'].nodeSets.keys()print 'Element sets = ', odb.rootAssembly.instances[ 'PART-1-1'].elementSets.keys() # ssigns a variable (topNodeSet) to the 'TOP' node set in the PART-1-1 part instance:topNodeSet = odb.rootAssembly.instances['PART-1-1'].nodeSets['TOP'] # Reading results data# Stepsfor stepName in odb.steps.keys(): print stepName step1 = odb.steps.values()[0]print step1.name#Frames the last framelastFrame = odb.steps['Step-1'].frames[-1] # Reading field output datafor fieldName in lastFrame.fieldOutputs.keys(): print fieldNamefor fieldName in lastFrame.fieldOutputs.values(): print fieldName # use the following to view all the available field data in a frame:# For each field output value in the last frame,# print the name, description, and type members. for f in lastFrame.fieldOutputs.values(): print f.name, ':', f.description print 'Type: ', f.type # For each location value, print the position. for loc in f.locations: print 'Position:', loc.position print# Results# COPEN TARGET/IMPACTOR: Contact opening# Type: SCALAR# Position: NODAL # CPRESS TARGET/IMPACTOR: Contact pressure# Type: SCALAR# Position: NODAL # CSHEAR1 TARGET/IMPACTOR: Frictional shear# Type: SCALAR# Position: NODAL # CSLIP1 TARGET/IMPACTOR: Relative tangential motion direction 1# Type: SCALAR# Position: NODAL # LE: Logarithmic strain components# Type: TENSOR_2D_PLANAR# Position: INTEGRATION_POINT # RF: Reaction force# Type: VECTOR# Position: NODAL # RM3: Reaction moment# Type: SCALAR# Position: NODAL # S: Stress components# Type: TENSOR_2D_PLANAR# Position: INTEGRATION_POINT # U: Spatial displacement# Type: VECTOR# Position: NODAL # UR3: Rotational displacement# Type: SCALAR# Position: NODAL displacement = lastFrame.fieldOutputs['U']fieldValues = displacement.values mises = lastFrame.fieldOutputs['S']fieldValues1 = mises.values # For each displacement value, print the nodeLabel# and data members. for v in fieldValues: print 'Node = %d U[x] = %6.4f, U[y] = %6.4f' % (v.nodeLabel, v.data[0], v.data[1]) for v in fieldValues1: print 'Element = %d Mises = %6.4f' % (v.elementLabel, v.mises) # lists all the members of a particular FieldValuefieldValues[1].__members__# The resulting output is# ['instance', 'elementLabel', 'nodeLabel', 'position',# 'face', 'integrationPoint', 'sectionPoint',# 'localCoordSystem', 'type', 'data', 'magnitude',# 'mises', 'tresca', 'press', 'inv3', 'maxPrincipal',# 'midPrincipal', 'minPrincipal', 'maxInPlanePrincipal',# 'minInPlanePrincipal', 'outOfPlanePrincipal'] # Using regions to read a subset of field output datacenter = odb.rootAssembly.instances['PART-1-1'].nodeSets['PUNCH']# get displacement of subset# The arguments to getSubset are a region, an element type, a position, or section point datacenterDisplacement = displacement.getSubset(region=center)centerValues = centerDisplacement.values for v in centerValues: print v.nodeLabel, v.data ## another exampletopCenter = \ odb.rootAssembly.instances['PART-1-1'].elementSets['CENT']stressField = odb.steps['Step-2'].frames[3].fieldOutputs['S'] # The following variable represents the stress at# integration points for CAX4 elements from the# element set "CENT." field = stressField.getSubset(region=topCenter, position=INTEGRATION_POINT, elementType='CAX4')# position argument INTEGRATION_POINT NODAL ELEMENT_NODEL CENTROIDfieldValues2 = field.valuesfor v in fieldValues2: print 'Element label = ', v.elementLabel, if v.integrationPoint: print 'Integration Point = ', v.integrationPoint else: print# For each tensor component. for component in v.data: # Print using a format. The comma at the end of the # print statement suppresses the carriage return. print 'S = %10.5f' % component, # After each tuple has printed, print a carriage return.# print ## write file and reading history outputdatafrom odbAccess import *step2 = odb.steps['Step-2']region = step2.historyRegions['Node PART-1-1.1000']u2Data = region.historyOutputs['U2'].datadispFile = open('disp.dat', 'w')for time, u2Disp in u2Data: dispFile.write('%10.4E %10.4E\n' % (time, u2Disp))else: dispFile.close() 目的:用python将米勒 指数 从odb文件中提取出来。
from abaqusConstants import*from odbAccess import*import osfrom textRepr import*import numpy as npmyodb = openOdb(path=r'C:\AbaqusWorkfile\FIB\try-model-210601-1.odb') myFrames = myodb.steps["Step-1"].frames # ff = (["SDV52"]["SDV65"]["SDV78"]# ["SDV91"]["SDV104"]["SDV117"])sdv52field = myFrames[-1].fieldOutputs["SDV52"] elementSets = odb.rootAssembly.instances['PART-1-1'].elementSetsbb = elementSets.keys() CRY = []for a in bb: cc = odb.rootAssembly.instances['PART-1-1'].elementSets[a] CRY.append(cc) field = []for a in CRY: dd = sdv52field.getSubset(region=a, position=INTEGRATION_POINT, elementType='C3D8R') field.append(dd) average = [] for a in field: fieldValues = a.values temp1 = [] for v in fieldValues: temp1 = [] for value in fieldValues: temp1.append(value.data) ee = np.mean(temp1) average.append(ee) average = np.array(average)np.savetxt(r"C:\AbaqusWorkfile\test_pythonOdb\miller.txt", average, fmt="% .10f")
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删