User login

Navigation

You are here

How to extract plastic strain in Abaqus

ntuecd's picture

Hallo,

i am looking for a python code with which i can extract all the plastic strain components for an element, i.e. PE11, PE22, PE33, PE12, PE13,  and PE23.  To extract the prinicpal strains i have used the follwoing code:

 

def evelaution(frame):

integral_eeeq, vol = 0, 0

ee = frame.fieldOutputs['PE']

eep1 = ee.getScalarField(MIN_PRINCIPAL)

eep2 = ee.getScalarField(MID_PRINCIPAL)

eep3 = ee.getScalarField(MAX_PRINCIPAL)

 

Now i want to modify it in such a way that i can extract all the six components of the PE. It will be really helpful  if someone knows how to do it.

 

Thanking You

 

<p>ntuecd,</p>
<p>I think your issue is that you access tensor values as an array. I have attached a little python script that prints all the plastic strain tensors in the last frame of the last step for each element set in each instance that it finds in the .odb. You also might want to be more explicit as to what values you are actually requesting. Do you want only one plastic strain tensor for each element even if the element has multiple integration points? Check the manual for options concerning how to treat each element. You might need to change my example to fit your needs (like the element type to be processed).</p>
<p>I hope this answers your question. Good luck!</p>
<p>&nbsp;</p>
<p>from odbAccess import *<br /># invoke:<br /># $ abaqus cae noGUI=this_file.py &amp;&amp; cat Job-1.pyout<br /><br />base_name = "Job-1"<br /><br /># Open the ODB and logfile.<br />odb = openOdb(path=base_name + ".odb")<br />log = open(base_name + ".pyout", 'w')<br /><br /># Look at all elements in the last frame of the last step.<br />last_step = odb.steps[odb.steps.keys()[-1]]<br />last_frame = last_step.frames[-1]<br /><br /># load the fields that we are interested in.<br />field = last_frame.fieldOutputs["PE"]<br /><br /># loop through instances<br />for instance_name, instance in odb.rootAssembly.instances.items():<br />&nbsp;&nbsp;&nbsp; log.write("\n ===== instance " + instance_name)<br />&nbsp;&nbsp;&nbsp; for elementSet_name, elementSet in instance.elementSets.items():<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log.write("\n&nbsp; elementSet " + elementSet_name)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subfield = field.getSubset(region=elementSet, position=INTEGRATION_POINT,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elementType="C3D8R")<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for v in subfield.values:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ep11, ep22, ep33, ep12, ep13, ep23 = v.data<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log.write("\n" + repr(v.data))<br /><br />log.close()</p>

I don't know why my previous post has all the html markup, but here is the python script again:

from odbAccess import *
# invoke:
# $ abaqus cae noGUI=this_file.py && cat Job-1.pyout

base_name = "Job-1"

# Open the ODB and logfile.
odb = openOdb(path=base_name + ".odb")
log = open(base_name + ".pyout", 'w')

# Look at all elements in the last frame of the last step.
last_step = odb.steps[odb.steps.keys()[-1]]
last_frame = last_step.frames[-1]

# load the fields that we are interested in.
field = last_frame.fieldOutputs["PE"]

# loop through instances
for instance_name, instance in odb.rootAssembly.instances.items():
    log.write("\n ===== instance " + instance_name)
    for elementSet_name, elementSet in instance.elementSets.items():
        log.write("\n  elementSet " + elementSet_name)
        subfield = field.getSubset(region=elementSet, position=INTEGRATION_POINT,
                                                      elementType="C3D8R")
        for v in subfield.values:
            ep11, ep22, ep33, ep12, ep13, ep23 = v.data
            log.write("\n" + repr(v.data))

log.close()

ntuecd's picture

Hallo mswan,

 

your python code had worked and now i can read all the values of plastic strains for an element. I am really very thankful to you. 

Now i want to use the values of pe11, pe22,  pe33, pe12, pe13, and pe23 in the following formula:

PEEQ = Σ \sqrt(pe_ij(t_k)- PE_ij(t_k-1)), where k = 1,2,........n

pe_ij(t_k) is the component of plastic strain at current time or better we can call it current value of the plastic strain component . PE_ij is the initial component of plastic strain or better call component of plastic strain at time k-1. 

 

I am just using this formula to show that the value of PEEQ computed by Abaqus can be computed with the help of above mentioned formula. Ofcourse, above mentioned formula is an approximate value of intergal form of the equivalent plastic strain. I am trying this long but not getting it as i m new to Python. I need this for my Bachelor thesis, which i need to submit on Tuesday. if you have any idea or python code for it then it ll be a great help for me. 

ntuecd,

I have made a couple changes to the script that I posted before and have placed it below. I have not coded up the equation you requested, but I have shown you how to access and store all of the relevant data that you will need for your project.

Good luck!

from odbAccess import *
# invoke:
# $ abaqus cae noGUI=this_file.py && cat Job-1.pyout

# This script creates a single dictionary containing all the plastic
# strain data from a .odb file. The keys to the dictionary are the
# element numbers (as an integer) and the value associated with that
# key is a list of the tensor values for each frame in the simulation.

base_name = "Job-1"

# Open the ODB and logfile.
odb = openOdb(path=base_name + ".odb")
log = open(base_name + ".pyout", 'w')

# Find all the frames.
frame_list = []
for step_name in odb.steps.keys():
    for frame in odb.steps[step_name].frames:
        frame_list.append(frame)

# loop through instances
for instance_name, instance in odb.rootAssembly.instances.items():

    # Find all the elements in this instance
    element_db = {}
    for element in instance.elements:
        element_db[element.label] = []

    # loop through each frame.
    for frame in frame_list:
        # load the fields that we are interested in.
        field = frame.fieldOutputs["PE"]

        # Loop through all the instance elements.
        for elementSet_name, elementSet in instance.elementSets.items():
            subfield = field.getSubset(region=elementSet, position=INTEGRATION_POINT,
                                                          elementType="C3D8R")
            for v in subfield.values:
                # v.data = [ep11, ep22, ep33, ep12, ep13, ep23]
                element_db[v.elementLabel].append(list(v.data))

    # Write out the collected information.
    log.write("\n ===== instance " + instance_name)
    for element in sorted(element_db.keys()):
        log.write("\nelement: {0:d}".format(element))
        for val in element_db[element]:
            log.write("\n  {0}".format(val))

log.close()

Subscribe to Comments for "How to extract plastic strain in Abaqus"

Recent comments

More comments

Syndicate

Subscribe to Syndicate