User defined function

  • 55 Views
  • Last Post 5 days ago
  • Topic Is Solved
Karthik K R posted this 2 weeks ago

How can i introduce a UDF of density and depth. That is density varying linearly with depth.

Order By: Standard | Newest | Votes
Karthik K R posted this 2 weeks ago

In order to get a linearly stratified medium. Thanks Karthik

Kremella posted this 2 weeks ago

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

  • Liked by
  • Karthik K R
Karthik K R posted this 2 weeks ago

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 posted this 2 weeks ago

Depth is the y-coordinate

Kremella posted this 2 weeks ago

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 posted this 2 weeks ago

I am very new to this .. it will be really helpful if any body could help me..please..

raul.raghav posted this 1 weeks ago

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!

Rahul

  • Liked by
  • Karthik K R
Karthik K R posted this 1 weeks ago

Thanks a lot for the replay...

abenhadj posted this 1 weeks ago

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).

Best regards,

Amine

Karthik K R posted this 1 weeks ago

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 posted this 1 weeks ago

This code is not working properly. There is an error 'undefined variable x)

Karthik K R posted this 1 weeks ago

Can you please verify and debug the code.

abenhadj posted this 1 weeks ago

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.

Best regards,

Amine

Karthik K R posted this 1 weeks ago

I have done the same . But there is an error can 'undefined variable x')

abenhadj posted this 1 weeks ago

Paste your UDF here.

Best regards,

Amine

Karthik K R posted this 1 weeks ago

 Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).\n\nThe system cannot find the path specified.
\n\nC:\Users\Sunayan\Desktop\KARNAV\20.7 successful\GEOM AND MESH\1_files\dp0\FFF\Fluent\libudf\win64\3ddp_host\libudf.dll

Karthik K R posted this 1 weeks ago

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

abenhadj posted this 1 weeks ago

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

Best regards,

Amine

abenhadj posted this 1 weeks ago

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

Best regards,

Amine

Karthik K R posted this 1 weeks ago

yes I did that still there is problem

 

Karthik K R posted this 1 weeks ago

Error: The UDF library you are trying to load (C:\Users\Sunayan\Desktop\KARNAV\20.7 successful\GEOM AND MESH\1_files\dp0\FFF\Fluent\libudf) is not compiled for 3ddp on the current platform (win64).\n\nThe system cannot find the path specified.
\n\nC:\Users\Sunayan\Desktop\KARNAV\20.7 successful\GEOM AND MESH\1_files\dp0\FFF\Fluent\C:\Users\Sunayan\Desktop\KARNAV\20.7 successful\GEOM AND MESH\1_files\dp0\FFF\Fluent\libudf\win64\3ddp\libudf.dll
Error Object: #f

 

 

abenhadj posted this 1 weeks ago

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

Best regards,

Amine

Karthik K R posted this 5 days ago

Thank you raul.raghav,abenhadj for the advice.thank you very much.

abenhadj posted this 5 days ago

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

Best regards,

Amine

Close