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

UDF for evaporation

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 23, 2013, 20:05
Default UDF for evaporation
  #1
Member
 
pranab_jha's Avatar
 
Pranab N Jha
Join Date: Nov 2009
Location: Houston, TX
Posts: 83
Rep Power: 7
pranab_jha is on a distinguished road
Hello,

I am trying to model evaporation from a droplet. So I have to apply my evaporation model at the interface. I have a 2D axisymmetric case set up. But I am not able to get my UDF to work. Could someone take a look and let me know please. Comments are added for convenience.

SUmmary of the code:
-I have used the DEFINE_MASS_TRANSFER macro and defined all variables and initialized them.

-I calculated saturation pressure using a polynomial function of cell temperature.

-Then the mass fraction of each species is used to compute the molar fraction of required species.

-Then I compute the interfacial area density from the volume fraction gradient.

-Then using that, I compute the mass transferred by evaporation.

Thanks for any help!!!

Temporary solver memory has been turned on from the solve-set-expert menu in Fluent.

/************************************************** *********
UDF to apply mass transfer rate from liquid to gas phase at the interface
************************************************** **********/
#include "udf.h"
#include "sg_mphase.h"
#include "materials.h"

#define MW_W 18.0
#define MW_A 29.0
#define R 8.314
#define pi 3.14159
#define a_c 0.04 /*accommodation coefficient*/

DEFINE_MASS_TRANSFER(mass_transfer1, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index)
{
/************ Declare variables *********/
float m_lg, T_cell, P_cell, P_sat;
float NV_VEC(G);
float X_W, Y_W, Y_A;
float cur_ts;
Thread *w_liq, *gas_mix, *w_gas;
face_t f;
Domain *mix_domain, *pdomain;
int i, pdomain_index;
float area[ND_ND], A, ad, theta, cotan, len;

/******** Define variables *********/
mix_domain = Get_Domain(1);
/* pdomain = DOMAIN_SUB_DOMAIN(mixture_domain,1); */ /* For gas domain */
pdomain_index = 0;
pdomain = DOMAIN_SUB_DOMAIN(mix_domain,pdomain_index);

w_liq = THREAD_SUB_THREAD(mixture_thread, from_phase_index);
gas_mix = THREAD_SUB_THREAD(mixture_thread, to_phase_index);
w_gas = THREAD_SUB_THREAD(mixture_thread, to_species_index);

T_cell = C_T(c,mixture_thread); /*cell mixture temperature*/
P_cell = C_P(c,mixture_thread); /*cell mixture pressure*/
m_lg = 0.;
cur_ts = CURRENT_TIMESTEP; /* real time step size (in seconds)*/

/* compute saturation pressure for water vapor using polynomial fit */
P_sat = 0.000001*pow(T_cell,5) - 0.001*pow(T_cell,4) + 0.681*pow(T_cell,3) - 203.9*pow(T_cell,2) + 39482*T_cell + 4000000;

/* calculate molar fraction X_W from mass fraction Y_W */
Y_W = C_YI(c,gas_mix,0); /* index for water vap = 0, air = 1*/
Y_A = C_YI(c,gas_mix,1);
X_W = (Y_W*29)/((29*Y_W) + (18*Y_A));

/**** Compute the interfacial area density ****/
NV_V(G,=,C_VOF_G(c,w_liq)); /* vof gradient vector assignment*/

theta = atan(G[0]/G[1]); /* compute angle of VOF gradient vector, n1/n2 because of how geometry is set up in Fluent */
cotan = cos(theta) / sin(theta); /* compute cotangent of angle*/

A = C_VOLUME(c,mixture_thread)/(2*pi); /* in 2D- axis area computed from volume */

len = sqrt((2*C_VOF(c,w_liq)*A/cotan) + (2*C_VOF(c,w_liq)*A*cotan)); /* compute length of interface in a cell */

ad = len/A; /* calculate interfacial area density*/
/***** Computed the area density ad = length of interface / area of cell ***/

if (C_VOF(c, w_liq) != 0.0 && C_VOF(c, w_liq) != 1.0)
{
Message("AD = %f, theta = %f\n",ad, theta);

/* Compute m_lg only if P_sat > (Pcell*XW) */
if (P_sat - (P_cell*X_W) > 0.0)
{
m_lg = cur_ts * ad *(2*a_c/(2-a_c)) * sqrt(MW_W/(2*pi*R)) * ((P_sat - (P_cell*X_W)) / sqrt(T_cell));
}
else
{ m_lg = 0.0;}
}
else
{ m_lg = 0.0;}

return (m_lg); /* return value of mass transfer rate */

}
pranab_jha is offline   Reply With Quote

Old   October 25, 2013, 11:32
Default
  #2
Member
 
pranab_jha's Avatar
 
Pranab N Jha
Join Date: Nov 2009
Location: Houston, TX
Posts: 83
Rep Power: 7
pranab_jha is on a distinguished road
Just a quick update. The problem has not yet been solved. But if I remove the line
NV_V(G,=,C_VOF_G(c,w_liq)); and related dependents, the code works fine.

Although, I have used the option of keeping the solver temporary memory, C_VOF_G is giving me the issue, which is strange. Still working on it. If someone has any suggestions, please do post.

Thanks.
pranab_jha is offline   Reply With Quote

Old   December 2, 2013, 09:56
Default
  #3
New Member
 
anonymous
Join Date: Nov 2013
Posts: 9
Rep Power: 3
MichaelVS is on a distinguished road
Dear pranab_jha,

Could you please specify the solution if you find one?
I am facing exactly the same problem with C_VOF_G.
MichaelVS is offline   Reply With Quote

Old   February 20, 2015, 09:02
Default
  #4
New Member
 
Omar Osama Mohamed
Join Date: Nov 2014
Posts: 16
Rep Power: 2
Omarspace is on a distinguished road
Hi , I am sorry but did no body of you find a solution for that ?
I checked the sg_mphase.h and i found the line
#define C_VOF_G(c,t) C_STORAGE_R_NV(c,t,SV_VOF_G)
and working with expert mood without freeing my memory i think VOF data should be saved .. Actually it is sent to my udf with zero value all of times despite it has value when i plot it in Fluent Solver .. did anyone find solution for this ?
Omarspace is offline   Reply With Quote

Reply

Tags
evaporation, multiphase, species

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 06:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
Dynamic Mesh UDF Qureshi FLUENT 1 December 2, 2009 01:27
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 19:11.