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

Defining species mass fraction using a UDF

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

Like Tree3Likes
  • 1 Post By T81
  • 2 Post By coglione

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 25, 2009, 11:06
Default Defining species mass fraction using a UDF
  #1
T81
New Member
 
Join Date: Mar 2009
Posts: 15
Rep Power: 17
T81 is on a distinguished road
Hi there,
I'd like to know how to define species mass fraction with a UDF.

I found the macro C_YI(c,t,i), for defining the species mass fraction.
But how to hook this in fluent?
Probably under inlet at the boundary conditions panel,
but which is the appropriate general-purpose macro for this?

I tried the following but the mass fraction doesn't change.

Code:
DEFINE_PROFILE(species_profile, t, position)
{
  cell_t c;

  begin_c_loop(c, t)
  {
    if (temp_avg  > 700)
    {
       C_YI(c,t,0) = 0.2;
    }
    else
    {
       C_YI(c,t,0) = 0.8;
    }
 }
 end_c_loop(c, t)
}
Thanks in advance
khaledhmz likes this.

Last edited by T81; March 25, 2009 at 12:55.
T81 is offline   Reply With Quote

Old   March 26, 2009, 02:57
Default
  #2
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Hello,

DEFINE_PROFILE has to return a value using C_PROFILE(c,t,i):

DEFINE_PROFILE(species_profile, t, i)
{
cell_t c;

begin_c_loop(c, t)
{
if (temp_avg > 700)
{
C_PROFILE(c,t,i) = 0.2;
}
else
{
C_PROFILE(c,t,i) = 0.8;
}
}
end_c_loop(c, t)
}Hook it in the boundary condition panel for your fluid zone(s) and make sure that Sum[C_YI(i)] = 1 is still valid after executing this UDF !

cheers
soheil_r7 and souza.emer like this.
coglione is offline   Reply With Quote

Old   March 26, 2009, 03:59
Default
  #3
T81
New Member
 
Join Date: Mar 2009
Posts: 15
Rep Power: 17
T81 is on a distinguished road
coglione thank you very much for the quick response.
It works!!!

Thanks again
T81 is offline   Reply With Quote

Old   April 19, 2018, 07:02
Default
  #4
New Member
 
pornthep sittisak
Join Date: Apr 2018
Posts: 4
Rep Power: 8
Pom Sittisak is on a distinguished road
I need co mass fraction from back surface of the fan (ID=5) to use as CO species of outlet at front of the fan.

I also try to find the cause of this error when in try to put below UDF in my problem.

Error: received a fatal signal (Segmentation fault).

Error: received a fatal signal (Segmentation fault).
Error Object: #f

Here my UDF, aim to bring the CO (species mass fraction) variable data from back to front of the long cylinder tube.

#include "udf.h"

//Global variable declaration
real co;

//Execute every timestep
DEFINE_EXECUTE_AT_END(Fanback)
{
//Specific the domain ** 1 = mixture domain
Domain *mix_domain = Get_Domain(1);
Thread *mix_thread;
Thread **pt;

//Initialize the variable
co = 0;

#if !RP_HOST
mp_thread_loop_f(mix_thread, mix_domain, pt)
{
face_t c;
// pt[0] ** number [0] is co phase index (co in this case)
begin_f_loop(c, pt[0])
{
// Check if it is a outlet thread (thread id = 5) (Lookup from region list)
if (THREAD_ID(mix_thread)==5){
// Loop and sum up the flux for each face
co =F_YI(c,pt[0],1);

}


}
end_f_loop(c, pt[0])


}

#endif /* !RP_HOST */
node_to_host_real_1(co);

#if RP_HOST
Message("CO Concentration at FAN BACK = %f\n",co);
#endif /* !RP_NODE */


}

// Creating profile for returning inlet
DEFINE_PROFILE(co_outlet,t,i)
{
face_t f;
begin_f_loop(f,t)
{
//Apply flowout variable to the face
F_PROFILE(f,t,i) = co;
}
end_f_loop(f,t)
}

I can pass the complied and Hook the run the simulation using these UDF but the error is shown when first the time step is finished.
Pom Sittisak 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
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 21:14
I need UDF help. S.Whitney FLUENT 0 October 15, 2007 11:29
UDF for Species mass fraction daniel FLUENT 3 June 22, 2005 08:40
UDF for Species mass fraction Rahul FLUENT 0 September 20, 2002 04:22
Species Mass Fraction inside UDF using PDF? Daniel Schneider FLUENT 0 September 20, 2000 06:34


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