1

I'm trying to get the element density from the abaqus output database. I know you can request a field output for the volume using 'EVOL', is something similar possible for the density?

I'm afraid it's not because of this: Getting element mass in Abaqus postprocessor

What would be the most efficient way to get the density? Look for every element in which section set it is?

ThaNoob
  • 520
  • 7
  • 23
  • related https://stackoverflow.com/q/49250071/1004168 – agentp Mar 18 '18 at 19:03
  • Thanks, I wrote the same solution as you mention in the linked topic. However it doesn't seem to work. I have the same problem as the guy commenting on your answer. The info in the sectionCategory attribute is just incorrect. It sais that all elements belong to the same material. I guess I'll have to scan the inp file but I'm afraid this will take very long. – ThaNoob Mar 19 '18 at 10:15
  • have you checked in the display group manager to see the material assignments are correct? (Maybe there is a way to script display group selection to extract the info..) – agentp Mar 19 '18 at 11:29
  • I immediately thought the same. So I checked it, but it displays it correctly. I'll to extract the info that way. – ThaNoob Mar 19 '18 at 14:21
  • for sure there is some bug here. See my update to the other question. – agentp Mar 19 '18 at 14:28
  • Okay I tried it doesn't work either. Querrying the element just produces a lot of comments in the script (it's not implemented in scripting). Changing the visualisation produces the following code: session.viewports['Viewport: 1'].enableMultipleColors() session.viewports['Viewport: 1'].setColor(initialColor='#BDBDBD') cmap=session.viewports['Viewport: 1'].colorMappings['Material'] session.viewports['Viewport: 1'].setColor(colorMapping=cmap) session.viewports['Viewport: 1'].disableMultipleColors() Which is also quite useless. – ThaNoob Mar 19 '18 at 14:45
  • The material information is more fully contained in the `.inp` or `.cae` file; specifically you should be looking at `sectionAssignments`. – dROOOze Mar 19 '18 at 15:38
  • @agentp yes I agree, this must be a bug. Right now I'm going back to the .inp file to find the density. I gave up on getting it from the .odb file. – ThaNoob Mar 19 '18 at 16:30

2 Answers2

1

Found a solution, I don't know if it's the fastest but it works:

odb_file_path=r'your_path\file.odb'
odb = session.openOdb(name=odb_file_path)

instance = odb.rootAssembly.instances['MY_PART']
material_name = instance.elements[0].sectionCategory.name[8:-2]
density=odb.materials[material_name].density.table[0][0])

note: the 'name' attribute will give you a string like, 'solid MATERIALNAME'. So I just cut out the part of the string that gave me the real material name. So it's the sectionCategory attribute of an OdbElementObject that is the answer.

EDIT: This doesn't seem to work after all, it turns out that it gives all elements the same material name, being the name of the first material.

ThaNoob
  • 520
  • 7
  • 23
0

The properties are associated something like this:

  • sectionAssignment connects section to set
  • set is the container for element
  • section connects sectionAssignment to material
  • instance is connected to part (could be from a part from another model)
  • part is connected to model
  • model is connected to section

Use the .inp or .cae file if you can. The following gets it from an opened cae file. To thoroughly get elements from materials, you would do something like the following, assuming you're starting your search in rootAssembly.instances:

  1. Find the parts which the instances were created from.
  2. Find the models which contain these parts.
  3. Look for all sections with material_name in these parts, and store all the sectionNames associated with this section
  4. Look for all sectionAssignments which references these sectionNames
  5. Under each of these sectionAssignments, there is an associated region object which has the name (as a string) of an elementSet and the name of a part. Get all the elements from this elementSet in this part.

Cleanup:

  1. Use the Python set object to remove any multiple references to the same element.
  2. Multiply the number of elements in this set by the number of identical part instances that refer to this material in rootAssembly.

E.g., for some cae model variable called model:

model_part_repeats = {}
model_part_elemLabels = {}

for instance in model.rootAssembly.instances.values():
    p = instance.part.name
    m = instance.part.modelName
    try:
        model_part_repeats[(m, p)] += 1
        continue
    except KeyError:
        model_part_repeats[(m, p)] = 1

    # Get all sections in model
    sectionNames = []
    for s in mdb.models[m].sections.values():
        if s.material == material_name: # material_name is already known

            # This is a valid section - search for section assignments
            # in part for this section, and then the associated set
            sectionNames.append(s.name)

    if sectionNames:
        labels = []
        for sa in mdb.models[m].parts[p].sectionAssignments:
            if sa.sectionName in sectionNames:
                eset = sa.region[0]
                labels = labels + [e.label for e in mdb.models[m].parts[p].sets[eset].elements]

        labels = list(set(labels))
        model_part_elemLabels[(m,p)] = labels

    else:
        model_part_elemLabels[(m,p)] = []

num_elements_with_material = sum([model_part_repeats[k]*len(model_part_elemLabels[k]) for k in model_part_repeats])

Finally, grab the material density associated with material_name then multiply it by num_elements_with_material.

Of course, this method will be extremely slow for larger models, and it is more advisable to use string techniques on the .inp file for faster performance.

dROOOze
  • 1,727
  • 1
  • 9
  • 17
  • 1
    Wow, this looks rather extremely complex. Really weird that there's no simpler method for something like this. In the mean time I already got the densities from the input file which takes +-8s, not super fast, but fast enough. I'm not going to test it out, but it seems a legit work around. Although I would recommend future readers to use the inp file as long as the sectionCategory attribute doesn't work. – ThaNoob Mar 20 '18 at 10:08
  • @ThaNoob I fully agree, I personally work with thousands of models and modify them using string functions in the .inp format only. CAE is extremely slow to achieve the equivalent goal. However, for people who like visualisation and may not be familiar with scripting in general, it is a legit copy + paste code that works (I've tested it already). The I/O overhead and the requirement for looping through the Abaqus data structures is just unbelievable for larger scale projects. – dROOOze Mar 20 '18 at 10:21