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/)
-   -   Help: Mass transfer is always 0 (https://www.cfd-online.com/Forums/fluent-udf/168558-help-mass-transfer-always-0-a.html)

RAJ KIRAN March 24, 2016 07:59

Help: Mass transfer is always 0
 
Hej,
I am using UDF to calculate mass transfer. I need to calculate interfacial area density using alpha fraction gradient. I am using below code,

if (C_VOF(c,liq)>0 && C_VOF(c,liq)<1)
{
if (NULL != THREAD_STORAGE(mixture_thread,SV_VOF_G))
{
vol_lx = C_VOF_G(c, liq)[0];
vol_ly = C_VOF_G(c, liq)[1];
vol_lz = C_VOF_G(c, liq)[2];
printf("THREAD_STORAGE : %f \n", THREAD_STORAGE(gas,SV_VOF_G));
}
ai = fabs (sqrt((vol_lx*vol_lx)+(vol_ly*vol_ly)+(vol_lz*vol_ lz)));
masstransfer = htc*ai*(Tsat-T_l)/h_lt;

}

I Checked Thread_Storage and it is always null, It is not entering loop. I switched on the temporary solver memory,but still it is not working. I saw this question in couple of threads , but there is no answer for the question.

I really appreciate if some one can answer this.

reagrds,
Raju

RAJ KIRAN March 24, 2016 09:57

I tried accessing the temperature gradient in the same way by replacing SV_VOF_G to SV_T_G and it works.

I really could use some help here,,

Thanks in Advance :)

regards,
Raju

pakk March 25, 2016 05:35

The manual of Fluent does not mention "SV_VOF_G". The manual of Fluent does mention "SV_T_G".

It is good that you tried, because many things in Fluent are not documented, and "SV_VOF_G" would be a logical name for the thing that you want to have, but at this point you should just conclude that "SV_VOF_G" is not implemented in Fluent, and that you need to find a different approach.

RAJ KIRAN March 25, 2016 08:35

Thank you for the reply pakk,

I checked sg_mphase.h which contain all the definitions for macros that are associated with VOF multiphase model. I found this definition there

#define C_VOF_G(c,t)C_STORAGE_R_NV(c,t,SV_VOF_G)

So I guess it is implemented in fluent. But, I am not sure whether this definition is the exact one I am looking for. If SV_VOF_G is not implemented in fluent, then I think it should give some sort compilation error but I did not get any.

Is there any other way for accessing volume fraction gradient?

regards,
Raju

pakk March 25, 2016 08:48

Your definition does not show that it is implemented; it only shows that if it is implemented, then C_VOF_G is also implemented.

This shows that there certainly were plans to implement it, and that the 'surrounding infrastructure' is already in place, but it does not show that it really is there. And your test shows it is not there...

Maybe it is implemented, but not stored by default. Maybe it is possible to activate it with a TUI text, just as you had to use to activate the other gradients. But there is nothing in the help about this. I think your best option there is to contact the Ansys helpdesk.

RAJ KIRAN March 25, 2016 08:57

Thanks again,

I have already sent a query regarding this to Ansys support, I will post the reply as soon as I get something from them.

regards,
Raju

stevie-tran March 20, 2017 19:11

Hi Raj,
Can you update me about this issue? I am facing the same problem!


Sent from my iPhone using CFD Online Forum mobile app

RAJ KIRAN March 20, 2017 19:24

Quote:

Originally Posted by stevie-tran (Post 641521)
Hi Raj,
Can you update me about this issue? I am facing the same problem!


Sent from my iPhone using CFD Online Forum mobile app

Hi,

I solved the issue by calculating Interfacial area density in a separate UDF and stored it in a UDM. I called the UDM wherever the interfacial area density is required. Below is the UDF which I wrote for it,

Code:


#include "udf.h"
 
DEFINE_ADJUST(gradient, domain)
 
{
#if !RP_HOST
 
Thread *t;
 
Thread **pt;
 
cell_t c;
 
 
int phase_domain_index = 0;  /* Check the phase whether it is primary or secondary */
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
 
 {
 
  Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
 
  Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
 
  Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);
 
 
 }
 
mp_thread_loop_c (t,domain,pt)
 
 
if (FLUID_THREAD_P(t))
 
 {
 
  Thread *ppt = pt[phase_domain_index];
 
 
  begin_c_loop (c,t)
 
  {
 
    C_UDMI(c,t,0) = sqrt((C_VOF_G(c,ppt)[0]*C_VOF_G(c,ppt)[0])+(C_VOF_G(c,ppt)[1]*C_VOF_G(c,ppt)[1]));
   
/*  C_UDMI(c,t,1) = C_VOF_G(c,ppt) [1];
    C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];*/
 
  }
 
end_c_loop (c,t)
 
 }
 
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
 #endif
}

This is written for a 2d case, Hope this helps, Good luck !!

pakk March 23, 2017 08:01

You can make this part shorter (and thus easier to understand and maintain):
Code:

C_UDMI(c,t,0) = sqrt((C_VOF_G(c,ppt)[0]*C_VOF_G(c,ppt)[0])+(C_VOF_G(c,ppt)[1]*C_VOF_G(c,ppt)[1]));
Replace it by:
Code:

C_UDMI(c,t,0) = NV_MAG(C_VOF_G(c,ppt));
NV_MAG means the magnitude of the vector.

xiatt March 12, 2018 06:28

Quote:

Originally Posted by RAJ KIRAN (Post 641522)
Hi,

I solved the issue by calculating Interfacial area density in a separate UDF and stored it in a UDM. I called the UDM wherever the interfacial area density is required. Below is the UDF which I wrote for it,

Code:


#include "udf.h"
 
DEFINE_ADJUST(gradient, domain)
 
{
#if !RP_HOST
 
Thread *t;
 
Thread **pt;
 
cell_t c;
 
 
int phase_domain_index = 0;  /* Check the phase whether it is primary or secondary */
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
 
 {
 
  Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
 
  Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
 
  Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);
 
 
 }
 
mp_thread_loop_c (t,domain,pt)
 
 
if (FLUID_THREAD_P(t))
 
 {
 
  Thread *ppt = pt[phase_domain_index];
 
 
  begin_c_loop (c,t)
 
  {
 
    C_UDMI(c,t,0) = sqrt((C_VOF_G(c,ppt)[0]*C_VOF_G(c,ppt)[0])+(C_VOF_G(c,ppt)[1]*C_VOF_G(c,ppt)[1]));
   
/*  C_UDMI(c,t,1) = C_VOF_G(c,ppt) [1];
    C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];*/
 
  }
 
end_c_loop (c,t)
 
 }
 
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
 #endif
}

This is written for a 2d case, Hope this helps, Good luck !!

Hi PAJ, based on your case, I alter mine. But when I run calculate, it take on a
error:
received a fatal signal (segmentation fault)
Could you tell me the reason?

obscureed March 13, 2018 11:31

Hi All,

Going back to the original post (admittedly 2 years ago), it strikes me that the test for existence of the vector quantity C_VOF_G might not involve if(NNULLP(THREAD_STORAGE(mixture_thread,SV_VOF_G)) )
but rather
if(NNULLP(T_STORAGE_R_NV(mixture_thread,SV_VOF_G)) )

I have not checked whether there is a difference in outcomes.

Ed


All times are GMT -4. The time now is 04:43.