
[Sponsors] 
June 15, 2020, 08:20 
Why my udf for condensation is useless

#1 
New Member
Sumz
Join Date: Jun 2020
Posts: 5
Rep Power: 4 
Hello Everyone,
I am trying to use the udf code to simulate intube condensation of the steam and air mixture.The VOF model and the species transport model were enabled in Fluent, and the udf code was compiled and loaded without error. A liquid phase mass source term, a gas phase mass source term, and an energy source term are defined. My idea is to judge whether it is a vaporliquid interface firstly, if it is, then assign a value to the source term, if not, then continue to judge whether it is a wall surface. The thickness of the first layer of my adherent mesh is 0.03mm. Here's my code. There's no condensation after running the case. Anybody know why that is? Any comments would be appreciated. #include "udf.h" #include "sg.h" #include "sg_mphase.h" #include "flow.h" #include "mem.h" #define air_molecular 28.966 #define vapor_molecular 18.0152 #define lam 0.8 #define standard_temper 298.15 #define standard_pressure 101325 #define standard_diffusivity 2.56e5 #define SYMMETRY 13 #define WALL_NUMBER1 12 #define prim_index 0 #define index_evap_primary 1 #define p_op 101325 int phase_domain_index; real face_center[ND_ND], cell_center[ND_ND], a[ND_ND], b[ND_ND]; real p, diffusivity, Wvol; real cell_vapor_pressure, wall_temper, wall_pressure; real NV_VEC(A),j,i; real area, area_density, mass_transfer_coeff, B1, area1; real water_temper, water_satpressure; real vapor_density,u,v; int n; Domain *domain1; cell_t c; Thread *t; Thread *tp; Thread *ts; Thread *tf,*tb; face_t fa; face_t fb ; real source; double latent_heat(double Tsat) { double sum; sum=2501.72.4114*(Tsat273.15); return sum; } DEFINE_SOURCE(vap_src,cell,first,dS,eqn) { Thread *mixer, *sec_th; Thread *sym; face_t f; real m_dot_first; real mass_dot; mixer = THREAD_SUPER_THREAD(first); sec_th = THREAD_SUB_THREAD(mixer,1); if (C_VOF(cell, first) > 0&&C_VOF(cell, first) < 1) { mass_dot = 2.56e4; dS[eqn] =0; } else { mass_dot =0; dS[eqn]=0; c_face_loop(cell, mixer, n) { fa = C_FACE(cell, mixer, n); tf = C_FACE_THREAD(cell, mixer, n); F_CENTROID(face_center, fa, tf); if (face_center[0] < 1e5) { mass_dot = 2.56e4; dS[eqn] =0; } } } source = mass_dot; return source; } DEFINE_SOURCE(liq_src, cell, sec_th, dS, eqn) { Thread *mixer, *first; Thread *sym; face_t f; real mass_dot; mixer = THREAD_SUPER_THREAD(sec_th); first = THREAD_SUB_THREAD(mixer, 0); if (C_VOF(cell, sec_th) > 0&&C_VOF(cell, sec_th) < 1) { mass_dot = 2.56e4; dS[eqn] =0; } else { mass_dot =0; dS[eqn]=0; c_face_loop(cell, mixer, n) { fa = C_FACE(cell, mixer, n); tf = C_FACE_THREAD(cell, mixer, n); F_CENTROID(face_center, fa, tf); if (face_center[0]< 1e5) { mass_dot = 2.56e4; dS[eqn] =0; } } } source = mass_dot; return source; } DEFINE_SOURCE(enrg_src, cell, mixer, dS, eqn) { Thread *first, *sec_th; Thread *sym; face_t f ; real m_dot, latentheat; real mass_dot; first = THREAD_SUB_THREAD(mixer, 0); sec_th = THREAD_SUB_THREAD(mixer, 1); /************************************************/ if (C_VOF(cell, sec_th) > 0&&C_VOF(cell, sec_th) < 1) { mass_dot = 2.56e4; dS[eqn] =0; } else { latentheat = latent_heat(C_T(cell, first)); mass_dot =0; dS[eqn]=0; c_face_loop(cell, mixer, n) { fa = C_FACE(cell, mixer, n); tf = C_FACE_THREAD(cell, mixer, n); F_CENTROID(face_center, fa, tf); if (face_center[0] < 1e5) { mass_dot = 2.56e4; dS[eqn] =0; } } } m_dot = mass_dot; return latentheat*m_dot; } 

June 15, 2020, 08:35 
The code

#2 
Senior Member

Your logic may be right but the code is very crude. First of all, C_VOF will always be less than 1, until the case diverges. So, you don't need to check for that. Secondly, the source UDF is executed over each cell and computers do not take 1 as 1; it could be 0.99999999999999. That means the code is being executed almost in each cell. And even in the energy source, the value of the source term is equal to mass.
What's the reason behind using a UDF and not using inbuilt model?
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. 

June 15, 2020, 09:13 

#3 
New Member
Sumz
Join Date: Jun 2020
Posts: 5
Rep Power: 4 
First of all,thank you very much for your reply. In my set, the primary phase is the gas mixture, the secondary phase is liquid water. At the initial time there is no existence of the secondary phase. C_VOF is used to determine gasliquid interface, at the initial moment, C_VOF values of all grid should be equal to 0, when the liquid filled with grid, C_VOF should be equal to 1, in both cases,the source terms are 0. The value of the energy source term is the mass times the latent heat, and I defined a function to find the latent heat. The above is my understanding,but I do not konw whether it is accurate. In addition to this,even the udf is crude,there should be a feedback,but there is no condensation in my case at all.As for the last question,I have read some relevant papers and found that many of them used udf, so I decided to try it.


June 15, 2020, 10:10 
Udf

#4 
Senior Member

If someone has used UDF, they might have had reasons for that, such as, older versions of Fluent.
If there is no liquid phase initially, then the code is supposed to add some liquid mass in the cells adjacent to the walls. But, since it is liquid, its volume would be extremely low, most likely below the cutoff value for the volume fraction. Default is 1e6. Implying that nothing would happen and eventually, all the mass will be lost.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. 

June 15, 2020, 22:06 

#5 
New Member
Sumz
Join Date: Jun 2020
Posts: 5
Rep Power: 4 
Okay, I'll try. Thank you, buddy！


Tags 
condensation, udf 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
udf for one dimensional linear motion based on force  maccheese  Fluent UDF and Scheme Programming  2  September 1, 2019 03:18 
can anyone help me about the udf of dynamic contact angle in FLUENT?  Albert Lee  FLUENT  0  July 1, 2018 09:21 
Save output of udf in another udf!  JuanJoMex  FLUENT  0  February 8, 2018 13:43 
UDF Compilation Error  Loading Library  COMMON Problem! Help!  robtheslob  Fluent UDF and Scheme Programming  8  July 24, 2015 01:53 
UDF parallel error: chipexec: function not found?????  shankara.2  Fluent UDF and Scheme Programming  1  January 16, 2012 23:14 