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

UDF issue when implementing a downstream resistance dependent outlet pressure

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2017, 11:37
Default UDF issue when implementing a downstream resistance dependent outlet pressure
  #1
New Member
 
joe
Join Date: Jun 2016
Posts: 2
Rep Power: 0
shiju7279 is on a distinguished road
I am trying to implement the following udf for a simple straight tube model that has laminar flow within it. The desired objective here is to have a flow within the pipe, that is dependent on the downstream resistance. This resistance affects the outlet pressure (P2=resistance*outlet flow). The udf is expected to do this job. However, I am not achieving what I should get.
The inlet pressure is set at 95 mm Hg while the outlet pressure is dependent on this downstream resistance and so this udf is prescribed at the outlet.

I am not sure where I am going wrong. Firstly I get a segmentation error during initialization. To avoid that I do initialization without the udf and while running it I reattach it. I know it is not a brilliant way but just want to see it working. Secondly, my outlet pressure and the mass flow rate always remains zero. I tried implementing lot of modifications on it but all seems to fail. Can you kindly help me with this.

#include "udf.h"

DEFINE_INIT(my_init_func)
{
Domain *domain = Get_Domain(1);
Thread *thread = Lookup_Thread(domain,11);
face_t f;
begin_f_loop(f, thread)
{
F_UDMI(f,thread,0) = 0;
}
end_f_loop(f, thread)
printf("Step Pressure Initialized!");
}

DEFINE_PROFILE(transient_pressure, thread, position)
{
real Res = 7.0e+08; /* Resistance m^-4 s^-1 kg^1 */
face_t f;
float flow, pout, pprev;
real dens = 1050; /* kg m^-3 */


begin_f_loop(f, thread)
{
flow = F_FLUX(f,thread)/dens;
pout = Res*flow;
F_PROFILE(f, thread, position) = pout;
}
end_f_loop(f, thread)

}


DEFINE_EXECUTE_AT_END(pressure_save)
{
Domain *domain = Get_Domain(1);
Thread *thread = Lookup_Thread(domain,11);
face_t f;
begin_f_loop(f, thread)
{
F_UDMI(f,thread,0) = F_P(f,thread);
}
end_f_loop(f, thread)
printf("Step Pressure Recorded!");
}
shiju7279 is offline   Reply With Quote

Old   October 26, 2017, 22:11
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by shiju7279 View Post
I am trying to implement the following udf for a simple straight tube model that has laminar flow within it. The desired objective here is to have a flow within the pipe, that is dependent on the downstream resistance. This resistance affects the outlet pressure (P2=resistance*outlet flow). The udf is expected to do this job. However, I am not achieving what I should get.
The inlet pressure is set at 95 mm Hg while the outlet pressure is dependent on this downstream resistance and so this udf is prescribed at the outlet.

I am not sure where I am going wrong. Firstly I get a segmentation error during initialization. To avoid that I do initialization without the udf and while running it I reattach it. I know it is not a brilliant way but just want to see it working. Secondly, my outlet pressure and the mass flow rate always remains zero. I tried implementing lot of modifications on it but all seems to fail. Can you kindly help me with this.

#include "udf.h"

DEFINE_INIT(my_init_func)
{
Domain *domain = Get_Domain(1);
Thread *thread = Lookup_Thread(domain,11);
face_t f;
begin_f_loop(f, thread)
{
F_UDMI(f,thread,0) = 0;
}
end_f_loop(f, thread)
printf("Step Pressure Initialized!");
}

DEFINE_PROFILE(transient_pressure, thread, position)
{
real Res = 7.0e+08; /* Resistance m^-4 s^-1 kg^1 */
face_t f;
float flow, pout, pprev;
real dens = 1050; /* kg m^-3 */


begin_f_loop(f, thread)
{
flow = F_FLUX(f,thread)/dens;
pout = Res*flow;
F_PROFILE(f, thread, position) = pout;
}
end_f_loop(f, thread)

}


DEFINE_EXECUTE_AT_END(pressure_save)
{
Domain *domain = Get_Domain(1);
Thread *thread = Lookup_Thread(domain,11);
face_t f;
begin_f_loop(f, thread)
{
F_UDMI(f,thread,0) = F_P(f,thread);
}
end_f_loop(f, thread)
printf("Step Pressure Recorded!");
}

Hello

you may try to use this code for initialization part:
Code:
DEFINE_INIT(my_init_func)
{
Thread *t;
face_t f;
Domain *d;
d = Get_Domain(1);
t = Lookup_Thread(domain,11);
thread_loop_f(t, domain)
{
begin_f_loop(f,t)
{
F_UDMI(f,thread,0) = 0;
}
end_f_loop(f, t)
}
printf("Step Pressure Initialized!");
}
Also I'm suggesting you to add UDMs to control your profile input, for instance add F_UDMI(f,thread,1) = pout; before F_PROFILE(f, thread, position) = pout;

In this way you may see your input data using contours.

Best regards
AlexanderZ 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
static vs. total pressure auf dem feld FLUENT 17 February 26, 2016 14:04
Help ME For Pressure Outlet UDF PLZ!!! Yapoo Fluent UDF and Scheme Programming 2 December 26, 2011 12:45
pressure inlet & outlet. help ASAP Plz engahmed Main CFD Forum 0 June 13, 2010 16:34
Fluent 5.2, UDF and Pressure BC's Alfonso Ferrandez FLUENT 0 May 4, 2000 08:02


All times are GMT -4. The time now is 21:25.