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 Robin Boundary Condition

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 16, 2016, 06:37
Thumbs down UDF for Robin Boundary Condition
  #1
New Member
 
Join Date: Jan 2016
Posts: 2
Rep Power: 0
msuccess is on a distinguished road
I’m simulating the mass fraction profile of a solution passing through a rectangular channel as shown in the figure below.

The inlet boundary is velocity inlet with a uniform velocity, e.g 0.05m/s. The mass fraction of the solute is 0.0001. The outlet is fully developed outflow. The upper and bottom edges are defined as wall. The mass fraction at the upper wall is the same as the inlet, 0.0001. But for the bottom wall, a UDF is hooked to define the mass species boundary condition. Here are my UDF codes:

#include "udf.h"
#define D 1e-10
#define J 1e-4
DEFINE_PROFILE(mass_fraction_profile, t, i)
{
real x[ND_ND];
real y;
cell_t c;
face_t f;
Thread *t0;
begin_f_loop(f,t)
{
F_CENTROID(x, f, t);
y=x[1];
t0=THREAD_T0(t);
c=F_C0(f,t);
F_PROFILE(f,t,i)=-D/J*(C_YI_G(c,t0,i)[1]);
}
end_f_loop(f,t)
}

The governing equation is D∙∂m/∂y+J∙m=0. D, J are known.
The expected result is that the mass fraction is increasing from the upper wall to the bottom, with the highest mass fraction (m) at the bottom wall. But the simulation result shows the opposite, with the mass fraction decreasing from the top to the bottom. If I change the value of D and J, sometimes the mass fraction can not converge.

If I set the bottom boundary mass fraction to a constant 0.2, the result seems right with the mass fraction increasing from the top wall to the bottom wall, which means there's something wrong with the UDF.

So could anyone please help me figure out where goes wrong? What are the correct UDF codes? Thank you very much!

Last edited by msuccess; January 16, 2016 at 08:28.
msuccess is offline   Reply With Quote

Old   January 20, 2016, 16:23
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
You're using the gradient macro for the mass fraction gradient at each time the profile is called (probably every time step). The gradient data is not available on the first iteration, a fix by HenrikS is suggested here.
`e` is offline   Reply With Quote

Old   January 22, 2016, 07:01
Default
  #3
New Member
 
Join Date: Jan 2016
Posts: 2
Rep Power: 0
msuccess is on a distinguished road
Thank you very much for your reply. I've already turned it on and tried several iterations before hooking the UDF, but it still doesn't work. As for including the code as he suggested, I'm not sure whether it also works for mass fraction, or how to adjust it to fit my case.

I have tried another way to write my code as below, but the result is not right either. Would you help me figure out what the problem is? Thx.

#include "udf.h"
#define D 1.6e-9
#define J 6.7e-5
#define dy 1e-5

DEFINE_PROFILE(mass_fraction_profile, t, i)
{
real x[ND_ND];
real y;
cell_t c;
face_t f;

begin_f_loop(f,t)
{
F_CENTROID(x, f, t);
y=x[1];
c=F_C0(f,t);
F_PROFILE(f,t,i)= C_YI(c,t,i)/(1-J/D*dy);
}
end_f_loop(f,t)
}
msuccess 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
write a UDF to give a velocity boundary condition at an interior face Tharanga Fluent UDF and Scheme Programming 19 August 5, 2018 04:29
several fields modified by single boundary condition schröder OpenFOAM Programming & Development 3 April 21, 2015 05:09
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
Boundary Condition Types Using Scheme and UDF Nasir FLUENT 0 September 15, 2008 21:54
UDF : boundary condition ID Flav FLUENT 4 June 28, 2001 09:52


All times are GMT -4. The time now is 04:50.