|
[Sponsors] |
August 10, 2012, 17:49 |
UDF for surface tension
|
#1 |
Member
Mohsen
Join Date: Jul 2012
Posts: 49
Rep Power: 14 |
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? |
|
August 22, 2012, 23:07 |
|
#2 | |
Member
Subhasish Mitra
Join Date: Oct 2009
Location: Australia
Posts: 56
Rep Power: 17 |
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:
__________________
SM |
||
August 23, 2012, 06:07 |
|
#3 |
Member
Mohsen
Join Date: Jul 2012
Posts: 49
Rep Power: 14 |
Hi Subha,
Thanks for your reply. I have mass transfer and I'm using species transport model. |
|
August 23, 2012, 09:11 |
|
#4 |
Member
Subhasish Mitra
Join Date: Oct 2009
Location: Australia
Posts: 56
Rep Power: 17 |
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,
__________________
SM |
|
August 23, 2012, 14:10 |
|
#5 |
Member
Mohsen
Join Date: Jul 2012
Posts: 49
Rep Power: 14 |
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. |
|
August 23, 2012, 21:57 |
|
#6 | |
Member
Subhasish Mitra
Join Date: Oct 2009
Location: Australia
Posts: 56
Rep Power: 17 |
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:
__________________
SM |
||
August 24, 2012, 09:47 |
|
#7 |
Member
Mohsen
Join Date: Jul 2012
Posts: 49
Rep Power: 14 |
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. |
|
January 26, 2022, 06:06 |
|
#8 |
New Member
Join Date: Jan 2022
Posts: 3
Rep Power: 4 |
Hi,
I am working on a project about welding. I use FLUENT vof to simulate the melting pool . During the calculation, I found that the surface tension define in my udf code have some problems. Here is my code: ------------------------------------------------------------------- DEFINE_PROPERTY(surf_tension,c,t) { real surf; int curr,i,j; real temp1=C_T(c,t); if(temp1>=1700) surf=1.0-0.0003*(temp1-1700); else if(temp1>=2980) surf=0.41; else surf=1.0; return surf; } ------------------------------------------------------------------- My surface tension seems like effect all the areas when temp1>=1700 and causes a whole area shape changing to my model. I think it should only effect the cell temp1>=1700. Is there anyone know what happen to that? |
|
February 2, 2022, 20:14 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
code seems to be correct
__________________
best regards ****************************** press LIKE if this message was helpful |
|
June 18, 2022, 02:14 |
|
#10 |
New Member
Brian Huffman
Join Date: Jun 2022
Posts: 4
Rep Power: 4 |
Hey there anyone it may help. I know this reply is late, but this post helped me on my journey and I would like to answer.
I have the same objective as this post states, to write a UDF that controls the surface tension coefficient by analyzing the mixture species fraction. The following code seems to be the answer: DEFINE_PROPERTY(Custom_Surface_Tension, c, t) { Domain *mix; mix = Get_Domain(1); Thread *mix_thread = Lookup_Thread(mix, 2); Thread *sec_phase = THREAD_SUB_THREAD(mix_thread,1); real sigma, xm; xm = C_YI(c,sec_phase,1); sigma = 0.043*xm*xm - 0.1081*xm + 0.0702; return sigma; } The key part being the first 4 lines of code: Lines 1-2. grab the mixture domain pointer (domain ID=1 for mixture domain) & assign variable *mix. Line 3. Find the relevant thread (domain ID=1 for mixture, Zone ID=2 for fluid), assign the lookup to a variable *mix_thread (this is a mixture level thread) Line 4. Assign a phase level pointer (*sec_phase) to secondary phase thread *sec_phase now has the required data to proceed with mass fraction function C_YI |
|
|
|
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 05:48 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
Surface tension gradient - Marangoni stress- through UDF | marimuthusundar | FLUENT | 0 | October 11, 2010 10:07 |
UDF macro for surface tension coefficient | Frederik | FLUENT | 2 | May 30, 2005 11:54 |
UDF for surface tension gradient | kiran | FLUENT | 2 | July 15, 2003 13:00 |