Marty
Marty

Reputation: 21

Find stresses at unique nodal on abaqus with python script

I explain my problem. I absolutely need to find the stresses at several unique nodal on my abaqus model using a python script. First I need to find the node experiencing the maximum principal stress and then I will also need to find the node that maximize a certain parameter which uses stresses and strains at the unique nodal.

I first tried the approach of max9111 I saw here https://stackoverflow.com/a/43175485/10960993 but I have a problem at the following line using the script:

for i in xrange(0,Values.shape[1]):
    unq_sum = np.bincount(unq_idx, weights=Values[:,i])
    ...

I have the following error message:

ValueError: The weights and list don't have the same length.

I have no idea what to do and I really need to find the id and coordinate of the unique nodal with maximum principal stress.

Thanks for the help!

Upvotes: 0

Views: 2325

Answers (1)

Marty
Marty

Reputation: 21

I finally found a solution to my problem which could help a lot of people (at least it helped my colleages). The solution proposed by max9111 to average stress values at the external node is the perfect and only solution if you want to know stresses at the surface through Abaqus scripting. However the code should be modified as follow to run, at least on Abaqus 6.16:

There is no change in the first part

Field = session.odbs['ModelName.odb'].steps['StepName'].frames[0].fieldOutputs['S']
Field = Field.getSubset(position = ELEMENT_NODAL)
Values=Field.bulkDataBlocks[0].data
NodeLabels=Field.bulkDataBlocks[0].nodeLabels

NodeLabels_unique, unq_idx = np.unique(NodeLabels, return_inverse=True)
Values_Averaged=np.zeros((NodeLabels_unique.size,Values.shape[1]))
unq_counts = np.bincount(unq_idx)

The change appears here in the way the Values variable is created due to the way Abaqus stores data with the bulkDataBlocks:

for i in xrange(0,Values.shape[1]):
    ValuesTemp = [item[i] for item in Values]
    unq_sum = np.bincount(unq_idx, weights=ValuesTemp)
    Values_Averaged[:,i] = unq_sum / unq_counts

    max_ind=np.unravel_index(np.argmax(Values_Averaged),Values_Averaged.shape)

print("The max stress is at NodeLabel "+str(NodeLabels_unique[max_ind[0]])+ " its value is "+ str(Values_Averaged[max_ind]) +" MPa.")

Upvotes: 1

Related Questions