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

Species mass transfer UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 31, 2020, 09:02
Default
  #21
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
I meant to say, the conditional statement is not working. The mass transfer is working on the full fluid phase. Rest of it is fine.

Thanks.
Anshs is offline   Reply With Quote

Old   May 31, 2020, 15:43
Default Condition statement
  #22
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
What do you mean by not working? Is it not compiling, or giving run-time error, or giving wrong values?

Fluent does not accept // for comments. So, either use /* */ or remove comments altogether.
The condition statement for interfacial mass transfer is not working.

Thanks
Anshs is offline   Reply With Quote

Old   June 2, 2020, 05:44
Default Volume Fraction Value
  #23
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
That won't have any effect if both the phases are rather well-mixed, otherwise, it should work. Try plotting volume fraction of phases.
__________________
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 2, 2020, 07:18
Default Volume fraction contours
  #24
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
That won't have any effect if both the phases are rather well-mixed, otherwise, it should work. Try plotting volume fraction of phases.
I did plot the volume fraction.

The image below represents the mass transfer which I have used

Screenshot 2020-06-02 at 4.37.19 PM.jpg

Initial Volume fraction: Water
water.jpg
Oil
oil.jpg

Phase interaction: mass transfer: after 100 timesteps.

Screenshot 2020-06-02 at 3.41.03 PM.jpg
Anshs is offline   Reply With Quote

Old   June 2, 2020, 07:53
Default Phases
  #25
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
How many phases do you have? Since the right-most region neither has water nor oil. So, is there a third phase?
Anshs 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 2, 2020, 08:36
Default Phases
  #26
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
How many phases do you have? Since the right-most region neither has water nor oil. So, is there a third phase?
Yes there re 3 phases.

Screenshot 2020-06-02 at 6.05.48 PM.png

Screenshot 2020-06-02 at 6.05.54 PM.png
Anshs is offline   Reply With Quote

Old   June 2, 2020, 08:42
Default Mass Transfer
  #27
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
Do you want mass transfer from gas to water or gas to oil? You have to ensure that you have selected correct phases under From and To in Mass Transfer Panel.
__________________
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 2, 2020, 09:17
Default water to oil.
  #28
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Do you want mass transfer from gas to water or gas to oil? You have to ensure that you have selected correct phases under From and To in Mass Transfer Panel.
None, I want mass transfer (species) from water to oil. I have posted the 'phase interaction tab' in the reply as well. you may have a look.

Thanks
Anshs is offline   Reply With Quote

Old   June 2, 2020, 09:27
Default Water to Oil
  #29
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 post does not contain Mass Transfer Tab. Anyway, then make changes to your code and use oil in place of gas. Though that is just a variable name yet it helps to remove ambiguity. Furthermore, to debug the code, try to make the condition even stricter. Use product of C_VOF(c, t, water) & C_VOF(c, t, oil) to define m_lg. This will have a non-zero value only at the interface of water and oil.
Anshs 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 4, 2020, 13:58
Default problem with 3rd phase.
  #30
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Your post does not contain Mass Transfer Tab. Anyway, then make changes to your code and use oil in place of gas. Though that is just a variable name yet it helps to remove ambiguity. Furthermore, to debug the code, try to make the condition even stricter. Use product of C_VOF(c, t, water) & C_VOF(c, t, oil) to define m_lg. This will have a non-zero value only at the interface of water and oil.
The mass transfer is working fine between water and oil phase, but it is also operating in some region between water and air (3rd phase).

Phases: Screenshot 2020-06-04 at 11.19.16 PM.jpg

Mass transfer rate: mt.jpg

UDF:

Code:
#include "udf.h"



DEFINE_MASS_TRANSFER(interface_transfer, cell, thread, from_index, from_species_index, to_index, to_species_index)

