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

mass source term to boundary cells adjacent to a wall

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By KaLium
  • 1 Post By Albert Lee

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 4, 2017, 20:39
Default mass source term to boundary cells adjacent to a wall
  #1
New Member
 
Join Date: Jun 2016
Posts: 17
Rep Power: 10
Kimia is on a distinguished road
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 liquid-vapor 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);
}
Kimia is offline   Reply With Quote

Old   June 5, 2017, 02:50
Default
  #2
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Is that a correct way to use F_C0 ?
KaLium is offline   Reply With Quote

Old   June 5, 2017, 03:07
Default
  #3
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Maybe you could use a face-loop:

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)
}
Kimia likes this.
KaLium is offline   Reply With Quote

Old   June 5, 2017, 04:57
Default
  #4
New Member
 
Join Date: Jun 2016
Posts: 17
Rep Power: 10
Kimia is on a distinguished road
Thank you so much for your help. I tried with face loop and it seems that it works!
I really appreciate your help.
Kimia is offline   Reply With Quote

Old   November 1, 2018, 08:02
Default
  #5
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10
vidyadhar is on a distinguished road
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_SAT-C_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_SAT-C_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_SAT-C_T(cell,mix_th))*fabs(v_s);
dS[eqn] = CON*fabs(v_s);
}
}
return LAT_HT*m_dot; }
Attached Files
File Type: txt UDF_evap_sources_at_desired_locations.txt (1.8 KB, 25 views)
vidyadhar is offline   Reply With Quote

Old   November 5, 2018, 06:49
Default
  #6
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10
vidyadhar is on a distinguished road
Quote:
Originally Posted by Kimia View Post
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 liquid-vapor 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);
}
Hi Kimia,


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)
vidyadhar is offline   Reply With Quote

Old   May 2, 2019, 02:47
Default
  #7
New Member
 
Join Date: Jul 2018
Posts: 7
Rep Power: 8
Albert Lee is on a distinguished road
Quote:
Originally Posted by vidyadhar View Post
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_SAT-C_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_SAT-C_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_SAT-C_T(cell,mix_th))*fabs(v_s);
dS[eqn] = CON*fabs(v_s);
}
}
return LAT_HT*m_dot; }
Hi vidyadhar!
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)
MohammedGhazi likes this.
Albert Lee is offline   Reply With Quote

Old   November 15, 2020, 11:53
Default
  #8
New Member
 
LouisK
Join Date: Aug 2013
Location: Shanghai,China
Posts: 10
Rep Power: 13
kangluyang is on a distinguished road
You can update the UDM using DEFINE_ADJUST in fluent during iteration.
kangluyang is offline   Reply With Quote

Reply

Tags
define macro, mass source term, on demand, source code, source terms


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
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
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 22:53
[Other] Adding solvers from DensityBasedTurbo to foam-extend 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


All times are GMT -4. The time now is 14:37.