Unable to load user-defined function in fluent by using Pyfluent script.

Gopi Raju Velpula
Gopi Raju Velpula Member Posts: 18
First Answer 10 Comments Photogenic Name Dropper
**

i am trying to load user-defined function in Ansys fluent by using the below code but iam getting below error.

"Error at host: Error code: 126"

i tried to execute below code.

solver.tui.define.user_defined.compiled_functions("compile","gopi","yes","gopi.c","","")
solver.tui.define.user_defined.use_built_in_compiler("yes")
solver.tui.define.user_defined.compiled_functions("load","gopi")

also tried by using TUI commands.

solver.execute_tui('/define/user-defined/compiled-functions "compile" "udf" "yes" "gopi.c" "" "" ')
solver.execute_tui('/define/user-defined/use-built-in-compiler? "yes"')
solver.execute_tui('/define/user-defined/compiled-functions "load" "udf"')

and also i need to mention that when i try to do it in Fluent-GUI it is working fine but i need to automate the process.so need to do it by using the Py-fluent script.

please p[provide any solution for this.

Comments

  • Gopi Raju Velpula
    Gopi Raju Velpula Member Posts: 18
    First Answer 10 Comments Photogenic Name Dropper
    **

    @Rajesh Meena can you please provide any solution for this.

  • Gopi Raju Velpula
    Gopi Raju Velpula Member Posts: 18
    First Answer 10 Comments Photogenic Name Dropper
    **

    @Chris Harrold can you please provide any solution for this.

  • Sravan
    Sravan Member, Employee Posts: 3
    Ansys Employee First Comment First Anniversary Name Dropper
    ✭✭✭

    @Gopi Raju Velpula You need to use the use built in compiler command at first to enable it before actually compiling the UDF. The following commands works for me. Please check.

  • Gopi Raju Velpula
    Gopi Raju Velpula Member Posts: 18
    First Answer 10 Comments Photogenic Name Dropper
    **

    Thank you for your Response Sravan.

    but i tried that way also but still i am getting the same error. attaching the error message here please check once.

  • Sravan
    Sravan Member, Employee Posts: 3
    Ansys Employee First Comment First Anniversary Name Dropper
    ✭✭✭

    @Gopi Raju Velpula does this UDF compile fine in standalone Fluent? is fluent being launched from the same folder where the UDF is present?

  • Adam Anderson
    Adam Anderson Member, Employee Posts: 4
    Ansys Employee First Comment First Anniversary
    ✭✭✭

    I was able to load a precompiled UDF using:
    scheme_eval(f'(open-udf-library "{libname}" {stop_profile_updates})')

    It's better to work with pre-compiled UDFs if they can.

  • Gopi Raju Velpula
    Gopi Raju Velpula Member Posts: 18
    First Answer 10 Comments Photogenic Name Dropper
    **

    @Sravan yes it is loading in the standalone fluent and also fluent is launching same folder where the udf is present.
    if i upload in the standalone fluent it was giving some warning but still uploading and also working fine because i am using the built-in compiler. i paste that warning here. please check once.

    "scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
    File "C:\Users\Gopi\Desktop\test\simulation\milli-meters\gopi\win64\2ddp_node\SConstruct", line 156, in
    C sources: ['gopi.c']"

    but if i use Pyfluent command to upload and load the udf it throughs me an error. please let me know weather it is erasing due to the warning which i have mention before. if it is due to that what is the solution for that please provide me.

    i have updated the VScode till date but still getting this error.

    also pasting the UDF file here please check once.

  • Sravan
    Sravan Member, Employee Posts: 3
    Ansys Employee First Comment First Anniversary Name Dropper
    ✭✭✭

    @Gopi Raju Velpula I am able to compile and load the UDF fine. I have used 24R1 and ansys-fluent-core version 0.19.2. Can you please paste the full path of the working directory. I am not sure if having spaces or some characters may pose issue in compilation.

  • Gopi Raju Velpula
    Gopi Raju Velpula Member Posts: 18
    First Answer 10 Comments Photogenic Name Dropper
    **

    @Sravan "C:\Users\Gopi\Desktop\test\gopi" this is my file path Sravan. and i need to mention that if i paste the same code in my python console in the fluent it is loading fine. when i try to load by using the Jupyter environment the problem is arising .and also getting some warning. please check.

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 183
    5 Answers 100 Comments Photogenic Name Dropper
    admin
    edited May 2

    @Gopi Raju Velpula - I will let others with more Fluent experience also chime in, but apparently this issue has plagued fluent as far back as 2007. I would be very surprised if Jupyter environments make it better, BUT one of the things that appears to be a common thread is reinstalling Visual Studio, and ensuring that you perform a Custom installation and specify the C++ install explicitly (it is no longer installed by default). It's worth a shot as an easy fix.

    The only other obvious thing I see is in the error message in the compiler path, there is a single set of " (quotes) and then the continuation of the path. Maybe a typo in your script somewhere?