{

real m_lg;


Thread *water = THREAD_SUB_THREAD(thread, from_index);

Thread *oil = THREAD_SUB_THREAD(thread, to_index);



m_lg = 0.0;




if ( C_VOF(cell,water)*C_VOF(cell,oil) != 0 )

{

/*m_lg = 0.1*C_VOF(cell,gas)*C_R(cell,gas)*

fabs(t_sat -C_T(cell,gas))/t_sat;

m_lg = 0.1* C_VOF(cell,gas) * C_R(cell,gas) * C_YI(cell , gas , 0) ; */

m_lg = 100;

/* here C_YI(c, gas, 0 ), denotes species mass fraction of 1st species in the mixture denoted by phase 'gas'.*/

}


else m_lg = 0.0;
return (m_lg);
Anshs is offline   Reply With Quote

Old   June 4, 2020, 14:09
Default Three Phases
  #31
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
That's because there are three phases. I suggested product of volume fractions assuming there are two phases. But with three phases, even with 0.1 volume fractions of water and oil, the condition matches, despite there being 80% air. So, you have to use a condition wherein the air content is extremely low. Ideally, this would mean that the product of volume fractions of oil and water should be 0.25. But that's ideal case, not practical. So, a better approach would be to ensure that the sum of water and oil volume fraction is close to 1, say, above 0.95, as well as their product is close to 0.25, say, above 0.21. These two conditions should get you closer to expected result.
__________________
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 4, 2020, 14:55
Default
  #32
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
That's because there are three phases. I suggested product of volume fractions assuming there are two phases. But with three phases, even with 0.1 volume fractions of water and oil, the condition matches, despite there being 80% air. So, you have to use a condition wherein the air content is extremely low. Ideally, this would mean that the product of volume fractions of oil and water should be 0.25. But that's ideal case, not practical. So, a better approach would be to ensure that the sum of water and oil volume fraction is close to 1, say, above 0.95, as well as their product is close to 0.25, say, above 0.21. These two conditions should get you closer to expected result.
Yes, but the triangular region has th water phase there! so how is the previous surface condition getting satisfied there?

Thanks
Anshs is offline   Reply With Quote

Old   June 4, 2020, 16:03
Default Condition
  #33
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
That's because the condition is for the product not to be 0, so, even if it is 0.9999 * 0.00001, it's not 0.
__________________
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 4, 2020, 16:08
Default
  #34
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
That's because the condition is for the product not to be 0, so, even if it is 0.9999 * 0.00001, it's not 0.
Okay so basically that's because of the limit to which the solver is storing data!

Thanks!
Anshs is offline   Reply With Quote

Old   June 4, 2020, 16:33
Default Precision
  #35
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
Solver stores data up to about 32 or even more decimal places.
__________________
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   July 28, 2020, 08:30
Default UDF help for the same thread
  #36
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Solver stores data up to about 32 or even more decimal places.
I have written the code where 'DEFINE_ADJUST(store_gradient, domain)' is calculating the area density of the cell, so that it can be used in the 'mass transfer' expression.


1. I think I can't write the function like this inside another function.
2. Shall I separate the area function ( DEFINE_ADJUST(store_gradient, domain) ) outside the mass transfer function?



Code:
#include "udf.h"
#include "math.h"


DEFINE_MASS_TRANSFER(interface_transfer, cell, thread, from_index, from_species_index, to_index, to_species_index)

{

real m_lg;
real c_tg;
real k_g;


Thread *water = THREAD_SUB_THREAD(thread, from_index);

Thread *oil = THREAD_SUB_THREAD(thread, to_index);

m_lg = 0.0;
c_tg = 0.0;
k_g = 0.0;

if ( ( C_VOF(cell,water)*C_VOF(cell,oil) > 0.21 ) && (C_VOF(cell,water) + C_VOF(cell,oil) >0.95) )

{

k_g = 0.4 * sqrt(C_DIFF_L(cell,water,0,1)) * pow((C_D(cell,water)/ C_MU_T(cell,water)), 0.25)

c_tg = C_VOF(cell,water) * C_R(cell,water) * C_YI(cell , water , 0) ;

m_lg = k_g * (NV_MAG(C_VOF_G(c,ppt))) * ( 4e-5 - c_tg ) ;


}

else m_lg = 0.0;

return (m_lg);

}
Anshs is offline   Reply With Quote

Old   July 28, 2020, 08:54
Default Modifying this in the above thread.
  #37
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 7
Anshs is on a distinguished road
Quote:
Originally Posted by Anshs View Post
Yeah, I got your point. In the mass transfer tab of phase interaction, we will need to put on these specific details.

One more thing, if I want to further modify the transfer rate as given in the picture below.

Attachment 78037

Code:
#include "udf.h"

 

DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,

from_species_index, to_index, to_species_index)

{

   real m_lg;

   real T_SAT = 373.15;

   Thread *gas = THREAD_SUB_THREAD(thread, from_index);      // gas phase

   Thread *liq = THREAD_SUB_THREAD(thread, to_index);          // liquid phase

 

   m_lg = 0.;           // initialisation 


   if ((m_lg == 0. ) && (C_T(cell, gas) <= T_SAT))

     {

       m_lg = 0.1*C_VOF(cell,gas)*C_R(cell,gas)*

         fabs(T_SAT-C_T(cell,gas))/T_SAT;

       
         D = DEFINE_DIFFUSIVITY*(*name,*c,*t,*I)

         X_co2_eq= 0.1;

         X_co2 = C_VOF(cell,gas) * C_R(cell,gas) * C_YI(c , gas , 0)*


         k = 0.4*sqrt(D)*(C_D(c,t)/ C_MU_T(c,t)).^0.25



         //a = interfacial area/volume 

 , I have the separate UDF for this

         m_lg = k*a* ( X_co2_eq - X_co2);

         //here C_YI(c, gas, 0 ), denotes species mass fraction of 1st species in 
         the mixture denoted by phase 'gas'.

      }

   return (m_lg);
Is this correct? Thanks

Modifying this in the above thread.
Anshs is offline   Reply With Quote

Old   August 18, 2022, 20:19
Default
  #38
New Member
 
vikash
Join Date: Oct 2020
Posts: 5
Rep Power: 5
vikash0603 is on a distinguished road
I am dealing with a single phase(having two species of water and ethanol). water and ethanol are entering from two different inlets. How can I write UDFs for a single phase and multiple species?
vikash0603 is offline   Reply With Quote

Old   August 18, 2022, 20:30
Default
  #39
New Member
 
vikash
Join Date: Oct 2020
Posts: 5
Rep Power: 5
vikash0603 is on a distinguished road
I am dealing with a single phase(having two species of water and ethanol). water and ethanol are entering from two different inlets. How can I write UDFs for a single phase and multiple species?
vikash0603 is offline   Reply With Quote

Reply

Tags
fluent, mass transfer, species tranport, 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
Accessing phase interaction mass transfer rate in UDF ahmadimo Fluent UDF and Scheme Programming 1 October 6, 2021 23:08
species transport, mass transfer rate mattK FLUENT 4 September 16, 2021 14:22
Coupled Heat and Mass Transfer Mecroob OpenFOAM Running, Solving & CFD 1 July 12, 2020 19:24
UDF Source Terms: Both Species and Mass? Baum Fluent UDF and Scheme Programming 5 April 17, 2020 09:11
Species Mass Transfer Abu-Khawlah FLUENT 0 December 9, 2005 10:35


All times are GMT -4. The time now is 07:48.