Home > Enterprise >  ABAQUS-python - writing ODB results to file
ABAQUS-python - writing ODB results to file

Time:11-20

I have the following script to open ABAQUS ODB file and get displacements and coordinates of a specific node set. I can get these to print on screen but need help to write them to a file (.xlsx, .cvs, .dat or .txt) for postprocess. I'm new to scripting with abaqus so any help would be great appreciated. Code is currently as follows:

from odbAccess import * from numpy import array

odb = openOdb(path='Test_3.odb')

lastFrame = odb.steps['Step-1'].frames[1]

displacement = lastFrame.fieldOutputs['U'] coords=lastFrame.fieldOutputs['COORD']

NodeSet_x = odb.rootAssembly.instances['CFRP_SKIN_TS-1'].
nodeSets['NODE_SET_X_AXIS']

NodeSet_y = odb.rootAssembly.instances['CFRP_SKIN_TS-1'].
nodeSets['NODE_SET_Y_AXIS']

centerDisplacement_x = displacement.getSubset(region=NodeSet_x) NodeCoord_x = coords.getSubset(region=NodeSet_x)

centerDisplacement_y = displacement.getSubset(region=NodeSet_y) NodeCoord_y = coords.getSubset(region=NodeSet_y)

for v in centerDisplacement_x.values: disp_out = v.nodeLabel, v.data[2]

print (disp_out)

for c in NodeCoord_x.values: coord_out = c.nodeLabel, c.data[0], c.data[1], c.data[2]

print (coord_out)

odb.close()

CodePudding user response:

I think, it just basic file read write thing. But anyways.

For more details on how to write the data in text file in python refer below links.
Click here to know about opening and closing files in python.
Click here to know about writing format in python.

Please follow below simple lines of code which works for any number of node sets.

node_sets = ['NODE_SET_X_AXIS','NODE_SET_Y_AXIS']
for node_set in node_sets:
   fileName = '%s.dat'%node_set
   fout = open(fileName,'w')
   nset = odb.rootAssembly.instances['CFRP_SKIN_TS-1'].nodeSets[node_set]
   field = odb.steps['Step-1'].frames[1].fieldOutputs['U'].getSubset(region=nset)
   for val in field.values:
       data = val.data
       node_label = val.nodeLabel
       node = odb.rootAssembly.instances['CFRP_SKIN_TS-1'].getNodeFromLabel(label=node_label)
       coords = node.coordinates
       fout.write('d.4E.4E.4E.4E.4E.4E\n'%tuple([node_label,] list(coords) list(data)))
   
   fout.close()

This code creates a separate text file for each node set.

  • Related