CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Creating a UDF for fluid inlet velocity (https://www.cfd-online.com/Forums/fluent-udf/183608-creating-udf-fluid-inlet-velocity.html)

ameetks99 February 8, 2017 08:05

Creating a UDF for fluid inlet velocity
 
Hi,
I am new in ansys, I don't know how to write a UDF.
Please can someone help me to write a UDF for fluid inlet velocity in recipricating pump which is rotating at 1450 rpm and total displacement of piston is 20 mm.
Diameter of piston is 14 mm.

pakk February 8, 2017 08:34

If you don't know how to start a udf, I would start by looking in the manual. Try if you can find a udf that does something similar, and think if you can figure out what should be changed. Change that in the code, as good as you guess/understand how that should be done.

Your first attempt will probably not work. Then post it here, so we can see how you are thinking, and can really assist you to learn how to make UDFs.

ameetks99 February 8, 2017 23:10

thank you for reply
But udf for sinusoidal velocity is not there in manual, if you have a udf for sinusoidal velocity please send it to me.

ameetks99 February 8, 2017 23:25

#include "udf.h"
DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
real t = CURRENT_TIME;
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) =2.61*sin(152*t);
}
end_f_loop(f, thread)
}
I tried this udf but inlet velocity is showing ZERO,

pakk February 9, 2017 02:59

And do you get any warnings when you compile or run?

I don't remember now if the sine function works by default, otherwise you have to add
Code:

#include <math.h>
to your code. But then you should have seen a warning like "undefined reference to sin"...

ameetks99 February 9, 2017 05:36

cpp -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/multiport/src" -I. -DUDF
ONFIG_H="<udfconfig.h>" "C:\Users\Ameet Kumar Singh\Desktop\piston pump h\udf.h.c"
C:\\Users\\Ameet Kumar Singh\\Desktop\\piston pump h\\udf.h.c:2: math.h: No such file or directory
This message is showing when I added #include "math.h" and I interpret it

pakk February 9, 2017 06:02

Go back to your original UDF, but now in a foldername that has no spaces.

Quote:

C:\Users\Ameet Kumar Singh\Desktop\piston pump h\
There are four spaces in the name of this folder, and Fluent is known to have problems with that.

ameetks99 February 9, 2017 06:16

cpp -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/multiport/src" -I. -DUDF
ONFIG_H="<udfconfig.h>" "D:\\udf.c"
D:\\\\udf.c:2: math.h: No such file or directory
the problem remain same when I copy the udf file to a drive

pakk February 9, 2017 06:19

That is impossible, because your original UDF did not have any reference to math.h in it.

ameetks99 February 9, 2017 06:21

If you can write the udf for inlet velocity of reciprocating pump which is rotating at 1450 rpm and movement of the piston is 20 mm It will be helpful for me

pakk February 9, 2017 06:29

Try this:
Code:

#include "udf.h"
DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
real t = CURRENT_TIME;
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) =2.61*sin(152*t);
}
end_f_loop(f, thread)
}

If you could read answers that people gave you, it would be helpful for yourself.


All times are GMT -4. The time now is 22:56.