
[Sponsors] 
Help with unsteady calculation with source/sink UDF 

LinkBack  Thread Tools  Search this Thread  Display Modes 
March 8, 2016, 05:28 
Help with unsteady calculation with source/sink UDF

#1 
New Member
Rob Vervoort
Join Date: Nov 2015
Posts: 20
Rep Power: 8 
Hello everyone,
i am experiencing some problems with a UDF related to species transport in Fluent. The goal of my simulation is to model the effect of a filter unit, which filters out a certain concentration of species in the mixture template (with a certain efficiency). The filter unit does not have to be simulated as a whole, therefore I simplified the simulation by making a channel with a sink term in it. I made the following UDF for the sink term (also attached to the thread). #include "udf.h" /* UDF for sink term PM10 */ /**/ DEFINE_SOURCE(filter_pm10,c,t,dS,eqn) /* function name, thread and variable number */ /*In fluent, concentrations of the species are given as mass fraction or parts per million */ /*Source term has to be specified in kg/m3s, calculations have to be performed for the transformation */ { real x[ND_ND]; int source; real U_f = 3.0; /* Fill in the velocity of the inlet channel */ /* real h_f = 0.6; /* Fill in the height of the filter unit */ /* real f_f = h_f * U_f; /* Calculate the volume flow of the filter unit */ real l_icz = 0.0655; /* Fill in the length of the inlet cell zone */ real l_f = 1.8; /* Fill in the length of the filter unit */ real f_t = (l_fl_icz) / U_f; /* Calculation of the duration of the flow through the filter unit */ real PM10_eff = 1.0; /* Fill in the efficiency of the flter*/ real rho = C_R(c,t); /* Obtaining the density of the fluid */ real YI = C_YI(c,t,0); /* Obtaining the mass fraction of the species  index 0 > pm10*/ real YI_PPM = YI * (1*10^6); /* Converting the mass fraction of the species into PPM */ /* PPM = mass species x [mg] / mass species total [kg]*/ /* PPM = concentration species x [mg/m3] / density species total [kg/m3]*/ /* concentration species x [mg/m3] = PPM * density species total [kg/m3]*/ /* concentration species x [kg/m3] = concentration species x [mg/m3] * 10^6 */ real YI_kg_m3 = (YI_PPM * rho) * (10^(6)); /* Converting the mass fraction/PPM of the species into concentration [kg/m3] */ /* Air moves through the filter within a certain time and has a certain efficiency for that time*/ /* source term requires the input unit kg/m3s*/ /* Calculating the concentration that moves through the unit per second*/ real YI_kg_m3_s = YI_kg_m3 / f_t; /*obtained unit kg/m3s*/ C_CENTROID(x,c,t); source = 1* (YI_kg_m3_s * PM10_eff); /*source term in kg/m3s (results in a negative number = sink) */ dS[eqn] = 0; /*message("The density of the fluid: %d\n", rho); message("The mass fraction of pm10: %d\n", YI); message("pm10 PPM: %d\n", YI_PPM); message("concentration pm10 [kg/m3]: %d\n", YI_kg_m3); message("concentration pm10 through the filter [kg/m3s]: %d\n", YI_kg_m3_s); message("filtered amount of pm10 based on efficiency [kg/m3s]: %d", source); */ printf("filtered amount of pm10 based on efficiency [kg/m3s]: %d\n", source); return source; } How it should work: The sink term has to be based on the instantenous species concentrations in each time step of the simulation in the channel that was modelled. Imagine a PM10 concentration of 'x' at timestep 't', the sink term has to be 'x' times the efficiency of the filter. The sink term has to be updated at each time step 't'. I did some test simulations with the UDF and I noticed that the decay of the concentrations is linear. I modelled a closed volume with a fixed concentration at t=0 and subsequently I plotted the decay of the concentraions. I expected the decay to be exponential since when the concentrations become lower, also a lower amount of species is filtered out of the domain. To check if all the variables (in the UDF) that are used in the calculation are correct, I wanted to print the values of these variables in the fluent console at each time step (using printf or message as visible in the .c file). The values that are printed in the console are Always '0'. Could anyone help me with my UDF? Is this the correct way to make a UDF for a unsteady RANS simulation? Why is the printing of the variables used in the UDF going wrong? Thank you in advance, Rob 

November 13, 2016, 06:44 

#2 
New Member
Hamid Nankali
Join Date: Jan 2016
Posts: 3
Rep Power: 7 
i didn't fully check your code but took a look and as a quick reply , you cannot print real values with %d , or the values shown this way will be wrong , use %g instead in your printf if interpreting or message if compiling. a more efficient way to check for your values will be using UDMs and storing your values in them, then you can view them in post processing such as contours or ...
i also noticed that you are dealing with ppm, for low concentration of species be sure to use double precision and also check species convergence criteria in monitors i hope it helps 

Tags 
sink, source, udf 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
unsteady inlet velocity udf  jill  FLUENT  8  February 10, 2015 07:04 
UDF to update C_T(c,t) with Unsteady Flamelet Values  clarkie_49  Fluent UDF and Scheme Programming  5  September 19, 2013 18:27 
unsteady statistics for UDF  Luis  FLUENT  0  April 16, 2008 16:45 
unsteady calculation and Nusselt averaging  elyyan  FLUENT  0  August 4, 2006 15:32 
UDF :Unsteady concentration profile  umesh  FLUENT  4  July 13, 2003 18:07 