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

UDF for decreasing pressure

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 9, 2010, 18:32
Default UDF for decreasing pressure
  #1
Member
 
pranab_jha's Avatar
 
Pranab N Jha
Join Date: Nov 2009
Location: Houston, TX
Posts: 86
Rep Power: 16
pranab_jha is on a distinguished road
Hello All,
Can someone tell me what am I doing wrong in this UDF that I have? I want to have a pressure inlet boundary condition with decreasing pressure as I march in time.


/************************************************** ********************
pr_10.c
UDF for specifying a pressure boundary condition
************************************************** ********************/

#include "udf.h"

DEFINE_PROFILE(pr_10, thread, nv)
{
face_t f; /* Defines f as a face thread index */
real t = CURRENT_TIME; /*current flow time*/
real dt = RP_Get_Real("physical-time-step");
real vel = F_V(f,thread); /* v-velocity*/
real Q0 = 5.0; /*Q0=l*b*h, l=b=1 */
real Q;
real newQ;
real rho = 0.6679; /*density*/
real g = 9.81;
real D = 0.05; /*inlet size*/
real PI=3.14159;
int time_step = N_TIME; /*returns time step number*/
real P0 = rho*g*Q0;
real A = PI*D*0.125; /*inlet area*/
real mem = F_UDMI(f,thread,0);

if(time_step = 1){newQ = Q0} /*initializing newQ*/
else{newQ = mem}

begin_f_loop(f, thread)
{
Q = newQ - (A*vel*dt);
F_PROFILE(f, thread, nv) = Q*P0/Q0;
mem = Q;
}
end_f_loop(f, thread)
}


When I try to interpret it, I get the following error messages:
Error: W:\Fluent files\Slug\2D\l1\pressure10.c: line 26: parse error.
Error: W:\Fluent files\Slug\2D\l1\pressure10.c: line 29: f_loop_last: undeclared variable


Can someone help me out with this.
Thanks,
Pranab
pranab_jha is offline   Reply With Quote

Old   November 10, 2010, 15:07
Default
  #2
Member
 
pranab_jha's Avatar
 
Pranab N Jha
Join Date: Nov 2009
Location: Houston, TX
Posts: 86
Rep Power: 16
pranab_jha is on a distinguished road
Has anybody had any experience with F_UDMI macro. I am a bit stuck here. I know there are a couple of simple errors in the if loop (which I have fixed). Still not able to get it to run correctly. My aim is:

1. to calculate the value of Q at a certain time step
2. store it in memory using F_UDMI
3. pass back the value of Q to fluent
4. in the next time step, use the last value of Q from F_UDMI
5. update F_UDMI using new value of Q.

Any help would be appreciated folks.
pranab_jha is offline   Reply With Quote

Old   December 10, 2010, 20:19
Default
  #3
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
What errors are you seeing now? I note in the if-then loop you're missing semicolons, and you equals statements should be ==...


Something like...

if(time_step == 1){newQ = Q0;} /*initializing newQ*/
else{newQ = mem;}

begin_f_loop(f, thread)
{
Q = newQ - (A*vel*dt);
F_PROFILE(f, thread, nv) = Q*P0/Q0;
mem = Q;
}
end_f_loop(f, thread)
}
ComputerGuy is offline   Reply With Quote

Old   December 10, 2010, 20:22
Default
  #4
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Also, I don't see anywhere in your code where you're updating F_UDMI with a new value. You update the value of mem (mem=Q), but you're never setting F_UDMI(f,thread,0)=Q;

ComputerGuy
ComputerGuy is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF to adjust pressure outlet a.lynchy FLUENT 4 February 15, 2021 01:50
Pressure BC for combustion chamber Giuki FLUENT 1 July 19, 2011 12:35
Modifying Pressure swirl atomizer model by UDF jeff_F FLUENT 0 May 22, 2010 10:22
calculation average pressure in a plane with UDF Vitalij FLUENT 1 April 10, 2007 04:39
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 03:15


All times are GMT -4. The time now is 06:53.