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

Why my udf for condensation is useless

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 15, 2020, 07:20
Default Why my udf for condensation is useless
  #1
New Member
 
Sumz
Join Date: Jun 2020
Posts: 5
Rep Power: 5
Su M Z is on a distinguished road
Hello Everyone,
I am trying to use the udf code to simulate in-tube 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 vapor-liquid 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.56e-5
#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.7-2.4114*(Tsat-273.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.56e-4;
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] < 1e-5)
{
mass_dot = -2.56e-4;
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.56e-4;
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]< 1e-5)
{
mass_dot = 2.56e-4;
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.56e-4;
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] < 1e-5)
{
mass_dot = -2.56e-4;
dS[eqn] =0;



}
}
}

m_dot = -mass_dot;
return latentheat*m_dot;
}
Su M Z is offline   Reply With Quote

Old   June 15, 2020, 07:35
Default The code
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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?
Morice likes this.
__________________
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.
vinerm is offline   Reply With Quote

Old   June 15, 2020, 08:13
Default
  #3
New Member
 
Sumz
Join Date: Jun 2020
Posts: 5
Rep Power: 5
Su M Z is on a distinguished road
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 gas-liquid 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.
Su M Z is offline   Reply With Quote

Old   June 15, 2020, 09:10
Default Udf
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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 cut-off value for the volume fraction. Default is 1e-6. 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.
vinerm is offline   Reply With Quote

Old   June 15, 2020, 21:06
Thumbs up
  #5
New Member
 
Sumz
Join Date: Jun 2020
Posts: 5
Rep Power: 5
Su M Z is on a distinguished road
Okay, I'll try. Thank you, buddy!
Su M Z is offline   Reply With Quote

Reply

Tags
condensation, udf


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
udf for one dimensional linear motion based on force maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 02:18
can anyone help me about the udf of dynamic contact angle in FLUENT? Albert Lee FLUENT 0 July 1, 2018 08:21
Save output of udf in another udf! JuanJoMex FLUENT 0 February 8, 2018 12:43
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 00:53
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14


All times are GMT -4. The time now is 01:18.