-
-
March 31, 2026 at 8:58 am
anthonybasuni.hamzah
SubscriberHi all,
I have been working on the modelling of ammonia absorption using water spray. For this purpose, the DPM simulation is used. To implement the mass-heat transfer terms, the transfer equations are hard-coded in a UDF.
An illustration of the computational domain is given in the schematic diagram below:Â
Note that the gas is mixture of ammonia diluted in air. Additionally, below is the UDF code I wrote to implement the ammonia gas absorption, which includes the mass transfer of ammonia gas from bulk to droplet, as well as the heat transfer.#include "udf.h"/* UDF for ammonia absorption into water droplets */DEFINE_DPM_HEAT_MASS(ammonia_absorption, tp, Cp, hgas, hvap, cvap_surf, Z, dydt, dzdt){Â Â int ns;Â Â Material *sp;Â Â int nc = TP_N_COMPONENTS(tp);Â Â Â Â Â Â Â /* Number of particle components */Â Â Thread *t0 = TP_CELL_THREAD(tp);Â Â Â Â Â Â /* Thread where the particle is located */Â Â Material *gas_mix = THREAD_MATERIAL(DPM_THREAD(t0, tp)); /* Gas mixture material */Â Â Material *cond_mix = TP_MATERIAL(tp);Â Â Â Â /* Particle mixture material */Â Â cphase_state_t *c = &(tp->cphase[0]);Â Â Â Â Â /* Cell information at particle location */Â Â real molwt[MAX_SPE_EQNS];Â Â Â Â Â Â Â Â Â /* Molecular weights of gas species */Â Â real Tp = TP_T(tp);Â Â Â Â Â Â Â Â Â Â Â Â Â /* Particle temperature */Â Â real mp = TP_MASS(tp);Â Â Â Â Â Â Â Â Â Â Â /* Particle mass */Â Â real molwt_bulk = 0.;Â Â Â Â Â Â Â Â Â Â Â /* Avg molecular weight in bulk gas */Â Â real Dp = DPM_DIAM_FROM_VOL(mp / TP_RHO(tp)); /* Particle diameter */Â Â real Ap = DPM_AREA(Dp);Â Â Â Â Â Â Â Â Â Â /* Particle surface area */ÂÂ Â /* Standard heat transfer calculation */Â Â real Pr = c->sHeat * c->mu / c->tCond;Â Â /* Prandtl number */Â Â real Nu = 2.0 + 0.6 * sqrt(tp->Re) * pow(Pr, 1./3.); /* Nusselt number */Â Â real h = Nu * c->tCond / Dp;Â Â Â Â Â Â Â /* Heat transfer coefficient */Â Â real dh_dt = h * (c->temp - Tp) * Ap;Â Â Â /* Heat source term */ÂÂ Â dydt[0] += dh_dt / (mp * Cp);Â Â Â Â Â Â Â /* Update particle temperature source */Â Â dzdt->energy -= dh_dt;Â Â Â Â Â Â Â Â Â Â /* Update gas phase enthalpy source */ÂÂ Â /* Calculate average molecular weight of the bulk gas */Â Â mixture_species_loop(gas_mix, sp, ns)Â Â {Â Â Â Â molwt[ns] = MATERIAL_PROP(sp, PROP_mwi);Â Â Â Â molwt_bulk += c->yi[ns] / molwt[ns];Â Â }Â Â molwt_bulk = MAX(molwt_bulk, DPM_SMALL);Â Â /* Loop through particle components to handle mass transfer */Â Â for (ns = 0; ns < nc; ns++)Â Â {Â Â Â Â int gas_index = TP_COMPONENT_INDEX_I(tp, ns); /* Index of vaporizing/absorbing species */Â Â Â Â if (gas_index >= 0)Â Â Â Â {Â Â Â Â Â Â Material *cond_c = MIXTURE_COMPONENT(cond_mix, ns);Â Â Â Â Â Â real D = MATERIAL_PROP_POLYNOMIAL(cond_c, PROP_binary_diffusivity, c->temp); Â /* Diffusion coefficient (polynomial of gas temperature) */Â Â Â Â Â Â real Sc = c->mu / (c->rho * D);Â Â /* Schmidt number */Â Â Â Â Â Â /* Mass transfer coefficient */Â Â Â Â Â Â real k_m = (2. + 0.6 * sqrt(tp->Re) * pow(Sc, 1./3.)) * D / Dp;Â Â Â Â Â Â ÂÂ Â Â Â Â Â /* Bulk gas concentration (Ideal Gas Law) */Â Â Â Â Â Â real cvap_bulk = c->pressure / UNIVERSAL_GAS_CONSTANT / c->temp * c->yi[gas_index] / molwt_bulk;Â Â Â Â Â Â /* The absorption/vaporization rate calculation: If cvap_bulk > cvap_surf[ns], the rate is negative (absorption) Note: cvap_surf[ns] is provided by Fluent based on equilibrium data */Â Â Â Â Â Â real abs_rate = k_m * molwt[gas_index] * Ap * (cvap_surf[ns] - cvap_bulk);Â Â Â Â Â Â /* saving bulk concentration of ammonia, TO BE CHECKED */Â Â Â Â Â Â C_UDMI(c, t0, 0) = abs_rate;Â Â Â Â Â Â /* Update particle and gas mass source terms */Â Â Â Â Â Â dydt[1 + ns] -= abs_rate;Â Â Â Â Â /* Change in particle component mass */Â Â Â Â Â Â dzdt->species[gas_index] += abs_rate;Â Â /* Change in gas species mass */Â Â Â Â }}}The problem I am facing right now is that when I checked the rate of ammonia gas absorption into the droplets (using Particle Track > Discrete Phase Sources > DPM NH3 source), the profile shows zero value (see screenshot below), which implies the absorption using the UDF above doesn't work. Appreciate if someone could help me with this matter.

-
March 31, 2026 at 9:54 am
Rob
Forum ModeratorStaff are unable to check/debug code, nor cover much on UDFs other than point at the documentation. Other Forum posters are not restricted in the same way.
So, what I can do is ask questions.Â
I assume you have a mixture for gas phase and multicomponent droplets? Does this need to be fully transient, or can you run steady flow with transient droplets? The latter can be more computationally efficient. In the DPM plot you're showing a fluid phase value on the droplets, why not plot that on a contour and plot ammonia concentration on the droplets?Â
-
March 31, 2026 at 11:07 am
anthonybasuni.hamzah
SubscriberYes, it's bulk gas - multicomponent droplets, and the simulation should be of the latter (steady gas flow, transient droplet).On the ammonia concentration value, the aim is to show ammonia concentration that should be absorbed into the droplets, thus the fluid phase value instead of the concentration on droplet surface.ÂHope that clarifies. -
March 31, 2026 at 12:28 pm
-
April 1, 2026 at 2:41 am
anthonybasuni.hamzah
Subscriber -
April 1, 2026 at 9:07 am
Rob
Forum ModeratorWhat is the DPM material composition?
-
April 1, 2026 at 9:25 am
-
April 1, 2026 at 1:19 pm
Rob
Forum ModeratorIf the droplet is only water where would the ammonia go?Â
-
- You must be logged in to reply to this topic.
-
5834
-
1906
-
1420
-
1305
-
1021
© 2026 Copyright ANSYS, Inc. All rights reserved.


.png)