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

DEFINE_INIT PROBLEM

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2008, 19:11
Default DEFINE_INIT PROBLEM
  #1
Craig
Guest
 
Posts: n/a
/* This function initializes my domain on the left side with species 0 at 300K and species 1 at 600K on the right side. domain is 1 meter long */

#include "udf.h"

DEFINE_INIT(my_init_function,d) { cell_t c; Thread *t; real xc[ND_ND];

thread_loop_c(t,d) {

begin_c_loop_all (c,t)

{

C_CENTROID(xc,c,t);

if (xc[0] < 0.5)

{

C_T(c,t) = 300.;

C_YI(c,t,0) = 0.;

}

else

{

C_T(c,t) = 600.;

C_YI(c,t,0) = 1.;

}

}

end_c_loop_all(c,t) } }

  Reply With Quote

Old   August 13, 2008, 19:16
Default DEFINE_INIT PROBLEM DESCRIPTION
  #2
Craig
Guest
 
Posts: n/a
The above UDF compiles and runs when hooked. The temperature on the left is 300K and the temp on the right is 600K. Species 0 is on the left and Species 1 is on the right.

However, when i zoom into the walls on the right side, the wall nodes appear to be initialized with Species 0.

I think that I need to add an f_loop to initialize nodes on the wall but the temperature loop seemed to work fine. Any ideas?

  Reply With Quote

Old   August 14, 2008, 02:28
Default Re: DEFINE_INIT PROBLEM DESCRIPTION
  #3
Smith_K
Guest
 
Posts: n/a
Assign the species mass fraction in the wall boundary conditions. By default the mass fraction of all the species will be zero. You do not need a UDF to assign the same on the walls. Regards,

  Reply With Quote

Old   August 14, 2008, 18:34
Default Re: DEFINE_INIT PROBLEM DESCRIPTION
  #4
Craig
Guest
 
Posts: n/a
Thanks for the response.

My wall boundary is set to: Zero Diffusive Flux for species and 0 Heat Flux for Temp. So, my wall species and Temp is allowed to float based on what happens in the interior.

When I initialize the domain to one temp and species without the UDF using solve/initialize I see that all interior nodes and wall nodes are at the initialized species and temperature.

When I initialize the domain using my UDF I find that only the interior nodes are properly initialized (because I have only looped on cell centroids).

Since I don't want to specify species or temp as a boundary condition, I believe that I must do something extra with my UDF to initialize the remaining part of my domain that my begin_c_loop missed.

Thanks again.

  Reply With Quote

Old   January 4, 2019, 06:58
Default UDF not initialzing species mass fraction
  #5
New Member
 
Kedar G. Bhide
Join Date: Apr 2016
Posts: 2
Rep Power: 0
Kedar G. Bhide is on a distinguished road
I've UDF that defines species mass fraction in the form of a profile.


#include "udf.h"
2 DEFINE_INIT(my_init_func, d)
3 {
4 cell_t c;
5 Thread *t;
6 real xc[ND_ND];
7 real x;
8 real phiphi;
9 real l1;
10 real l2;
11 real loc;
12 real dl;
13 real k;
14 int i;
15 Material *m, *sp;
16 printf("\n end of variables declarations");
17 l1=0.0;
18 l2=0.004;
19 loc=0.0;
20 k=2500.0;
21 thread_loop_c(t,d)
22 {
23 begin_c_loop_all(c,t)
24 {
25 C_CENTROID(xc,c,t);
26 loc=xc[0];
27 phiphi=((1.0/(1.0+exp(-2*k*(loc-l1))))-(1.0/(1.0+exp(-2.0*k*(loc-l2)))));
28 if(xc[0] < 0.002)
29 {
30 phiphi=1.0;
31 }
32 /* m=THREAD_MATERIAL(t);
33 mixture_species_loop(m,sp,i)
34 {
35 printf("\n %d",i);
36 }*/
37 C_T(c,t)=300.0+phiphi*1360.0;
38 C_YI(c,t,0)= 1.0*phiphi;
39 C_YI(c,t,1)= 1.0*(1-phiphi);
40 C_YI(c,t,2)= 0.0;
41 C_YI(c,t,4)= 0.0;
42 C_YI(c,t,4)= 0.0;
43 C_YI(c,t,5)= 0.0;
44 }
45 end_c_loop_all (c,t)

It gets hooked and executes without showing any error. However, only temperature gets initialized as per the equation. Mass fractions continue to remain zero.
Kedar G. Bhide 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
DEFINE_INIT in multiphase eulerian model isabel FLUENT 0 January 21, 2009 15:13
need help whith hooking UDF and DEFINE_INIT macro cax FLUENT 3 June 6, 2006 13:35
problem in solving "wave generation" problem san FLUENT 2 April 4, 2006 00:37
field initialization using DEFINE_INIT Maziar Mahzari FLUENT 0 September 14, 2005 03:36
about DEFINE_INIT mikhail FLUENT 1 October 14, 2000 00:17


All times are GMT -4. The time now is 22:39.