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

UDF for surface tension

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 10, 2012, 16:49
Default UDF for surface tension
  #1
Member
 
Mohsen
Join Date: Jul 2012
Posts: 39
Rep Power: 4
smhosseini is on a distinguished road
Hi friends,
I want to determine surface tension. I wrote udf by using DEFINE_PROPERTY macro. I have an error and I know that this error is bcous of using this code:

Thread *liq = THREAD_SUB_THREAD(t,1);
x_water = C_YI(c,liq,1);
----------------------------------
liq is secondary phase and I have 4 species in liq phase.
is there anyone that knows how can I define mass fraction in secondary phase?
smhosseini is offline   Reply With Quote

Old   August 22, 2012, 22:07
Default
  #2
Member
 
subha_meter's Avatar
 
Subhasish Mitra
Join Date: Oct 2009
Location: Australia
Posts: 51
Rep Power: 7
subha_meter is on a distinguished road
The mass fraction (C_YI) macro is valid only when you use species transport model. Probably you are looking for volume fraction of secondary phase (C_VOF).

Quote:
Originally Posted by smhosseini View Post
Hi friends,
I want to determine surface tension. I wrote udf by using DEFINE_PROPERTY macro. I have an error and I know that this error is bcous of using this code:

Thread *liq = THREAD_SUB_THREAD(t,1);
x_water = C_YI(c,liq,1);
----------------------------------
liq is secondary phase and I have 4 species in liq phase.
is there anyone that knows how can I define mass fraction in secondary phase?
__________________
SM
subha_meter is offline   Reply With Quote

Old   August 23, 2012, 05:07
Default
  #3
Member
 
Mohsen
Join Date: Jul 2012
Posts: 39
Rep Power: 4
smhosseini is on a distinguished road
Hi Subha,
Thanks for your reply. I have mass transfer and I'm using species transport model.
smhosseini is offline   Reply With Quote

Old   August 23, 2012, 08:11
Default
  #4
Member
 
subha_meter's Avatar
 
Subhasish Mitra
Join Date: Oct 2009
Location: Australia
Posts: 51
Rep Power: 7
subha_meter is on a distinguished road
Hi,
I actually didn't notice that you are using species transport model. When you specify mass fractions (xi) of three species, the fourth one is automatically determined : 1 - sum(xi) (i= 0 to 2). What error message did you get? If you write the complete UDF here, it will be easy to debug it.

Regards,

Quote:
Originally Posted by smhosseini View Post
Hi Subha,
Thanks for your reply. I have mass transfer and I'm using species transport model.
__________________
SM
subha_meter is offline   Reply With Quote

Old   August 23, 2012, 13:10
Default
  #5
Member
 
Mohsen
Join Date: Jul 2012
Posts: 39
Rep Power: 4
smhosseini is on a distinguished road
dear subha,
thanks for your attention, i am really sorry for not being completely clear in explaining the problem .
my udf is:

#include "udf.h"
DEFINE_PROPERTY(surface_tension,c,t)
{
real x_water, sigma_water, sigma_MEA, sigma;
Thread *liq = THREAD_SUB_THREAD(t,1);
x_water = (1-C_YI(c,liq,3)) / (18.01 * ((1-C_YI(c,liq,3)) / 18.01 + C_YI(c,liq,3) / 61.08));
sigma_water = 76.0852 - 0.1609 * (C_T(c,t) - 273.15);
sigma_MEA = 53.082 - 0.1648 * (C_T(c,t) - 273.15);
sigma = (sigma_water - (sigma_water - sigma_MEA) * (1 + (0.63036 - (1.3e-5) * (C_T(c,t) - 273.15)) * x_water / (1 - ( 0.947 - 2e-5 * (C_T(c,t) - 273.15)) * x_water)) * (1 - x_water)) / 1000;
return sigma;
}
----------------------------------------------------------------------------------------------------
and my error is:
fluent received a fatal signal (segmentation violation).
I don't have error when i don't use C_YI.
smhosseini is offline   Reply With Quote

Old   August 23, 2012, 20:57
Default
  #6
Member
 
subha_meter's Avatar
 
Subhasish Mitra
Join Date: Oct 2009
Location: Australia
Posts: 51
Rep Power: 7
subha_meter is on a distinguished road
Hi sm,

It seems that your liquid phase contains water and MEA however you mentioned that there are 4 species in your liquid phase. What are the other two?

In your UDF you have accessed C_YI(c,liq,3) which is the mass fraction of 4th species. This will cause a "segment violation" problem if the appropriate component is not already defined in the species panel.

You already have the mass fraction of each component from C_YI(c,t,i) macro but if you would like to calculate the mole fraction of any component, you need to find out average molecular weight of the mixture. This can be done as follows,

#define N 4 /*maximum number of species*/

int i;
real mw[N],x[N],mol_frac[N],avg_mol_wt;
MATERIAL *mix,sp;
Thread *liq = THREAD_SUB_THREAD(t,1);
mix = THREAD_MATERIAL(liq);

mixture_species_loop(mix,sp,i)
{
mw[i] = MATERIAL_PROP(sp,PROP_mwi);
x[i] = C_YI(cell,liq,i);
avg_mol_wt + =mw[i]*x[i];
}

for(i=0;i<N;i++)
{
mol_frac[i] = C_YI(c,liq,i)/avg_mol_wt;
}

Hope it helps,

Quote:
Originally Posted by smhosseini View Post
dear subha,
thanks for your attention, i am really sorry for not being completely clear in explaining the problem .
my udf is:

#include "udf.h"
DEFINE_PROPERTY(surface_tension,c,t)
{
real x_water, sigma_water, sigma_MEA, sigma;
Thread *liq = THREAD_SUB_THREAD(t,1);
x_water = (1-C_YI(c,liq,3)) / (18.01 * ((1-C_YI(c,liq,3)) / 18.01 + C_YI(c,liq,3) / 61.08));
sigma_water = 76.0852 - 0.1609 * (C_T(c,t) - 273.15);
sigma_MEA = 53.082 - 0.1648 * (C_T(c,t) - 273.15);
sigma = (sigma_water - (sigma_water - sigma_MEA) * (1 + (0.63036 - (1.3e-5) * (C_T(c,t) - 273.15)) * x_water / (1 - ( 0.947 - 2e-5 * (C_T(c,t) - 273.15)) * x_water)) * (1 - x_water)) / 1000;
return sigma;
}
----------------------------------------------------------------------------------------------------
and my error is:
fluent received a fatal signal (segmentation violation).
I don't have error when i don't use C_YI.
__________________
SM
subha_meter is offline   Reply With Quote

Old   August 24, 2012, 08:47
Default
  #7
Member
 
Mohsen
Join Date: Jul 2012
Posts: 39
Rep Power: 4
smhosseini is on a distinguished road
Dear subha,
I have five species in liq phase. But three other species are in low concentration and I disregard them against water and MEA.
you can compute mole fraction exactly from this formula:

xi = (wi / Mi) / (wi / Mi + wj / Mj + . . . )

w and M is mass fraction and molecular weight respectively.
smhosseini is offline   Reply With Quote

Reply

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
surface tension gradient using UDF; surface tension gradient as function of temperatu marimuthusundar Fluent UDF and Scheme Programming 0 June 21, 2012 04:48
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
Surface tension gradient - Marangoni stress- through UDF marimuthusundar FLUENT 0 October 11, 2010 09:07
UDF macro for surface tension coefficient Frederik FLUENT 2 May 30, 2005 10:54
UDF for surface tension gradient kiran FLUENT 2 July 15, 2003 12:00


All times are GMT -4. The time now is 21:30.