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

How do i create time dependent flows on UDF?

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

Like Tree1Likes
  • 1 Post By lomba

Reply
 
LinkBack Thread Tools Display Modes
Old   December 9, 2010, 16:22
Default How do i create time dependent flows on UDF?
  #1
New Member
 
Nuril
Join Date: Dec 2010
Posts: 17
Rep Power: 9
nha1g08 is on a distinguished road
How do I create this conditon using a UDF?

I want the velocity at the pipe inlet to be 10m/s from t=0 to 5

then i want the v=20m/s from t=5 to 6,

then i want the velocity again to be 10m/s from t =6 to 11

How do i set the time ticking ticking on the UDF? and what is the varaible for time?

Thanks
nha1g08 is offline   Reply With Quote

Old   December 9, 2010, 20:56
Default
  #2
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 9
ComputerGuy is on a distinguished road
nha1g08,

Try something like this. Inevitably I'm missing a semicolon in the following, but it should be relatively simple to fix. Interpret (or better, compile) this UDF, then hook it to your face velocity boundary condition. This loops over all cell faces at the inlet boundary and sets them to the given velocity depending on the simulation time.

Make sure you run transient!

Regards,
ComputerGuy

DEFINE_PROFILE(velocity_magnitude, t, i)
{
real velocity;
real the_current_time;
face_t f;

the_current_time = CURRENT_TIME;

if ((the_current_time>=0) && (the_current_time<5))
{
velocity=10;
}
if ((the_current_time>=5) && (the_current_time<6))
{
velocity=20;
}
if ((the_current_time>=6))
{
velocity=10;
}


begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)
}
ComputerGuy is offline   Reply With Quote

Old   December 12, 2010, 04:20
Default
  #3
New Member
 
zhuliang
Join Date: Nov 2010
Location: China
Posts: 13
Rep Power: 9
bright181 is on a distinguished road
I want the pressure of the pressureinlet to be 0 form 0 to 5 second
and the pressure of 8Mpa from 5 to 6 second
is it similar?
thank you in advance
bright181 is offline   Reply With Quote

Old   December 12, 2010, 09:24
Default
  #4
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 9
ComputerGuy is on a distinguished road
bright181,

Yes. You have to change the udf slightly and hook it to a different place on the inlet boundary conditions panel, but it's effectively the same. I have changed variable names for clarity.

ComputerGuy


Code:
#include "udf.h"
DEFINE_PROFILE(pressure_magnitude, t, i)
{
real pressure_mag;
real the_current_time;
face_t f;

the_current_time = CURRENT_TIME;

if ((the_current_time>=0.0) && (the_current_time<5.))
{
pressure_mag=0.0;
}
if ((the_current_time>=5.0) && (the_current_time<6.0))
{
pressure_mag=8.0e6;
}



begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = pressure_mag;
}
end_f_loop(f,t)
}

Last edited by ComputerGuy; December 12, 2010 at 11:27. Reason: Changed pressure from 10 --> 8 MPa
ComputerGuy is offline   Reply With Quote

Old   January 5, 2011, 00:42
Default
  #5
New Member
 
ekkapong
Join Date: Oct 2010
Posts: 18
Rep Power: 9
nuengao is on a distinguished road
Dear computerGuy

how to hook your codes to Fluent and how to set time in fluent


please give me your suggestion

thank
nuengao is offline   Reply With Quote

Old   January 5, 2011, 00:48
Default
  #6
New Member
 
ekkapong
Join Date: Oct 2010
Posts: 18
Rep Power: 9
nuengao is on a distinguished road
Could I have one question?

I'd like to know that how to define current time at fluent ?
nuengao is offline   Reply With Quote

Old   June 17, 2013, 03:03
Default
  #7
New Member
 
Sakshi Sharma
Join Date: Jun 2013
Posts: 1
Rep Power: 0
sakshi1632 is on a distinguished road
I want to inject a fluid at every 6 mins. I prepared a code, but ther seems to be an error in line 10 saying:" line 10: invalid type for integral binary expression: double % int."
Can anyone give me a solution to this?
Thankyou.
Here's the code:

#include "udf.h"

DEFINE_PROFILE(insulin_inlet,thread,position )
{ face_t f;

begin_f_loop(f,thread)
{
real t = RP_Get_Real("flow-time");

if (t%360==0)

F_PROFILE(f,thread,position) = 0.1;

else
F_PROFILE(f,thread,position) = 0;

} end_f_loop(f,thread) }
sakshi1632 is offline   Reply With Quote

Old   June 17, 2013, 06:06
Default get cell value
  #8
New Member
 
Join Date: Feb 2013
Posts: 2
Rep Power: 0
lomba is on a distinguished road
Hi,
Someone can help me please.
I would like to retrieve the value in a cell in the liquid phase and compared with a set value. Depending on the value found, I modified the condition of gas inlet. like a regulation loop.
Here is the UDF I wrote but I am having acces_violation.
the coordenates of the cell where i want get mass fraction value are x=0.08 and y=0.015

I get acess violation when i compiled my UDF.

Best regards!!!
Sorry for my english level!
/*---------------------------------------------------------------*/

#include "udf.h"

