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

mass transfer udf not working

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

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 26, 2020, 19:59
Default mass transfer udf not working
  #1
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
I'm simulating a mass transfer udf, mass transfer from 'water' to the 'oil' phase at an interface between these 2 phases. but my udf's inequality condition is not working.

my 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.15)

{

m_lg = 100;

}

else m_lg = 0.0;
return (m_lg);

}

I tried displaying the contour for a custom function: (C_VOF(cell,water)*C_VOF(cell,oil) )

Screenshot 2020-07-27 at 5.20.01 AM.jpg

But the mass transfer in zero.
Anshs is offline   Reply With Quote

Old   July 26, 2020, 22:41
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,638
Rep Power: 23
AlexanderZ will become famous soon enough
your UDF seems to be correct,
are you sure, I've hooked UDF properly?

from manual
Code:
In order to hook a DEFINE_MASS_TRANSFER UDF to Fluent, you must first issue the TUI command solve/set/expert and enter no at the LinearizedMass Transfer UDF? prompt.
more information is in Ansys Fluent Customization manual
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 27, 2020, 03:35
Default UDF works for code without inequality condition.
  #3
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
your UDF seems to be correct,
are you sure, I've hooked UDF properly?

from manual
Code:
In order to hook a DEFINE_MASS_TRANSFER UDF to Fluent, you must first issue the TUI command solve/set/expert and enter no at the LinearizedMass Transfer UDF? prompt.
more information is in Ansys Fluent Customization manual
Yes the UDF works well if I remove this inequality condition!

It will just not be working as per my requirements, the mass transfer occurs through whole of the water phase rather than happening at the interface between the oil and water phase.
Anshs is offline   Reply With Quote

Old   July 28, 2020, 23:44
Default Some modifications in UDF.
  #4
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by Anshs View Post
I'm simulating a mass transfer udf, mass transfer from 'water' to the 'oil' phase at an interface between these 2 phases. but my udf's inequality condition is not working.

Attachment 79321

But the mass transfer in zero.
Quote:
Originally Posted by AlexanderZ View Post
your UDF seems to be correct,
are you sure, I've hooked UDF properly?

from manual
Code:
In order to hook a DEFINE_MASS_TRANSFER UDF to Fluent, you must first issue the TUI command solve/set/expert and enter no at the LinearizedMass Transfer UDF? prompt.
more information is in Ansys Fluent Customization manual


The UDF below works and prints the first statement 'hello_fluent 1' but does not print the other statement which is inside the loop.



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;

Message("\n \n hello_fluent 1");


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(cell,water))) * ( 4e-5 - c_tg ) ;


Message("\n \n hello_fluent 2");




}


else m_lg = 0.0;



return (m_lg);

}
Anshs is offline   Reply With Quote

Old   July 29, 2020, 01:08
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,638
Rep Power: 23
AlexanderZ will become famous soon enough
it means, that your condition is not true in the whole domain.

1. you may decrease criteria values
2. may be the problem is your mesh, which could be too course (elements are too huge)
C_VOF macro gets value from the center of cell (not from the nodes)
so you may try to refine the mesh
Anshs likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 29, 2020, 02:44
Default changing the mesh does no help
  #6
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
it means, that your condition is not true in the whole domain.

1. you may decrease criteria values
2. may be the problem is your mesh, which could be too course (elements are too huge)
C_VOF macro gets value from the center of cell (not from the nodes)
so you may try to refine the mesh
Ewen after efining the mesh the custom field (vof oil * vof water)contour stays like this :

Screenshot 2020-07-29 at 12.11.54 PM.jpg

The model is 3 phase model, there is a 3rd phase as well. Is this not working because of that?
Anshs is offline   Reply With Quote

Old   July 29, 2020, 02:58
Default segmentation fault
  #7
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
it means, that your condition is not true in the whole domain.

1. you may decrease criteria values
2. may be the problem is your mesh, which could be too course (elements are too huge)
C_VOF macro gets value from the center of cell (not from the nodes)
so you may try to refine the mesh
After running for many time steps the fluent is showing ' Error: fatal signal, segmentation fault '

1. This does not happen without UDF.
2. The residual plot is well within 1e-02 for all scalars.

Why is this happening?

I am running the setup in serial mode. The CPU meter for RAM is also within 40% usage at the time I start.
Anshs is offline   Reply With Quote

Old   July 29, 2020, 04:54
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,638
Rep Power: 23
AlexanderZ will become famous soon enough
unfortunately, I have very little experience in multiphase simulations

if you have 3 phases it could be an issue, try following code to check fileds of concentrations distribution:

dont forget to allocate 3 UDMI variables in fluent gui

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

DEFINE_MASS_TRANSFER(interface_transfer, c, t, from_index, from_species_index, to_index, to_species_index)
{
real m_lg;
real c_tg;
real k_g;
Thread **pt = THREAD_SUB_THREADS(t);
real vof_i = C_VOF(c,pt[0]);
real vof_j = C_VOF(c,pt[1]);
real vof_k = C_VOF(c,pt[2]);

m_lg = 0.0;

C_UDMI(c,t,0) = vof_i*vof_j;
C_UDMI(c,t,1) = vof_i*vof_k;
C_UDMI(c,t,2) = vof_k*vof_j;

return (m_lg);
}
plot user defined variables and compare it with your custom field function
I expect C_UDMI(c,t,0) should give you same distribution as (C_VOF(cell,water)*C_VOF(cell,oil) )

