CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

how to set up and write a cosine UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By ghost82
  • 1 Post By ghost82

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 19, 2012, 11:16
Default how to set up and write a cosine UDF
  #1
New Member
 
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14
chriskit is on a distinguished road
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<x<2.

Now, i just dont know how to setup this function in fluent and how and where to wirte it. I know that i have to define this function somewhere and upload it after in fluent. and how can i tell fluent that one period is like 4 seconds?

Would be really great if someone can help me with this.

regards, chris
chriskit is offline   Reply With Quote

Old   September 19, 2012, 13:47
Default
  #2
Member
 
NormalVector's Avatar
 
NormalVector
Join Date: Oct 2010
Posts: 71
Rep Power: 16
NormalVector is on a distinguished road
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
NormalVector is offline   Reply With Quote

Old   September 20, 2012, 09:02
Default
  #3
New Member
 
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14
chriskit is on a distinguished road
ok thanks i`ll try it!
chriskit is offline   Reply With Quote

Old   September 20, 2012, 12:22
Default
  #4
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Quote:
Originally Posted by chriskit View Post
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<x<2.

Now, i just dont know how to setup this function in fluent and how and where to wirte it. I know that i have to define this function somewhere and upload it after in fluent. and how can i tell fluent that one period is like 4 seconds?

Would be really great if someone can help me with this.

regards, chris
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"

DEFINE_PROFILE(my_velocity, thread, position)
{
  face_t f;
  real t = CURRENT_TIME;

  begin_f_loop(f, thread)
    {
          F_PROFILE(f, thread, position) = 10.*cos(t*3.14159)+10.;
    }
  end_f_loop(f, thread)
}
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.
Then in your velocity boundary condition choose your interpreted udf ("my_velocity").
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
Far and Chong070940103 like this.

Last edited by ghost82; September 20, 2012 at 12:39.
ghost82 is offline   Reply With Quote

Old   September 21, 2012, 07:08
Default
  #5
New Member
 
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14
chriskit is on a distinguished road
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
chriskit is offline   Reply With Quote

Old   September 21, 2012, 07:28
Default
  #6
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Quote:
Originally Posted by chriskit View Post
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
Far likes this.
ghost82 is offline   Reply With Quote

Old   September 21, 2012, 10:38
Default
  #7
New Member
 
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14
chriskit is on a distinguished road
ok great, thank you, now it works!!!
chriskit is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



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