|
[Sponsors] |
Need help for UDF for Convective Mass Transfer |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 3, 2022, 12:43 |
Need help for UDF for Convective Mass Transfer
|
#1 |
New Member
Join Date: May 2022
Posts: 3
Rep Power: 4 |
Greetings to all users. I am trying to simulate the convective mass transfer of water into a vapor by using an UDF that first stores the magnitude VOF gradient (which is also a way to define the Interfacial Area Density), to then use it to calculate the volumetric flux of the evaporation. I am using a Sherwood model to calculate the MTC. The UDF is as follows:
#include "udf.h" #include "math.h" #include "mem.h" #include "prf.h" #include "sg_mphase.h" #include "sg.h" #define MF_SAT 0.03484 /*At T = 308.2 K for the water phase*/ #define D 2.45e-05 #define g 9.81 #define L 0.15 #define R 8.314 #define A 6.209 #define B 2354.37 #define C 7.559 #define PM_acq 18.1 DEFINE_ADJUST(store_gradient, domain) { Thread *t; Thread **pt; cell_t c; int phase_domain_index = 0; Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index); { Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL); 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); } /*Loop over all the cells in the domain*/ mp_thread_loop_c (t,domain,pt) if (FLUID_THREAD_P(t)) /*Checks if the threads are fluids*/ { Thread *ppt = pt[phase_domain_index]; begin_c_loop(c,t) { if (C_VOF(c, ppt) != 0.0 && C_VOF(c, ppt) != 1.0) /*Check for cells that have interfaces*/ { C_UDMI(c,t,0)=C_VOF_G(c,ppt)[0]; /*VOF gradient along x*/ C_UDMI(c,t,1)=C_VOF_G(c,ppt)[1]; /*VOF gradient along y*/ C_UDMI(c,t,2)=C_VOF_G(c,ppt)[2]; /*VOF gradient along z*/ C_UDMI(c,t,3)=NV_MAG(C_VOF_G(c,ppt)); /* with a unit of 1/m, since it is the gradient of the VOF volume along the axis, I needed the Interfacial area density*/ } } end_c_loop (c,t) } Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL); } DEFINE_MASS_TRANSFER(evap_source,c,t,from_index,fr om_species_index,to_index,to_species_index) { Thread *liq = THREAD_SUB_THREAD(t,from_index); Thread *gas = THREAD_SUB_THREAD(t,to_index); real m_lg; m_lg = 0.0; /*process only done in the interfacial cells*/ if (C_YI(c,gas,0) < MF_SAT && C_VOF(c,liq) != 0.0 && C_VOF(c,liq) != 1.0 ) { real mu_c = C_MU_L(c,gas) / (C_R(c,gas)); /* density is kg/m3 and viscosity is Pa*s, so Kinematic Viscosity*/ real T = C_T(c, gas) ; /*In K*/ real coeff = A + (B / (C+T)); real Pev = pow (10,coeff) * 100000; /*in Pa*/ real rho_o = (Pev * PM_acq) / (R * T * 1000); /*Saturation rho for water*/ real Sc = mu_c / D ; real Gr = ((g * pow(L,3))/ pow (mu_c,2)) * (((C_R(c,gas) * C_YI(c,gas,0)) / rho_o)-1); real Kc = (0.508 * pow(Sc,0.5) * pow(0.952+Sc,-0.25)* pow(Gr,0.25))* D / L; /* in m/s*/ m_lg = Kc *C_UDMI(c,t,3) * C_R(c,gas) * (MF_SAT - C_YI(c,gas,0)); /*kg/m3 s*/ } else { m_lg = 0; } return (m_lg); } Would you be so kind to help me with debugging the code? It compiles well, but as soon as I start the simulation (after Inizializing), the process stops with a critical error warning. (Also, if I remove the conditional of only checking cells with an interface in the C_UDMI store_gradient Macro, Fluent Crashes, without error. Is it because it has to store too many values for all cells?) Thank you in advance, FF. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mass transfer between air and water | aminhgn | Fluent UDF and Scheme Programming | 4 | October 18, 2020 12:54 |
Table bounds warnings at: END OF TIME STEP | CFXer | CFX | 4 | July 17, 2020 00:44 |
Coupled Heat and Mass Transfer | Mecroob | OpenFOAM Running, Solving & CFD | 1 | July 12, 2020 20:24 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
How to calculate Volumetric Mass transfer coefficient using CFX? | tuks_123 | CFX | 2 | July 22, 2010 02:15 |