if yes, add your condition in this code, modify variables and try to run it.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 29, 2020, 07:39
Default All shows zero value.
  #9
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
unfortunately, I have very little experience in multiphase simulations

if you have 3 phases it could be an issue, try following code to check fileds of concentrations distribution:

dont forget to allocate 3 UDMI variables in fluent gui

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

DEFINE_MASS_TRANSFER(interface_transfer, c, t, from_index, from_species_index, to_index, to_species_index)
{
real m_lg;
real c_tg;
real k_g;
Thread **pt = THREAD_SUB_THREADS(t);
real vof_i = C_VOF(c,pt[0]);
real vof_j = C_VOF(c,pt[1]);
real vof_k = C_VOF(c,pt[2]);

m_lg = 0.0;

C_UDMI(c,t,0) = vof_i*vof_j;
C_UDMI(c,t,1) = vof_i*vof_k;
C_UDMI(c,t,2) = vof_k*vof_j;

return (m_lg);
}
plot user defined variables and compare it with your custom field function
I expect C_UDMI(c,t,0) should give you same distribution as (C_VOF(cell,water)*C_VOF(cell,oil) )

if yes, add your condition in this code, modify variables and try to run it.

1) All the 3 UDMI's are showing 0 in the value.

2) I want to know how will the UDMI save the values, will it not update for every node? Like some nodes, the UDMI's will be zero and for some others, it may be non zero, but it will only show the last updated value.

3) In such a case should I not export an array for the values of these UDMI's?

4) If so, then how may I construct an array inside the UDF and saw the values of the UDMI inside the array so that I can later see it!
Anshs is offline   Reply With Quote

Old   July 30, 2020, 04:34
Default
  #10
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,638
Rep Power: 23
AlexanderZ will become famous soon enough
UDMIs are variables which store values of defined variable in the whole domain for one time moment (last one)
for instance it is temperature, which could be different along the domain

to store data for different timesteps you may define monitors and write information to file, or you can write data files and extract information from there

for more information read Ansys Fluent Customization manual
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 30, 2020, 06:26
Default
  #11
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
UDMIs are variables which store values of the defined variable in the whole domain for one time moment (last one)
for instance it is temperature, which could be different along the domain

to store data for different timesteps you may define monitors and write information to file, or you can write data files and extract information from there

for more information read Ansys Fluent Customization manual
If that's the case then the UDMI is storing only zero values and it's not the same as that shown by the contour of C_vof(cell, water)*C_vof(cell, oil)
Anshs is offline   Reply With Quote

Old   July 30, 2020, 20:40
Default
  #12
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,638
Rep Power: 23
AlexanderZ will become famous soon enough
it should be same with C_vof(cell, water)*C_vof(cell, oil)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 30, 2020, 21:43
Default
  #13
Member
 
Anshuman Sinha
Join Date: Oct 2018
Posts: 70
Rep Power: 4
Anshs is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
it should be same with C_vof(cell, water)*C_vof(cell, oil)
Yes, that's the problem I think.

C_vof(cell, water)*C_vof(cell, oil) :

Screenshot 2020-07-31 at 6.54.47 AM.png
Screenshot 2020-07-31 at 6.54.59 AM.jpg

UDMI : Screenshot 2020-07-31 at 6.56.02 AM.jpg

The UDF which I'm using:

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

DEFINE_MASS_TRANSFER(interface_transfer, c, t, from_index, from_species_index, to_index, to_species_index)
{
real m_lg;
real c_tg;
real k_g;
Thread **pt = THREAD_SUB_THREADS(t);
real vof_i = C_VOF(c,pt[0]);
real vof_j = C_VOF(c,pt[1]);
real vof_k = C_VOF(c,pt[2]);

m_lg = 0.0;

C_UDMI(c,t,0) = vof_i*vof_j;
C_UDMI(c,t,1) = vof_i*vof_k;
C_UDMI(c,t,2) = vof_k*vof_j;

return (m_lg);
}
Anshs is offline   Reply With Quote

Reply

Tags
mass transfer, multi phase flow, udf

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coupled Heat and Mass Transfer Mecroob OpenFOAM Running, Solving & CFD 1 July 12, 2020 19:24
UDF for mass transfer between phases in two phase ice-slurry pipe flow devshi Fluent UDF and Scheme Programming 5 November 14, 2016 19:27
Problems modelling nucleate boiling using mass transfer udf from tutorial aayushjain27 Fluent UDF and Scheme Programming 0 February 7, 2015 07:23
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT subhankar_bhandari Fluent UDF and Scheme Programming 0 August 19, 2010 03:09
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT subhankar_bhandari FLUENT 0 August 19, 2010 03:01


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