CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for surface tension (http://www.cfd-online.com/Forums/fluent-udf/105857-udf-surface-tension.html)

smhosseini August 10, 2012 16:49

UDF for surface tension
 
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?

subha_meter August 22, 2012 22:07

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 (Post 376501)
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 August 23, 2012 05:07

Hi Subha,
Thanks for your reply. I have mass transfer and I'm using species transport model. ;)

subha_meter August 23, 2012 08:11

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 (Post 378286)
Hi Subha,
Thanks for your reply. I have mass transfer and I'm using species transport model. ;)


smhosseini August 23, 2012 13:10

dear subha,
thanks for your attention, i am really sorry for not being completely clear in explaining the problem :o.
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.

subha_meter August 23, 2012 20:57

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 (Post 378394)
dear subha,
thanks for your attention, i am really sorry for not being completely clear in explaining the problem :o.
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 August 24, 2012 08:47

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.


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