|
[Sponsors] |
September 19, 2012, 11:16 |
how to set up and write a cosine UDF
|
#1 |
New Member
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14 |
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 |
|
September 19, 2012, 13:47 |
|
#2 |
Member
NormalVector
Join Date: Oct 2010
Posts: 71
Rep Power: 16 |
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, 09:02 |
|
#3 |
New Member
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14 |
ok thanks i`ll try it!
|
|
September 20, 2012, 12:22 |
|
#4 | |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Quote:
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) } 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 Last edited by ghost82; September 20, 2012 at 12:39. |
||
September 21, 2012, 07:08 |
|
#5 |
New Member
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14 |
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, 07:28 |
|
#6 | |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Quote:
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, 10:38 |
|
#7 |
New Member
Chris K
Join Date: Jun 2012
Posts: 7
Rep Power: 14 |
ok great, thank you, now it works!!!
|
|
|
|