DEFINE_INIT PROBLEM
/* 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) } } |
DEFINE_INIT PROBLEM DESCRIPTION
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? |
Re: DEFINE_INIT PROBLEM DESCRIPTION
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,
|
Re: DEFINE_INIT PROBLEM DESCRIPTION
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. |
UDF not initialzing species mass fraction
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. |
All times are GMT -4. The time now is 11:31. |