Implementing UMAT using shared library

Hi

I am trying to use a UMAT (attached) in calculix as a shared library.
I followed the procedure given in calculix documentation but the solution doesn’t proceed (please check bottom of terminal screenshot).

Here’s what I did:

  1. Assigned UMAT as the name of the subroutine inside the file UJ2PLASEMP.f
  2. Compiled UJ2PLASEMP.f using: abaqus make library=UJ2PLASEMP.f
  3. This resulted in 2 files: UJ2PLASEMP-std.o and libstandardU.so
  4. I renamed the latter file to libUJ2PLASEMP.so
  5. In the input file, I set the material name to: @UJ2PLASEMP_UMAT
  6. Submitted the job on the terminal

Can you please help me with this?
All files are uploaded to this folder

Thanks
Bhanu

Terminal screenshot:

1 Like

It would be best if you compiled everything using the same compilers. I’m not sure if Abaqus does something different internally to create the libs. I haven’t tried it this way, to be honest, but it appears to be problematic just by thinking about it.

Thank you for your reply.
I just checked the compiler in the environment file of ABAQUS. It is “gfortran”.
And while compiling CalculiX, in the Makefile, the FC variable (Fortran compiler) was also set to “gfortran”.

I have uploaded two new files to the same folder:
File from abaqus directory mentioning Fortran compiler: lin86_64.env
CalculiX Makefile: Makefile

Based on these, can you please tell me if I need to modify the ABAQUS env file?

But otherwise, is the sequence of steps I have taken alright?
I mean could it be a syntax issue because of inconsistent names for the function, library, and material, which prevents CalculiX from reading the UMAT.

Thanks
Bhanu

Why don’t you use the umat thru the Abaqus umats and recompile ccx? It is a much cleaner approach and you will know exactly what is the problem because it won’t compile

In your Makefile I don’t see the compiler option
-DCALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT
which seems to be needed to link UMAT related dynamic linked libraries to ccx. Try to compile the entire code with this option. Thank you!

2 Likes

It would be also a good idea to also add the option
-DCALCULIX_EXTERNAL_BEHAVIOUR_DEBUG. That gives extra information about what is going on.
See the source code file external.c in the ccx source distribution.

Neither the Makefile nor the lnx86_64.env are usable as-is.

The Makefile is for building CalculiX itself.
The Python script lnx86_64.env defines some useful commands but doesn’t execute them.

You should be able to build a shared library from a single file like this:

gfortran -shared -O2 -fPIC -o libUJ2PLASEMP.so UJ2PLASEMP.f 

Note that this currently fails because a needed include file is not in your folder:

> gfortran -shared -O2 UJ2PLASEMP.f -o libUJ2PLASEMP.so -fPIC
UJ2PLASEMP.f:18:0:

   18 |       INCLUDE 'ABA_PARAM.INC'
      | 
Fatal Error: Cannot open included file 'ABA_PARAM.INC'
compilation terminated.

Note: The file aba_param.inc can be found here; don’t forget to rename to uppercase.

With ABA_PARAM.INC available, the compilation works, and the shared library contains the external symbol for umat (checked on a FreeBSD UNIX machine):

nm ./libUJ2PLASEMP.so | grep ' T '
0000000000001884 T _fini
00000000000006d0 T _init
0000000000000860 T umat_

If I understand the CalculiX manual correctly, the material name for the user material should indeed be @UJ2PLASEMP_UMAT.

Note that you should rebuild CalculiX with the option to load shared libraries, as @johanngil explained.

1 Like