|
[Sponsors] |
UDF for DPM modelling to simulate ammonia absorption |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 29, 2021, 05:17 |
UDF for DPM modelling to simulate ammonia absorption
|
#1 | ||
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Hi,
I am new to udf and c programming. Currently I am working on a project to simulate ammonia absorption into water droplets using two-film theory and DPM. I have read the udf manuals and researching online for examples but I am not sure whether my functions are correct. Below is the code: Quote:
Quote:
Does anyone know how to solve the errors? Thanks a lot Last edited by Jack0210Jack; March 30, 2021 at 15:37. |
|||
March 29, 2021, 09:58 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Compile them, load them, try them.
Do you get errors? Does it do what you want? That is the best test.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
March 29, 2021, 10:00 |
|
#3 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
||
March 29, 2021, 12:03 |
|
#4 | ||
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Quote:
Quote:
Last edited by Jack0210Jack; March 29, 2021 at 14:37. |
|||
March 30, 2021, 01:32 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
line 19
was Code:
cphase_state_t* c = &(p->cphase); Code:
cphase_state_t *c = &(p->cphase); in case you need velocity magnitude, you can use this Code:
real v = NV_MAG(P_VEL(tp));
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 30, 2021, 01:44 |
|
#6 | |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Quote:
Code:
cphase_state_t *c = &(p->cphase); Code:
cphase_state_t* c = &(p->cphase); Code:
cphase_state_t *c = &(p->cphase); Actually the variable I used is "tp" because in some posts I saw people using "tp" instead of "p" and I assumed because "tp" is the latest format. Should I change all "tp" variable to "p" variable? Thank you. |
||
March 30, 2021, 01:47 |
|
#7 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Wait a min, after I change
Code:
cphase_state_t* c = &(p->cphase); Code:
cphase_state_t** c = &(p->cphase); |
|
March 30, 2021, 15:53 |
|
#8 | |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
The errors I face currently are:
Quote:
Code:
real den_g = C_R(c, gas_index); /*density of air*/ Code:
real yi_NH3_g = C_YI(c, gas_index, 4); /*mass fraction of ammonia in air*/ I also tried to add in another macro "DEFINE_PROPERTY" for those 4 lines (38~41) but P_g in line 41 cannot be linked to P_g in line 49. Any helps will appreciated. Thanks. |
||
March 30, 2021, 16:45 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I guess you want info of the cell that your particle is in, and you call that c0, not c.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
March 30, 2021, 16:48 |
|
#10 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Thanks but not really. I want the info of the cell where particle is not in.
|
|
March 31, 2021, 01:52 |
|
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
But which cell is c then referring to? I don't know, and neither does fluent.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
March 31, 2021, 02:37 |
|
#12 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
||
March 31, 2021, 02:54 |
|
#13 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Code:
#include "udf.h" DEFINE_DPM_HEAT_MASS(nh3absorption, tp, Cp, hgas, hvap, cvap_surf, Z, dydt, dzdt) { int is; int nc = TP_N_COMPONENTS(tp); /*number of particle components*/ real gas_index; printf("\n######"); for (is = 0; is < nc; is++) { int gas_index = TP_COMPONENT_INDEX_I(tp, is); /* index of vaporizing component in the gas phase */ printf(" gas_index=%d is=%d TP_COMPONENT_I=%e ", gas_index, is, TP_COMPONENT_I(tp, is)); } printf("#######$\n"); Thread* t0 = P_CELL_THREAD(tp); /*thread where the particle is in*/ Material* gas_mix = THREAD_MATERIAL(DPM_THREAD(t0, tp)); /*gas mixture material*/ Material* cond_mix = P_MATERIAL(tp); /*particle mixture material*/ cphase_state_t** c0 = &(tp->cphase); /*cell information of particle location*/ real mp = P_MASS(tp); /* particle mass */ real Dp = DPM_DIAM_FROM_VOL(mp / P_RHO(tp)); /* particle diameter */ real Ap = DPM_AREA(Dp); /*particle surface area*/ real v = NV_MAG(P_VEL(tp)); /*water droplet velocity*/ real vg = 15.69e-6; /*kinematic viscosity of air*//*[m2/s]*/ real Re = Dp * v / vg; real D = 1.64e-7; /*molecular diffusivity coefficient*//*[m/s]*/ real Sc = vg / D; real ky = 2.0 + 0.6 * sqrt(Re) * pow(Sc, 1. / 3.); /*mass transfer coefficient in liquid phase*/ real T = 300; /*Temperature*//*[K]*/ real H = 0.59 * exp(4200 * ((1 / T) - 1 / (298.15))); /*Henry Constant*//*[mol/(m3*Pa)]*/ real MW_NH3 = 17.031e-3; /*Molecular mass of ammonia*//*[kg/mol]*/ Domain* domain = Get_Domain(1); /* Get domain pointer */ Thread* t; cell_t c; int i; /* Loop over all cell threads in domain */ thread_loop_c(t, domain) { /* Loop over all cells */ begin_c_loop(c, t) { { C_R(c, t) = 0.0; C_YI(c, t, i) = 0.0; } } end_c_loop(c, t); } real yi_NH3_g = C_YI(c, gas_index, 4); /*mass fraction of ammonia in air*/ real den_g = C_R(c, gas_index); /*density of air*/ real C_g = yi_NH3_g * den_g / MW_NH3; /*molar concentration of NH3 in air*//*[mol/m3]*/ real P_g = C_g * 8.314 * T; /*partial pressure of ammonia in air*/ real den_l = P_RHO(tp); /*density of particle*/ real yi_NH3_l; /*mass fraction of ammonia in particle*/ for (yi_NH3_l = 0; yi_NH3_l < 1; ++TP_COMPONENT_I(tp, is)) { real C_l = yi_NH3_l * den_l / MW_NH3; /*molar concentration of ammonia in water droplet*//*[mol/m3]*/ real NA = ky * (P_g - H * C_l); /*Mass transfer flux of ammonia*/ dydt[2] = NA; } return; } |
|
March 31, 2021, 08:10 |
|
#14 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
if you look at definition of macros C_YI and C_R you will see, that they are using treads inside: C_R(c, t)
t has type thread not int so based on expamle from manual Ansys Fluent Customization manual -> DEFINE_DPM_HEAT_MASS I think you should change Code:
real yi_NH3_g = C_YI(c, gas_index, 4); /*mass fraction of ammonia in air*/ real den_g = C_R(c, gas_index); /*density of air*/ Code:
real den_g = c->rho; /*density of gas*/ real yi_NH3_g = yi[gas_index]; /*mass fraction of ammonia*/ Code:
cphase_state_t *c = &(p->cphase); /* cell information of particle location*/
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 31, 2021, 08:46 |
|
#15 | ||
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Hi AlexanderZ,
Thanks for your reply. It actually works for once (no error) but I don't know what happen afterward, it cannot work. Below are the errors shown: Quote:
Code:
cphase_state_t *c = &(p->cphase); /* cell information of particle location*/ Quote:
Thanks. |
|||
March 31, 2021, 13:16 |
|
#16 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
After you tell me which cell it should point to, I can help. But all I know now is that it should not be the cell of the particle. That's not enough information.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
||
March 31, 2021, 13:23 |
|
#17 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Based on your description in your other question, I think you want the UDF from here, but then c0 in stead of c.
You said that you don't want the cell that the particle is in, but that statement makes no sense. Just use c0.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
March 31, 2021, 14:17 |
|
#18 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
I have made a huge modification since I messed up the steps. If anyone would like to continue helping me, please visit the link below:
UDF for DPM modelling to simulate ammonia absorption into water droplets Thank you very much. |
|
Tags |
absorption, dpm, fluent, heat_mass, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for absorption coefficient | paolofug87 | Fluent UDF and Scheme Programming | 0 | August 11, 2017 05:20 |
UDF for modelling heat loss in 2D | Shrinand | Fluent UDF and Scheme Programming | 2 | February 29, 2016 06:50 |
Modelling filter cake growing with UDF? | skumanov | Fluent UDF and Scheme Programming | 1 | February 20, 2013 03:23 |
modelling heat flux in udf | dzuodoka | Fluent UDF and Scheme Programming | 0 | November 24, 2010 06:10 |
Constant velocity of the material | Sas | CFX | 15 | July 13, 2010 09:56 |