
[Sponsors] 
mass source term to boundary cells adjacent to a wall 

LinkBack  Thread Tools  Search this Thread  Display Modes 
June 4, 2017, 20:39 
mass source term to boundary cells adjacent to a wall

#1 
New Member
Join Date: Jun 2016
Posts: 17
Rep Power: 6 
Hi all,
I am trying to write a UDF code for applying mass source term only to those cells adjacent to a wall boundary. The idea is to model evaporation by considering a static interface between water and vapor and applying convective heat transfer and mass source term to it. I have defined the interface as a wall and written the code below to assign proper mass source terms to those cells adjacent to it. I am sure the code is not right. I will be beyond grateful if you could help me to write it properly. Thank you so much. #include "udf.h" //get the boundary cells DEFINE_ON_DEMAND(on_demand_calc) { Domain *d; face_t f; cell_t c; Thread *t; real source; d= Get_Domain(1); Thread *tb = Lookup_Thread(d,1); //Get boundary thread, wall zone ID is 1 // which is assumed to be the liquidvapor interface thread_loop_c(t,d) { begin_c_loop(c,t) { if (c == F_C0(f,tb)) //i.e if cell is adjacent to the wall boundary { source= 100; C_UDMI(c,t,0)=source; } else { source=0; C_UDMI(c,t,0)=source; } } end_c_loop(c,t) } } //define the source term DEFINE_SOURCE(mass_source, c, t, dS, eqn) { //Thread *t; //cell_t c; real mdot; mdot=C_UDMI(c,t,0); return (mdot); } 

June 5, 2017, 02:50 

#2 
Senior Member
KalEl
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 5 
Is that a correct way to use F_C0 ?


June 5, 2017, 03:07 

#3 
Senior Member
KalEl
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 5 
Maybe you could use a faceloop:
thread = Lookup_Thread(domain,P_ID); begin_f_loop(f,thread) { c0 = F_C0(f,thread); t0 = THREAD_T0(thread); source= 100.0; C_UDMI(c0,t0,0)=source; end_f_loop(f,thread) } 

June 5, 2017, 04:57 

#4 
New Member
Join Date: Jun 2016
Posts: 17
Rep Power: 6 
Thank you so much for your help. I tried with face loop and it seems that it works!
I really appreciate your help. 

November 1, 2018, 08:02 

