Fluids

Fluids

User defined function

    • Karthik K R
      Subscriber
      How can i introduce a UDF of density and depth.
      That is density varying linearly with depth.
    • Karthik K R
      Subscriber
      In order to get a linearly stratified medium.
      Thanks
      Karthik
    • Karthik R
      Administrator

      Hello,


      Please check out the DEFINE_PROPERTY UDF macro in the Fluent Customization manual. There are some examples such as defining viscosity as a function of temperature, and density function for compressible fluids. You might want to make density a function of your coordinate which indicates depth. 


      You might also want to look into this example - "UDF for specifying an x-momentum source term in a spatially dependent porous media". This will give you some idea as to how to use the centroid macro in such UDFs.


      I hope this helps.


      Best Regards,


      Karthik

    • Karthik K R
      Subscriber
      Can any one please help me writing the UDF function
      Its a function of detph
      Density varies linearly with depth
      Assuming the fuction as f(x)
    • Karthik K R
      Subscriber
      Depth is the y-coordinate
    • Karthik R
      Administrator

      Hello,


      I'd strongly recommend you go through the Fluent customization manual. It contains several examples. You might find a similar UDF which you can make small modifications to suit your needs. I've found this approach to writing UDFs extremely useful. I'll let other members of this community weigh in their opinions.


      Thank you.


      Best Regards,


      Karthik

    • Karthik K R
      Subscriber
      I am very new to this .. it will be really helpful if any body could help me..please..
    • raul.raghav
      Subscriber

      KKR, attached is a snippet of the UDF you need.



      DEFINE_PROPERTY(density_function,c,t)


      {


      real rho;


      real y, x[ND_ND];


      C_CENTROID(x,c,t);


      y = x[1];


      rho = /*define your function rho(y)*/ ;


      return rho;


      }



      And as Karthik (Kremella) mentioned, you need to go through the given examples to write your own UDFs. And if you are writing a complicated UDF, you can ask specific questions and users of the community would be of help. Good luck!

    • Karthik K R
      Subscriber
      Thanks a lot for the replay...
    • DrAmine
      Ansys Employee

      What is the fluid used here? Are you trying to model atmospheric problem? Using DEFINE_PROPERTY for density is generally only suitable for temperature depdendency or for compressible liquid (small compressibility).

    • Karthik K R
      Subscriber
      Fluid is water.. and i want to create a linearly density stratified medium. That is density increases linearly with depth(y axis). I want simulate sea condition (pycnocline)
    • Karthik K R
      Subscriber
      This code is not working properly.
      There is an error 'undefined variable x)
    • Karthik K R
      Subscriber
      Can you please verify and debug the code.
    • DrAmine
      Ansys Employee

      First of all ANSYS Stuff colleagues are not here to debug your code as this is mainly your task. We are here only to provide guidance.


       


      The snipped provided has to work:


       


      #include "udf.h"


      DEFINE_PROPERTY(density_function,c,t)


       


      {


       


      real rho;


       


      real y, x[ND_ND];


       


      C_CENTROID(x,c,t);


       


      y = x[1];


       


      rho =y*1000  ;/*define your function rho(y)*/


       


      return rho;


       


      }


      You might past you final function here.

    • Karthik K R
      Subscriber
      I have done the same . But there is an error can 'undefined variable x')
    • DrAmine
      Ansys Employee

      Paste your UDF here.

    • Karthik K R
      Subscriber

       Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the path specified.
      nnC:UsersSunayanDesktopKARNAV20.7 successfulGEOM AND MESH1_filesdp0FFFFluentlibudfwin643ddp_hostlibudf.dll

    • Karthik K R
      Subscriber

      while I complied my code this error popped up. how can I rectify this problem.

    • DrAmine
      Ansys Employee

      You go under Mange to unload any loaded libraries. Then you comple the UDF once again and load it.

    • DrAmine
      Ansys Employee

      You go under Mange to unload any loaded libraries. Then you comple the UDF once again and load it.

    • Karthik K R
      Subscriber

      yes I did that still there is problem


       

    • Karthik K R
      Subscriber

      Error: The UDF library you are trying to load (C:UsersSunayanDesktopKARNAV20.7 successfulGEOM AND MESH1_filesdp0FFFFluentlibudf) is not compiled for 3ddp on the current platform (win64).nnThe system cannot find the path specified.
      nnC:UsersSunayanDesktopKARNAV20.7 successfulGEOM AND MESH1_filesdp0FFFFluentC:UsersSunayanDesktopKARNAV20.7 successfulGEOM AND MESH1_filesdp0FFFFluentlibudfwin643ddplibudf.dll
      Error Object: #f


       


       


    • DrAmine
      Ansys Employee

      Terminate Fluent. Compile and try again. You can even try Standalone.

    • Karthik K R
      Subscriber
      Thank you raul.raghav,abenhadj for the advice.thank you very much.
    • DrAmine
      Ansys Employee

      You are welcome and thanks for marking this issue as resolved.

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