General Mechanical

General Mechanical

Topics relate to Mechanical Enterprise, Motion, Additive Print and more

Workbench UPF/Usermat problems with the linking process

    • janot.lubritz

      Hey guys,


      I still have problems with the linking of my USERMAT with my workbench file so I'll try it with a new separate post. Hopefully anybody can help me.

      Firstly I am not entirely new to USERMAT and the linking process with APDL but for my work I need to link the same USERMAT with a Workbench file. I am using Ansys 2022R1 and Windows 10. All intel compilers and visual studio packages are installed and the compilation is working without issues for APDL.

      Within Workbench I added the "\upf, usermat.f" APDL command in the solver tree and set two system variables (ANS_USE_UPF = TRUE and ANS_USER_PATH = path to compiled dlls files). All files have been compiled beforhands and reside in the win64 folder of the ansys folder. Whenever I try to run the workbench file the solver prompts the following error:

      ”An error occured while starting the solver module.”

      When I delete the upf commands everything solves without issues (and without the UPF as expected). I also tried to include the compiled files in the solver files directory (right mouse on the solver tree) but nothing works. I think I am missing a step at some point.

      In the solver files directory after the failed solving process a link_error file and a link file appears so it looks like the linking did not work. Is there a way to check whether everything is linked correctly and compiling/running the usermat when I run/solve the workbench file? Maybe somebody is familiar with using USERMAT files within the workbench environment.

      In addition there is another question. How do I assign material properties when using an UPF in the workbench environment. With APDL you assign them with the TB command and there is nothing assigned beforehand. When using workbench there is always a basic material (Steel or so) assigned beforehand and I cannot delete it. Do I have to assign the material properties for my usermat via an APDL command in the workbench tree and do I have to delete the steel properties somehow? I tried the following APDL command but since the whole process does not work I do not know whether that's correct.

      "TB,DELE,ALL" and afterwards defining the new material "TB,USER,....."


      Would be great if somebody could give me a hint.

      Thanks in advance!

    • Aleksandr Zhadkovskii




      Can you include the insides of the link_error file? I’ve come across the same issue before, and in my experience, possible solutions are listed below.

      1) ansys created a restart control file and locked it (file that cannot be deleted can be seen in the solver files directory in this case), and in this case something like “link cannot be recognised” is printed in link. However, to see this error, you first need to have some successful runs (pass the building mathematical model step of the solution).

      2) Which version of Intel compiler are you using? Is it one in oneAPI? I’m not entirely sure rn how user subroutines are done in APDL, but when using /UPF in WB, I edited ansupf.bat file while using oneAPI. It was written for parallel studio paths, I believe, and currently the paths there are wrong. Possible solution then is to add command to ansupf.bat file (…\*ansys version*\ansys\custom\user\winx64\ANSUPF.bat) calling setvars.bat file (…\Intel\oneAPI\setvars.bat) from oneAPI directory. Something like “call “path-to-intel-directory\Intel\oneAPI\setvars.bat)””.


      About material properties: I believe ones from the engineering data are not used in usermat unless you pass them explicitly. Following the example provided by ANSYS for usermat, they are defined as “young” and “posn” inside and used for calculations. To pass them from the workbench you can add a command snippet to the body of interest (right-click on any body inside in Geometry and add command snippet) and use TB, USER. Inside the command snippet, I used something like this in my case:

      *GET,YOUNG,EX,matid,TEMP,20       ! young modulus from material properties
      *GET,POISN,NUXY,matid,TEMP,20     ! poisson’s ratio from material properties

      d_t = 8.0                         ! linear temperature function coefficient
      b_t = 0.081                       ! linear temperature function coefficient
      alpha = -0.372                    ! coeff for Young modulus calculation
      gamma = 0.722                     ! coeff for Young modulus calculation

      TB,USER,matid,,6                  ! passing data to script
      ! 1 – young modulus, 2 – poisson’s ratio, 3-4 – linear temperature function coefficient

      and then you can access passed values using prop() as in the ANSYS usermat example.


      • janot.lubritz

        Thanks for the quick response! 

        What you're saying about the material properties is what I thought but I did not find any examples with workbench in combination with a usermat so I was not sure. This is basically how I do it right now.

        To number 1)  this is what's included in the link_error file. Actually both files (link and error_link) look the same.

        2) yes I am using the oneAPI 2022 since we couldn't get a hold of the old versions and everything worked up until now. 

        I tried to find the location in the ansupf.bat file where I have to include what you proposed but I'm not sure where it belongs. Could you give me a hint?


        Besides that as you are familiar with WB and UPF: right now I compile everything in the ansys...\winx64 folder and have my ans_user_path variable set to the same folder. Is this the correct way or do I have to include the usermat.f in the solver files directory. I read somewhere that usually it should be put there and the compilation process starts when solving the model when all variables are set correctly.


        Thank you again for the response!

    • Aleksandr Zhadkovskii

      ANSUPF.bat should be located in your ansys installation directory; the full path should include something like “ANSYS Inc\v221\ansys\custom\user\winx64”. I believe directory ‘custom’ may be missing in case you unchecked something in the installation process; however, I’m not sure exactly what and how it can be fixed other than reinstalling ASNSYS.

      I do indeed put all my .F files in the solver files directory since it seems that solver first checks for .F files in solver directory and then picks one from standart ones in customize directory of ANSYS installation. I believe that the only environment variable for /UPS method should be “ANS_USE_UPF” as ansupf.bat sets the solver files directory to the ANS_USER_PATH for the time of solving.

      EDIT: forgot about one more thing. Quoting ANSYS help:

      ”A script named findUPF.bat is used to detect the /UPF command. You must include the path to this script in your system PATH variable. This script is typically located in Program Files\Ansys Inc\Vxxx\ansys\bin\< platform where <platform > is a directory that uniquely identifies the hardware platform version: “Winx64” for 64-bit Windows.”

      EDIT 2: Misread your sentence about the ansupf file. You can put it almost anywhere before “if “%PLATFORM_DIR%”==”winx64″ (” string. I personally put it between strings “call “%~dp0/set_revn.bat”” and
      ”set “ROOT_DIR=!AWP_ROOT%revn%!”” at the start of the file. 

      EDIT 3: also check if command ifort in your cmd prints info about your installed fortran compiler (“Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.10.0 Build 20230609_000000” or something like this). If it is not the case, add …\Intel\oneAPI\compiler\latest\windows\bin\intel64 to your PATH system environment variable.



      • janot.lubritz

        Okay so I think I got it!

        I deleted the ANS_USER_PATH variable and added the command in the ansupf.bat file as well as the path variable for the findUPF.bat file. Thanks so far! The ifort command does work in the intel oneAPI command prompt but not in the general windows cmd. Should be correct I guess.

        Since I changed quite a lot I'm not sure what the problem was but thanks so much! Somehow I at least missed the part in the help with the path variable. I always thought they mean the ANS_USER_PATH variable when saying PATH...I just found out that there is a general PATH variable.

        I'll check everything for the results (if everything worked correctly with my usermat) but it looks good!


        • Aleksandr Zhadkovskii

          Glad it helped! I was struggling myself with UPF features some time before and was pleased to help.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.