pythonpluginsscriptingabaqusfinite-element-analysis

Is it possible to import material from material library in Abaqus CAE using scripts?


I'm working on Abaqus 6.14 plugin that would help me in my Engineer's Thesis, which I'm writing in Python. According to Abaqus scripting reference guide it is possible to import materials from Output Databases (*.odb files) by calling:

from abaqus import mdb
mdb.models[name].materialsFromOdb(filename)

However, as Abaqus allows user to export/import materials to/from relatively lightweight Material Libraries (*.lib files) and share them between models I would like to import the materials from these rather than from, often bulky, *.odb files.

Of course this can be done manually with ease, although I want to reduce amount of repetitive job with my plugin, as I need to run dozens of simulations on pretty similiar models but with varying materials and some other parameters. I am aware I could also provide necessary materials in template *.cae file too, although this could be quite inconvenient if I had to manually import new material(s) to dozens of models or I had to update existing material's properties.

What am I looking for is a workaround allowing to import materials from material libraries to Abaqus mdb models with Python scripts, but avoiding implementing custom *.lib files parser, if only such workaround exists.


Solution

  • The first thing you need to know is that Abaqus material library is just a pickled file. No special parser is needed to work with it. You can just use the standard Python libraries pickle or cPickle. Of course, you need to figure out the exact structure of the objects inside. This is not difficult as you'll see it's a just list of simple tuples.

    However, if you have an existing material library and you want to import a material in your Abaqus CAE database, there is an existing method to do it.

    There is a method in Abaqus which uses a material string from a material database and creates a material object from that. I can't remember the exact name, but if you import one material manually and look into abaqus.rpy file, you will see it inside.

    One tricky thing here is that in order to use this method, you need to have a material string from the material library. This can be done by reading the material database file. As already mentioned, this is in pickle format.

    As you know, Abaqus already has a way of reading data from the material library and importing it into a CAE model. They have a Python module which you could use, but it can only be used inside a GUI process, not the kernel one. If you want to spend some time, you can figure out which module does that. Inside Abaqus installation folder, you will find some .pyc files. If you use a Python decompiler, you can obtain source code for those modules. Look for those beginning with mat.