CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Structural Mechanics (https://www.cfd-online.com/Forums/structural-mechanics/)
-   -   Abaqus python scripting (https://www.cfd-online.com/Forums/structural-mechanics/249215-abaqus-python-scripting.html)

inouzil April 26, 2023 19:10

Abaqus python scripting
 
Hi,

I want to extract history output of interaction contact force using a python script in abaqus. I was trying to use an example code as below:

[I]"import odbAccess
import csv

odb_path = 'Job1.odb'
set_name = 'ASSEMBLY_S_SET-44_CNS_/ASSEMBLY_M_SURF-10' # Name of the set containing the contact region
output_name = 'CFT1' # Name of the contact force output variable

# Open the ODB file
odb = odbAccess.openOdb(odb_path)

# Get the output object
step = odb.steps.values()[0]
output = step.historyRegions[set_name].historyOutputs[output_name]

# Get the data for the output variable
data = output.data

# Export the data to a CSV file
with open('contact_force.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Time', 'Contact Force'])
for i in range(len(data)):
writer.writerow([data[i][0], data[1]])

# Close the ODB file
odb.close()"



The set name for the interaction I obtained from abaqus GUI. It appears I am making some mistake. I get 'Key word error for the setname'.

Kindly assist.

Ibrahim


All times are GMT -4. The time now is 05:53.