DEFINE_PROFILE(profile,thread,i)
{

face_t f;
cell_t c;
real YH, Rhol, ConsH, pH, pH1, cent,YH1, x, y;
real xc[ND_ND];


/*--------------------------------------------------------------------*/
Thread *thread_l = THREAD_SUB_THREAD(thread,0); /*to pointer the liquid phase*/
Thread *cell_thread;

/*--------------------------------------------------------------------*/

/*---mesurement---*/
/*--------------------------------------------------------------------*/
/*to get cell YI value*/

begin_c_loop_all(c,cell_thread)
{
x=xc[0];
y=xc[1];

C_CENTROID(xc,c,cell_thread);

if( x=0.08. && y=0.015.) /*probe position*/

YH = C_YI(c,thread_l,0);

ConsH=YH*C_R(c,thread_l);

}

end_c_loop_all(c,cell_thread)

pH=-log(ConsH);



/*--------------------------------------------------------------------*/


/*---injection CO2---*/
/*--------------------------------------------------------------------*/
begin_f_loop(f,thread)
{

if(pH >7)

F_PROFILE(f,thread,i) = 1;

else

F_PROFILE(f,thread,i) = 0;

}

end_f_loop(f,thread)

/*--------------------------------------------------------------------*/

}
Chong070940103 likes this.
lomba is offline   Reply With Quote

Old   July 9, 2017, 11:10
Default sakshi1632
  #9
New Member
 
saman
Join Date: Jul 2017
Posts: 1
Rep Power: 0
sam2629 is on a distinguished road
I want to inject a fluid at every 6 mins. I prepared a code, but ther seems to be an error in line 10 saying:" line 10: invalid type for integral binary expression: double % int."
Can anyone give me a solution to this?
Thankyou.
Here's the code:

#include "udf.h"

DEFINE_PROFILE(insulin_inlet,thread,position )
{ face_t f;

begin_f_loop(f,thread)
{
real t = RP_Get_Real("flow-time");

if (t%360==0)

F_PROFILE(f,thread,position) = 0.1;

else
F_PROFILE(f,thread,position) = 0;

} end_f_loop(f,thread) }

hi,
did you know what was the problem of your code?
sam2629 is offline   Reply With Quote

Old   September 21, 2017, 07:57
Default
  #10
New Member
 
madan
Join Date: Sep 2017
Posts: 5
Rep Power: 2
madhan is on a distinguished road
Hi everybody,

I am doing a transient simulation of conjugated heat transfer problem. In that I have a solid that plays a role of heat generation(W/m3) varying with time (q=q(t)). Since i am weak in codings, I need a help to write a udf for heat source varying with time. value is q=6.75e11

Thank you.
madhan is offline   Reply With Quote

Old   September 22, 2017, 08:57
Default
  #11
Senior Member
 
Join Date: Nov 2013
Posts: 1,137
Rep Power: 15
pakk will become famous soon enough
If q=6.75e11, it is not varying in time but constant... So I think you should be more clear in what you want.
pakk is offline   Reply With Quote

Old   September 22, 2017, 14:37
Default
  #12
New Member
 
madan
Join Date: Sep 2017
Posts: 5
Rep Power: 2
madhan is on a distinguished road
Quote:
Originally Posted by pakk View Post
If q=6.75e11, it is not varying in time but constant... So I think you should be more clear in what you want.
Hi,

I found out the example source. When I tried to run transient simulation with this udf. It doesnt looklike its working. The heat generation source is increasing for every 100 sec. But when i see the avearge temperature of heat source its was almost the same for all timesteps. Hereby I have attached the Udf. Please tell me what are the mistakes I have did.
Thank You.

#define Q1 2e10
#define Q2 2.97e10
#define Q3 3.80e10

DEFINE_SOURCE(qgen_source,c,t,dS,eqn)
{
real source;
real time = CURRENT_TIME;

if (time <= 100) /* time 0-100 q = Q1 */
{
/* source term */
source = Q1;

/* derivative of source term. */
dS[eqn] = 0.;
}
if (time > 100 && time < 200) /* time 100-200 q = Q2 */
{
source = Q2;

dS[eqn] = 0.;
}
if (time >= 200 && time < 300) /* time 200-300 q = Q3 */
{
source = Q3;

dS[eqn] = 0.;
}
if (time >= 300 && time <400) /* time 300 -400 q = 0 */
{
source = dS[eqn] = 0.;
}

return source;
}
madhan is offline   Reply With Quote

Old   September 25, 2017, 10:09
Default
  #13
Senior Member
 
Join Date: Nov 2013
Posts: 1,137
Rep Power: 15
pakk will become famous soon enough
What makes you think that you made a mistake?
pakk is offline   Reply With Quote

Old   September 25, 2017, 16:58
Default Regarding entropy generation due to heat transfer and fluid friction.
  #14
New Member
 
madan
Join Date: Sep 2017
Posts: 5
Rep Power: 2
madhan is on a distinguished road
Quote:
Originally Posted by pakk View Post
What makes you think that you made a mistake?
Hi pakk,

I figured out the mistake.that was is in timestep size when iam iterating it..

And I have a another doubt in the entropy generation for 3d problem. I am trying to calculate entropy generation for heat transfer and fluid friction using custom field functions.
from the literature i have found that the entropy for heat transfer can be found out from following formula but for fluid friction i dont know how to implement that formula..herby i have attached the photo.
please help me about that.

Thanking you.
Attached Images
File Type: png 122.png (20.4 KB, 7 views)
madhan is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Emergency:UDF for a time dependent parabolic velocity zumaqiong Fluent UDF and Scheme Programming 12 March 25, 2010 13:00
Availability of previous time level values in UDF ranga sudarsan FLUENT 0 September 1, 2008 09:17
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
AMG versus ICCG msrinath80 OpenFOAM Running, Solving & CFD 2 November 7, 2006 16:15
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 16:58.