#5 
Senior Member
vidyadhar
Join Date: Jul 2016
Posts: 137
Rep Power: 6 
Hello Kimia!
I am also trying to write UDF for modeling evaporation (copied below and also attached herewith). My problem involves evaporation of a liquid into its vapor. I have few queries: 1. Whether this way of writing UDF is okay? or can you help me in writing UDF for simulating evaporation. 2. Whether source terms for evaporation mass flux are to be applied over the entire liquid and vapor regions? or in a particular cells near the interface? How to apply the source terms at a particular region? 3. How to get the calculated mass fluxes in Fluent GUI? whether UDF will create a field for the evaporative mass flux in Fluent? Thanks in advance! #include "udf.h" #include "sg_mphase.h" #define T_SAT 343 #define LAT_HT 2455.1345e3 #define CON 20 DEFINE_SOURCE(vap_src, cell, pri_th, dS, eqn) { Thread *mix_th, *sec_th; real m_dot_v; real v_s; mix_th = THREAD_SUPER_THREAD(pri_th); sec_th = THREAD_SUB_THREAD(mix_th, 1); /*m_dot_v=0.;*/ if (NULL != THREAD_STORAGE(mix_th,SV_VOF_G)) { v_s = C_VOF_G(cell,mix_th)[0]; } if(C_T(cell,mix_th)>=T_SAT) { if(0<C_VOF(cell,mix_th)<1) { m_dot_v = CON*(C_T(cell,mix_th)T_SAT)*fabs(v_s); dS[eqn] = 0.; } } if(C_T(cell,mix_th)<=T_SAT) { if(0<C_VOF(cell,mix_th)<1) { m_dot_v = CON*(T_SATC_T(cell,mix_th))*fabs(v_s); dS[eqn] = 0.; } } return m_dot_v ; } DEFINE_SOURCE(liq_src, cell, sec_th, dS, eqn) { Thread *mix_th, *pri_th; real m_dot_l; real v_s; mix_th = THREAD_SUPER_THREAD(sec_th); pri_th = THREAD_SUB_THREAD(mix_th, 0); /*m_dot_l=0.;*/ if (NULL != THREAD_STORAGE(mix_th,SV_VOF_G)) { v_s = C_VOF_G(cell,mix_th)[0]; } if(C_T(cell,mix_th)>=T_SAT) { if(0<C_VOF(cell,mix_th)<1) { m_dot_l = CON*(C_T(cell,mix_th)T_SAT)*fabs(v_s); dS[eqn] = 0.; } } if(C_T(cell,mix_th)<=T_SAT) { if(0<C_VOF(cell,mix_th)<1) { m_dot_l = CON*(T_SATC_T(cell,mix_th))*fabs(v_s); dS[eqn] =0.; } } return m_dot_l; } DEFINE_SOURCE(enrg_src, cell, mix_th, dS, eqn) { Thread *pri_th, *sec_th; real m_dot; real v_s; pri_th = THREAD_SUB_THREAD(mix_th, 0); sec_th = THREAD_SUB_THREAD(mix_th, 1); if (NULL != THREAD_STORAGE(mix_th,SV_VOF_G)) { v_s = C_VOF_G(cell,mix_th)[0]; } if(C_T(cell,mix_th)>=T_SAT) { if(0<C_VOF(cell,mix_th)<1) { m_dot = CON*(C_T(cell,mix_th)T_SAT)*fabs(v_s); dS[eqn] = CON*fabs(v_s); } } if(C_T(cell,mix_th)<=T_SAT) { if(0<C_VOF(cell,mix_th)<1) { m_dot = CON*(T_SATC_T(cell,mix_th))*fabs(v_s); dS[eqn] = CON*fabs(v_s); } } return LAT_HT*m_dot; } 

November 5, 2018, 06:49 

#6  
Senior Member
vidyadhar
Join Date: Jul 2016
Posts: 137
Rep Power: 6 
Quote:
Could you get success in executing the evaporation UDF. In the UDF that you have written in this post: You are storing source in User defined memory under DEFINE_ON_DEMAND. Then you are using UDMI(c0,t0,0) in DEFINE_SOURCE. Since DEFINE_ON_DEMAND executes only once, if the source term is a function of temperature, how to change the UDF so that in each iteration the mdot term will be updated? (As in your case, you have used source term=100 which is a constant) 

May 2, 2019, 02:47 

#7  
New Member
Join Date: Jul 2018
Posts: 7
Rep Power: 4 
Quote:
Have you solved this kind of simulation of evaporation and using VOF? Recently, I also tried to simulation the evaporation in a tank, the udf of mass transfer are same as your post. When I simulated for some time, the temperature distribution in the tank is weird. It shows that the temperature of vapor phase reaches the maximum of temperature distribution (I loaded the heat source at the liquid side). Have you confronted this kind of problem? If yes, how did you solved it ? Could you do me a favor? Thank you very much! (The question I was posted on Using Fluent VOF and Lee model to simulate mass transfer of two phase) 

November 15, 2020, 11:53 

#8 
New Member
LouisK
Join Date: Aug 2013
Location: Shanghai,China
Posts: 10
Rep Power: 9 
You can update the UDM using DEFINE_ADJUST in fluent during iteration.


Tags 
define macro, mass source term, on demand, source code, source terms 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Centrifugal fan  j0hnny  CFX  13  October 1, 2019 14:55 
Multiphase flow  incorrect velocity on inlet  Mike_Tom  CFX  6  September 29, 2016 02:27 
[foamextend.org] problem when installing foamextend1.6  Thomas pan  OpenFOAM Installation  7  September 9, 2015 22:53 
[Other] Adding solvers from DensityBasedTurbo to foamextend 3.0  Seroga  OpenFOAM Community Contributions  9  June 12, 2015 18:18 
Question about heat transfer coefficient setting for CFX  Anna Tian  CFX  1  June 16, 2013 07:28 