How to know a material name of a PID in ABAQUS odb file(not MDB file) using Python scripting?

235 views Asked by At

Here I need to know how to find the name of the material for each PID. I'm a beginner so every answer can help me a lot.


    odb= odbAccess.openOdb(path=(path+file), readOnly=True)
    tag="ERT"
    step = []
    step.append(odb.steps[odb.steps.keys()[0]])
    
    frame = []
    frame.append(step[0].frames[-1])
    
    
    assembly = []
    assembly.append(odb.rootAssembly)
    
    instance = []
    instance.append(assembly[0].instances[instance_n])
        
    PIDs = []
    for key in instance[0].elementSets.keys():
      if tag in key:
        PIDs.append(key)
        
        
    for PID in PIDs:   
        print(material_name[PID])  # here i need to know name of material for this PID  
1

There are 1 answers

0
Nic On

The information about the material or rather the section is stored within the section object. If you know your sections (you did not mention if you have actual access to the model). If not then you also have to obtain the materials information and the section information from the odb.

What you CAN do within your set is this

odb = odbAccess.openOdb(path=(path+file), readOnly=True)
my_elset = odb.rootAssembly.instances[0].elementSets[setname]
element_from_set = my_elset.elements[0] # list with mesh element object, e.g. first
sec_category = element_from_set[0].sectionCatergory

section category contains several informations about the underlying section. In case you do know your sections and the corresponding material (maybe stored in a file after creating the model): good.

Id not, you have to further obtain section information e.g. by:

odb.sections[sectionname]

which amongst other contains the material for each section in the odb.

In any case you I think you would make your live easier if you obtained that information directly within the mdb if possible.

The above examples are only rudimentary, you might need to loop over them in case you don't have explicit setnames but they can also be obtained.

EDIT: As a general recommendation: You can try all of this in the command line either by opening abaqus command promt and typing

abaqus python

and you get abaqus python shell or, with open abaqus you can use the shell at the bottom (>>> on yellow ground) or the PDE.