Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python automatic displacement extraction

Status
Not open for further replies.

Cor46

Mechanical
Feb 6, 2024
3
Hi,
I'm currently trying to set up a Python code able to extract automatically node displacement from an ODB file. Inside the ODB there is no path manually predefined because I want to specify the path in the Pyton code (so in Python I want to write the coordinates of the nodes for which I want the displacement extraction). I was wondering if it's feasible, because I wrote a caode that can open the correct .OBD file but then in Abaqus an error "Incorrect data for path" appears. I am 100% sure that the node coordinates are correct so it's not the problem.

Thanks in advice.
 
Replies continue below

Recommended for you

Thanks. I want to clarify a bit my problem.
I have already wrote this Python code in Pycharm:
"
from abaqus import *
from abaqusConstants import *
import numpy as np

def extract_deformation_along_path(odb_path, node_coordinates):
# open the ODB file
odb = session.openOdb(odb_path)

# Get the model instance
model = odb.rootAssembly.instances.values()[0]

# Create a path
path = session.Path(name='Path-1', type=NODE_LIST, expression=((model.name, node_coordinates),))

# Get the result along the path
field_output = odb.steps['Step-1'].frames[-1].fieldOutputs['U']

# Extract deformation values
deformations = []
for nodeId in path.nodes:
node = model.nodes[nodeId]
disp = field_output.getSubset(region=node).values[0].data
deformations.append(disp)

return deformations

# Example
if __name__ == '__main__':
# ODB directory
odb_path = r'directory'

# Node of interest coordinates
node_coordinates = [(5, 0, 50), (20, 0, 50)]

deformations = extract_deformation_along_path(odb_path, node_coordinates)
print("Deformations along the path:", deformations)
"
When I try to run this code it's able to open the correct ODB file. The problem is that when the ODb file opens, an error message window appears saying "Incorrect data for path". I am 100% sure that the node coordinates are correct, so I don't get why this error message.
Thanks in advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor