CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for decreasing pressure (https://www.cfd-online.com/Forums/fluent-udf/81884-udf-decreasing-pressure.html)

pranab_jha November 9, 2010 17:32

UDF for decreasing pressure
 
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 November 10, 2010 14:07

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.

ComputerGuy December 10, 2010 19:19

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 December 10, 2010 19:22

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


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