×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Homogenization for stress and strain in abaqus python script

Homogenization for stress and strain in abaqus python script

Homogenization for stress and strain in abaqus python script

(OP)
Dear All,
I have a simple 2D model which I would like to get stress and strain components in each frame of each step, and then calculate the average in each frame by dividing over all elements.I have write such a code:

def write_res():
global a
a = np.array([])
odb = openOdb(abq_job+'.odb', readOnly=True)
ubc = np.zeros(2)
elementset=odb.rootAssembly.instances['PART-1-1'].elements
n_elements=len(elementset)
s11 = np.zeros(n_elements)
s22 = np.zeros(n_elements)
s33 = np.zeros(n_elements)
s12 = np.zeros(n_elements)

Le11 = np.zeros(n_elements)
Le22 = np.zeros(n_elements)
Le33 = np.zeros(n_elements)
Le12 = np.zeros(n_elements)

ep11 = np.zeros(n_elements)
ep22 = np.zeros(n_elements)
ep33 = np.zeros(n_elements)
ep12 = np.zeros(n_elements)
with open(path_r+f_name,'a') as f:
for step in odb.steps.values(): # iterate through all the steps in the ODB
for frame in step.frames: # iterate through all the frames in the step
field_stress = frame.fieldOutputs['S']
field_strain = frame.fieldOutputs['LE']
field_plastic_strain =frame.fieldOutputs['PE']
# Get the subset of the stress and strain field data for the element set
subfield_stress = field_stress.getSubset(region=odb.rootAssembly.instances['PART-1-1'])
subfield_strain = field_strain.getSubset(region=odb.rootAssembly.instances['PART-1-1'])
subfield_plastic_strain=field_plastic_strain.getSubset(region=odb.rootAssembly.instances['PART-1-1'])
ubc[0] = xload
ubc[1] = yload
# Loop over all stress and strain field data in the subset
for i, value in enumerate(subfield_stress.values):
s11[i] = value.data[0]
s22[i] = value.data[1]
s33[i] = value.data[2]
s12[i] = value.data[3]

Le11[i] = subfield_strain.values[i].data[0]
Le22[i] = subfield_strain.values[i].data[1]
Le33[i] = subfield_strain.values[i].data[2]
Le12[i] = subfield_strain.values[i].data[3]

ep11[i] = subfield_plastic_strain.values[i].data[0]
ep22[i] = subfield_plastic_strain.values[i].data[1]
ep33[i] = subfield_plastic_strain.values[i].data[2]
ep12[i] = subfield_plastic_strain.values[i].data[3]

# Calculate the average stress components for each element for the current frame
s11_avg = sum(s11)/n_elements
s22_avg = sum(s22)/n_elements
s33_avg = sum(s33)/n_elements
s12_avg = sum(s12)/n_elements
Le11_avg = sum(Le11)/n_elements
Le22_avg = sum(Le22)/n_elements
Le33_avg = sum(Le33)/n_elements
Le12_avg = sum(Le12)/n_elements
ep11_avg = sum(ep11)/n_elements
ep22_avg= sum(ep22)/n_elements
ep33_avg= sum(ep33)/n_elements
ep12_avg= sum(ep12)/n_elements

# Append the results to the row variable
row = [s11_avg, s22_avg, s33_avg, s12_avg, Le11_avg, Le22_avg, Le33_avg, Le12_avg, ep11_avg, ep22_avg, ep33_avg, ep12_avg,ubc[0],ubc[1]]
a=np.append(a,row)
a.tofile(f, sep=';', format='%12.5e')
f.write('\n')

return None
Bu when I open the CSV, instead of having for each row average of each component, the values decrease sequentially in each row. Can you please tell me where I have a code mistake? or whether it is true or not.
Thank!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close