CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   mass transfer udf not working (https://www.cfd-online.com/Forums/fluent-udf/229090-mass-transfer-udf-not-working.html)

Anshs July 26, 2020 19:59

mass transfer udf not working
 
1 Attachment(s)
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) )

Attachment 79321

But the mass transfer in zero.

AlexanderZ July 26, 2020 22:41

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

Anshs July 27, 2020 03:35

UDF works for code without inequality condition.
 
Quote:

Originally Posted by AlexanderZ (Post 778865)
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 July 28, 2020 23:44

Some modifications in UDF.
 
Quote:

Originally Posted by Anshs (Post 778859)
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 (Post 778865)
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);

}


AlexanderZ July 29, 2020 01:08

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 July 29, 2020 02:44

changing the mesh does no help
 
1 Attachment(s)
Quote:

Originally Posted by AlexanderZ (Post 779026)
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 :

Attachment 79350

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

Anshs July 29, 2020 02:58

segmentation fault
 
Quote:

Originally Posted by AlexanderZ (Post 779026)
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.

AlexanderZ July 29, 2020 04:54

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.

Anshs July 29, 2020 07:39

All shows zero value.
 
Quote:

Originally Posted by AlexanderZ (Post 779047)
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!

AlexanderZ July 30, 2020 04:34

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

Anshs July 30, 2020 06:26

Quote:

Originally Posted by AlexanderZ (Post 779143)
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)

AlexanderZ July 30, 2020 20:40

it should be same with C_vof(cell, water)*C_vof(cell, oil)

Anshs July 30, 2020 21:43

3 Attachment(s)
Quote:

Originally Posted by AlexanderZ (Post 779188)
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) :

Attachment 79371
Attachment 79372

UDMI : Attachment 79373

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);
}



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