|
[Sponsors] |
UDF for DPM modelling to simulate ammonia absorption into water droplets |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 31, 2021, 07:52 |
UDF for DPM modelling to simulate ammonia absorption into water droplets
|
#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 to come up with codes below: 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 yi_NH3_l; /*mass fraction of ammonia in particle*/ for (yi_NH3_l = 0; yi_NH3_l < 1; ++TP_COMPONENT_I(tp, is)) { Domain* d; /* Get domain pointer */ real T; /*Temperature*//*[K]*/ real yi_NH3_g; real den_g; Thread* t; cell_t c; int i; d = Get_Domain(1); /* Loop over all cell threads in domain */ thread_loop_c(t, d) { /* Loop over all cells */ begin_c_loop(c, t) { { T = C_T(c, t); yi_NH3_g = C_YI(c, gas_index, 4); /*mass fraction of ammonia in air*/ den_g = C_R(c, gas_index); /*density of air*/ } } end_c_loop(c, t); } real MW_NH3 = 17.031e-3; /*Molecular mass of ammonia*//*[kg/mol]*/ 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 C_l = yi_NH3_l * den_l / MW_NH3; /*molar concentration of ammonia in water droplet*//*[mol/m3]*/ real H = 0.59 * exp(4200 * ((1 / T) - 1 / (298.15))); /*Henry Constant*//*[mol/(m3*Pa)]*/ 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 NA = ky * (P_g - H * C_l); /*Mass transfer flux of ammonia*/ dydt[2] = NA; } return; } Quote:
Quote:
|
|||
March 31, 2021, 13:26 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You added a loop over all cells. But you use only info from the last cell, which is chosen by fluent. It makes no sense.
Go back to your old udf, replace c by c0, and you will use the gas density at the location of the particle. If you want the gas density somewhere else (why would you?) explain what you want.
__________________
"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:42 |
|
#3 | ||
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Thanks. I think I have more understanding on this. Initially I assumed c0 is where the cell that has particle and the particle = cell. Now if I'm not wrong, c0
is the cell that holds the particle and the spaces surrounding the particle. So based on your suggestions, I changed it to Code:
real T = C_T(c0, t0); /*Temperature*//*[K]*/ real yi_NH3_g = C_YI(c0, t0, 4); /*mass fraction of ammonia in air*/ real den_g = C_R(c0, t0); /*density of air*/ However, here comes new errors Quote:
btw, I have changed this line Code:
cphase_state_t** c0 = &(tp->cphase); /*cell information of particle location*/ Code:
cphase_state_t* c0 = &(tp->cphase); /*cell information of particle location*/ Quote:
Thanks. |
|||
March 31, 2021, 14:52 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You first had
Code:
cell_t c0 = P_CELL(tp); /*cell where the particle is in*/
__________________
"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, 15:00 |
|
#5 | |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Oh gawd, no more error now.
At first due to that misunderstanding I thought that line was useless and I changed "cphase_state_t** c" into "cphase_state_t** c0" since I wanted to use "c" variable in Get_Domain below. Thanks for reminding me those lines have been modified when I rearrange the codes. Now only left this error to be solved which I think it is related to Environment Variables Quote:
|
||
March 31, 2021, 15:26 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Hmm, that one is probably Fluent installation/configuration. Don't know much about that, sorry...
__________________
"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, 16:15 |
|
#7 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
No worries. You and others have helped me a lot. Hopefully I can get the results I want from this udf.
Thank you. |
|
April 1, 2021, 07:38 |
|
#8 | |||||
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
Hi, I need helps again.
So after all those editing, the file shows no error after I "build". But when I want to load the codes, it shows Quote:
By installing VS 2012, the LINK error has been solved. But it came up another error: Quote:
Quote:
Quote:
Quote:
Code:
Thread* t0 = P_CELL_THREAD(tp); /*thread where the particle is in*/ Code:
cell_t c0 = P_CELL(tp); /*cell where the particle is in*/ Code:
Material* gas_mix = THREAD_MATERIAL(DPM_THREAD(t0, tp)); /*gas mixture material*/ I have tried with another code which I copied from udf manual and this code shows no errors like the the above mentioned (Thread, LINK, ...not compiled for parallel use) Code:
#include "udf.h" DEFINE_ADJUST(my_adjust, d) { Thread* t; /* Integrate dissipation. */ real sum_diss = 0.; cell_t c; thread_loop_c(t, d) { begin_c_loop(c, t) sum_diss += C_D(c, t) * C_VOLUME(c, t); end_c_loop(c, t) } printf("Volume integral of turbulent dissipation: %g\n", sum_diss); } |
||||||
April 1, 2021, 09:16 |
|
#9 |
New Member
Join Date: Mar 2021
Posts: 25
Rep Power: 5 |
UPDATE
I think the issue lies within the compiler. So I tried with Ansys 2020 R2 and it doesn't show any errors I mentioned above now. Once again, thank you. |
|
December 28, 2023, 02:36 |
|
#10 |
New Member
Zain
Join Date: Dec 2023
Posts: 1
Rep Power: 0 |
Hi guys, I am just wondering with this udf what species transport model and multiphase model has been used? Do we define any reactions with it. Thank you
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mass flow in is not equal to mass flow out | saii | CFX | 12 | March 19, 2018 06:21 |
Need help to Simulate Phase change of Water liquid after mixing with Hot Air Stream | diineshns | FLUENT | 0 | March 17, 2018 07:14 |
Modelling free falling water into a air filled duct? | sandmike_83 | CFX | 4 | August 24, 2010 04:27 |
Constant velocity of the material | Sas | CFX | 15 | July 13, 2010 09:56 |
Modelling of bubble merging submerge on water | Carlos | Main CFD Forum | 0 | October 26, 2005 10:30 |