# how to set up and write a cosine UDF

 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 19, 2012, 10:16 how to set up and write a cosine UDF #1 New Member   Chris K Join Date: Jun 2012 Posts: 7 Rep Power: 6 Hello everybody, i ve got a problem with my inlet boundary conditions. i want to implement a cosine (or sine) function because, i got a pulsative flow at the inlet. my flow changes every second from 0 to 20 m/s. one possible function would be 10*cos(x*pi)+10 with 0

 September 19, 2012, 12:47 #2 Member     NormalVector Join Date: Oct 2010 Posts: 72 Rep Power: 8 You should read the Fluent UDF manual here: http://hpce.iitm.ac.in/website/Manua...f/main_pre.htm Alternatively you can create a Profile file with discrete velocity vs. time data and use that. See here: http://hpce.iitm.ac.in/website/Manua...ug/node301.htm

 September 20, 2012, 08:02 #3 New Member   Chris K Join Date: Jun 2012 Posts: 7 Rep Power: 6 ok thanks i`ll try it!

September 20, 2012, 11:22
#4
Senior Member

Daniele
Join Date: Oct 2010
Location: Italy
Posts: 992
Rep Power: 17
Quote:
 Originally Posted by chriskit Hello everybody, i ve got a problem with my inlet boundary conditions. i want to implement a cosine (or sine) function because, i got a pulsative flow at the inlet. my flow changes every second from 0 to 20 m/s. one possible function would be 10*cos(x*pi)+10 with 0
Hi,
I don't understand very well: your function should be time dependent but there isn't time in your function..what is x?time?
From what I understand I think you want to change velocity at inlet with a time dependent cos function.
If so, try this udf.

Code:
```#include "udf.h"
#include "math.h"
#include "mem.h"

{
face_t f;
real t = CURRENT_TIME;

{
}
}```
Am I right?
If so copy this udf in a textedit file and save it as somename.c (not txt extension but c extension) and put it in the folder of your cas and dat files.
Open fluent and go to define->user-defined->functions->interpreted.
Choose the c file and interpret it.
Choose an appropriate time step for your unsteady simulation and stop it after some periods (you know 1 period is 2 seconds).

Also, I don't understand this:
..and how can i tell fluent that one period is like 4 seconds?

your period is 2 seconds not 4.
If I don't understand post a sketch of your domain and explain better.

Daniele

Last edited by ghost82; September 20, 2012 at 11:39.

 September 21, 2012, 06:08 #5 New Member   Chris K Join Date: Jun 2012 Posts: 7 Rep Power: 6 Hey Daniele, thanks a lot! You understood it absolute right. And really thanks for the code, my knowledge at C and C++ isnīt that big... So now, i made it like your proposal but the new problem is that "my_velocity" doesn`t appear at the boundary conditions. I think interpreting worked well but i can`t choose this condition. Do you know what kind of problem could be the reason for that? Thank you and regards, chris

September 21, 2012, 06:28
#6
Senior Member

Daniele
Join Date: Oct 2010
Location: Italy
Posts: 992
Rep Power: 17
Quote:
 Originally Posted by chriskit Hey Daniele, thanks a lot! You understood it absolute right. And really thanks for the code, my knowledge at C and C++ isnīt that big... So now, i made it like your proposal but the new problem is that "my_velocity" doesn`t appear at the boundary conditions. I think interpreting worked well but i can`t choose this condition. Do you know what kind of problem could be the reason for that? Thank you and regards, chris
Hi Chris,
after interpreting your udf, go to boundary condition panel, choose your inlet, then change from "constant" to udf my_velocity.

PS: if you start your simulation with your function velocity at time=0 s is 20 m/s; you should perform a steady state simulation first, with v=constant=20 m/s than switch to unsteady and apply your cosine udf.

Daniele

 September 21, 2012, 09:38 #7 New Member   Chris K Join Date: Jun 2012 Posts: 7 Rep Power: 6 ok great, thank you, now it works!!!

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

All times are GMT -4. The time now is 15:12.