pythonabaqusabaqus-odb

Python scripting in Abaqus extracting output from the output data base


I'm writing a code in python that extracts the contact stress (CPRESS) in Abaqus 2019 of all the nodes on a given surface. I managed to write the code so that the Node-Label as well as the coordinates of the nodes from the surface get extracted and are written to a csv file. However, I'm not having any success in accessing the CPRESS-Value for the nodes that I'm interested in.

I read in the user's manual about where to find the values of CPRESS, but I don't see the reason, on why the code isn't extracting any values for the given nodes. There is my code:

import csv
from odbAccess import *

odb_Pfad = '123.odb' #not important
odb = openOdb(odb_Pfad)

instance_name = 'PRUEFKOERPER_4-1'
instance = odb.rootAssembly.instances[instance_name]

start_node_id = 0
end_node_id = 5000

partlabel = []
partxcord = []
partycord = []
partzcord = []

for node in instance.nodes:
    if start_node_id <= node.label <= end_node_id:
        partlabel.append(node.label)
        partxcord.append(node.coordinates[0])
        partycord.append(node.coordinates[1])
        partzcord.append(node.coordinates[2])

step_name = 'Belastung'
step = odb.steps[step_name]
last_frame = step.frames[-1]  #Last frame
cpress_dict = {value.nodeLabel: value.magnitude for value in last_frame.fieldOutputs['CPRESS'].values}

#write a csv file with the node ladel and the coordinates of the corresponding node, as  well as cpress-Value
csv_datei = '123.csv' #not important
with open(csv_datei, 'wb') as file:
    writer = csv.writer(file)
    writer.writerow(['Knoten ID', 'x', 'y', 'z', 'CPRESS'])
    for i in range(len(partlabel)):
        cpress_value = cpress_dict.get(partlabel[i], 'N/A')
        writer.writerow([partlabel[i], partxcord[i], partycord[i], partzcord[i],     cpress_value])

odb.close()

Solution

  • Accessing the Contact related output is bit different than other field outputs, as contact related output is written specific to the contact pairs.

    To access the contact related outputs for contact pair, you need the names of Slave and master node/surface names.
    You can find the exact name for the contact pair from Abaqus viewer as "Tool" -> "Field Output" -> "Create From Fields" --> Here, under the 'Name' column, you can find the exact names for all the available contact pairs. Further, you can output the data to text file as below.

    import numpy
    cdata = odb.steps['Belastung'].frames[1].fieldOutputs['CPRESS   BOLTHEAD-CARR/CARR-BOLTHEAD']
    
    # Get the contact surface names from field output name
    fieldOutputname = cdata.name
    surface_names = fieldOutputname.split('   ')[1].split('/')
    fout = open('cpress.dat', 'w')
    
    for i, data in enumerate(cdata.bulkDataBlocks):
        fout.write('%s\n' % surface_names[i])
        numpy.savetxt(fout, numpy.column_stack((data.nodeLabels, data.data)), fmt='%10d  
     %.8E')
    
    fout.close()